From 6796c9244aed343976fa7cb9b08e24896a6301a6 Mon Sep 17 00:00:00 2001 From: mehmet yusufoglu Date: Mon, 7 Oct 2024 18:38:39 +0200 Subject: [PATCH] Prints acc tags at runtime --- example/heatEquation2D/src/heatEquation2D.cpp | 2 ++ include/alpaka/acc/Tag.hpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/example/heatEquation2D/src/heatEquation2D.cpp b/example/heatEquation2D/src/heatEquation2D.cpp index b186e9ec6dba..a90aa47fcc17 100644 --- a/example/heatEquation2D/src/heatEquation2D.cpp +++ b/example/heatEquation2D/src/heatEquation2D.cpp @@ -215,5 +215,7 @@ auto main() -> int // TagCpuSerial, TagGpuHipRt, TagGpuCudaRt, TagCpuOmp2Blocks, TagCpuTbbBlocks, // TagCpuOmp2Threads, TagCpuSycl, TagCpuTbbBlocks, TagCpuThreads, // TagFpgaSyclIntel, TagGenericSycl, TagGpuSyclIntel + + alpaka::printAccTags(); return alpaka::executeForEachAccTag([=](auto const& tag) { return example(tag); }); } diff --git a/include/alpaka/acc/Tag.hpp b/include/alpaka/acc/Tag.hpp index f7880afd6f15..7ad166059f65 100644 --- a/include/alpaka/acc/Tag.hpp +++ b/include/alpaka/acc/Tag.hpp @@ -7,6 +7,7 @@ #include "alpaka/core/BoostPredef.hpp" #include +#include #include #define CREATE_ACC_TAG(tag_name) \ @@ -69,4 +70,21 @@ namespace alpaka alpaka::TagFpgaSyclIntel, alpaka::TagGpuSyclIntel>; + //! \brief Function to print the names of each tag in the given tuple of acc tags + //! \tparam TTuple is the type of the tuple of tags + template + void printAccTags() + { + // Check if the tuple is empty using std::tuple_size + if(std::tuple_size{} == 0) + { + std::cout << "No Acc Tags!"; + } + else + { + std::cout << "Acc Tags: "; + std::apply([](auto... args) { ((std::cout << args.get_name() << " "), ...); }, TTuple{}); + } + std::cout << std::endl; + } } // namespace alpaka