24 namespace ext::oneapi {
29 sycl::detail::enable_if_t<sycl::detail::is_scalar_arithmetic<T>::value, T>;
33 sycl::detail::enable_if_t<sycl::detail::is_vector_arithmetic<T>::value, T>;
35 template <
typename Ptr,
typename T>
37 sycl::detail::enable_if_t<sycl::detail::is_pointer<Ptr>::value, T>;
41 sycl::detail::enable_if_t<std::is_trivially_copyable<T>::value &&
42 !sycl::detail::is_vector_arithmetic<T>::value,
46 template <
typename T,
typename BinaryOperation>
48 sycl::detail::is_scalar_arithmetic<T>::value &&
49 sycl::detail::is_native_op<T, BinaryOperation>::value,
52 template <
typename T,
typename BinaryOperation>
54 sycl::detail::is_vector_arithmetic<T>::value &&
55 sycl::detail::is_native_op<T, BinaryOperation>::value,
59 template <
typename T,
typename BinaryOperation>
61 (!sycl::detail::is_scalar_arithmetic<T>::value &&
62 !sycl::detail::is_vector_arithmetic<T>::value &&
63 std::is_trivially_copyable<T>::value) ||
64 !sycl::detail::is_native_op<T, BinaryOperation>::value,
67 template <
typename Group>
69 "ext::oneapi::all_of is deprecated. Use all_of_group instead.")
75 template <
typename Group,
typename T,
class Predicate>
77 "ext::oneapi::all_of is deprecated. Use all_of_group instead.")
79 Group g, T x, Predicate pred) {
83 template <
typename Group,
typename Ptr,
class Predicate>
85 "ext::oneapi::all_of is deprecated. Use joint_all_of instead.")
86 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
87 detail::is_pointer<Ptr>::value),
88 bool>
all_of(Group g, Ptr first, Ptr last, Predicate pred) {
92 template <
typename Group>
94 "ext::oneapi::any_of is deprecated. Use any_of_group instead.")
100 template <
typename Group,
typename T,
class Predicate>
102 "ext::oneapi::any_of is deprecated. Use any_of_group instead.")
104 Group g, T x, Predicate pred) {
108 template <
typename Group,
typename Ptr,
class Predicate>
110 "ext::oneapi::any_of is deprecated. Use joint_any_of instead.")
111 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
112 detail::is_pointer<Ptr>::value),
113 bool>
any_of(Group g, Ptr first, Ptr last, Predicate pred) {
117 template <
typename Group>
119 "ext::oneapi::none_of is deprecated. Use none_of_group instead.")
121 Group g,
bool pred) {
125 template <
typename Group,
typename T,
class Predicate>
127 "ext::oneapi::none_of is deprecated. Use none_of_group instead.")
129 Group g, T x, Predicate pred) {
133 template <
typename Group,
typename Ptr,
class Predicate>
135 "ext::oneapi::none_of is deprecated. Use joint_none_of instead.")
136 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
137 detail::is_pointer<Ptr>::value),
138 bool>
none_of(Group g, Ptr first, Ptr last,
143 template <
typename Group,
typename T>
145 "ext::oneapi::broadcast is deprecated. Use group_broadcast instead.")
146 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
147 std::is_trivially_copyable<T>::value &&
148 !detail::is_vector_arithmetic<T>::value),
149 T> broadcast(Group, T x, typename Group::id_type local_id) {
150 #ifdef __SYCL_DEVICE_ONLY__
151 return sycl::detail::spirv::GroupBroadcast<Group>(x, local_id);
155 throw runtime_error(
"Group algorithms are not supported on host device.",
156 PI_ERROR_INVALID_DEVICE);
160 template <
typename Group,
typename T>
162 "ext::oneapi::broadcast is deprecated. Use group_broadcast instead.")
163 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
164 detail::is_vector_arithmetic<T>::value),
165 T> broadcast(Group g, T x,
166 typename Group::id_type local_id) {
167 #ifdef __SYCL_DEVICE_ONLY__
169 for (
int s = 0;
s < x.size(); ++
s) {
170 result[
s] = broadcast(g, x[
s], local_id);
177 throw runtime_error(
"Group algorithms are not supported on host device.",
178 PI_ERROR_INVALID_DEVICE);
182 template <
typename Group,
typename T>
184 "ext::oneapi::broadcast is deprecated. Use group_broadcast instead.")
185 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
186 std::is_trivially_copyable<T>::value &&
187 !detail::is_vector_arithmetic<T>::value),
188 T> broadcast(Group g, T x,
189 typename Group::linear_id_type
191 #ifdef __SYCL_DEVICE_ONLY__
198 (void)linear_local_id;
199 throw runtime_error(
"Group algorithms are not supported on host device.",
200 PI_ERROR_INVALID_DEVICE);
204 template <
typename Group,
typename T>
206 "ext::oneapi::broadcast is deprecated. Use group_broadcast instead.")
207 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
208 detail::is_vector_arithmetic<T>::value),
209 T> broadcast(Group g, T x,
210 typename Group::linear_id_type
212 #ifdef __SYCL_DEVICE_ONLY__
214 for (
int s = 0;
s < x.size(); ++
s) {
215 result[
s] = broadcast(g, x[
s], linear_local_id);
221 (void)linear_local_id;
222 throw runtime_error(
"Group algorithms are not supported on host device.",
223 PI_ERROR_INVALID_DEVICE);
227 template <
typename Group,
typename T>
229 "ext::oneapi::broadcast is deprecated. Use group_broadcast instead.")
230 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
231 std::is_trivially_copyable<T>::value &&
232 !detail::is_vector_arithmetic<T>::value),
233 T> broadcast(Group g, T x) {
234 #ifdef __SYCL_DEVICE_ONLY__
235 return broadcast(g, x, 0);
239 throw runtime_error(
"Group algorithms are not supported on host device.",
240 PI_ERROR_INVALID_DEVICE);
244 template <
typename Group,
typename T>
246 "ext::oneapi::broadcast is deprecated. Use group_broadcast instead.")
247 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
248 detail::is_vector_arithmetic<T>::value),
249 T> broadcast(Group g, T x) {
250 #ifdef __SYCL_DEVICE_ONLY__
252 for (
int s = 0;
s < x.size(); ++
s) {
253 result[
s] = broadcast(g, x[
s]);
259 throw runtime_error(
"Group algorithms are not supported on host device.",
260 PI_ERROR_INVALID_DEVICE);
264 template <
typename Group,
typename T,
class BinaryOperation>
266 "ext::oneapi::reduce is deprecated. Use reduce_over_group instead.")
267 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
268 detail::is_scalar_arithmetic<T>::value &&
269 detail::is_native_op<T, BinaryOperation>::value),
270 T>
reduce(Group g, T x, BinaryOperation binary_op) {
274 template <
typename Group,
typename T,
class BinaryOperation>
276 "ext::oneapi::reduce is deprecated. Use reduce_over_group instead.")
277 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
278 detail::is_vector_arithmetic<T>::value &&
279 detail::is_native_op<T, BinaryOperation>::value),
280 T>
reduce(Group g, T x, BinaryOperation binary_op) {
284 template <
typename Group,
typename T,
class BinaryOperation>
286 "ext::oneapi::reduce is deprecated. Use reduce_over_group instead.")
287 detail::
enable_if_t<(detail::is_sub_group<Group>::value &&
288 std::is_trivially_copyable<T>::value &&
289 (!detail::is_arithmetic<T>::value ||
290 !detail::is_native_op<T, BinaryOperation>::value)),
291 T>
reduce(Group g, T x, BinaryOperation op) {
293 for (
int mask = 1; mask < g.get_max_local_range()[0]; mask *= 2) {
294 T tmp = g.shuffle_xor(result,
id<1>(mask));
295 if ((g.get_local_id()[0] ^ mask) < g.get_local_range()[0]) {
296 result = op(result, tmp);
299 return g.shuffle(result, 0);
302 template <
typename Group,
typename V,
typename T,
class BinaryOperation>
304 "ext::oneapi::reduce is deprecated. Use reduce_over_group instead.")
305 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
306 detail::is_scalar_arithmetic<V>::value &&
307 detail::is_scalar_arithmetic<T>::value &&
308 detail::is_native_op<V, BinaryOperation>::value &&
309 detail::is_native_op<T, BinaryOperation>::value),
310 T>
reduce(Group g, V x, T init, BinaryOperation binary_op) {
314 template <
typename Group,
typename V,
typename T,
class BinaryOperation>
316 "ext::oneapi::reduce is deprecated. Use reduce_over_group instead.")
317 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
318 detail::is_vector_arithmetic<V>::value &&
319 detail::is_vector_arithmetic<T>::value &&
320 detail::is_native_op<V, BinaryOperation>::value &&
321 detail::is_native_op<T, BinaryOperation>::value),
322 T>
reduce(Group g, V x, T init, BinaryOperation binary_op) {
326 template <
typename Group,
typename V,
typename T,
class BinaryOperation>
328 "ext::oneapi::reduce is deprecated. Use reduce_over_group instead.")
329 detail::
enable_if_t<(detail::is_sub_group<Group>::value &&
330 std::is_trivially_copyable<T>::value &&
331 std::is_trivially_copyable<V>::value &&
332 (!detail::is_arithmetic<T>::value ||
333 !detail::is_arithmetic<V>::value ||
334 !detail::is_native_op<T, BinaryOperation>::value)),
335 T>
reduce(Group g, V x, T init, BinaryOperation op) {
337 for (
int mask = 1; mask < g.get_max_local_range()[0]; mask *= 2) {
338 T tmp = g.shuffle_xor(result,
id<1>(mask));
339 if ((g.get_local_id()[0] ^ mask) < g.get_local_range()[0]) {
340 result = op(result, tmp);
343 return g.shuffle(op(init, result), 0);
346 template <
typename Group,
typename Ptr,
class BinaryOperation>
348 "ext::oneapi::reduce is deprecated. Use joint_reduce instead.")
350 (detail::is_generic_group<Group>::value && detail::is_pointer<Ptr>::value &&
351 detail::is_arithmetic<typename detail::remove_pointer<Ptr>::type>::value),
352 typename detail::remove_pointer<Ptr>::type>
reduce(Group g, Ptr first,
359 template <
typename Group,
typename Ptr,
typename T,
class BinaryOperation>
361 "ext::oneapi::reduce is deprecated. Use joint_reduce instead.")
363 (detail::is_generic_group<Group>::value && detail::is_pointer<Ptr>::value &&
364 detail::is_arithmetic<typename detail::remove_pointer<Ptr>::type>::value &&
365 detail::is_arithmetic<T>::value &&
366 detail::is_native_op<typename detail::remove_pointer<Ptr>::type,
367 BinaryOperation>::value &&
368 detail::is_native_op<T, BinaryOperation>::value),
369 T>
reduce(Group g, Ptr first, Ptr last, T init, BinaryOperation binary_op) {
373 template <
typename Group,
typename T,
class BinaryOperation>
375 "exclusive_scan_over_group instead.")
376 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
377 detail::is_scalar_arithmetic<T>::value &&
378 detail::is_native_op<T, BinaryOperation>::value),
379 T> exclusive_scan(Group g, T x, BinaryOperation binary_op) {
383 template <
typename Group,
typename T,
class BinaryOperation>
385 "exclusive_scan_over_group instead.")
386 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
387 detail::is_vector_arithmetic<T>::value &&
388 detail::is_native_op<T, BinaryOperation>::value),
389 T> exclusive_scan(Group g, T x, BinaryOperation binary_op) {
393 template <
typename Group,
typename V,
typename T,
class BinaryOperation>
395 "exclusive_scan_over_group instead.")
396 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
397 detail::is_vector_arithmetic<V>::value &&
398 detail::is_vector_arithmetic<T>::value &&
399 detail::is_native_op<V, BinaryOperation>::value &&
400 detail::is_native_op<T, BinaryOperation>::value),
401 T> exclusive_scan(Group g, V x, T init,
402 BinaryOperation binary_op) {
406 template <
typename Group,
typename V,
typename T,
class BinaryOperation>
408 "exclusive_scan_over_group instead.")
409 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
410 detail::is_scalar_arithmetic<V>::value &&
411 detail::is_scalar_arithmetic<T>::value &&
412 detail::is_native_op<V, BinaryOperation>::value &&
413 detail::is_native_op<T, BinaryOperation>::value),
414 T> exclusive_scan(Group g, V x, T init,
415 BinaryOperation binary_op) {
419 template <
typename Group,
typename InPtr,
typename OutPtr,
typename T,
420 class BinaryOperation>
422 "joint_exclusive_scan instead.")
424 (detail::is_generic_group<Group>::value &&
425 detail::is_pointer<InPtr>::value && detail::is_pointer<OutPtr>::value &&
426 detail::is_arithmetic<
427 typename detail::remove_pointer<InPtr>::type>::value &&
428 detail::is_arithmetic<T>::value &&
429 detail::is_native_op<typename detail::remove_pointer<InPtr>::type,
430 BinaryOperation>::value &&
431 detail::is_native_op<T, BinaryOperation>::value),
432 OutPtr> exclusive_scan(Group g, InPtr first, InPtr last, OutPtr result,
433 T init, BinaryOperation binary_op) {
437 template <
typename Group,
typename InPtr,
typename OutPtr,
438 class BinaryOperation>
440 "joint_exclusive_scan instead.")
442 (detail::is_generic_group<Group>::value &&
443 detail::is_pointer<InPtr>::value && detail::is_pointer<OutPtr>::value &&
444 detail::is_arithmetic<
445 typename detail::remove_pointer<InPtr>::type>::value &&
446 detail::is_native_op<typename detail::remove_pointer<InPtr>::type,
447 BinaryOperation>::value),
448 OutPtr> exclusive_scan(Group g, InPtr first, InPtr last, OutPtr result,
449 BinaryOperation binary_op) {
453 template <
typename Group,
typename T,
class BinaryOperation>
455 "inclusive_scan_over_group instead.")
456 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
457 detail::is_vector_arithmetic<T>::value &&
458 detail::is_native_op<T, BinaryOperation>::value),
459 T> inclusive_scan(Group g, T x, BinaryOperation binary_op) {
463 template <
typename Group,
typename T,
class BinaryOperation>
465 "inclusive_scan_over_group instead.")
466 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
467 detail::is_scalar_arithmetic<T>::value &&
468 detail::is_native_op<T, BinaryOperation>::value),
469 T> inclusive_scan(Group g, T x, BinaryOperation binary_op) {
473 template <
typename Group,
typename V,
class BinaryOperation,
typename T>
475 "inclusive_scan_over_group instead.")
476 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
477 detail::is_scalar_arithmetic<V>::value &&
478 detail::is_scalar_arithmetic<T>::value &&
479 detail::is_native_op<V, BinaryOperation>::value &&
480 detail::is_native_op<T, BinaryOperation>::value),
481 T> inclusive_scan(Group g, V x, BinaryOperation binary_op,
486 template <
typename Group,
typename V,
class BinaryOperation,
typename T>
488 "inclusive_scan_over_group instead.")
489 detail::
enable_if_t<(detail::is_generic_group<Group>::value &&
490 detail::is_vector_arithmetic<V>::value &&
491 detail::is_vector_arithmetic<T>::value &&
492 detail::is_native_op<V, BinaryOperation>::value &&
493 detail::is_native_op<T, BinaryOperation>::value),
494 T> inclusive_scan(Group g, V x, BinaryOperation binary_op,
499 template <
typename Group,
typename InPtr,
typename OutPtr,
500 class BinaryOperation,
typename T>
502 "joint_inclusive_scan instead.")
504 (detail::is_generic_group<Group>::value &&
505 detail::is_pointer<InPtr>::value && detail::is_pointer<OutPtr>::value &&
506 detail::is_arithmetic<
507 typename detail::remove_pointer<InPtr>::type>::value &&
508 detail::is_arithmetic<T>::value &&
509 detail::is_native_op<typename detail::remove_pointer<InPtr>::type,
510 BinaryOperation>::value &&
511 detail::is_native_op<T, BinaryOperation>::value),
512 OutPtr> inclusive_scan(Group g, InPtr first, InPtr last, OutPtr result,
513 BinaryOperation binary_op, T init) {
517 template <
typename Group,
typename InPtr,
typename OutPtr,
518 class BinaryOperation>
520 "joint_inclusive_scan instead.")
522 (detail::is_generic_group<Group>::value &&
523 detail::is_pointer<InPtr>::value && detail::is_pointer<OutPtr>::value &&
524 detail::is_arithmetic<
525 typename detail::remove_pointer<InPtr>::type>::value &&
526 detail::is_native_op<typename detail::remove_pointer<InPtr>::type,
527 BinaryOperation>::value),
528 OutPtr> inclusive_scan(Group g, InPtr first, InPtr last, OutPtr result,
529 BinaryOperation binary_op) {
533 template <
typename Group>
535 "ext::oneapi::leader free function is deprecated. Use member function "
536 "leader of the sycl::group/sycl::sub_group instead.")
537 detail::
enable_if_t<detail::is_generic_group<Group>::value,
bool> leader(
539 #ifdef __SYCL_DEVICE_ONLY__
540 typename Group::linear_id_type linear_id =
542 return (linear_id == 0);
545 throw runtime_error(
"Group algorithms are not supported on host device.",
546 PI_ERROR_INVALID_DEVICE);
#define __SYCL_INLINE_VER_NAMESPACE(X)
#define __SYCL2020_DEPRECATED(message)
id< 3 > linear_id_to_id(range< 3 > r, size_t linear_id)
typename std::enable_if< B, T >::type enable_if_t
Group::linear_id_type get_local_linear_id(Group g)
sycl::detail::enable_if_t< sycl::detail::is_scalar_arithmetic< T >::value, T > EnableIfIsScalarArithmetic
sycl::detail::enable_if_t< sycl::detail::is_vector_arithmetic< T >::value, T > EnableIfIsVectorArithmetic
sycl::detail::enable_if_t< sycl::detail::is_vector_arithmetic< T >::value &&sycl::detail::is_native_op< T, BinaryOperation >::value, T > EnableIfIsVectorArithmeticNativeOp
sycl::detail::enable_if_t< std::is_trivially_copyable< T >::value &&!sycl::detail::is_vector_arithmetic< T >::value, T > EnableIfIsTriviallyCopyable
sycl::detail::enable_if_t< sycl::detail::is_scalar_arithmetic< T >::value &&sycl::detail::is_native_op< T, BinaryOperation >::value, T > EnableIfIsScalarArithmeticNativeOp
sycl::detail::enable_if_t<(!sycl::detail::is_scalar_arithmetic< T >::value &&!sycl::detail::is_vector_arithmetic< T >::value &&std::is_trivially_copyable< T >::value)||!sycl::detail::is_native_op< T, BinaryOperation >::value, T > EnableIfIsNonNativeOp
sycl::detail::enable_if_t< sycl::detail::is_pointer< Ptr >::value, T > EnableIfIsPointer
detail::enable_if_t<(is_group_v< std::decay_t< Group >> &&detail::is_pointer< Ptr >::value &&detail::is_arithmetic_or_complex< typename detail::remove_pointer< Ptr >::type >::value &&detail::is_arithmetic_or_complex< T >::value &&detail::is_native_op< typename detail::remove_pointer< Ptr >::type, BinaryOperation >::value &&detail::is_plus_if_complex< typename detail::remove_pointer< Ptr >::type, BinaryOperation >::value &&detail::is_plus_if_complex< T, BinaryOperation >::value &&detail::is_native_op< T, BinaryOperation >::value), T > joint_reduce(Group g, Ptr first, Ptr last, T init, BinaryOperation binary_op)
detail::enable_if_t<(is_group_v< std::decay_t< Group >> &&(detail::is_scalar_arithmetic< V >::value||detail::is_complex< V >::value) &&(detail::is_scalar_arithmetic< T >::value||detail::is_complex< T >::value) &&detail::is_native_op< V, BinaryOperation >::value &&detail::is_native_op< T, BinaryOperation >::value &&detail::is_plus_if_complex< V, BinaryOperation >::value &&detail::is_plus_if_complex< T, BinaryOperation >::value), T > exclusive_scan_over_group(Group g, V x, T init, BinaryOperation binary_op)
detail::enable_if_t< is_group_v< std::decay_t< Group > >, bool > none_of_group(Group g, T x, Predicate pred)
detail::enable_if_t<(is_group_v< std::decay_t< Group >> &&detail::is_pointer< Ptr >::value), bool > joint_all_of(Group g, Ptr first, Ptr last, Predicate pred)
detail::enable_if_t< is_group_v< Group >, bool > any_of_group(Group g, T x, Predicate pred)
detail::enable_if_t< is_group_v< std::decay_t< Group > >, bool > all_of_group(Group g, T x, Predicate pred)
detail::enable_if_t<(is_group_v< std::decay_t< Group >> &&detail::is_pointer< Ptr >::value), bool > joint_any_of(Group g, Ptr first, Ptr last, Predicate pred)
detail::enable_if_t<(is_group_v< std::decay_t< Group >> &&detail::is_pointer< Ptr >::value), bool > joint_none_of(Group g, Ptr first, Ptr last, Predicate pred)
detail::enable_if_t<(is_group_v< std::decay_t< Group >> &&detail::is_vector_arithmetic< V >::value &&detail::is_vector_arithmetic< T >::value &&detail::is_native_op< V, BinaryOperation >::value &&detail::is_native_op< T, BinaryOperation >::value), T > reduce_over_group(Group g, V x, T init, BinaryOperation binary_op)
detail::enable_if_t<(is_group_v< std::decay_t< Group >> &&detail::is_vector_arithmetic< V >::value &&detail::is_vector_arithmetic< T >::value &&detail::is_native_op< V, BinaryOperation >::value &&detail::is_native_op< T, BinaryOperation >::value), T > inclusive_scan_over_group(Group g, V x, BinaryOperation binary_op, T init)
detail::enable_if_t<(is_group_v< std::decay_t< Group >> &&detail::is_pointer< InPtr >::value &&detail::is_pointer< OutPtr >::value &&detail::is_arithmetic_or_complex< typename detail::remove_pointer< InPtr >::type >::value &&detail::is_native_op< typename detail::remove_pointer< InPtr >::type, BinaryOperation >::value &&detail::is_plus_if_complex< typename detail::remove_pointer< InPtr >::type, BinaryOperation >::value), OutPtr > joint_exclusive_scan(Group g, InPtr first, InPtr last, OutPtr result, BinaryOperation binary_op)
detail::enable_if_t<(is_group_v< std::decay_t< Group >> &&detail::is_pointer< InPtr >::value &&detail::is_pointer< OutPtr >::value &&detail::is_arithmetic_or_complex< typename detail::remove_pointer< InPtr >::type >::value &&detail::is_native_op< typename detail::remove_pointer< InPtr >::type, BinaryOperation >::value &&detail::is_plus_if_complex< typename detail::remove_pointer< InPtr >::type, BinaryOperation >::value), OutPtr > joint_inclusive_scan(Group g, InPtr first, InPtr last, OutPtr result, BinaryOperation binary_op)
---— Error handling, matching OpenCL plugin semantics.
bool any_of(const simd_mask< _Tp, _Abi > &) noexcept
bool all_of(const simd_mask< _Tp, _Abi > &) noexcept
bool none_of(const simd_mask< _Tp, _Abi > &) noexcept
_Tp reduce(const simd< _Tp, _Abi > &, _BinaryOp=_BinaryOp())