diff --git a/examples/dynamic_mat_transpose.cpp b/examples/dynamic_mat_transpose.cpp index feb5247224..2002f39b6f 100644 --- a/examples/dynamic_mat_transpose.cpp +++ b/examples/dynamic_mat_transpose.cpp @@ -325,7 +325,7 @@ int main(int argc, char *argv[]) RAJA::launch (res, RAJA::LaunchParams(RAJA::Teams(outer_Dimc, outer_Dimr), RAJA::Threads(TILE_DIM, TILE_DIM), dynamic_shared_mem_size), - "Matrix tranpose with dynamic shared memory kernel", + RAJA::expt::KernelName("Matrix tranpose with dynamic shared memory kernel"), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { RAJA::loop(ctx, RAJA::RangeSegment(0, outer_Dimr), [&] (int by){ diff --git a/examples/launch-param-reductions.cpp b/examples/launch-param-reductions.cpp index 5bec907c33..c7b732d341 100644 --- a/examples/launch-param-reductions.cpp +++ b/examples/launch-param-reductions.cpp @@ -151,7 +151,7 @@ int main(int RAJA_UNUSED_ARG(argc), char** RAJA_UNUSED_ARG(argv[])) RAJA::Index_type seq_maxloc2(-1); RAJA::launch - (host_res, RAJA::LaunchParams(), "SeqReductionKernel", + (host_res, RAJA::LaunchParams(), RAJA::expt::Reduce(&seq_sum), RAJA::expt::Reduce(&seq_min), RAJA::expt::Reduce(&seq_max), @@ -159,6 +159,7 @@ int main(int RAJA_UNUSED_ARG(argc), char** RAJA_UNUSED_ARG(argv[])) RAJA::expt::Reduce(&seq_maxloc), RAJA::expt::ReduceLoc(&seq_min2, &seq_minloc2), RAJA::expt::ReduceLoc(&seq_max2, &seq_maxloc2), + RAJA::expt::KernelName("SeqReductionKernel"), [=] RAJA_HOST_DEVICE ( RAJA::LaunchContext ctx, VALOP_INT_SUM &_seq_sum, VALOP_INT_MIN &_seq_min, @@ -218,7 +219,7 @@ int main(int RAJA_UNUSED_ARG(argc), char** RAJA_UNUSED_ARG(argv[])) RAJA::Index_type omp_maxloc2(-1); RAJA::launch - (host_res, RAJA::LaunchParams(), "OmpReductionKernel", + (host_res, RAJA::LaunchParams(), RAJA::expt::Reduce(&omp_sum), RAJA::expt::Reduce(&omp_min), RAJA::expt::Reduce(&omp_max), @@ -226,6 +227,7 @@ int main(int RAJA_UNUSED_ARG(argc), char** RAJA_UNUSED_ARG(argv[])) RAJA::expt::Reduce(&omp_maxloc), RAJA::expt::ReduceLoc(&omp_min2, &omp_minloc2), RAJA::expt::ReduceLoc(&omp_max2, &omp_maxloc2), + RAJA::expt::KernelName("OmpReductionKernel"), [=] RAJA_HOST_DEVICE (RAJA::LaunchContext ctx, VALOP_INT_SUM &_omp_sum, VALOP_INT_MIN &_omp_min, diff --git a/examples/launch_reductions.cpp b/examples/launch_reductions.cpp index 24e313e649..13c90b28da 100644 --- a/examples/launch_reductions.cpp +++ b/examples/launch_reductions.cpp @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) (select_cpu_or_gpu, RAJA::LaunchParams(RAJA::Teams(GRID_SZ), RAJA::Threads(TEAM_SZ)), - "Launch Reductions", + RAJA::expt::KernelName("Launch Reductions"), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { diff --git a/include/RAJA/pattern/launch/launch_core.hpp b/include/RAJA/pattern/launch/launch_core.hpp index 53aee6f264..6a63063cb2 100644 --- a/include/RAJA/pattern/launch/launch_core.hpp +++ b/include/RAJA/pattern/launch/launch_core.hpp @@ -215,53 +215,13 @@ class LaunchContext } }; -//----------- - template struct LaunchExecute; -//Policy based launch with support to new reducers... -template -void launch(LaunchParams const &launch_params, const char *kernel_name, ReduceParams&&... rest_of_launch_args) -{ - - //Get reducers - auto reducers = expt::make_forall_param_pack(std::forward(rest_of_launch_args)...); - - //kernel name - std::string kname; - - auto&& launch_body = expt::get_lambda(std::forward(rest_of_launch_args)...); - - //Take the first policy as we assume the second policy is not user defined. - //We rely on the user to pair launch and loop policies correctly. - util::PluginContext context{util::make_context(&kname)}; - util::callPreCapturePlugins(context); - - using RAJA::util::trigger_updates_before; - auto p_body = trigger_updates_before(launch_body); - - util::callPostCapturePlugins(context); - - util::callPreLaunchPlugins(context); - - using launch_t = LaunchExecute; - - using Res = typename resources::get_resource::type; - - launch_t::exec(Res::get_default(), launch_params, kernel_name, p_body, reducers); - - util::callPostLaunchPlugins(context); -} - - //Duplicate of code above on account that we need to support the case in which a kernel_name is not given template void launch(LaunchParams const &launch_params, ReduceParams&&... rest_of_launch_args) { - std::cout<<"-----RAJA launch!----"<(rest_of_launch_args)...); @@ -287,7 +247,7 @@ void launch(LaunchParams const &launch_params, ReduceParams&&... rest_of_launch_ using Res = typename resources::get_resource::type; - launch_t::exec(Res::get_default(), launch_params, kernel_name_ptr, p_body, reducers); + launch_t::exec(Res::get_default(), launch_params, nullptr, p_body, reducers); util::callPostLaunchPlugins(context); } @@ -301,78 +261,25 @@ void launch(ExecPlace place, LaunchParams const ¶ms, BODY const &body) launch(place, params, nullptr, body); } -template -void launch(ExecPlace place, const LaunchParams ¶ms, const char *kernel_name, BODY const &body) -{ - - //Forward to single policy launch API - simplifies testing of plugins - switch (place) { - case ExecPlace::HOST: { - using Res = typename resources::get_resource::type; - launch>(Res::get_default(), params, kernel_name, body); - break; - } -#if defined(RAJA_GPU_ACTIVE) - case ExecPlace::DEVICE: { - using Res = typename resources::get_resource::type; - launch>(Res::get_default(), params, kernel_name, body); - break; - } -#endif - default: - RAJA_ABORT_OR_THROW("Unknown launch place or device is not enabled"); - } - -} - -//Run-time API for new reducer interface -template -void launch(ExecPlace place, const LaunchParams &launch_params, const char *kernel_name, ReduceParams&&... rest_of_launch_args) -{ - - //Forward to single policy launch API - simplifies testing of plugins - switch (place) { - case ExecPlace::HOST: { - using Res = typename resources::get_resource::type; - launch> - (Res::get_default(), launch_params, kernel_name, std::forward(rest_of_launch_args)...); - break; - } -#if defined(RAJA_GPU_ACTIVE) - case ExecPlace::DEVICE: { - using Res = typename resources::get_resource::type; - launch> - (Res::get_default(), launch_params, kernel_name, std::forward(rest_of_launch_args)...); - break; - } -#endif - default: - RAJA_ABORT_OR_THROW("Unknown launch place or device is not enabled"); - } - -} - //Run-time API for new reducer interface with support of the case without a new kernel name template void launch(ExecPlace place, const LaunchParams &launch_params, ReduceParams&&... rest_of_launch_args) //BODY const &body) { - const char *kernel_name = nullptr; - //Forward to single policy launch API - simplifies testing of plugins switch (place) { case ExecPlace::HOST: { using Res = typename resources::get_resource::type; launch> - (Res::get_default(), launch_params, kernel_name, std::forward(rest_of_launch_args)...); + (Res::get_default(), launch_params, std::forward(rest_of_launch_args)...); break; } #if defined(RAJA_GPU_ACTIVE) case ExecPlace::DEVICE: { using Res = typename resources::get_resource::type; launch> - (Res::get_default(), launch_params, kernel_name, std::forward(rest_of_launch_args)...); + (Res::get_default(), launch_params, std::forward(rest_of_launch_args)...); break; } #endif @@ -400,73 +307,6 @@ RAJA::resources::Resource Get_Host_Resource(T host_res, RAJA::ExecPlace device){ } //Launch API which takes team resource struct and supports new reducers -template -resources::EventProxy -launch(RAJA::resources::Resource res, LaunchParams const &launch_params, - const char *kernel_name, ReduceParams&&... rest_of_launch_args) -{ - - //Get reducers - auto reducers = expt::make_forall_param_pack(std::forward(rest_of_launch_args)...); - - auto&& launch_body = expt::get_lambda(std::forward(rest_of_launch_args)...); - - ExecPlace place; - if(res.get_platform() == RAJA::Platform::host) { - place = RAJA::ExecPlace::HOST; - } else { - place = RAJA::ExecPlace::DEVICE; - } - - //Get kernel name - std::string kname; - - // - //Configure plugins - // -#if defined(RAJA_GPU_ACTIVE) - util::PluginContext context{place == ExecPlace::HOST ? - util::make_context(&kname) : - util::make_context(&kname)}; -#else - util::PluginContext context{util::make_context(&kname)}; -#endif - - util::callPreCapturePlugins(context); - - using RAJA::util::trigger_updates_before; - auto p_body = trigger_updates_before(launch_body); - - util::callPostCapturePlugins(context); - - util::callPreLaunchPlugins(context); - - switch (place) { - case ExecPlace::HOST: { - using launch_t = LaunchExecute; - resources::EventProxy e_proxy = launch_t::exec(res, launch_params, kernel_name, p_body, reducers); - util::callPostLaunchPlugins(context); - return e_proxy; - } -#if defined(RAJA_GPU_ACTIVE) - case ExecPlace::DEVICE: { - using launch_t = LaunchExecute; - resources::EventProxy e_proxy = launch_t::exec(res, launch_params, kernel_name, p_body, reducers); - util::callPostLaunchPlugins(context); - return e_proxy; - } -#endif - default: { - RAJA_ABORT_OR_THROW("Unknown launch place or device is not enabled"); - } - } - - RAJA_ABORT_OR_THROW("Unknown launch place"); - - //^^ RAJA will abort before getting here - return resources::EventProxy(res); -} - //Duplicate of API above on account that we need to handle the case that a kernel name is not provided template @@ -475,12 +315,11 @@ launch(RAJA::resources::Resource res, LaunchParams const &launch_params, ReduceParams&&... rest_of_launch_args) { - const char *kernel_name = nullptr; - //Get reducers auto reducers = expt::make_forall_param_pack(std::forward(rest_of_launch_args)...); - std::string kname; + auto kernel_name = expt::get_kernel_name(std::forward(rest_of_launch_args)...); + std::string kname = get_kernel_name::get(kernel_name); auto&& launch_body = expt::get_lambda(std::forward(rest_of_launch_args)...); @@ -514,14 +353,14 @@ launch(RAJA::resources::Resource res, LaunchParams const &launch_params, switch (place) { case ExecPlace::HOST: { using launch_t = LaunchExecute; - resources::EventProxy e_proxy = launch_t::exec(res, launch_params, kernel_name, p_body, reducers); + resources::EventProxy e_proxy = launch_t::exec(res, launch_params, nullptr, p_body, reducers); util::callPostLaunchPlugins(context); return e_proxy; } #if defined(RAJA_GPU_ACTIVE) case ExecPlace::DEVICE: { using launch_t = LaunchExecute; - resources::EventProxy e_proxy = launch_t::exec(res, launch_params, kernel_name, p_body, reducers); + resources::EventProxy e_proxy = launch_t::exec(res, launch_params, nullptr, p_body, reducers); util::callPostLaunchPlugins(context); return e_proxy; } diff --git a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceMin.hpp b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceMin.hpp index 91ab75dbab..f4f377ae43 100644 --- a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceMin.hpp +++ b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceMin.hpp @@ -59,9 +59,9 @@ void LaunchParamExptReduceMinBasicTestImpl(const SEG_TYPE& seg, RAJA::launch (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), - "LaunchMinBasicTest", RAJA::expt::Reduce(&mininit), RAJA::expt::Reduce(&min), + RAJA::expt::KernelName("LaunchMinBasicTest"), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx, REF_MIN &_mininit, REF_MIN &_min) { RAJA::loop(ctx, seg, [&](IDX_TYPE idx) { diff --git a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceSum.hpp b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceSum.hpp index f6200628cf..f15bdc53cd 100644 --- a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceSum.hpp +++ b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceSum.hpp @@ -57,9 +57,9 @@ void LaunchParamExptReduceSumBasicTestImpl(const SEG_TYPE& seg, RAJA::launch (RAJA::LaunchParams(RAJA::Teams(blocks), RAJA::Threads(threads)), - "LaunchSumBasicTest", RAJA::expt::Reduce(&sum), RAJA::expt::Reduce(&sum2), + RAJA::expt::KernelName("LaunchSumBasicTest"), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx, REF_SUM &_sum, REF_SUM &_sum2) { RAJA::loop(ctx, seg, [&](IDX_TYPE idx) {