DPC++ Runtime
Runtime libraries for oneAPI DPC++
sycl::_V1::detail::combiner< Reducer > Class Template Reference

Use CRTP to avoid redefining shorthand operators in terms of combine. More...

#include <sycl/reduction.hpp>

Public Member Functions

template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims==0) &&IsPlus< _T, BinaryOp >::value &&is_geninteger_v< _T >, Reducer & > operator++ ()
 
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims==0) &&IsPlus< _T, BinaryOp >::value &&is_geninteger_v< _T >, Reducer & > operator++ (int)
 
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims==0) &&IsPlus< _T, BinaryOp >::value, Reducer & > operator+= (const _T &Partial)
 
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims==0) &&IsMultiplies< _T, BinaryOp >::value, Reducer & > operator*= (const _T &Partial)
 
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims==0) &&IsBitOR< _T, BinaryOp >::value, Reducer & > operator|= (const _T &Partial)
 
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims==0) &&IsBitXOR< _T, BinaryOp >::value, Reducer & > operator^= (const _T &Partial)
 
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims==0) &&IsBitAND< _T, BinaryOp >::value, Reducer & > operator&= (const _T &Partial)
 
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t< BasicCheck< _T, Space, _BinaryOperation > &&(IsReduOptForFastAtomicFetch< _T, _BinaryOperation >::value||IsReduOptForAtomic64Op< _T, _BinaryOperation >::value) &&IsPlus< _T, _BinaryOperation >::value > atomic_combine (_T *ReduVarPtr) const
 Atomic ADD operation: *ReduVarPtr += MValue;. More...
 
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t< BasicCheck< _T, Space, _BinaryOperation > &&IsReduOptForFastAtomicFetch< _T, _BinaryOperation >::value &&IsBitOR< _T, _BinaryOperation >::value > atomic_combine (_T *ReduVarPtr) const
 Atomic BITWISE OR operation: *ReduVarPtr |= MValue;. More...
 
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t< BasicCheck< _T, Space, _BinaryOperation > &&IsReduOptForFastAtomicFetch< _T, _BinaryOperation >::value &&IsBitXOR< _T, _BinaryOperation >::value > atomic_combine (_T *ReduVarPtr) const
 Atomic BITWISE XOR operation: *ReduVarPtr ^= MValue;. More...
 
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t< std::is_same_v< remove_decoration_t< _T >, _T > &&IsReduOptForFastAtomicFetch< _T, _BinaryOperation >::value &&IsBitAND< _T, _BinaryOperation >::value &&(Space==access::address_space::global_space||Space==access::address_space::local_space)> atomic_combine (_T *ReduVarPtr) const
 Atomic BITWISE AND operation: *ReduVarPtr &= MValue;. More...
 
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t< BasicCheck< _T, Space, _BinaryOperation > &&(IsReduOptForFastAtomicFetch< _T, _BinaryOperation >::value||IsReduOptForAtomic64Op< _T, _BinaryOperation >::value) &&IsMinimum< _T, _BinaryOperation >::value > atomic_combine (_T *ReduVarPtr) const
 Atomic MIN operation: *ReduVarPtr = sycl::minimum(*ReduVarPtr, MValue);. More...
 
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t< BasicCheck< _T, Space, _BinaryOperation > &&(IsReduOptForFastAtomicFetch< _T, _BinaryOperation >::value||IsReduOptForAtomic64Op< _T, _BinaryOperation >::value) &&IsMaximum< _T, _BinaryOperation >::value > atomic_combine (_T *ReduVarPtr) const
 Atomic MAX operation: *ReduVarPtr = sycl::maximum(*ReduVarPtr, MValue);. More...
 

Detailed Description

template<class Reducer>
class sycl::_V1::detail::combiner< Reducer >

Use CRTP to avoid redefining shorthand operators in terms of combine.

Also, for many types with known identity the operation 'atomic_combine()' is implemented here, which allows to use more efficient version of kernels using those operations, which are based on functionality provided by sycl::atomic class.

For example, it is known that 0 is identity for sycl::plus operations accepting native scalar types to which scalar 0 is convertible. Also, for int32/64 types the atomic_combine() is lowered to sycl::atomic::fetch_add().

Definition at line 223 of file reduction.hpp.

Member Function Documentation

◆ atomic_combine() [1/6]

template<class Reducer >
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t<BasicCheck<_T, Space, _BinaryOperation> && (IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value || IsReduOptForAtomic64Op<_T, _BinaryOperation>::value) && IsPlus<_T, _BinaryOperation>::value> sycl::_V1::detail::combiner< Reducer >::atomic_combine ( _T *  ReduVarPtr) const
inline

Atomic ADD operation: *ReduVarPtr += MValue;.

