Skip to content

Commit ef969c1

Browse files
authored
[SYCL] Remove two-input sub-group shuffles (#2614)
These functions were deprecated in bea6aa2. Removing them now allows for a simpler implementation of the interface to SPIR-V that is more closely tied to supported functionality. These changes will make it simpler to implement sub-group shuffles for other backends. Signed-off-by: John Pennycook <[email protected]>
1 parent b1cf776 commit ef969c1

File tree

2 files changed

+16
-68
lines changed

2 files changed

+16
-68
lines changed

sycl/include/CL/sycl/ONEAPI/sub_group.hpp

+2-48
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ struct sub_group {
191191

192192
template <typename T> T shuffle_down(T x, uint32_t delta) const {
193193
#ifdef __SYCL_DEVICE_ONLY__
194-
return sycl::detail::spirv::SubgroupShuffleDown(x, x, delta);
194+
return sycl::detail::spirv::SubgroupShuffleDown(x, delta);
195195
#else
196196
(void)x;
197197
(void)delta;
@@ -202,7 +202,7 @@ struct sub_group {
202202

203203
template <typename T> T shuffle_up(T x, uint32_t delta) const {
204204
#ifdef __SYCL_DEVICE_ONLY__
205-
return sycl::detail::spirv::SubgroupShuffleUp(x, x, delta);
205+
return sycl::detail::spirv::SubgroupShuffleUp(x, delta);
206206
#else
207207
(void)x;
208208
(void)delta;
@@ -222,52 +222,6 @@ struct sub_group {
222222
#endif
223223
}
224224

225-
/* --- two-input shuffles --- */
226-
/* indices in [0 , 2 * sub_group size) */
227-
228-
template <typename T>
229-
__SYCL_DEPRECATED("Two-input sub-group shuffles are deprecated.")
230-
T shuffle(T x, T y, id_type local_id) const {
231-
#ifdef __SYCL_DEVICE_ONLY__
232-
return sycl::detail::spirv::SubgroupShuffleDown(
233-
x, y, (local_id - get_local_id()).get(0));
234-
#else
235-
(void)x;
236-
(void)y;
237-
(void)local_id;
238-
throw runtime_error("Sub-groups are not supported on host device.",
239-
PI_INVALID_DEVICE);
240-
#endif
241-
}
242-
243-
template <typename T>
244-
__SYCL_DEPRECATED("Two-input sub-group shuffles are deprecated.")
245-
T shuffle_down(T current, T next, uint32_t delta) const {
246-
#ifdef __SYCL_DEVICE_ONLY__
247-
return sycl::detail::spirv::SubgroupShuffleDown(current, next, delta);
248-
#else
249-
(void)current;
250-
(void)next;
251-
(void)delta;
252-
throw runtime_error("Sub-groups are not supported on host device.",
253-
PI_INVALID_DEVICE);
254-
#endif
255-
}
256-
257-
template <typename T>
258-
__SYCL_DEPRECATED("Two-input sub-group shuffles are deprecated.")
259-
T shuffle_up(T previous, T current, uint32_t delta) const {
260-
#ifdef __SYCL_DEVICE_ONLY__
261-
return sycl::detail::spirv::SubgroupShuffleUp(previous, current, delta);
262-
#else
263-
(void)previous;
264-
(void)current;
265-
(void)delta;
266-
throw runtime_error("Sub-groups are not supported on host device.",
267-
PI_INVALID_DEVICE);
268-
#endif
269-
}
270-
271225
/* --- sub_group load/stores --- */
272226
/* these can map to SIMD or block read/write hardware where available */
273227

sycl/include/CL/sycl/detail/spirv.hpp

+14-20
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,16 @@ EnableIfNativeShuffle<T> SubgroupShuffleXor(T x, id<1> local_id) {
443443
}
444444

445445
template <typename T>
446-
EnableIfNativeShuffle<T> SubgroupShuffleDown(T x, T y, id<1> local_id) {
446+
EnableIfNativeShuffle<T> SubgroupShuffleDown(T x, id<1> local_id) {
447447
using OCLT = detail::ConvertToOpenCLType_t<T>;
448448
return __spirv_SubgroupShuffleDownINTEL(
449-
OCLT(x), OCLT(y), static_cast<uint32_t>(local_id.get(0)));
449+
OCLT(x), OCLT(x), static_cast<uint32_t>(local_id.get(0)));
450450
}
451451

452452
template <typename T>
453-
EnableIfNativeShuffle<T> SubgroupShuffleUp(T x, T y, id<1> local_id) {
453+
EnableIfNativeShuffle<T> SubgroupShuffleUp(T x, id<1> local_id) {
454454
using OCLT = detail::ConvertToOpenCLType_t<T>;
455-
return __spirv_SubgroupShuffleUpINTEL(OCLT(x), OCLT(y),
455+
return __spirv_SubgroupShuffleUpINTEL(OCLT(x), OCLT(x),
456456
static_cast<uint32_t>(local_id.get(0)));
457457
}
458458

@@ -488,22 +488,20 @@ EnableIfBitcastShuffle<T> SubgroupShuffleXor(T x, id<1> local_id) {
488488
}
489489

490490
template <typename T>
491-
EnableIfBitcastShuffle<T> SubgroupShuffleDown(T x, T y, id<1> local_id) {
491+
EnableIfBitcastShuffle<T> SubgroupShuffleDown(T x, id<1> local_id) {
492492
using ShuffleT = ConvertToNativeShuffleType_t<T>;
493493
auto ShuffleX = detail::bit_cast<ShuffleT>(x);
494-
auto ShuffleY = detail::bit_cast<ShuffleT>(y);
495494
ShuffleT Result = __spirv_SubgroupShuffleDownINTEL(
496-
ShuffleX, ShuffleY, static_cast<uint32_t>(local_id.get(0)));
495+
ShuffleX, ShuffleX, static_cast<uint32_t>(local_id.get(0)));
497496
return detail::bit_cast<T>(Result);
498497
}
499498

500499
template <typename T>
501-
EnableIfBitcastShuffle<T> SubgroupShuffleUp(T x, T y, id<1> local_id) {
500+
EnableIfBitcastShuffle<T> SubgroupShuffleUp(T x, id<1> local_id) {
502501
using ShuffleT = ConvertToNativeShuffleType_t<T>;
503502
auto ShuffleX = detail::bit_cast<ShuffleT>(x);
504-
auto ShuffleY = detail::bit_cast<ShuffleT>(y);
505503
ShuffleT Result = __spirv_SubgroupShuffleUpINTEL(
506-
ShuffleX, ShuffleY, static_cast<uint32_t>(local_id.get(0)));
504+
ShuffleX, ShuffleX, static_cast<uint32_t>(local_id.get(0)));
507505
return detail::bit_cast<T>(Result);
508506
}
509507

@@ -550,33 +548,29 @@ EnableIfGenericShuffle<T> SubgroupShuffleXor(T x, id<1> local_id) {
550548
}
551549

552550
template <typename T>
553-
EnableIfGenericShuffle<T> SubgroupShuffleDown(T x, T y, id<1> local_id) {
551+
EnableIfGenericShuffle<T> SubgroupShuffleDown(T x, id<1> local_id) {
554552
T Result;
555553
char *XBytes = reinterpret_cast<char *>(&x);
556-
char *YBytes = reinterpret_cast<char *>(&y);
557554
char *ResultBytes = reinterpret_cast<char *>(&Result);
558555
auto ShuffleBytes = [=](size_t Offset, size_t Size) {
559-
uint64_t ShuffleX, ShuffleY, ShuffleResult;
556+
uint64_t ShuffleX, ShuffleResult;
560557
detail::memcpy(&ShuffleX, XBytes + Offset, Size);
561-
detail::memcpy(&ShuffleY, YBytes + Offset, Size);
562-
ShuffleResult = SubgroupShuffleDown(ShuffleX, ShuffleY, local_id);
558+
ShuffleResult = SubgroupShuffleDown(ShuffleX, local_id);
563559
detail::memcpy(ResultBytes + Offset, &ShuffleResult, Size);
564560
};
565561
GenericCall<T>(ShuffleBytes);
566562
return Result;
567563
}
568564

569565
template <typename T>
570-
EnableIfGenericShuffle<T> SubgroupShuffleUp(T x, T y, id<1> local_id) {
566+
EnableIfGenericShuffle<T> SubgroupShuffleUp(T x, id<1> local_id) {
571567
T Result;
572568
char *XBytes = reinterpret_cast<char *>(&x);
573-
char *YBytes = reinterpret_cast<char *>(&y);
574569
char *ResultBytes = reinterpret_cast<char *>(&Result);
575570
auto ShuffleBytes = [=](size_t Offset, size_t Size) {
576-
uint64_t ShuffleX, ShuffleY, ShuffleResult;
571+
uint64_t ShuffleX, ShuffleResult;
577572
detail::memcpy(&ShuffleX, XBytes + Offset, Size);
578-
detail::memcpy(&ShuffleY, YBytes + Offset, Size);
579-
ShuffleResult = SubgroupShuffleUp(ShuffleX, ShuffleY, local_id);
573+
ShuffleResult = SubgroupShuffleUp(ShuffleX, local_id);
580574
detail::memcpy(ResultBytes + Offset, &ShuffleResult, Size);
581575
};
582576
GenericCall<T>(ShuffleBytes);

0 commit comments

Comments
 (0)