Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prints Acc tags of tags-tuple at runtime #2411

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

mehmetyusufoglu
Copy link
Contributor

@mehmetyusufoglu mehmetyusufoglu commented Oct 7, 2024

Examples was exiting silently if there are no enabled backends. This issue is reported by the assistants of the october2024 workshop.

This PR creates a function that prints the Acc-tags of the enabled backends at runtime. If there is no backends, the user is informed.

./heatEquation2D
Check enabled accelerator tags:
No Tags!
./heatEquation2D 
Check enabled accelerator tags:
Tags: TagCpuSerial,TagCpuThreads
Using alpaka accelerator: AccCpuSerial<2,unsigned int>
Execution results correct!
Using alpaka accelerator: AccCpuThreads<2,unsigned int>
Execution results correct!

@mehmetyusufoglu mehmetyusufoglu force-pushed the printTagType branch 2 times, most recently from 42b5e5a to 6796c92 Compare October 7, 2024 17:57
example/heatEquation2D/src/heatEquation2D.cpp Outdated Show resolved Hide resolved
void printAccTags()
{
// Check if the tuple is empty using std::tuple_size
if(std::tuple_size<TTuple>{} == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::size_size_v<TTuple>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done using std::tuple_size_v

else
{
std::cout << "Acc Tags: ";
std::apply([](auto... args) { ((std::cout << args.get_name() << " "), ...); }, TTuple{});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest something like this following code (Not tested) to have a comma seperated list.

std::apply(
  [](auto... args) { 
    auto i = std::size_size_v<TTuple>;
    ((std::cout << args.get_name() << (--i > 0u ? "," : "")), ...);
  }, 
  TTuple{}
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, good idea

Copy link
Contributor Author

@mehmetyusufoglu mehmetyusufoglu Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatives exists using make_index_sequence but i preferred this since it is still cleaner. thanks.

@mehmetyusufoglu mehmetyusufoglu force-pushed the printTagType branch 2 times, most recently from 879ce62 to 5bf182f Compare October 8, 2024 13:02
@mehmetyusufoglu mehmetyusufoglu changed the title Prints Acc tags of tags-tuple type at runtime Prints Acc tags of tags-tuple at runtime Oct 8, 2024
@psychocoderHPC psychocoderHPC added this to the 2.0.0 milestone Oct 9, 2024
@psychocoderHPC
Copy link
Member

I updated already which CI jobs are required. This PR was created before the last merge where clang10-12 got removed, therefore I merge it with my admin power.

@psychocoderHPC psychocoderHPC merged commit 1aeeccd into alpaka-group:develop Oct 9, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants