@@ -22,121 +22,100 @@ namespace ONEAPI {
22
22
23
23
namespace detail {
24
24
25
+ using cl::sycl::detail::bool_constant;
26
+ using cl::sycl::detail::enable_if_t ;
27
+ using cl::sycl::detail::is_sgenfloat;
28
+ using cl::sycl::detail::is_sgeninteger;
25
29
using cl::sycl::detail::queue_impl;
30
+ using cl::sycl::detail::remove_AS;
26
31
27
32
__SYCL_EXPORT size_t reduGetMaxWGSize (shared_ptr_class<queue_impl> Queue,
28
33
size_t LocalMemBytesPerWorkItem);
29
34
__SYCL_EXPORT size_t reduComputeWGSize (size_t NWorkItems, size_t MaxWGSize,
30
35
size_t &NWorkGroups);
31
36
32
- using cl::sycl::detail::bool_constant;
33
- using cl::sycl::detail::enable_if_t ;
34
- using cl::sycl::detail::is_geninteger16bit;
35
- using cl::sycl::detail::is_geninteger32bit;
36
- using cl::sycl::detail::is_geninteger64bit;
37
- using cl::sycl::detail::is_geninteger8bit;
38
- using cl::sycl::detail::remove_AS;
39
-
40
37
template <typename T, class BinaryOperation >
41
- using IsReduPlus = detail::bool_constant<
42
- std::is_same<BinaryOperation, ONEAPI::plus<T>>::value ||
43
- std::is_same<BinaryOperation, ONEAPI::plus<void >>::value>;
38
+ using IsReduPlus =
39
+ bool_constant< std::is_same<BinaryOperation, ONEAPI::plus<T>>::value ||
40
+ std::is_same<BinaryOperation, ONEAPI::plus<void >>::value>;
44
41
45
42
template <typename T, class BinaryOperation >
46
- using IsReduMultiplies = detail::bool_constant<
47
- std::is_same<BinaryOperation, std::multiplies<T>>::value ||
48
- std::is_same<BinaryOperation, std::multiplies<void >>::value>;
43
+ using IsReduMultiplies =
44
+ bool_constant< std::is_same<BinaryOperation, std::multiplies<T>>::value ||
45
+ std::is_same<BinaryOperation, std::multiplies<void >>::value>;
49
46
50
47
template <typename T, class BinaryOperation >
51
- using IsReduMinimum = detail::bool_constant<
52
- std::is_same<BinaryOperation, ONEAPI::minimum<T>>::value ||
53
- std::is_same<BinaryOperation, ONEAPI::minimum<void >>::value>;
48
+ using IsReduMinimum =
49
+ bool_constant< std::is_same<BinaryOperation, ONEAPI::minimum<T>>::value ||
50
+ std::is_same<BinaryOperation, ONEAPI::minimum<void >>::value>;
54
51
55
52
template <typename T, class BinaryOperation >
56
- using IsReduMaximum = detail::bool_constant<
57
- std::is_same<BinaryOperation, ONEAPI::maximum<T>>::value ||
58
- std::is_same<BinaryOperation, ONEAPI::maximum<void >>::value>;
53
+ using IsReduMaximum =
54
+ bool_constant< std::is_same<BinaryOperation, ONEAPI::maximum<T>>::value ||
55
+ std::is_same<BinaryOperation, ONEAPI::maximum<void >>::value>;
59
56
60
57
template <typename T, class BinaryOperation >
61
- using IsReduBitOR = detail::bool_constant<
62
- std::is_same<BinaryOperation, ONEAPI::bit_or<T>>::value ||
63
- std::is_same<BinaryOperation, ONEAPI::bit_or<void >>::value>;
58
+ using IsReduBitOR =
59
+ bool_constant< std::is_same<BinaryOperation, ONEAPI::bit_or<T>>::value ||
60
+ std::is_same<BinaryOperation, ONEAPI::bit_or<void >>::value>;
64
61
65
62
template <typename T, class BinaryOperation >
66
- using IsReduBitXOR = detail::bool_constant<
67
- std::is_same<BinaryOperation, ONEAPI::bit_xor<T>>::value ||
68
- std::is_same<BinaryOperation, ONEAPI::bit_xor<void >>::value>;
63
+ using IsReduBitXOR =
64
+ bool_constant< std::is_same<BinaryOperation, ONEAPI::bit_xor<T>>::value ||
65
+ std::is_same<BinaryOperation, ONEAPI::bit_xor<void >>::value>;
69
66
70
67
template <typename T, class BinaryOperation >
71
- using IsReduBitAND = detail::bool_constant<
72
- std::is_same<BinaryOperation, ONEAPI::bit_and<T>>::value ||
73
- std::is_same<BinaryOperation, ONEAPI::bit_and<void >>::value>;
68
+ using IsReduBitAND =
69
+ bool_constant< std::is_same<BinaryOperation, ONEAPI::bit_and<T>>::value ||
70
+ std::is_same<BinaryOperation, ONEAPI::bit_and<void >>::value>;
74
71
75
72
template <typename T, class BinaryOperation >
76
73
using IsReduOptForFastAtomicFetch =
77
- detail::bool_constant<(is_geninteger32bit<T>::value ||
78
- is_geninteger64bit<T>::value) &&
79
- (IsReduPlus<T, BinaryOperation>::value ||
80
- IsReduMinimum<T, BinaryOperation>::value ||
81
- IsReduMaximum<T, BinaryOperation>::value ||
82
- IsReduBitOR<T, BinaryOperation>::value ||
83
- IsReduBitXOR<T, BinaryOperation>::value ||
84
- IsReduBitAND<T, BinaryOperation>::value)>;
74
+ bool_constant<is_sgeninteger<T>::value && IsValidAtomicType<T>::value &&
75
+ (IsReduPlus<T, BinaryOperation>::value ||
76
+ IsReduMinimum<T, BinaryOperation>::value ||
77
+ IsReduMaximum<T, BinaryOperation>::value ||
78
+ IsReduBitOR<T, BinaryOperation>::value ||
79
+ IsReduBitXOR<T, BinaryOperation>::value ||
80
+ IsReduBitAND<T, BinaryOperation>::value)>;
85
81
86
82
template <typename T, class BinaryOperation >
87
- using IsReduOptForFastReduce = detail::bool_constant<
88
- (is_geninteger32bit<T>::value || is_geninteger64bit<T>::value ||
89
- std::is_same<T, half>::value || std::is_same<T, float >::value ||
90
- std::is_same<T, double >::value) &&
91
- (IsReduPlus<T, BinaryOperation>::value ||
92
- IsReduMinimum<T, BinaryOperation>::value ||
93
- IsReduMaximum<T, BinaryOperation>::value)>;
83
+ using IsReduOptForFastReduce =
84
+ bool_constant<(is_sgeninteger<T>::value || is_sgenfloat<T>::value) &&
85
+ (IsReduPlus<T, BinaryOperation>::value ||
86
+ IsReduMinimum<T, BinaryOperation>::value ||
87
+ IsReduMaximum<T, BinaryOperation>::value)>;
94
88
95
89
// Identity = 0
96
90
template <typename T, class BinaryOperation >
97
91
using IsZeroIdentityOp = bool_constant<
98
- ((is_geninteger8bit<T>::value || is_geninteger16bit<T>::value ||
99
- is_geninteger32bit<T>::value || is_geninteger64bit<T>::value) &&
100
- (IsReduPlus<T, BinaryOperation>::value ||
101
- IsReduBitOR<T, BinaryOperation>::value ||
102
- IsReduBitXOR<T, BinaryOperation>::value)) ||
103
- ((std::is_same<T, half>::value || std::is_same<T, float >::value ||
104
- std::is_same<T, double >::value) &&
105
- IsReduPlus<T, BinaryOperation>::value)>;
92
+ (is_sgeninteger<T>::value && (IsReduPlus<T, BinaryOperation>::value ||
93
+ IsReduBitOR<T, BinaryOperation>::value ||
94
+ IsReduBitXOR<T, BinaryOperation>::value)) ||
95
+ (is_sgenfloat<T>::value && IsReduPlus<T, BinaryOperation>::value)>;
106
96
107
97
// Identity = 1
108
98
template <typename T, class BinaryOperation >
109
- using IsOneIdentityOp = bool_constant<
110
- (is_geninteger8bit<T>::value || is_geninteger16bit<T>::value ||
111
- is_geninteger32bit<T>::value || is_geninteger64bit<T>::value ||
112
- std::is_same<T, half>::value || std::is_same<T, float >::value ||
113
- std::is_same<T, double >::value) &&
114
- IsReduMultiplies<T, BinaryOperation>::value>;
99
+ using IsOneIdentityOp =
100
+ bool_constant<(is_sgeninteger<T>::value || is_sgenfloat<T>::value) &&
101
+ IsReduMultiplies<T, BinaryOperation>::value>;
115
102
116
103
// Identity = ~0
117
104
template <typename T, class BinaryOperation >
118
- using IsOnesIdentityOp = bool_constant<
119
- (is_geninteger8bit<T>::value || is_geninteger16bit<T>::value ||
120
- is_geninteger32bit<T>::value || is_geninteger64bit<T>::value) &&
121
- IsReduBitAND<T, BinaryOperation>::value>;
105
+ using IsOnesIdentityOp = bool_constant<is_sgeninteger<T>::value &&
106
+ IsReduBitAND<T, BinaryOperation>::value>;
122
107
123
108
// Identity = <max possible value>
124
109
template <typename T, class BinaryOperation >
125
- using IsMinimumIdentityOp = bool_constant<
126
- (is_geninteger8bit<T>::value || is_geninteger16bit<T>::value ||
127
- is_geninteger32bit<T>::value || is_geninteger64bit<T>::value ||
128
- std::is_same<T, half>::value || std::is_same<T, float >::value ||
129
- std::is_same<T, double >::value) &&
130
- IsReduMinimum<T, BinaryOperation>::value>;
110
+ using IsMinimumIdentityOp =
111
+ bool_constant<(is_sgeninteger<T>::value || is_sgenfloat<T>::value) &&
112
+ IsReduMinimum<T, BinaryOperation>::value>;
131
113
132
114
// Identity = <min possible value>
133
115
template <typename T, class BinaryOperation >
134
- using IsMaximumIdentityOp = bool_constant<
135
- (is_geninteger8bit<T>::value || is_geninteger16bit<T>::value ||
136
- is_geninteger32bit<T>::value || is_geninteger64bit<T>::value ||
137
- std::is_same<T, half>::value || std::is_same<T, float >::value ||
138
- std::is_same<T, double >::value) &&
139
- IsReduMaximum<T, BinaryOperation>::value>;
116
+ using IsMaximumIdentityOp =
117
+ bool_constant<(is_sgeninteger<T>::value || is_sgenfloat<T>::value) &&
118
+ IsReduMaximum<T, BinaryOperation>::value>;
140
119
141
120
template <typename T, class BinaryOperation >
142
121
using IsKnownIdentityOp =
@@ -1604,7 +1583,7 @@ reduction(accessor<T, Dims, AccMode, access::target::global_buffer, IsPH> &Acc,
1604
1583
// / The identity value is not passed to this version as it is statically known.
1605
1584
template <typename T, class BinaryOperation , int Dims, access::mode AccMode,
1606
1585
access::placeholder IsPH>
1607
- detail ::enable_if_t <
1586
+ std ::enable_if_t <
1608
1587
detail::IsKnownIdentityOp<T, BinaryOperation>::value,
1609
1588
detail::reduction_impl<T, BinaryOperation, Dims, false , AccMode, IsPH>>
1610
1589
reduction (accessor<T, Dims, AccMode, access::target::global_buffer, IsPH> &Acc,
@@ -1632,16 +1611,18 @@ reduction(T *VarPtr, const T &Identity, BinaryOperation BOp) {
1632
1611
// / operation used in the reduction.
1633
1612
// / The identity value is not passed to this version as it is statically known.
1634
1613
template <typename T, class BinaryOperation >
1635
- detail ::enable_if_t <detail::IsKnownIdentityOp<T, BinaryOperation>::value,
1636
- detail::reduction_impl<T, BinaryOperation, 0 , true ,
1637
- access::mode::read_write>>
1614
+ std ::enable_if_t <detail::IsKnownIdentityOp<T, BinaryOperation>::value,
1615
+ detail::reduction_impl<T, BinaryOperation, 0 , true ,
1616
+ access::mode::read_write>>
1638
1617
reduction (T *VarPtr, BinaryOperation) {
1639
1618
return detail::reduction_impl<T, BinaryOperation, 0 , true ,
1640
1619
access::mode::read_write>(VarPtr);
1641
1620
}
1642
1621
1622
+ } // namespace ONEAPI
1623
+
1643
1624
template <typename BinaryOperation, typename AccumulatorT>
1644
- struct has_known_identity : detail::has_known_identity_impl<
1625
+ struct has_known_identity : ONEAPI:: detail::has_known_identity_impl<
1645
1626
typename std::decay<BinaryOperation>::type,
1646
1627
typename std::decay<AccumulatorT>::type> {};
1647
1628
#if __cplusplus >= 201703L
@@ -1651,15 +1632,14 @@ inline constexpr bool has_known_identity_v =
1651
1632
#endif
1652
1633
1653
1634
template <typename BinaryOperation, typename AccumulatorT>
1654
- struct known_identity
1655
- : detail::known_identity_impl< typename std::decay<BinaryOperation>::type,
1656
- typename std::decay<AccumulatorT>::type> {};
1635
+ struct known_identity : ONEAPI::detail::known_identity_impl<
1636
+ typename std::decay<BinaryOperation>::type,
1637
+ typename std::decay<AccumulatorT>::type> {};
1657
1638
#if __cplusplus >= 201703L
1658
1639
template <typename BinaryOperation, typename AccumulatorT>
1659
1640
inline constexpr AccumulatorT known_identity_v =
1660
1641
known_identity<BinaryOperation, AccumulatorT>::value;
1661
1642
#endif
1662
1643
1663
- } // namespace ONEAPI
1664
1644
} // namespace sycl
1665
1645
} // __SYCL_INLINE_NAMESPACE(cl)
0 commit comments