alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::onAcc::internal::SimdTransformReduce< T_Parent > Struct Template Reference

concurrent reduce implementation More...

#include <SimdTransformReduce.hpp>

Classes

struct  ScalarReducer

Public Member Functions

constexpr SimdTransformReduce ()=default

Protected Member Functions

template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
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

Private Member Functions

constexpr auto const & asParent () const
ALPAKA_FN_INLINE constexpr auto getReducer (onAcc::concepts::Acc auto const &, auto &&reduceOp) const
 Get the reducer functor.
ALPAKA_FN_INLINE constexpr auto getReducer (onAcc::concepts::Acc auto const &acc, auto &&reduceOp) const
template<uint32_t T_simdWidth, uint32_t T_numSimdPerFnCall, alpaka::concepts::Alignment T_MemAlignment>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto reduceSimdPackExecution (auto const &acc, alpaka::concepts::Vector auto numElements, auto const &neutralElement, auto &&userReduceFunc, auto &&func, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN) const

Static Private Member Functions

template<alpaka::concepts::Alignment T_MemAlignment, uint32_t T_width>
static ALPAKA_FN_INLINE constexpr auto executeDoTransform (concepts::Acc auto const &acc, auto const &dataIdx, auto &&func, alpaka::concepts::IDataSource auto &&... data)
template<alpaka::concepts::Alignment T_MemAlignment, uint32_t T_width, uint32_t... T_repeat>
static ALPAKA_FN_INLINE constexpr auto executeReduce (concepts::Acc auto const &acc, auto &iter, std::integer_sequence< uint32_t, T_repeat... >, auto &&reduceFunc, auto &&func, alpaka::concepts::IDataSource auto &&... data)
 Calls the transform functor T_repeat times and reduces the results with the given reduce function.
template<alpaka::concepts::Alignment T_MemAlignment, uint32_t T_width, uint32_t... T_repeat>
static ALPAKA_FN_INLINE constexpr void executeReduceInto (concepts::Acc auto const &acc, auto &iter, std::integer_sequence< uint32_t, T_repeat... >, auto &result, auto &&reduceFn, auto &&transformFn, alpaka::concepts::IDataSource auto &&... data)
 Reduce simdized packs into a single simdized pack with the given reduce function.
template<uint32_t... T_idx>
ALPAKA_FN_INLINE static ALPAKA_FN_ACC constexpr auto loadAncExecuteScalarOp (std::integer_sequence< uint32_t, T_idx... >, auto &&op, auto const &acc, auto &&func, auto &&... data)
template<uint32_t... T_repeat>
static ALPAKA_FN_INLINE constexpr auto makeAdvanceIterators (auto &iter, std::integer_sequence< uint32_t, T_repeat... >)
 advance the iterator T_repeat times
template<uint32_t T_simdWidth, uint32_t T_numSimdPerFnCall, alpaka::concepts::Alignment T_MemAlignment>
static ALPAKA_FN_INLINE constexpr void reduceNextSimdized (auto const &acc, auto &iter, auto &tmpReturn, auto &&reduceFn, auto &&transformFn, alpaka::concepts::IDataSource auto &&data0, alpaka::concepts::IDataSource auto &&... dataN)
 Reduce T_numSimdPerFnCall simdized packs.
ALPAKA_FN_INLINE static ALPAKA_FN_ACC constexpr decltype(auto) wrapTransformFunc (auto &&transformFunc)

Detailed Description

template<typename T_Parent>
struct alpaka::onAcc::internal::SimdTransformReduce< T_Parent >

concurrent reduce implementation

Definition at line 28 of file SimdTransformReduce.hpp.

Constructor & Destructor Documentation

◆ SimdTransformReduce()

template<typename T_Parent>
alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::SimdTransformReduce ( )
constexprdefault

Member Function Documentation

◆ asParent()

template<typename T_Parent>
auto const & alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::asParent ( ) const
inlineconstexprprivate

Definition at line 354 of file SimdTransformReduce.hpp.

◆ executeDoTransform()

template<typename T_Parent>
template<alpaka::concepts::Alignment T_MemAlignment, uint32_t T_width>
ALPAKA_FN_INLINE constexpr auto alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::executeDoTransform ( concepts::Acc auto const & acc,
auto const & dataIdx,
auto && func,
alpaka::concepts::IDataSource auto &&... data )
inlinestaticconstexprprivate

Definition at line 146 of file SimdTransformReduce.hpp.

◆ executeReduce()

template<typename T_Parent>
template<alpaka::concepts::Alignment T_MemAlignment, uint32_t T_width, uint32_t... T_repeat>
ALPAKA_FN_INLINE constexpr auto alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::executeReduce ( concepts::Acc auto const & acc,
auto & iter,
std::integer_sequence< uint32_t, T_repeat... > ,
auto && reduceFunc,
auto && func,
alpaka::concepts::IDataSource auto &&... data )
inlinestaticconstexprprivate

Calls the transform functor T_repeat times and reduces the results with the given reduce function.