Definition at line 315 of file reduction.hpp.

◆ atomic_combine() [2/6]

template<class Reducer >
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t<BasicCheck<_T, Space, _BinaryOperation> && IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value && IsBitOR<_T, _BinaryOperation>::value> sycl::_V1::detail::combiner< Reducer >::atomic_combine ( _T *  ReduVarPtr) const
inline

Atomic BITWISE OR operation: *ReduVarPtr |= MValue;.

Definition at line 326 of file reduction.hpp.

◆ atomic_combine() [3/6]

template<class Reducer >
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t<BasicCheck<_T, Space, _BinaryOperation> && IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value && IsBitXOR<_T, _BinaryOperation>::value> sycl::_V1::detail::combiner< Reducer >::atomic_combine ( _T *  ReduVarPtr) const
inline

Atomic BITWISE XOR operation: *ReduVarPtr ^= MValue;.

Definition at line 337 of file reduction.hpp.

◆ atomic_combine() [4/6]

template<class Reducer >
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t<std::is_same_v<remove_decoration_t<_T>, _T> && IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value && IsBitAND<_T, _BinaryOperation>::value && (Space == access::address_space::global_space || Space == access::address_space::local_space)> sycl::_V1::detail::combiner< Reducer >::atomic_combine ( _T *  ReduVarPtr) const
inline

Atomic BITWISE AND operation: *ReduVarPtr &= MValue;.

Definition at line 350 of file reduction.hpp.

◆ atomic_combine() [5/6]

template<class Reducer >
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t<BasicCheck<_T, Space, _BinaryOperation> && (IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value || IsReduOptForAtomic64Op<_T, _BinaryOperation>::value) && IsMinimum<_T, _BinaryOperation>::value> sycl::_V1::detail::combiner< Reducer >::atomic_combine ( _T *  ReduVarPtr) const
inline

Atomic MIN operation: *ReduVarPtr = sycl::minimum(*ReduVarPtr, MValue);.

Definition at line 362 of file reduction.hpp.

◆ atomic_combine() [6/6]

template<class Reducer >
template<access::address_space Space = access::address_space::global_space, typename _T = Ty, class _BinaryOperation = BinaryOp>
std::enable_if_t<BasicCheck<_T, Space, _BinaryOperation> && (IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value || IsReduOptForAtomic64Op<_T, _BinaryOperation>::value) && IsMaximum<_T, _BinaryOperation>::value> sycl::_V1::detail::combiner< Reducer >::atomic_combine ( _T *  ReduVarPtr) const
inline

Atomic MAX operation: *ReduVarPtr = sycl::maximum(*ReduVarPtr, MValue);.

Definition at line 374 of file reduction.hpp.

◆ operator&=()

template<class Reducer >
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims == 0) && IsBitAND<_T, BinaryOp>::value, Reducer &> sycl::_V1::detail::combiner< Reducer >::operator&= ( const _T &  Partial)
inline

Definition at line 272 of file reduction.hpp.

◆ operator*=()

template<class Reducer >
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims == 0) && IsMultiplies<_T, BinaryOp>::value, Reducer &> sycl::_V1::detail::combiner< Reducer >::operator*= ( const _T &  Partial)
inline

Definition at line 254 of file reduction.hpp.

◆ operator++() [1/2]

template<class Reducer >
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims == 0) && IsPlus<_T, BinaryOp>::value && is_geninteger_v<_T>, Reducer &> sycl::_V1::detail::combiner< Reducer >::operator++ ( )
inline

Definition at line 234 of file reduction.hpp.

◆ operator++() [2/2]

template<class Reducer >
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims == 0) && IsPlus<_T, BinaryOp>::value && is_geninteger_v<_T>, Reducer &> sycl::_V1::detail::combiner< Reducer >::operator++ ( int  )
inline

Definition at line 242 of file reduction.hpp.

◆ operator+=()

template<class Reducer >
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims == 0) && IsPlus<_T, BinaryOp>::value, Reducer &> sycl::_V1::detail::combiner< Reducer >::operator+= ( const _T &  Partial)
inline

Definition at line 248 of file reduction.hpp.

◆ operator^=()

template<class Reducer >
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims == 0) && IsBitXOR<_T, BinaryOp>::value, Reducer &> sycl::_V1::detail::combiner< Reducer >::operator^= ( const _T &  Partial)
inline

Definition at line 266 of file reduction.hpp.

◆ operator|=()

template<class Reducer >
template<typename _T = Ty, int _Dims = Dims>
std::enable_if_t<(_Dims == 0) && IsBitOR<_T, BinaryOp>::value, Reducer &> sycl::_V1::detail::combiner< Reducer >::operator|= ( const _T &  Partial)
inline

Definition at line 260 of file reduction.hpp.


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