diff --git a/sycl/include/sycl/reduction.hpp b/sycl/include/sycl/reduction.hpp index c249588f1d6e8..1b9ecceb65e82 100644 --- a/sycl/include/sycl/reduction.hpp +++ b/sycl/include/sycl/reduction.hpp @@ -95,15 +95,15 @@ using IsReduOptForFastAtomicFetch = #ifdef SYCL_REDUCTION_DETERMINISTIC bool_constant; #else - bool_constant<((sycl::detail::is_sgenfloat::value && sizeof(T) == 4) || - sycl::detail::is_sgeninteger::value) && - sycl::detail::IsValidAtomicType::value && - (sycl::detail::IsPlus::value || - sycl::detail::IsMinimum::value || - sycl::detail::IsMaximum::value || - sycl::detail::IsBitOR::value || - sycl::detail::IsBitXOR::value || - sycl::detail::IsBitAND::value)>; + bool_constant<((is_sgenfloat::value && sizeof(T) == 4) || + is_sgeninteger::value) && + IsValidAtomicType::value && + (IsPlus::value || + IsMinimum::value || + IsMaximum::value || + IsBitOR::value || + IsBitXOR::value || + IsBitAND::value)>; #endif // This type trait is used to detect if the atomic operation BinaryOperation @@ -119,10 +119,10 @@ using IsReduOptForAtomic64Op = #ifdef SYCL_REDUCTION_DETERMINISTIC bool_constant; #else - bool_constant<(sycl::detail::IsPlus::value || - sycl::detail::IsMinimum::value || - sycl::detail::IsMaximum::value) && - sycl::detail::is_sgenfloat::value && sizeof(T) == 8>; + bool_constant<(IsPlus::value || + IsMinimum::value || + IsMaximum::value) && + is_sgenfloat::value && sizeof(T) == 8>; #endif // This type trait is used to detect if the group algorithm reduce() used with @@ -135,12 +135,12 @@ using IsReduOptForFastReduce = #ifdef SYCL_REDUCTION_DETERMINISTIC bool_constant; #else - bool_constant<((sycl::detail::is_sgeninteger::value && + bool_constant<((is_sgeninteger::value && (sizeof(T) == 4 || sizeof(T) == 8)) || - sycl::detail::is_sgenfloat::value) && - (sycl::detail::IsPlus::value || - sycl::detail::IsMinimum::value || - sycl::detail::IsMaximum::value)>; + is_sgenfloat::value) && + (IsPlus::value || + IsMinimum::value || + IsMaximum::value)>; #endif // std::tuple seems to be a) too heavy and b) not copyable to device now @@ -191,45 +191,45 @@ template class combiner { public: template - enable_if_t<(_Dims == 0) && sycl::detail::IsPlus<_T, BinaryOp>::value && - sycl::detail::is_geninteger<_T>::value> + enable_if_t<(_Dims == 0) && IsPlus<_T, BinaryOp>::value && + is_geninteger<_T>::value> operator++() { static_cast(this)->combine(static_cast<_T>(1)); } template - enable_if_t<(_Dims == 0) && sycl::detail::IsPlus<_T, BinaryOp>::value && - sycl::detail::is_geninteger<_T>::value> + enable_if_t<(_Dims == 0) && IsPlus<_T, BinaryOp>::value && + is_geninteger<_T>::value> operator++(int) { static_cast(this)->combine(static_cast<_T>(1)); } template - enable_if_t<(_Dims == 0) && sycl::detail::IsPlus<_T, BinaryOp>::value> + enable_if_t<(_Dims == 0) && IsPlus<_T, BinaryOp>::value> operator+=(const _T &Partial) { static_cast(this)->combine(Partial); } template - enable_if_t<(_Dims == 0) && sycl::detail::IsMultiplies<_T, BinaryOp>::value> + enable_if_t<(_Dims == 0) && IsMultiplies<_T, BinaryOp>::value> operator*=(const _T &Partial) { static_cast(this)->combine(Partial); } template - enable_if_t<(_Dims == 0) && sycl::detail::IsBitOR<_T, BinaryOp>::value> + enable_if_t<(_Dims == 0) && IsBitOR<_T, BinaryOp>::value> operator|=(const _T &Partial) { static_cast(this)->combine(Partial); } template - enable_if_t<(_Dims == 0) && sycl::detail::IsBitXOR<_T, BinaryOp>::value> + enable_if_t<(_Dims == 0) && IsBitXOR<_T, BinaryOp>::value> operator^=(const _T &Partial) { static_cast(this)->combine(Partial); } template - enable_if_t<(_Dims == 0) && sycl::detail::IsBitAND<_T, BinaryOp>::value> + enable_if_t<(_Dims == 0) && IsBitAND<_T, BinaryOp>::value> operator&=(const _T &Partial) { static_cast(this)->combine(Partial); } @@ -266,7 +266,7 @@ template class combiner { enable_if_t && (IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value || IsReduOptForAtomic64Op<_T, _BinaryOperation>::value) && - sycl::detail::IsPlus<_T, _BinaryOperation>::value> + IsPlus<_T, _BinaryOperation>::value> atomic_combine(_T *ReduVarPtr) const { atomic_combine_impl( ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_add(Val); }); @@ -277,7 +277,7 @@ template class combiner { typename _T = Ty, class _BinaryOperation = BinaryOp> enable_if_t && IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value && - sycl::detail::IsBitOR<_T, _BinaryOperation>::value> + IsBitOR<_T, _BinaryOperation>::value> atomic_combine(_T *ReduVarPtr) const { atomic_combine_impl( ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_or(Val); }); @@ -288,7 +288,7 @@ template class combiner { typename _T = Ty, class _BinaryOperation = BinaryOp> enable_if_t && IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value && - sycl::detail::IsBitXOR<_T, _BinaryOperation>::value> + IsBitXOR<_T, _BinaryOperation>::value> atomic_combine(_T *ReduVarPtr) const { atomic_combine_impl( ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_xor(Val); }); @@ -299,7 +299,7 @@ template class combiner { typename _T = Ty, class _BinaryOperation = BinaryOp> enable_if_t::type, _T>::value && IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value && - sycl::detail::IsBitAND<_T, _BinaryOperation>::value && + IsBitAND<_T, _BinaryOperation>::value && (Space == access::address_space::global_space || Space == access::address_space::local_space)> atomic_combine(_T *ReduVarPtr) const { @@ -313,7 +313,7 @@ template class combiner { enable_if_t && (IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value || IsReduOptForAtomic64Op<_T, _BinaryOperation>::value) && - sycl::detail::IsMinimum<_T, _BinaryOperation>::value> + IsMinimum<_T, _BinaryOperation>::value> atomic_combine(_T *ReduVarPtr) const { atomic_combine_impl( ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_min(Val); }); @@ -325,7 +325,7 @@ template class combiner { enable_if_t && (IsReduOptForFastAtomicFetch<_T, _BinaryOperation>::value || IsReduOptForAtomic64Op<_T, _BinaryOperation>::value) && - sycl::detail::IsMaximum<_T, _BinaryOperation>::value> + IsMaximum<_T, _BinaryOperation>::value> atomic_combine(_T *ReduVarPtr) const { atomic_combine_impl( ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_max(Val); }); @@ -339,15 +339,15 @@ template class combiner { /// It stores a copy of the identity and binary operation associated with the /// reduction. template -class reducer::value>> +class reducer< + T, BinaryOperation, Dims, Extent, View, + std::enable_if_t::value>> : public detail::combiner< reducer::value>>> { + std::enable_if_t< + Dims == 0 && Extent == 1 && View == false && + !detail::IsKnownIdentityOp::value>>> { public: reducer(const T &Identity, BinaryOperation BOp) : MValue(Identity), MIdentity(Identity), MBinaryOp(BOp) {} @@ -371,15 +371,15 @@ class reducer -class reducer::value>> +class reducer< + T, BinaryOperation, Dims, Extent, View, + std::enable_if_t::value>> : public detail::combiner< reducer::value>>> { + std::enable_if_t< + Dims == 0 && Extent == 1 && View == false && + detail::IsKnownIdentityOp::value>>> { public: reducer() : MValue(getIdentity()) {} reducer(const T & /* Identity */, BinaryOperation) : MValue(getIdentity()) {} @@ -390,7 +390,7 @@ class reducer::value; + return detail::known_identity_impl::value; } T &getElement(size_t) { return MValue; } @@ -419,15 +419,15 @@ class reducer -class reducer::value>> +class reducer< + T, BinaryOperation, Dims, Extent, View, + std::enable_if_t::value>> : public detail::combiner< reducer::value>>> { + std::enable_if_t< + Dims == 1 && View == false && + !detail::IsKnownIdentityOp::value>>> { public: reducer(const T &Identity, BinaryOperation BOp) : MValue(Identity), MIdentity(Identity), MBinaryOp(BOp) {} @@ -449,15 +449,15 @@ class reducer -class reducer::value>> +class reducer< + T, BinaryOperation, Dims, Extent, View, + std::enable_if_t::value>> : public detail::combiner< reducer::value>>> { + std::enable_if_t< + Dims == 1 && View == false && + detail::IsKnownIdentityOp::value>>> { public: reducer() : MValue(getIdentity()) {} reducer(const T & /* Identity */, BinaryOperation) : MValue(getIdentity()) {} @@ -469,7 +469,7 @@ class reducer::value; + return detail::known_identity_impl::value; } T &getElement(size_t E) { return MValue[E]; } @@ -491,14 +491,14 @@ template class reduction_impl_common { public: /// Returns the statically known identity value. template - enable_if_t::value, + enable_if_t::value, _T> constexpr getIdentity() { - return sycl::detail::known_identity_impl<_BinaryOperation, _T>::value; + return known_identity_impl<_BinaryOperation, _T>::value; } /// Returns the identity value given by user. template - enable_if_t::value, _T> + enable_if_t::value, _T> getIdentity() { return MIdentity; } @@ -765,7 +765,7 @@ class reduction_impl using self = reduction_impl; static constexpr bool is_known_identity = - sycl::detail::IsKnownIdentityOp::value; + IsKnownIdentityOp::value; // TODO: Do we also need chooseBinOp? static constexpr T chooseIdentity(const T &Identity) { @@ -880,8 +880,8 @@ auto make_reduction(RedOutVar RedVar, RestTy &&...Rest) { /// must do that to avoid name collisions. template