Skip to content

Commit 0d6bc09

Browse files
committed
[SYCL] Improve error handling
Improve error handling in enqueue_kernel_launch::handleError. #935 Signed-off-by: amochalo <[email protected]>
1 parent 0203c6c commit 0d6bc09

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

sycl/source/detail/error_handling/enqueue_kernel.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
177177

178178
const plugin &Plugin = DeviceImpl.getPlugin();
179179
RT::PiDevice Device = DeviceImpl.getHandleRef();
180-
181180
if (HasLocalSize) {
182181
size_t MaxThreadsPerBlock[3] = {};
183182
Plugin.call<PiApiKind::piDeviceGetInfo>(
@@ -211,6 +210,27 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
211210
"PI backend failed. PI backend returns: " + codeToString(Error), Error);
212211
}
213212

213+
bool handleInvalidWorkItemSize(const device_impl &DeviceImpl,
214+
const NDRDescT &NDRDesc) {
215+
216+
const plugin &Plugin = DeviceImpl.getPlugin();
217+
RT::PiDevice Device = DeviceImpl.getHandleRef();
218+
219+
size_t MaxWISize[] = {0, 0, 0};
220+
221+
Plugin.call<PiApiKind::piDeviceGetInfo>(Device, PI_DEVICE_MAX_WORK_ITEM_SIZE,
222+
sizeof(MaxWISize), &MaxWISize,
223+
nullptr);
224+
for (int i = 0; i < NDRDesc.Dims; i++) {
225+
if (NDRDesc.LocalSize[i] > MaxWISize[i])
226+
throw sycl::nd_range_error("Number of local work group number " +
227+
std::to_string(i) +
228+
" greater then corresponding values"
229+
"PI_DEVISE_MAX_WORK_SIZE",
230+
PI_INVALID_WORK_ITEM_SIZE);
231+
}
232+
}
233+
214234
bool handleError(pi_result Error, const device_impl &DeviceImpl,
215235
pi_kernel Kernel, const NDRDescT &NDRDesc) {
216236
assert(Error != PI_SUCCESS &&

0 commit comments

Comments
 (0)