Skip to content

Commit

Permalink
Prints acc tags at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetyusufoglu committed Oct 8, 2024
1 parent f778f87 commit 2f73786
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example/heatEquation2D/src/heatEquation2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,8 @@ auto main() -> int
// TagCpuSerial, TagGpuHipRt, TagGpuCudaRt, TagCpuOmp2Blocks, TagCpuTbbBlocks,
// TagCpuOmp2Threads, TagCpuSycl, TagCpuTbbBlocks, TagCpuThreads,
// TagFpgaSyclIntel, TagGenericSycl, TagGpuSyclIntel

std::cout << "Check enabled accelerator tags:" << std::endl;
alpaka::printTagNames<alpaka::EnabledAccTags>();
return alpaka::executeForEachAccTag([=](auto const& tag) { return example(tag); });
}
25 changes: 25 additions & 0 deletions include/alpaka/acc/Tag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "alpaka/core/BoostPredef.hpp"

#include <iostream>
#include <tuple>
#include <type_traits>

#define CREATE_ACC_TAG(tag_name) \
Expand Down Expand Up @@ -69,4 +70,28 @@ namespace alpaka
alpaka::TagFpgaSyclIntel,
alpaka::TagGpuSyclIntel>;

//! \brief Function to print the names of each tag in the given tuple of tags
//! \tparam TTuple is the type of the tuple of tags
template<typename TTuple>
void printTagNames()
{
// Check if the tuple is empty using std::tuple_size
if(std::tuple_size<TTuple>{} == 0)
{
std::cout << "No Tags!";
}
else
{
std::cout << "Tags: ";
// Print tags with comma in between
std::apply(
[](auto... args)
{
auto index = std::tuple_size_v<TTuple>;
((std::cout << args.get_name() << (--index > 0u ? "," : "")), ...);
},
TTuple{});
}
std::cout << std::endl;
}
} // namespace alpaka

0 comments on commit 2f73786

Please sign in to comment.