alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout > Struct Template Reference

Creates a functor operate on contiguous data concurrently. More...

#include <SimdAlgo.hpp>

Inheritance diagram for alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >:

Classes

struct  SimdPackConfig

Public Member Functions

constexpr SimdAlgo (T_WorkGroup const workGroup, T_Traverse traverse=T_Traverse{}, T_IdxLayout idxLayout=T_IdxLayout{})
constexpr T_IdxLayout getIdxLayoutPolicy () const
constexpr T_Traverse getTraversePolicy () const
constexpr T_WorkGroup getWorkGroup () const
template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto transformReduce (auto const &acc, alpaka::concepts::Vector auto extents, auto const &neutralElement, auto &&reduceFunc, auto &&transformFunc, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const
 transform the input data and reduce it to a single value
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto transformReduce (auto const &acc, alpaka::concepts::Vector auto extents, auto const &neutralElement, auto &&reduceFunc, auto &&transformFunc, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const
 transform the input data and reduce it to a single value
template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto transformReduce (auto const &acc, auto const &neutralElement, auto &&reduceFunc, auto &&transformFunc, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const
 transform the input data and reduce it to a single value
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto transformReduce (auto const &acc, auto const &neutralElement, auto &&reduceFunc, auto &&transformFunc, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const
 transform the input data and reduce it to a single value
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.
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr void concurrent (auto const &acc, alpaka::concepts::Vector auto extents, auto &&func, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const
template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
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.
template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr void concurrent (auto const &acc, alpaka::concepts::Vector auto extents, auto &&func, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const

Private Types

using ConcurrentAlgo = internal::SimdConcurrent<SimdAlgo<T_WorkGroup, T_Traverse, T_IdxLayout>>
using ReduceAlgo = internal::SimdTransformReduce<SimdAlgo<T_WorkGroup, T_Traverse, T_IdxLayout>>

Static Private Member Functions

template<typename T_ValueType>
static consteval SimdPackConfig< T_ValueType > calcSimdPackConfig (alpaka::concepts::Api auto api, alpaka::concepts::DeviceKind auto deviceKind, uint32_t maxConcurrencyInByte)
 Generate a SIMD config for the API and device kind.
template<typename T_Type, uint32_t T_maxConcurrencyInByte, uint32_t T_cacheLineInByte>
static constexpr auto calcSimdWidth ()

Private Attributes

friend ConcurrentAlgo
T_WorkGroup m_workGroup
friend ReduceAlgo

Additional Inherited Members

Protected Member Functions inherited from alpaka::onAcc::internal::SimdConcurrent< SimdAlgo< T_WorkGroup, traverse::Flat, layout::Optimized > >
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr void concurrent (auto const &acc, alpaka::concepts::Vector auto extents, auto &&func, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const
constexpr SimdConcurrent ()=default
Protected Member Functions inherited from alpaka::onAcc::internal::SimdTransformReduce< SimdAlgo< T_WorkGroup, traverse::Flat, layout::Optimized > >
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto transformReduce (concepts::Acc auto const &acc, alpaka::concepts::Vector auto extents, auto const &neutralElement, auto &&reduceFunc, auto &&func, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const
constexpr SimdTransformReduce ()=default

Detailed Description

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
struct alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >

Creates a functor operate on contiguous data concurrently.

The class is automatically configured to use the best fitting SIMD width for the given data type and is able to expose instruction level parallelism.

Parameters
T_WorkGroupparticipating thread description. More than one thread can have the same index within the group. All worker with the same id will get the same index as result.
T_TraversePolicy to configure the method used to find the next valid index for a worker.
See also
namespace traverse
Parameters
T_IdxLayoutPolicy to define how index data will be mapped to worker threads.
See also
namespace layout

Definition at line 33 of file SimdAlgo.hpp.

Member Typedef Documentation

◆ ConcurrentAlgo

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
using alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::ConcurrentAlgo = internal::SimdConcurrent<SimdAlgo<T_WorkGroup, T_Traverse, T_IdxLayout>>
private

Definition at line 292 of file SimdAlgo.hpp.

◆ ReduceAlgo

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
using alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::ReduceAlgo = internal::SimdTransformReduce<SimdAlgo<T_WorkGroup, T_Traverse, T_IdxLayout>>
private

Definition at line 293 of file SimdAlgo.hpp.

Constructor & Destructor Documentation

◆ SimdAlgo()

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::SimdAlgo ( T_WorkGroup const workGroup,
T_Traverse traverse = T_Traverse{},
T_IdxLayout idxLayout = T_IdxLayout{} )
inlineconstexpr

Definition at line 37 of file SimdAlgo.hpp.

Member Function Documentation

◆ calcSimdPackConfig()

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
template<typename T_ValueType>
consteval SimdPackConfig< T_ValueType > alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::calcSimdPackConfig ( alpaka::concepts::Api auto api,
alpaka::concepts::DeviceKind auto deviceKind,
uint32_t maxConcurrencyInByte )
inlinestaticnodiscardconstevalprivate

Generate a SIMD config for the API and device kind.

Produces an optimized SIMD configuration based on technical constraints. The SIMD is set to a power of two. If possible, the SIMD configuration is aligned to the cacheline size for the given device kind.

Parameters
maxConcurrencyInByteThe upper limit in bytes a SIMD configuration must not exceed, except a single value is larger. This parameter is used to control the register pressure.
Returns
a configuration with the number of SIMD pack which should be used in parallel for a single invocation. And the width of a single SIMD pack.

Definition at line 326 of file SimdAlgo.hpp.

◆ calcSimdWidth()

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
template<typename T_Type, uint32_t T_maxConcurrencyInByte, uint32_t T_cacheLineInByte>
constexpr auto alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::calcSimdWidth ( )
inlinestaticconstexprprivate

Definition at line 299 of file SimdAlgo.hpp.

◆ concurrent() [1/4]

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr void alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::concurrent ( auto const & acc,
alpaka::concepts::Vector auto extents,
auto && func,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN ) const
inlineconstexpr
Parameters
extentsnumber of elements to process in each dimension

Definition at line 144 of file SimdAlgo.hpp.

◆ concurrent() [2/4]

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr void alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::concurrent ( auto const & acc,
alpaka::concepts::Vector auto extents,
auto && func,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN ) const
inlineconstexpr
Parameters
extentsnumber of elements to process in each dimension

Definition at line 85 of file SimdAlgo.hpp.

◆ concurrent() [3/4]

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr void alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::concurrent ( auto const & acc,
auto && func,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN ) const
inlineconstexpr

execute the functor concurrently over the given data.

Attention
The number of elements to process is derived from the first MdSpan object. All other MdSpan objects must have at least the same number of elements.
Parameters
T_maxConcurrencyInByteMaximum number of bytes to be used for concurrency. Concurrency bytes describe a virtual simd pack size which is not exceeded. Internally a best fitting SIMD width is calculated and instruction parallelism is exposed based on T_maxConcurrencyInByte.
T_MemAlignmentalignment of the memory, if no alignments is given the alignment will be derived from the MdSpan data descriptions
functhe functor to be executed
data0the first data to be processed
dataNthe remaining data to be processed

Definition at line 126 of file SimdAlgo.hpp.

◆ concurrent() [4/4]

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr void alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::concurrent ( auto const & acc,
auto && func,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN ) const
inlineconstexpr

execute the functor concurrently over the given data.

Attention
The number of elements to process is derived from the first MdSpan object. All other MdSpan objects must have at least the same number of elements. The optimal concurrency is also derived from the first MdSpan.
Parameters
functhe functor to be executed
data0the first data to be processed
dataNthe remaining data to be processed

Definition at line 73 of file SimdAlgo.hpp.

◆ getIdxLayoutPolicy()

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
T_IdxLayout alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::getIdxLayoutPolicy ( ) const
inlineconstexpr

Definition at line 56 of file SimdAlgo.hpp.

◆ getTraversePolicy()

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
T_Traverse alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::getTraversePolicy ( ) const
inlineconstexpr

Definition at line 51 of file SimdAlgo.hpp.

◆ getWorkGroup()

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
T_WorkGroup alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::getWorkGroup ( ) const
inlineconstexpr

Definition at line 46 of file SimdAlgo.hpp.

◆ transformReduce() [1/4]

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::transformReduce ( auto const & acc,
alpaka::concepts::Vector auto extents,
auto const & neutralElement,
auto && reduceFunc,
auto && transformFunc,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN ) const
inlineconstexpr

transform the input data and reduce it to a single value

Attention
If no extent is given the number of elements to process is derived from the first MdSpan object. All other MdSpan objects must have at least the same number of elements.
Parameters
neutralElementthe neutral element for the reduction operation
reduceFuncThe binary reduction operation to be executed, e.g. std::plus. The functor should support Simd packages.
transformFuncN-nary functor to be executed, values of all containers will be passed to the functor as arguments. The functor should support Simd packages. If not you can enforce the element wise execution by wrapping into ScalarFunc. If you would like to support stencil executions wrapp fn into StencilFunc. StencilFunc is getting all arguments as SimdPtr. If StencilFunc is used you should take care to not read outside of valid memory ranges by using sub-views to your input and output data. Optionally a transformFn can have an accelerator as first argument. If the result of this functor is a structured value providing an overload to simdize the type can improve the performance see alpaka::makeSimdized.
data0the first data to be processed
dataNthe remaining data to be processed
Returns
A single reduced value.
Parameters
extentsnumber of elements to process in each dimension
Template Parameters
T_maxConcurrencyInByteMaximum number of bytes to be used for concurrency. Concurrency bytes describe a virtual simd pack size which is not exceeded. Internally a best fitting SIMD width is calculated and instruction parallelism is exposed based on T_maxConcurrencyInByte.
T_MemAlignmentalignment of the memory, if no alignments is given the alignment will be derived from the MdSpan data descriptions

Definition at line 272 of file SimdAlgo.hpp.

◆ transformReduce() [2/4]

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::transformReduce ( auto const & acc,
alpaka::concepts::Vector auto extents,
auto const & neutralElement,
auto && reduceFunc,
auto && transformFunc,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN ) const
inlineconstexpr

transform the input data and reduce it to a single value

Attention
If no extent is given the number of elements to process is derived from the first MdSpan object. All other MdSpan objects must have at least the same number of elements.
Parameters
neutralElementthe neutral element for the reduction operation
reduceFuncThe binary reduction operation to be executed, e.g. std::plus. The functor should support Simd packages.
transformFuncN-nary functor to be executed, values of all containers will be passed to the functor as arguments. The functor should support Simd packages. If not you can enforce the element wise execution by wrapping into ScalarFunc. If you would like to support stencil executions wrapp fn into StencilFunc. StencilFunc is getting all arguments as SimdPtr. If StencilFunc is used you should take care to not read outside of valid memory ranges by using sub-views to your input and output data. Optionally a transformFn can have an accelerator as first argument. If the result of this functor is a structured value providing an overload to simdize the type can improve the performance see alpaka::makeSimdized.
data0the first data to be processed
dataNthe remaining data to be processed
Returns
A single reduced value.
Parameters
extentsnumber of elements to process in each dimension

Definition at line 205 of file SimdAlgo.hpp.

◆ transformReduce() [3/4]

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::transformReduce ( auto const & acc,
auto const & neutralElement,
auto && reduceFunc,
auto && transformFunc,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN ) const
inlineconstexpr

transform the input data and reduce it to a single value

Attention
If no extent is given the number of elements to process is derived from the first MdSpan object. All other MdSpan objects must have at least the same number of elements.
Parameters
neutralElementthe neutral element for the reduction operation
reduceFuncThe binary reduction operation to be executed, e.g. std::plus. The functor should support Simd packages.
transformFuncN-nary functor to be executed, values of all containers will be passed to the functor as arguments. The functor should support Simd packages. If not you can enforce the element wise execution by wrapping into ScalarFunc. If you would like to support stencil executions wrapp fn into StencilFunc. StencilFunc is getting all arguments as SimdPtr. If StencilFunc is used you should take care to not read outside of valid memory ranges by using sub-views to your input and output data. Optionally a transformFn can have an accelerator as first argument. If the result of this functor is a structured value providing an overload to simdize the type can improve the performance see alpaka::makeSimdized.
data0the first data to be processed
dataNthe remaining data to be processed
Returns
A single reduced value.
Template Parameters
T_maxConcurrencyInByteMaximum number of bytes to be used for concurrency. Concurrency bytes describe a virtual simd pack size which is not exceeded. Internally a best fitting SIMD width is calculated and instruction parallelism is exposed based on T_maxConcurrencyInByte.
T_MemAlignmentalignment of the memory, if no alignments is given the alignment will be derived from the MdSpan data descriptions

Definition at line 241 of file SimdAlgo.hpp.

◆ transformReduce() [4/4]

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::transformReduce ( auto const & acc,
auto const & neutralElement,
auto && reduceFunc,
auto && transformFunc,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN ) const
inlineconstexpr

transform the input data and reduce it to a single value

Attention
If no extent is given the number of elements to process is derived from the first MdSpan object. All other MdSpan objects must have at least the same number of elements.
Parameters
neutralElementthe neutral element for the reduction operation
reduceFuncThe binary reduction operation to be executed, e.g. std::plus. The functor should support Simd packages.
transformFuncN-nary functor to be executed, values of all containers will be passed to the functor as arguments. The functor should support Simd packages. If not you can enforce the element wise execution by wrapping into ScalarFunc. If you would like to support stencil executions wrapp fn into StencilFunc. StencilFunc is getting all arguments as SimdPtr. If StencilFunc is used you should take care to not read outside of valid memory ranges by using sub-views to your input and output data. Optionally a transformFn can have an accelerator as first argument. If the result of this functor is a structured value providing an overload to simdize the type can improve the performance see alpaka::makeSimdized.
data0the first data to be processed
dataNthe remaining data to be processed
Returns
A single reduced value.

Definition at line 183 of file SimdAlgo.hpp.

Member Data Documentation

◆ ConcurrentAlgo

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
friend alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::ConcurrentAlgo
private

Definition at line 295 of file SimdAlgo.hpp.

◆ m_workGroup

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
T_WorkGroup alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::m_workGroup
private

Definition at line 364 of file SimdAlgo.hpp.

◆ ReduceAlgo

template<typename T_WorkGroup, concepts::IdxTraversing T_Traverse = traverse::Flat, concepts::IdxMapping T_IdxLayout = layout::Optimized>
friend alpaka::onAcc::SimdAlgo< T_WorkGroup, T_Traverse, T_IdxLayout >::ReduceAlgo
private

Definition at line 296 of file SimdAlgo.hpp.


The documentation for this struct was generated from the following file: