Skip to content

Commit 9073865

Browse files
authored
[SYCL][NATIVECPU] Offset subgroup read/write by subgroup id (#15627)
Fixes a bug in the implementation of `__spirv_SubgroupBlockRead`/`Write` for Native CPU, making it so the pointer dereference is offset-ed by the subgroup id.
1 parent 42b924e commit 9073865

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libdevice/nativecpu_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ __spirv_MemoryBarrier(uint32_t Memory, uint32_t Semantics) {
6565
template <> \
6666
__SYCL_CONVERGENT__ DEVICE_EXTERNAL Type \
6767
__spirv_SubgroupBlockReadINTEL<Type>(const OCL_GLOBAL PType *Ptr) noexcept { \
68-
return *Ptr; \
68+
return Ptr[__spirv_SubgroupLocalInvocationId()]; \
6969
} \
7070
template <> \
7171
__SYCL_CONVERGENT__ DEVICE_EXTERNAL void \
7272
__spirv_SubgroupBlockWriteINTEL<Type>(PType OCL_GLOBAL * ptr, \
7373
Type v) noexcept { \
74-
*(Type *)ptr = v; \
74+
((Type*)ptr)[__spirv_SubgroupLocalInvocationId()] = v; \
7575
}
7676

7777
#define DefSubgroupBlockINTEL_vt(Type, VT_name) \

0 commit comments

Comments
 (0)