10 #ifndef RAJA_target_forall_openmp_HPP
11 #define RAJA_target_forall_openmp_HPP
13 #include "RAJA/config.hpp"
15 #if defined(RAJA_ENABLE_TARGET_OPENMP)
38 template<
size_t ThreadsPerTeam,
42 RAJA_INLINE concepts::enable_if_t<
43 resources::EventProxy<resources::Omp>,
46 const omp_target_parallel_for_exec<ThreadsPerTeam>& p,
51 using EXEC_POL = camp::decay<decltype(p)>;
52 constexpr
bool is_forall_param_empty =
54 if constexpr (!is_forall_param_empty)
59 using Body =
typename std::remove_reference<decltype(loop_body)>::type;
60 Body
body = loop_body;
65 int tperteam = ThreadsPerTeam;
66 if (tperteam > omp::MAXNUMTHREADS)
68 tperteam = omp::MAXNUMTHREADS;
74 if (numteams > tperteam)
84 if constexpr (is_forall_param_empty)
86 #pragma omp target teams distribute parallel for num_teams(numteams) \
87 schedule(static, 1) map(to : body, begin_it)
88 for (i = 0; i < distance_it; ++i)
96 RAJA_OMP_DECLARE_REDUCTION_COMBINE
97 #pragma omp target teams distribute parallel for num_teams(numteams) \
98 schedule(static, 1) map(to : body, begin_it) reduction(combine : f_params)
99 for (i = 0; i < distance_it; ++i)
108 return resources::EventProxy<resources::Omp>(omp_res);
111 template<
typename Iterable,
typename Func,
typename ForallParam>
112 RAJA_INLINE concepts::enable_if_t<
113 resources::EventProxy<resources::Omp>,
116 const omp_target_parallel_for_exec_nt& p,
119 ForallParam f_params)
121 using EXEC_POL = camp::decay<decltype(p)>;
122 constexpr
bool is_forall_param_empty =
124 if constexpr (!is_forall_param_empty)
129 using Body =
typename std::remove_reference<decltype(loop_body)>::type;
130 Body
body = loop_body;
134 if constexpr (!is_forall_param_empty)
136 RAJA_OMP_DECLARE_REDUCTION_COMBINE;
137 #pragma omp target teams distribute parallel for schedule(static, 1) \
138 firstprivate(body, begin_it) reduction(combine : f_params)
139 for (decltype(distance_it) i = 0; i < distance_it; ++i)
149 #pragma omp target teams distribute parallel for schedule(static, 1) \
150 firstprivate(body, begin_it)
151 for (decltype(distance_it) i = 0; i < distance_it; ++i)
157 return resources::EventProxy<resources::Omp>(omp_res);
#define RAJA_DIVIDE_CEILING_INT(dividend, divisor)
Definition: macros.hpp:122
value_type::device_call &[i_loop] iter
Definition: WorkRunner.hpp:216
constexpr RAJA_HOST_DEVICE auto invoke_body(Params &¶ms, Fn &&f, Ts &&... extra)
Definition: forall.hpp:598
RAJA_INLINE concepts::enable_if_t< resources::EventProxy< resources::Host >, RAJA::expt::type_traits::is_ForallParamPack< ForallParam >, concepts::negate< RAJA::expt::type_traits::is_ForallParamPack_empty< ForallParam > > > forall_impl(resources::Host host_res, const omp_parallel_exec< InnerPolicy > &, Iterable &&iter, Func &&loop_body, ForallParam f_params)
Definition: forall.hpp:325
Definition: AlignedRangeIndexSetBuilders.cpp:35
auto & body
Definition: launch.hpp:177
Header file containing RAJA OpenMP policy definitions.
#define RAJA_EXTRACT_BED_IT(CONTAINER)
Definition: forall.hpp:32
static constexpr void parampack_resolve(EXEC_POL const &pol, ForallParamPack< Params... > &f_params, Args &&... args)
Definition: forall.hpp:304
static constexpr void parampack_init(EXEC_POL const &pol, ForallParamPack< Params... > &f_params, Args &&... args)
Definition: forall.hpp:269
Definition: TypeTraits.hpp:67
Definition: TypeTraits.hpp:59
Header file for RAJA type definitions.