Skip to content

Commit 1292532

Browse files
[SYCL] Make local accessor argument allocation 1-byte minimum (#6032)
Some DPC++ backends, such as OpenCL, does not allow setting local memory kernel arguments with a size of zero bytes. As such, the runtime library can fail with a backend error if a local accessor has a zero-size. These changes make a special case for local accessors with a zero byte size making it allocate a single byte of memory. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent f300e05 commit 1292532

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sycl/source/handler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ void handler::processArg(void *Ptr, const detail::kernel_param_kind_t &Kind,
543543
int SizeInBytes = LAcc->MElemSize;
544544
for (int I = 0; I < Dims; ++I)
545545
SizeInBytes *= Size[I];
546+
// Some backends do not accept zero-sized local memory arguments, so we
547+
// make it a minimum allocation of 1 byte.
548+
SizeInBytes = std::max(SizeInBytes, 1);
546549
MArgs.emplace_back(kernel_param_kind_t::kind_std_layout, nullptr,
547550
SizeInBytes, Index + IndexShift);
548551
if (!IsKernelCreatedFromSource) {

0 commit comments

Comments
 (0)