Skip to content

Commit b382ba6

Browse files
committed
[SYCL] Restore sub-group collectives
Signed-off-by: John Pennycook <[email protected]>
1 parent ca39fa6 commit b382ba6

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

sycl/include/CL/sycl/intel/sub_group.hpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,74 @@ struct sub_group {
470470
#endif
471471
}
472472

473+
/* --- deprecated collective functions --- */
474+
template <typename T>
475+
__SYCL_DEPRECATED("Collectives in the sub-group class are deprecated. Use "
476+
"sycl::intel::broadcast instead.")
477+
EnableIfIsScalarArithmetic<T> broadcast(T x, id<1> local_id) const {
478+
return sycl::detail::spirv::GroupBroadcast<sub_group>(x, local_id);
479+
}
480+
481+
template <typename T, class BinaryOperation>
482+
__SYCL_DEPRECATED("Collectives in the sub-group class are deprecated. Use "
483+
"sycl::intel::reduce instead.")
484+
EnableIfIsScalarArithmetic<T> reduce(T x, BinaryOperation op) const {
485+
return sycl::detail::calc<T, __spv::GroupOperation::Reduce,
486+
__spv::Scope::Subgroup>(
487+
typename sycl::detail::GroupOpTag<T>::type(), x, op);
488+
}
489+
490+
template <typename T, class BinaryOperation>
491+
__SYCL_DEPRECATED("Collectives in the sub-group class are deprecated. Use "
492+
"sycl::intel::reduce instead.")
493+
EnableIfIsScalarArithmetic<T> reduce(T x, T init, BinaryOperation op) const {
494+
return op(init, reduce(x, op));
495+
}
496+
497+
template <typename T, class BinaryOperation>
498+
__SYCL_DEPRECATED("Collectives in the sub-group class are deprecated. Use "
499+
"sycl::intel::exclusive_scan instead.")
500+
EnableIfIsScalarArithmetic<T> exclusive_scan(T x, BinaryOperation op) const {
501+
return sycl::detail::calc<T, __spv::GroupOperation::ExclusiveScan,
502+
__spv::Scope::Subgroup>(
503+
typename sycl::detail::GroupOpTag<T>::type(), x, op);
504+
}
505+
506+
template <typename T, class BinaryOperation>
507+
__SYCL_DEPRECATED("Collectives in the sub-group class are deprecated. Use "
508+
"sycl::intel::exclusive_scan instead.")
509+
EnableIfIsScalarArithmetic<T> exclusive_scan(T x, T init,
510+
BinaryOperation op) const {
511+
if (get_local_id().get(0) == 0) {
512+
x = op(init, x);
513+
}
514+
T scan = exclusive_scan(x, op);
515+
if (get_local_id().get(0) == 0) {
516+
scan = init;
517+
}
518+
return scan;
519+
}
520+
521+
template <typename T, class BinaryOperation>
522+
__SYCL_DEPRECATED("Collectives in the sub-group class are deprecated. Use "
523+
"sycl::intel::inclusive_scan instead.")
524+
EnableIfIsScalarArithmetic<T> inclusive_scan(T x, BinaryOperation op) const {
525+
return sycl::detail::calc<T, __spv::GroupOperation::InclusiveScan,
526+
__spv::Scope::Subgroup>(
527+
typename sycl::detail::GroupOpTag<T>::type(), x, op);
528+
}
529+
530+
template <typename T, class BinaryOperation>
531+
__SYCL_DEPRECATED("Collectives in the sub-group class are deprecated. Use "
532+
"sycl::intel::inclusive_scan instead.")
533+
EnableIfIsScalarArithmetic<T> inclusive_scan(T x, BinaryOperation op,
534+
T init) const {
535+
if (get_local_id().get(0) == 0) {
536+
x = op(init, x);
537+
}
538+
return inclusive_scan(x, op);
539+
}
540+
473541
protected:
474542
template <int dimensions> friend class cl::sycl::nd_item;
475543
sub_group() = default;

0 commit comments

Comments
 (0)