27 template<
typename T_DataType>
33 T_DataType
const& neutralElement,
35 auto const& reduceFunc,
36 auto const& transformFunc,
41 "The neutral element type must match the data output type.");
47 auto tbSum =
MdSpan{dynS, chunkExtents, pitchMd};
56 for(
auto elemIdxInFrame : traverseInFrame)
58 tbSum[elemIdxInFrame] = neutralElement;
61 auto const chunkDataExtent = numChunks * chunkExtents;
67 for(
auto chunkIdx : traverseOverFrames)
77 .transformReduce(acc, extentMd, neutralElement, reduceFunc, transformFunc, inputs...);
78 auto& tbSumRef = tbSum[elemIdxInChunk];
79 tbSumRef = reduceFunc(tbSumRef, reducedValue);
94 dynS[laneIdInBlock] = reduceFunc(dynS[laneIdInBlock], dynS[linearSharedElemIdx]);
101 for(
auto offset = blockSize / 2; offset > 0; offset /= 2)
104 if(laneIdInBlock < offset)
106 dynS[laneIdInBlock] = reduceFunc(dynS[laneIdInBlock], dynS[laneIdInBlock + offset]);
111 if(laneIdInBlock == 0)
119 using ReduceFunctor =
typename ALPAKA_TYPEOF(reduceFunc)::Functor;
121 static_cast<ReduceFunctor const&
>(reduceFunc),
124 dynS[laneIdInBlock]);
127 alpakaAtomicInvoke(reduceFunc, acc, output.data(), dynS[laneIdInBlock]);
132 template<
typename T_DataType>
136 T_DataType
const& neutralElement,
152 IndexType multiprocessorScaling = 1u;
157 multiprocessorScaling = 32u;
160 auto const numMultiProcessors = queue.getDevice().getDeviceProperties().multiProcessorCount;
162 frameSpec.getNumFrames(),
163 static_cast<IndexType
>(numMultiProcessors * multiprocessorScaling));
164 frameSpec =
FrameSpec{adjsutedNumFrames, frameSpec.getFrameExtents(),
exec};
172 auto chunkExtents = frameSpec.getFrameExtents();
175 static_cast<uint32_t
>(frameSpec.getFrameExtents().product() *
sizeof(T_DataType))};
181 std::stringstream ss;
188 onHost::fill(queue, out, neutralElement, out.getExtents().fill(1));
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...
#define ALPAKA_TYPEOF(...)
Get the type of instance.
#define ALPAKA_FORWARD(instance)
Perfectly forward an instance as argument.
Concept to check for an executor.
Interface concept for objects describing multidimensional memory access.
Validates if T is a specialization of the unspecialized template type U.
Concept to check if a type is a vector.
Concept to check if a type is an accelerator.
#define ALPAKA_LOG_INFO(logLvl, callable)
Write a meta data message to the output.
consteval auto adjustToLimit(concepts::CVector auto const input)
adjust the input vector to a given limit by halving all components until the product of these is belo...
ALPAKA_FN_ACC void alpakaAtomicInvoke(auto &&fn, concepts::Acc auto const &acc, auto *inOut, auto &&... args)
Defines the equivalent of an atomic invoke for user defined functors.
constexpr auto blocksInGrid
constexpr auto linearThreadsInBlock
constexpr auto threadsInBlock
ALPAKA_FN_HOST_ACC constexpr auto makeIdxMap(auto const &acc, auto const workGroup, auto const range, T_Traverse traverse=T_Traverse{}, T_IdxLayout idxLayout=T_IdxLayout{})
Creates an index container.
constexpr auto getDynSharedMem(concepts::Acc auto const &acc) -> T *
Get block shared dynamic memory.
constexpr void syncBlockThreads(concepts::Acc auto const &acc)
Synchronize all threads within a thread block.
constexpr auto getSimdFrameSpec(auto const &internalDevice, alpaka::concepts::Executor auto executor, alpaka::concepts::VectorOrScalar auto const &extents)
Provides a SIMD optimized frame specification.
void transformReduce(auto const &queue, alpaka::concepts::Executor auto const exec, T_DataType const &neutralElement, alpaka::concepts::IMdSpan auto out, auto &&reduceFn, auto &&transformFn, auto &&in0, alpaka::concepts::IDataSource auto &&... in)
void fill(Queue< T_Device, T_QueueKind > const &queue, auto &&dest, T_Value elementValue)
fill memory element wise
constexpr auto demangledName()
decltype(auto) getExtents(auto &&any)
Object extents.
typename GetValueType< T >::type GetValueType_t
constexpr auto calculatePitchesFromExtents(T_Vec const &extent)
Calculate the pitches purely from the extents.
constexpr T_IntegralType linearize(Vec< T_IntegralType, T_dim - 1u, T_Storage > const &dim, Vec< T_IntegralType, T_dim, T_OtherStorage > const &idx)
Give the linear index of an N-dimensional index within an N-dimensional index space.
Lightweight view to data in an n-dimensional array.
Marks a functor that can only be executed with scalar types and not SIMD packages.
Marks a functor which supports SimdPtr as arguments.
Creates a functor operate on contiguous data concurrently.
Device/Api-agnostic description of the logical parallelism exposed to a kernel.
constexpr NumFramesVecType const & getNumFrames() const noexcept