alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
ExecuteForEachAccTag.hpp
Go to the documentation of this file.
1/* Copyright 2023 Jeffrey Kelling, Bernhard Manfred Gruber, Jan Stephan, Aurora Perego, Andrea Bocci
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#include "alpaka/alpaka.hpp"
6
7#include <functional>
8#include <tuple>
9#include <utility>
10
11#pragma once
12
13namespace alpaka
14{
15 //! execute a callable for each active accelerator tag
16 //
17 // @param callable callable which can be invoked with an accelerator tag
18 // @return disjunction of all invocation results
19 //
20 template<typename TCallable>
21 inline auto executeForEachAccTag(TCallable&& callable)
22 {
23 // Execute the callable once for each enabled accelerator.
24 // Pass the tag as first argument to the callable.
25 return std::apply([=](auto const&... tags) { return (callable(tags) || ...); }, alpaka::EnabledAccTags{});
26 }
27} // namespace alpaka
The alpaka accelerator library.
auto executeForEachAccTag(TCallable &&callable)
execute a callable for each active accelerator tag
alpaka::meta::Filter< AccTags, alpaka::AccIsEnabled > EnabledAccTags
list of all tags where the related accelerator is enabled