@@ -37,6 +37,11 @@ using IsMaximum =
37
37
bool_constant<std::is_same<BinaryOperation, sycl::maximum<T>>::value ||
38
38
std::is_same<BinaryOperation, sycl::maximum<void >>::value>;
39
39
40
+ template <typename T, class BinaryOperation >
41
+ using IsBitAND =
42
+ bool_constant<std::is_same<BinaryOperation, sycl::bit_and<T>>::value ||
43
+ std::is_same<BinaryOperation, sycl::bit_and<void >>::value>;
44
+
40
45
template <typename T, class BinaryOperation >
41
46
using IsBitOR =
42
47
bool_constant<std::is_same<BinaryOperation, sycl::bit_or<T>>::value ||
@@ -48,9 +53,14 @@ using IsBitXOR =
48
53
std::is_same<BinaryOperation, sycl::bit_xor<void >>::value>;
49
54
50
55
template <typename T, class BinaryOperation >
51
- using IsBitAND =
52
- bool_constant<std::is_same<BinaryOperation, sycl::bit_and<T>>::value ||
53
- std::is_same<BinaryOperation, sycl::bit_and<void >>::value>;
56
+ using IsLogicalAND = bool_constant<
57
+ std::is_same<BinaryOperation, sycl::logical_and<T>>::value ||
58
+ std::is_same<BinaryOperation, sycl::logical_and<void >>::value>;
59
+
60
+ template <typename T, class BinaryOperation >
61
+ using IsLogicalOR =
62
+ bool_constant<std::is_same<BinaryOperation, sycl::logical_or<T>>::value ||
63
+ std::is_same<BinaryOperation, sycl::logical_or<void >>::value>;
54
64
55
65
// Identity = 0
56
66
template <typename T, class BinaryOperation >
@@ -83,13 +93,23 @@ using IsMaximumIdentityOp =
83
93
bool_constant<(is_sgeninteger<T>::value || is_sgenfloat<T>::value) &&
84
94
IsMaximum<T, BinaryOperation>::value>;
85
95
96
+ // Identity = false
97
+ template <typename T, class BinaryOperation >
98
+ using IsFalseIdentityOp = bool_constant<IsLogicalOR<T, BinaryOperation>::value>;
99
+
100
+ // Identity = true
101
+ template <typename T, class BinaryOperation >
102
+ using IsTrueIdentityOp = bool_constant<IsLogicalAND<T, BinaryOperation>::value>;
103
+
86
104
template <typename T, class BinaryOperation >
87
105
using IsKnownIdentityOp =
88
106
bool_constant<IsZeroIdentityOp<T, BinaryOperation>::value ||
89
107
IsOneIdentityOp<T, BinaryOperation>::value ||
90
108
IsOnesIdentityOp<T, BinaryOperation>::value ||
91
109
IsMinimumIdentityOp<T, BinaryOperation>::value ||
92
- IsMaximumIdentityOp<T, BinaryOperation>::value>;
110
+ IsMaximumIdentityOp<T, BinaryOperation>::value ||
111
+ IsFalseIdentityOp<T, BinaryOperation>::value ||
112
+ IsTrueIdentityOp<T, BinaryOperation>::value>;
93
113
94
114
template <typename BinaryOperation, typename AccumulatorT>
95
115
struct has_known_identity_impl
@@ -101,16 +121,16 @@ struct known_identity_impl {};
101
121
102
122
// / Returns zero as identity for ADD, OR, XOR operations.
103
123
template <typename BinaryOperation, typename AccumulatorT>
104
- struct known_identity_impl <BinaryOperation, AccumulatorT,
105
- typename std::enable_if<IsZeroIdentityOp<
106
- AccumulatorT, BinaryOperation>::value>::type > {
124
+ struct known_identity_impl <
125
+ BinaryOperation, AccumulatorT,
126
+ std:: enable_if_t <IsZeroIdentityOp< AccumulatorT, BinaryOperation>::value>> {
107
127
static constexpr AccumulatorT value = 0 ;
108
128
};
109
129
110
130
template <typename BinaryOperation>
111
- struct known_identity_impl <BinaryOperation, half,
112
- typename std::enable_if<IsZeroIdentityOp<
113
- half, BinaryOperation>::value>::type > {
131
+ struct known_identity_impl <
132
+ BinaryOperation, half,
133
+ std:: enable_if_t <IsZeroIdentityOp< half, BinaryOperation>::value>> {
114
134
static constexpr half value =
115
135
#ifdef __SYCL_DEVICE_ONLY__
116
136
0 ;
@@ -121,16 +141,16 @@ struct known_identity_impl<BinaryOperation, half,
121
141
122
142
// / Returns one as identify for MULTIPLY operations.
123
143
template <typename BinaryOperation, typename AccumulatorT>
124
- struct known_identity_impl <BinaryOperation, AccumulatorT,
125
- typename std::enable_if<IsOneIdentityOp<
126
- AccumulatorT, BinaryOperation>::value>::type > {
144
+ struct known_identity_impl <
145
+ BinaryOperation, AccumulatorT,
146
+ std:: enable_if_t <IsOneIdentityOp< AccumulatorT, BinaryOperation>::value>> {
127
147
static constexpr AccumulatorT value = 1 ;
128
148
};
129
149
130
150
template <typename BinaryOperation>
131
- struct known_identity_impl <BinaryOperation, half,
132
- typename std::enable_if<IsOneIdentityOp<
133
- half, BinaryOperation>::value>::type > {
151
+ struct known_identity_impl <
152
+ BinaryOperation, half,
153
+ std:: enable_if_t <IsOneIdentityOp< half, BinaryOperation>::value>> {
134
154
static constexpr half value =
135
155
#ifdef __SYCL_DEVICE_ONLY__
136
156
1 ;
@@ -141,17 +161,17 @@ struct known_identity_impl<BinaryOperation, half,
141
161
142
162
// / Returns bit image consisting of all ones as identity for AND operations.
143
163
template <typename BinaryOperation, typename AccumulatorT>
144
- struct known_identity_impl <BinaryOperation, AccumulatorT,
145
- typename std::enable_if<IsOnesIdentityOp<
146
- AccumulatorT, BinaryOperation>::value>::type > {
164
+ struct known_identity_impl <
165
+ BinaryOperation, AccumulatorT,
166
+ std:: enable_if_t <IsOnesIdentityOp< AccumulatorT, BinaryOperation>::value>> {
147
167
static constexpr AccumulatorT value = ~static_cast <AccumulatorT>(0 );
148
168
};
149
169
150
170
// / Returns maximal possible value as identity for MIN operations.
151
171
template <typename BinaryOperation, typename AccumulatorT>
152
172
struct known_identity_impl <BinaryOperation, AccumulatorT,
153
- typename std::enable_if <IsMinimumIdentityOp<
154
- AccumulatorT, BinaryOperation>::value>::type > {
173
+ std::enable_if_t <IsMinimumIdentityOp<
174
+ AccumulatorT, BinaryOperation>::value>> {
155
175
static constexpr AccumulatorT value =
156
176
std::numeric_limits<AccumulatorT>::has_infinity
157
177
? std::numeric_limits<AccumulatorT>::infinity()
@@ -161,22 +181,38 @@ struct known_identity_impl<BinaryOperation, AccumulatorT,
161
181
// / Returns minimal possible value as identity for MAX operations.
162
182
template <typename BinaryOperation, typename AccumulatorT>
163
183
struct known_identity_impl <BinaryOperation, AccumulatorT,
164
- typename std::enable_if <IsMaximumIdentityOp<
165
- AccumulatorT, BinaryOperation>::value>::type > {
184
+ std::enable_if_t <IsMaximumIdentityOp<
185
+ AccumulatorT, BinaryOperation>::value>> {
166
186
static constexpr AccumulatorT value =
167
187
std::numeric_limits<AccumulatorT>::has_infinity
168
188
? static_cast <AccumulatorT>(
169
189
-std::numeric_limits<AccumulatorT>::infinity())
170
190
: std::numeric_limits<AccumulatorT>::lowest();
171
191
};
172
192
193
+ // / Returns false as identity for LOGICAL OR operations.
194
+ template <typename BinaryOperation, typename AccumulatorT>
195
+ struct known_identity_impl <
196
+ BinaryOperation, AccumulatorT,
197
+ std::enable_if_t <IsFalseIdentityOp<AccumulatorT, BinaryOperation>::value>> {
198
+ static constexpr AccumulatorT value = false ;
199
+ };
200
+
201
+ // / Returns true as identity for LOGICAL AND operations.
202
+ template <typename BinaryOperation, typename AccumulatorT>
203
+ struct known_identity_impl <
204
+ BinaryOperation, AccumulatorT,
205
+ std::enable_if_t <IsTrueIdentityOp<AccumulatorT, BinaryOperation>::value>> {
206
+ static constexpr AccumulatorT value = true ;
207
+ };
208
+
173
209
} // namespace detail
174
210
175
211
// ---- has_known_identity
176
212
template <typename BinaryOperation, typename AccumulatorT>
177
- struct has_known_identity : detail::has_known_identity_impl<
178
- typename std::decay <BinaryOperation>::type ,
179
- typename std::decay <AccumulatorT>::type > {};
213
+ struct has_known_identity
214
+ : detail::has_known_identity_impl< std::decay_t <BinaryOperation>,
215
+ std::decay_t <AccumulatorT>> {};
180
216
181
217
template <typename BinaryOperation, typename AccumulatorT>
182
218
__SYCL_INLINE_CONSTEXPR bool has_known_identity_v =
@@ -185,8 +221,8 @@ __SYCL_INLINE_CONSTEXPR bool has_known_identity_v =
185
221
// ---- known_identity
186
222
template <typename BinaryOperation, typename AccumulatorT>
187
223
struct known_identity
188
- : detail::known_identity_impl<typename std::decay <BinaryOperation>::type ,
189
- typename std::decay <AccumulatorT>::type > {};
224
+ : detail::known_identity_impl<std::decay_t <BinaryOperation>,
225
+ std::decay_t <AccumulatorT>> {};
190
226
191
227
template <typename BinaryOperation, typename AccumulatorT>
192
228
__SYCL_INLINE_CONSTEXPR AccumulatorT known_identity_v =
0 commit comments