The calls to the functor are independent and compile time unrolled to support instruction parallelism. In contrast to executeReduceInto() the register footprint is larger because T_repeat temporary results will be holt. This allows the compiler to use instruction level parallelism. Call this function if result of reduceFunc is a SIMD pack.

Parameters
iterthe caller must ensure tha the interator can be increased T_repeat times without jumping over iter.end()
Returns
a single simdized pack

Definition at line 184 of file SimdTransformReduce.hpp.

◆ executeReduceInto()

template<typename T_Parent>
template<alpaka::concepts::Alignment T_MemAlignment, uint32_t T_width, uint32_t... T_repeat>
ALPAKA_FN_INLINE constexpr void alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::executeReduceInto ( concepts::Acc auto const & acc,
auto & iter,
std::integer_sequence< uint32_t, T_repeat... > ,
auto & result,
auto && reduceFn,
auto && transformFn,
alpaka::concepts::IDataSource auto &&... data )
inlinestaticconstexprprivate

Reduce simdized packs into a single simdized pack with the given reduce function.

In contrast to executeReduce() the register footprint is lower because all intermediate results are directly reduced into the result variable. Call this function if the type of result is a simdized pack is not a SIMD pack.

Parameters
resultThe results of reduceFn with the result of transformFn will be reduced into this simdized pack.

Definition at line 223 of file SimdTransformReduce.hpp.

◆ getReducer() [1/2]

template<typename T_Parent>
ALPAKA_FN_INLINE constexpr auto alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::getReducer ( onAcc::concepts::Acc auto const & ,
auto && reduceOp ) const
inlineconstexprprivate

Get the reducer functor.

Returns
wrapped functor in case the input is
See also
ScalarFunc else the identity

Definition at line 342 of file SimdTransformReduce.hpp.

◆ getReducer() [2/2]

template<typename T_Parent>
ALPAKA_FN_INLINE constexpr auto alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::getReducer ( onAcc::concepts::Acc auto const & acc,
auto && reduceOp ) const
inlineconstexprprivate

Definition at line 348 of file SimdTransformReduce.hpp.

◆ loadAncExecuteScalarOp()

template<typename T_Parent>
template<uint32_t... T_idx>
ALPAKA_FN_INLINE static ALPAKA_FN_ACC constexpr auto alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::loadAncExecuteScalarOp ( std::integer_sequence< uint32_t, T_idx... > ,
auto && op,
auto const & acc,
auto && func,
auto &&... data )
inlinestaticconstexprprivate

Definition at line 100 of file SimdTransformReduce.hpp.

◆ makeAdvanceIterators()

template<typename T_Parent>
template<uint32_t... T_repeat>
ALPAKA_FN_INLINE constexpr auto alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::makeAdvanceIterators ( auto & iter,
std::integer_sequence< uint32_t, T_repeat... >  )
inlinestaticconstexprprivate

advance the iterator T_repeat times

We do not check if the iterator points to a valid element, the caller must ensure that we can safely advance the iterator T_repeat time without jumping over iter.end().

Template Parameters
T_repeatNumber of time sthe iterator should be advanced.
Returns
Tuple with T_repeat times iterators.

Definition at line 164 of file SimdTransformReduce.hpp.

◆ reduceNextSimdized()

template<typename T_Parent>
template<uint32_t T_simdWidth, uint32_t T_numSimdPerFnCall, alpaka::concepts::Alignment T_MemAlignment>
ALPAKA_FN_INLINE constexpr void alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::reduceNextSimdized ( auto const & acc,
auto & iter,
auto & tmpReturn,
auto && reduceFn,
auto && transformFn,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN )
inlinestaticconstexprprivate

Reduce T_numSimdPerFnCall simdized packs.

Definition at line 248 of file SimdTransformReduce.hpp.

◆ reduceSimdPackExecution()

template<typename T_Parent>
template<uint32_t T_simdWidth, uint32_t T_numSimdPerFnCall, alpaka::concepts::Alignment T_MemAlignment>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::reduceSimdPackExecution ( auto const & acc,
alpaka::concepts::Vector auto numElements,
auto const & neutralElement,
auto && userReduceFunc,
auto && func,
alpaka::concepts::IDataSource auto && data0,
alpaka::concepts::IDataSource auto &&... dataN ) const
inlineconstexprprivate

To avoid an overflow in the index range we divide first by the number of elements per function call and then by the number of workers.

Definition at line 360 of file SimdTransformReduce.hpp.

◆ transformReduce()

template<typename T_Parent>
template<uint32_t T_maxConcurrencyInByte, alpaka::concepts::Alignment T_MemAlignment = AutoAligned>
ALPAKA_FN_INLINE ALPAKA_FN_ACC constexpr auto alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::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
inlineconstexprprotected

Definition at line 34 of file SimdTransformReduce.hpp.

◆ wrapTransformFunc()

template<typename T_Parent>
ALPAKA_FN_INLINE static ALPAKA_FN_ACC constexpr decltype(auto) alpaka::onAcc::internal::SimdTransformReduce< T_Parent >::wrapTransformFunc ( auto && transformFunc)
inlinestaticconstexprprivate

Definition at line 110 of file SimdTransformReduce.hpp.


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