54 #ifndef RAJA_forall_generic_HPP
55 #define RAJA_forall_generic_HPP
57 #include "RAJA/config.hpp"
61 #include <type_traits>
101 template<
typename Range,
typename Body,
typename IndexT>
105 typename std::decay<Body>::type
body;
132 typename ForallParams>
133 RAJA_INLINE camp::resources::EventProxy<Res>
operator()(T
const&,
148 typename ForallParams>
149 RAJA_INLINE camp::resources::EventProxy<Res>
operator()(T
const&,
177 template<
typename Res,
178 typename ExecutionPolicy,
181 typename ForallParams>
182 RAJA_INLINE concepts::enable_if_t<
183 RAJA::resources::EventProxy<Res>,
184 concepts::negate<type_traits::is_indexset_policy<ExecutionPolicy>>,
185 type_traits::is_range<Container>>
189 LoopBody&& loop_body,
190 ForallParams&& f_params)
192 RAJA_FORCEINLINE_RECURSIVE
194 r, std::forward<ExecutionPolicy>(p), std::forward<Container>(c),
195 std::forward<LoopBody>(loop_body), std::forward<ForallParams>(f_params));
198 template<
typename Res,
199 typename ExecutionPolicy,
202 RAJA_INLINE concepts::enable_if_t<
203 RAJA::resources::EventProxy<Res>,
204 concepts::negate<type_traits::is_indexset_policy<ExecutionPolicy>>,
205 type_traits::is_range<Container>>
206 forall(Res r, ExecutionPolicy&& p, Container&& c, LoopBody&& loop_body)
208 RAJA_FORCEINLINE_RECURSIVE
210 r, std::forward<ExecutionPolicy>(p), std::forward<Container>(c),
211 std::forward<LoopBody>(loop_body), expt::get_empty_forall_param_pack());
221 template<
typename Res,
222 typename ExecutionPolicy,
226 typename ForallParams>
231 LoopBody&& loop_body,
232 ForallParams&& f_params)
237 auto range =
RangeSegment(0, distance(begin(c), end(c)));
241 RAJA_FORCEINLINE_RECURSIVE
242 return forall_impl(r, std::forward<ExecutionPolicy>(p), range, adapted,
243 std::forward<ForallParams>(f_params));
255 template<
typename Res,
256 typename SegmentIterPolicy,
257 typename SegmentExecPolicy,
258 typename... SegmentTypes,
260 typename ForallParams>
266 ForallParams f_params)
271 wrap::forall(segIterRes, SegmentIterPolicy(), iset, [=, &r](
int segID) {
272 iset.segmentCall(segID,
274 SegmentExecPolicy(), loop_body, r, f_params);
276 return RAJA::resources::EventProxy<Res>(r);
279 template<
typename Res,
280 typename SegmentIterPolicy,
281 typename SegmentExecPolicy,
283 typename... SegmentTypes,
284 typename ForallParams>
285 RAJA_INLINE resources::EventProxy<Res>
forall(
290 ForallParams f_params)
294 wrap::forall(segIterRes, SegmentIterPolicy(), iset, [=, &r](
int segID) {
296 loop_body, r, f_params);
298 return RAJA::resources::EventProxy<Res>(r);
312 inline namespace policy_by_value_interface
323 template<
typename ExecutionPolicy,
333 "Expected a TypedIndexSet but did not get one. Are you using "
334 "a TypedIndexSet policy by mistake?");
336 std::string kernel_name =
343 util::make_context<camp::decay<ExecutionPolicy>>(std::move(kernel_name))};
353 RAJA::resources::EventProxy<Res> e =
355 std::forward<IdxSet>(c), std::move(
body), f_params);
361 template<
typename ExecutionPolicy,
367 LoopBody&& loop_body)
369 auto r = Res::get_default();
371 std::forward<ExecutionPolicy>(p), r, std::forward<IdxSet>(c),
372 std::forward<LoopBody>(loop_body));
382 template<
typename ExecutionPolicy,
386 RAJA_INLINE concepts::enable_if_t<
387 resources::EventProxy<Res>,
388 type_traits::is_indexset_policy<ExecutionPolicy>>
392 "Expected a TypedIndexSet but did not get one. Are you using "
393 "a TypedIndexSet policy by mistake?");
397 std::string kernel_name =
403 util::make_context<camp::decay<ExecutionPolicy>>(std::move(kernel_name))};
413 resources::EventProxy<Res> e =
414 wrap::forall(r, std::forward<ExecutionPolicy>(p), std::forward<IdxSet>(c),
415 std::move(
body), f_params);
421 template<
typename ExecutionPolicy,
425 RAJA_INLINE concepts::enable_if_t<
426 resources::EventProxy<Res>,
427 type_traits::is_indexset_policy<ExecutionPolicy>>
428 forall(ExecutionPolicy&& p, IdxSet&& c, LoopBody&& loop_body)
430 auto r = Res::get_default();
432 std::forward<ExecutionPolicy>(p), r, std::forward<IdxSet>(c),
433 std::forward<LoopBody>(loop_body));
443 template<
typename ExecutionPolicy,
447 RAJA_INLINE concepts::enable_if_t<resources::EventProxy<Res>,
448 type_traits::is_multi_policy<ExecutionPolicy>,
449 type_traits::is_range<Container>>
450 forall(ExecutionPolicy&& p, Container&& c, LoopBody&& loop_body)
452 static_assert(type_traits::is_random_access_range<Container>::value,
453 "Container does not model RandomAccessIterator");
455 auto r = Res::get_default();
458 return forall_impl(r, std::forward<ExecutionPolicy>(p),
459 std::forward<Container>(c),
460 std::forward<LoopBody>(loop_body));
470 template<
typename ExecutionPolicy,
476 RAJA_INLINE concepts::enable_if_t<resources::EventProxy<Res>,
477 type_traits::is_range<Container>,
478 type_traits::is_integral<IndexType>>
486 static_assert(type_traits::is_random_access_range<Container>::value,
487 "Container does not model RandomAccessIterator");
490 std::forward<Params>(params)...);
491 std::string kernel_name =
494 std::forward<Params>(params)...);
498 util::make_context<camp::decay<ExecutionPolicy>>(std::move(kernel_name))};
509 r, std::forward<ExecutionPolicy>(p), std::forward<Container>(c), icount,
510 std::move(
body), f_params);
516 template<
typename ExecutionPolicy,
521 RAJA_INLINE concepts::enable_if_t<
522 resources::EventProxy<Res>,
523 type_traits::is_range<Container>,
524 concepts::negate<type_traits::is_indexset_policy<ExecutionPolicy>>,
525 type_traits::is_integral<IndexType>>
529 LoopBody&& loop_body)
531 auto r = Res::get_default();
533 std::forward<ExecutionPolicy>(p), r, std::forward<Container>(c), icount,
534 std::forward<LoopBody>(loop_body));
545 template<
typename ExecutionPolicy,
549 RAJA_INLINE concepts::enable_if_t<
550 resources::EventProxy<Res>,
551 concepts::negate<type_traits::is_indexset_policy<ExecutionPolicy>>,
552 concepts::negate<type_traits::is_multi_policy<ExecutionPolicy>>,
553 type_traits::is_range<Container>>
556 static_assert(type_traits::is_random_access_range<Container>::value,
557 "Container does not model RandomAccessIterator");
561 std::string kernel_name =
568 util::make_context<camp::decay<ExecutionPolicy>>(std::move(kernel_name))};
578 resources::EventProxy<Res> e =
580 std::forward<Container>(c), std::move(
body), f_params);
586 template<
typename ExecutionPolicy,
590 RAJA_INLINE concepts::enable_if_t<
591 resources::EventProxy<Res>,
592 concepts::negate<type_traits::is_indexset_policy<ExecutionPolicy>>,
593 concepts::negate<type_traits::is_multi_policy<ExecutionPolicy>>,
594 type_traits::is_range<Container>>
595 forall(ExecutionPolicy&& p, Container&& c, LoopBody&& loop_body)
597 auto r = Res::get_default();
599 std::forward<ExecutionPolicy>(p), r, std::forward<Container>(c),
600 std::forward<LoopBody>(loop_body));
610 template<
typename ExecutionPolicy,
613 RAJA_INLINE resources::EventProxy<Res>
forall(Args&&...
args)
615 Res r = Res::get_default();
617 std::forward<Args>(
args)...);
620 template<
typename ExecutionPolicy,
typename Res,
typename... Args>
621 RAJA_INLINE concepts::enable_if_t<resources::EventProxy<Res>,
622 type_traits::is_resource<Res>>
626 std::forward<Args>(
args)...);
635 template<
typename ExecutionPolicy,
640 Res r = Res::get_default();
642 ExecutionPolicy(), r, std::forward<Args>(
args)...);
645 template<
typename ExecutionPolicy,
typename Res,
typename... Args>
646 RAJA_INLINE concepts::enable_if_t<resources::EventProxy<Res>,
647 type_traits::is_resource<Res>>
651 ExecutionPolicy(), r, std::forward<Args>(
args)...);
658 typename ExecutionPolicy,
661 typename ForallParams>
667 ForallParams f_params)
const
671 RAJA_FORCEINLINE_RECURSIVE
678 typename ExecutionPolicy,
681 typename ForallParams>
687 ForallParams f_params)
const
704 template<camp::
idx_t IDX,
typename POLICY_LIST>
707 template<
typename SEGMENT,
typename... PARAMS>
714 using t_pol =
typename camp::at<POLICY_LIST, camp::num<IDX>>::type;
715 RAJA::forall<t_pol>(seg, params...);
721 template<
typename SEGMENT,
typename... PARAMS>
723 RAJA::resources::Resource r,
729 using t_pol =
typename camp::at<POLICY_LIST, camp::num<IDX>>::type;
734 RAJA::forall<t_pol>(r.get<resource_type>(), seg, params...);
746 template<
typename POLICY_LIST>
749 template<
typename SEGMENT,
typename... PARAMS>
756 using t_pol =
typename camp::at<POLICY_LIST, camp::num<0>>::type;
757 RAJA::forall<t_pol>(seg, params...);
763 template<
typename SEGMENT,
typename... PARAMS>
765 RAJA::resources::Resource r,
772 using t_pol =
typename camp::at<POLICY_LIST, camp::num<0>>::type;
775 RAJA::forall<t_pol>(r.get<resource_type>(), seg, params...);
783 template<
typename POLICY_LIST,
typename SEGMENT,
typename... PARAMS>
786 constexpr
int N = camp::size<POLICY_LIST>::value;
787 static_assert(N > 0,
"RAJA policy list must not be empty");
796 template<
typename POLICY_LIST,
typename SEGMENT,
typename... PARAMS>
798 RAJA::resources::Resource r,
803 constexpr
int N = camp::size<POLICY_LIST>::value;
804 static_assert(N > 0,
"RAJA policy list must not be empty");
RAJA header file defining index set classes.
Header file for RAJA iterator constructs.
Header file containing definition of RAJA list segment class.
RAJA wrapper for "multi-policy" and dynamic policy selection.
Header file for basic RAJA policy mechanics.
Header file containing definitions of RAJA range segment classes.
Header file for RAJA span constructs.
Definition: IndexSet.hpp:52
Header file for RAJA concept definitions.
RAJA_HOST_DEVICE void RAJA_ABORT_OR_THROW(const char *str)
Definition: macros.hpp:143
#define RAJA_HOST_DEVICE
Definition: macros.hpp:65
#define RAJA_SUPPRESS_HD_WARN
Definition: macros.hpp:68
Args args
Definition: WorkRunner.hpp:212
std::string get_kernel_name(Args &&... args)
Definition: forall.hpp:442
constexpr void check_forall_optional_args(Lambda &&l, ForallParams &fpp)
Definition: forall.hpp:557
constexpr auto && get_lambda(Args &&... args)
Definition: forall.hpp:396
constexpr auto make_forall_param_pack(Args &&... args)
Definition: forall.hpp:377
RAJA_INLINE concepts::enable_if_t< resources::EventProxy< resources::Host >, expt::type_traits::is_ForallParamPack< ForallParam > > forall_impl(resources::Host host_res, const seq_exec &pol, Iterable &&iter, Func &&body, ForallParam f_params)
Definition: forall.hpp:62
RAJA_INLINE concepts::enable_if_t< resources::EventProxy< resources::Host >, expt::type_traits::is_ForallParamPack< ForallParam >, expt::type_traits::is_ForallParamPack_empty< ForallParam > > forall_impl(resources::Host host_res, const simd_exec &, Iterable &&iter, Func &&body, ForallParam)
Definition: forall.hpp:81
RAJA_INLINE concepts::enable_if_t< resources::EventProxy< Res >, type_traits::is_indexset_policy< ExecutionPolicy > > forall(ExecutionPolicy &&p, Res r, IdxSet &&c, Params &&... params)
Generic dispatch over index set with a value-based policy.
Definition: forall.hpp:389
RAJA_INLINE resources::EventProxy< Res > forall_Icount(ExecutionPolicy &&p, Res r, IdxSet &&c, Params &&... params)
Generic dispatch over index set with icount with a value-based policy.
Definition: forall.hpp:327
RAJA_INLINE void callPreLaunchPlugins(const PluginContext &p)
Definition: plugins.hpp:56
RAJA_INLINE void callPostCapturePlugins(const PluginContext &p)
Definition: plugins.hpp:46
RAJA_INLINE auto trigger_updates_before(T &&item) -> typename std::remove_reference< T >::type
Definition: plugins.hpp:29
RAJA_INLINE void callPostLaunchPlugins(const PluginContext &p)
Definition: plugins.hpp:66
RAJA_INLINE void callPreCapturePlugins(const PluginContext &p)
Definition: plugins.hpp:36
RAJA_INLINE concepts::enable_if_t< RAJA::resources::EventProxy< Res >, concepts::negate< type_traits::is_indexset_policy< ExecutionPolicy > >, type_traits::is_range< Container > > forall(Res r, ExecutionPolicy &&p, Container &&c, LoopBody &&loop_body, ForallParams &&f_params)
Generic dispatch over containers with a value-based policy.
Definition: forall.hpp:186
RAJA_INLINE resources::EventProxy< Res > forall_Icount(Res r, ExecutionPolicy &&p, Container &&c, IndexType &&icount, LoopBody &&loop_body, ForallParams &&f_params)
Generic dispatch over containers with a value-based policy with icount.
Definition: forall.hpp:227
Definition: AlignedRangeIndexSetBuilders.cpp:35
TypedRangeSegment< Index_type > RangeSegment
Alias for TypedRangeSegment<Index_type>
Definition: RangeSegment.hpp:528
RAJA_INLINE concepts::enable_if_t< resources::EventProxy< Res >, type_traits::is_resource< Res > > forall_Icount(Res r, Args &&... args)
Definition: forall.hpp:648
std::ptrdiff_t Index_type
Definition: types.hpp:226
camp::list< internal::LambdaArg< internal::lambda_arg_param_t, args >... > Params
Definition: Lambda.hpp:95
auto & body
Definition: launch.hpp:177
void dynamic_forall(const int pol, SEGMENT const &seg, PARAMS &&... params)
Definition: forall.hpp:784
RAJA_INLINE concepts::enable_if_t< resources::EventProxy< Res >, type_traits::is_resource< Res > > forall(Res r, Args &&... args)
Definition: forall.hpp:623
Internal header for RAJA forall "BED" macros (i.e., loop bounds 'BED' --> begin, end,...
Header file containing RAJA index set and segment iteration template methods for sequential execution...
Header file for RAJA resource definitions.
Definition: forall.hpp:141
constexpr CallForallIcount(int s)
Definition: forall.hpp:675
RAJA_INLINE camp::resources::EventProxy< Res > operator()(T const &, ExecPol, Body, Res, ForallParams) const
const int start
Definition: forall.hpp:155
Definition: forall.hpp:127
RAJA_INLINE camp::resources::EventProxy< Res > operator()(T const &, ExecPol, Body, Res, ForallParams) const
Adapter to replace specific implementations for the icount variants.
Definition: forall.hpp:103
RAJA_SUPPRESS_HD_WARN RAJA_HOST_DEVICE void operator()(T const &i) const
Definition: forall.hpp:120
icount_adapter(Range const &r, Body const &b, IndexT icount_)
Definition: forall.hpp:110
Index_type icount
Definition: forall.hpp:108
container_type::iterator begin_it
Definition: forall.hpp:107
typename std::decay< IndexT >::type index_type
Definition: forall.hpp:104
std::decay< Body >::type body
Definition: forall.hpp:105
typename std::decay< Range >::type container_type
Definition: forall.hpp:106
static resources::EventProxy< resources::Resource > invoke_forall(RAJA::resources::Resource r, const int pol, SEGMENT const &seg, PARAMS &&... params)
Definition: forall.hpp:764
static void invoke_forall(const int pol, SEGMENT const &seg, PARAMS &&... params)
Definition: forall.hpp:750
Definition: forall.hpp:706
static void invoke_forall(const int pol, SEGMENT const &seg, PARAMS &&... params)
Definition: forall.hpp:708
static resources::EventProxy< resources::Resource > invoke_forall(RAJA::resources::Resource r, const int pol, SEGMENT const &seg, PARAMS &&... params)
Definition: forall.hpp:722
Definition: IndexSet.hpp:70
Definition: resource.hpp:48
camp::resources::Host type
Definition: resource.hpp:49
Definition: IndexSet.hpp:796
Definition: PluginContext.hpp:26
Header file for RAJA type definitions.