From 41a3765d80b079c2ce0f200ee105da8396806775 Mon Sep 17 00:00:00 2001 From: Arturo Vargas Date: Thu, 31 Oct 2024 16:40:48 -0700 Subject: [PATCH] remove dynamic forall from expt --- examples/dynamic-forall.cpp | 2 +- include/RAJA/pattern/forall.hpp | 141 +++++++++++++++----------------- 2 files changed, 69 insertions(+), 74 deletions(-) diff --git a/examples/dynamic-forall.cpp b/examples/dynamic-forall.cpp index 3c120cb0ea..7c037571e9 100644 --- a/examples/dynamic-forall.cpp +++ b/examples/dynamic-forall.cpp @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) RAJA::RangeSegment range(0, N); //policy is chosen from the list - RAJA::expt::dynamic_forall(pol, range, + RAJA::dynamic_forall(pol, range, RAJA::expt::Reduce(&sum), RAJA::expt::KernelName("RAJA dynamic forall"), [=] RAJA_HOST_DEVICE (int i, VAL_INT_SUM &_sum) { diff --git a/include/RAJA/pattern/forall.hpp b/include/RAJA/pattern/forall.hpp index 28e8897397..e75cc43af7 100644 --- a/include/RAJA/pattern/forall.hpp +++ b/include/RAJA/pattern/forall.hpp @@ -647,68 +647,29 @@ RAJA_INLINE camp::resources::EventProxy CallForallIcount::operator()(T cons // - Returns a generic event proxy only if a resource is provided // avoids overhead of constructing a typed erased resource // -namespace expt +template +struct dynamic_helper { - - template - struct dynamic_helper + template + static void invoke_forall(const int pol, SEGMENT const &seg, PARAMS&&... params) { - template - static void invoke_forall(const int pol, SEGMENT const &seg, PARAMS&&... params) - { - if(IDX==pol){ - using t_pol = typename camp::at>::type; - RAJA::forall(seg, params...); - return; - } - dynamic_helper::invoke_forall(pol, seg, params...); - } - - template - static resources::EventProxy - invoke_forall(RAJA::resources::Resource r, const int pol, SEGMENT const &seg, PARAMS&&... params) - { - + if(IDX==pol){ using t_pol = typename camp::at>::type; - using resource_type = typename resources::get_resource::type; - - if(IDX==pol){ - RAJA::forall(r.get(), seg, params...); - - //Return a generic event proxy from r, - //because forall returns a typed event proxy - return {r}; - } - - return dynamic_helper::invoke_forall(r, pol, seg, params...); + RAJA::forall(seg, params...); + return; } + dynamic_helper::invoke_forall(pol, seg, params...); + } - }; - - template - struct dynamic_helper<0, POLICY_LIST> + template + static resources::EventProxy + invoke_forall(RAJA::resources::Resource r, const int pol, SEGMENT const &seg, PARAMS&&... params) { - template - static void - invoke_forall(const int pol, SEGMENT const &seg, PARAMS&&... params) - { - if(0==pol){ - using t_pol = typename camp::at>::type; - RAJA::forall(seg, params...); - return; - } - RAJA_ABORT_OR_THROW("Policy enum not supported "); - } - template - static resources::EventProxy - invoke_forall(RAJA::resources::Resource r, const int pol, SEGMENT const &seg, PARAMS&&... params) - { - if(pol != 0) RAJA_ABORT_OR_THROW("Policy value out of range "); - - using t_pol = typename camp::at>::type; - using resource_type = typename resources::get_resource::type; + using t_pol = typename camp::at>::type; + using resource_type = typename resources::get_resource::type; + if(IDX==pol){ RAJA::forall(r.get(), seg, params...); //Return a generic event proxy from r, @@ -716,35 +677,69 @@ namespace expt return {r}; } - }; + return dynamic_helper::invoke_forall(r, pol, seg, params...); + } - template - void dynamic_forall(const int pol, SEGMENT const &seg, PARAMS&&... params) - { - constexpr int N = camp::size::value; - static_assert(N > 0, "RAJA policy list must not be empty"); +}; - if(pol > N-1) { - RAJA_ABORT_OR_THROW("Policy enum not supported"); +template +struct dynamic_helper<0, POLICY_LIST> +{ + template + static void + invoke_forall(const int pol, SEGMENT const &seg, PARAMS&&... params) + { + if(0==pol){ + using t_pol = typename camp::at>::type; + RAJA::forall(seg, params...); + return; } - dynamic_helper::invoke_forall(pol, seg, params...); + RAJA_ABORT_OR_THROW("Policy enum not supported "); } - template - resources::EventProxy - dynamic_forall(RAJA::resources::Resource r, const int pol, SEGMENT const &seg, PARAMS&&... params) + template + static resources::EventProxy + invoke_forall(RAJA::resources::Resource r, const int pol, SEGMENT const &seg, PARAMS&&... params) { - constexpr int N = camp::size::value; - static_assert(N > 0, "RAJA policy list must not be empty"); + if(pol != 0) RAJA_ABORT_OR_THROW("Policy value out of range "); - if(pol > N-1) { - RAJA_ABORT_OR_THROW("Policy value out of range"); - } + using t_pol = typename camp::at>::type; + using resource_type = typename resources::get_resource::type; + + RAJA::forall(r.get(), seg, params...); + + //Return a generic event proxy from r, + //because forall returns a typed event proxy + return {r}; + } + +}; - return dynamic_helper::invoke_forall(r, pol, seg, params...); +template +void dynamic_forall(const int pol, SEGMENT const &seg, PARAMS&&... params) +{ + constexpr int N = camp::size::value; + static_assert(N > 0, "RAJA policy list must not be empty"); + + if(pol > N-1) { + RAJA_ABORT_OR_THROW("Policy enum not supported"); + } + dynamic_helper::invoke_forall(pol, seg, params...); +} + +template +resources::EventProxy +dynamic_forall(RAJA::resources::Resource r, const int pol, SEGMENT const &seg, PARAMS&&... params) +{ + constexpr int N = camp::size::value; + static_assert(N > 0, "RAJA policy list must not be empty"); + + if(pol > N-1) { + RAJA_ABORT_OR_THROW("Policy value out of range"); } -} // namespace expt + return dynamic_helper::invoke_forall(r, pol, seg, params...); +} } // namespace RAJA