alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
concurrent.hpp
Go to the documentation of this file.
1/* Copyright 2025 René Widera
2 * SPDX-License-Identifier: MPL-2.0
3 */
4
5#pragma once
6
7#include "alpaka/Vec.hpp"
9#include "alpaka/functor.hpp"
10#include "alpaka/onAcc/Acc.hpp"
14#include "alpaka/trait.hpp"
15
17{
19 {
21 onAcc::concepts::Acc auto const& acc,
22 alpaka::concepts::VectorOrScalar auto const& extents,
23 auto const& func,
24 alpaka::concepts::IDataSource auto&&... inputs) const
25 {
26 Vec const extentMd = extents;
28
29 return simdGrid.concurrent(
30 acc,
31 extentMd,
32 [&func](auto const& acc, auto&&... in)
33 {
34 static_assert(
35 std::same_as<decltype(callFunctor(acc, func, ALPAKA_FORWARD(in)...)), void>,
36 "The return type for a stencil concurrent functor should be void.");
37 callFunctor(acc, func, ALPAKA_FORWARD(in)...);
38 },
39 ALPAKA_FORWARD(inputs)...);
40 }
41 };
42
43 template<typename T_DataType>
44 inline void concurrent(
45 auto const& queue,
47 alpaka::concepts::VectorOrScalar auto const& extents,
48 auto&& fn,
50 {
51 Vec const extentMd = extents;
52 auto frameSpec = getSimdFrameSpec<T_DataType>(queue.getDevice(), exec, extentMd);
53
56 [&]()
57 {
58 std::stringstream ss;
59 ss << "concurrent{ extents=" << extentMd << ", value_type=" << onHost::demangledName<T_DataType>()
60 << ", " << frameSpec << ", fn=" << onHost::demangledName(fn) << " }";
61 return ss.str();
62 });
63
64 queue.enqueue(
65 frameSpec,
67 }
68} // namespace alpaka::onHost::internal
The class used to bind kernel function object and arguments together. Once an instance of this class ...
#define ALPAKA_FN_ACC
All functions that can be used on an accelerator have to be attributed with ALPAKA_FN_ACC or ALPAKA_F...
Definition common.hpp:31
#define ALPAKA_FORWARD(instance)
Perfectly forward an instance as argument.
Definition common.hpp:148
Concept to check for an executor.
Definition trait.hpp:133
Concept to check if a type is a vector or scalar variable.
Definition Vec.hpp:65
Concept to check if a type is an accelerator.
Definition Acc.hpp:119
#define ALPAKA_LOG_INFO(logLvl, callable)
Write a meta data message to the output.
Definition logger.hpp:106
alpaka'S function interface
Definition fn.hpp:38
constexpr auto threadsInGrid
constexpr auto getSimdFrameSpec(auto const &internalDevice, alpaka::concepts::Executor auto executor, alpaka::concepts::VectorOrScalar auto const &extents)
Provides a SIMD optimized frame specification.
void concurrent(auto const &queue, alpaka::concepts::Executor auto const exec, alpaka::concepts::VectorOrScalar auto const &extents, auto &&fn, alpaka::concepts::IDataSource auto &&... in)
constexpr auto memory
Definition lvl.hpp:112
constexpr auto demangledName()
constexpr auto callFunctor(T_Acc const &acc, T_Functor &&functor, T_Args &&... args)
Execute the functor with or without an accelerator as first argument.
Definition functor.hpp:58
Creates a functor operate on contiguous data concurrently.
Definition SimdAlgo.hpp:36
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr void concurrent(auto const &acc, auto &&func, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const
execute the functor concurrently over the given data.
Definition SimdAlgo.hpp:73
ALPAKA_FN_ACC void operator()(onAcc::concepts::Acc auto const &acc, alpaka::concepts::VectorOrScalar auto const &extents, auto const &func, alpaka::concepts::IDataSource auto &&... inputs) const