Skip to content

Commit

Permalink
support non-naming of kernels
Browse files Browse the repository at this point in the history
  • Loading branch information
artv3 committed Dec 26, 2024
1 parent 03b43e6 commit 5ec0597
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions examples/plugin/caliper-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class CaliperPlugin : public RAJA::util::PluginStrategy
public:
void preLaunch(const RAJA::util::PluginContext&p) override
{
CALI_MARK_BEGIN(p.kernel_name->c_str());
if(!p.kernel_name->empty()) CALI_MARK_BEGIN(p.kernel_name->c_str());
}

void postLaunch(const RAJA::util::PluginContext& p) override
{
CALI_MARK_END(p.kernel_name->c_str());
if(!p.kernel_name->empty()) CALI_MARK_END(p.kernel_name->c_str());
}

private:
Expand Down
5 changes: 2 additions & 3 deletions examples/plugin/raja-caliper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void printResult(double* v, int len);

int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))
{
CALI_CXX_MARK_FUNCTION;
std::cout << "\n\nRAJA daxpy example...\n";

//
Expand Down Expand Up @@ -110,7 +109,7 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))
std::cout << "\n Running RAJA sequential daxpy...\n";

std::memcpy( a, a0, N * sizeof(double) );

#if 1
{
timer.reset();
timer.start();
Expand All @@ -124,7 +123,7 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))
RAJA::Timer::ElapsedType etime = timer.elapsed();
std::cout << "C-version elapsed time : " << etime << " seconds" << std::endl;
}

#endif
checkResult(a, aref, N);
//printResult(a, N);

Expand Down
29 changes: 21 additions & 8 deletions include/RAJA/pattern/forall.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <functional>
#include <iterator>
#include <type_traits>
#include <typeinfo>

#include "RAJA/internal/Iterators.hpp"

Expand Down Expand Up @@ -509,6 +510,25 @@ forall_Icount(ExecutionPolicy&& p,
******************************************************************************
*/

template<typename T>
struct get_kernel_name
{
template<typename U>
static std::string get(U &)
{
return std::string(); //return empty string
}
};

template<>
struct get_kernel_name<RAJA::expt::detail::KernelName>
{
static std::string get(const RAJA::expt::detail::KernelName &kernel_name)
{
return kernel_name.name;
}
};

template <typename ExecutionPolicy, typename Res, typename Container, typename... Params>
RAJA_INLINE concepts::enable_if_t<
resources::EventProxy<Res>,
Expand All @@ -527,14 +547,7 @@ forall(ExecutionPolicy&& p, Res r, Container&& c, Params&&... params)

expt::check_forall_optional_args(loop_body, f_params);

//Need to handle the case in which we have no kernel name...
std::string kname;
if (std::is_same<decltype(kernel_name), RAJA::expt::detail::KernelName>::value == true){
std::cout<<" found a kernel name: "<<kernel_name.name<<" assigning it to kernel... " <<std::endl;
kname = kernel_name.name;
}else{
kname = "-1";
}
std::string kname = get_kernel_name<decltype(kernel_name)>::get(kernel_name);

util::PluginContext context{util::make_context<camp::decay<ExecutionPolicy>>(&kname)};
util::callPreCapturePlugins(context);
Expand Down

0 comments on commit 5ec0597

Please sign in to comment.