Skip to content

Commit 2a41dfa

Browse files
committed
small fix
Signed-off-by: amochalo <[email protected]>
1 parent 0d6bc09 commit 2a41dfa

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

sycl/include/CL/sycl/detail/pi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,14 @@ typedef enum {
8383
PI_COMPILER_NOT_AVAILABLE = CL_COMPILER_NOT_AVAILABLE,
8484
PI_PROFILING_INFO_NOT_AVAILABLE = CL_PROFILING_INFO_NOT_AVAILABLE,
8585
PI_DEVICE_NOT_FOUND = CL_DEVICE_NOT_FOUND,
86+
PI_INVALID_WORK_ITEM_SIZE=CL_INVALID_WORK_ITEM_SIZE,
87+
PI_INVALID_KERNEL_ARGS=CL_INVALID_KERNEL_ARGS,
88+
PI_IMAGE_FORMAT_NOT_SUPPORTED=CL_IMAGE_FORMAT_NOT_SUPPORTED,
89+
PI_MEM_OBJECT_ALLOCATION_FAILURE=CL_MEM_OBJECT_ALLOCATION_FAILURE,
8690
PI_ERROR_UNKNOWN = -999
8791
} _pi_result;
8892

93+
8994
typedef enum {
9095
PI_EVENT_COMPLETE = CL_COMPLETE,
9196
PI_EVENT_RUNNING = CL_RUNNING,

sycl/source/detail/error_handling/enqueue_kernel.cpp

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,17 @@ bool oclHandleInvalidWorkGroupSize(const device_impl &DeviceImpl,
159159
}
160160
}
161161
}
162+
163+
// TODO: required number of sub-groups, OpenCL 2.1:
164+
// CL_INVALID_WORK_GROUP_SIZE if local_work_size is specified and is not
165+
// consistent with the required number of sub-groups for kernel in the
166+
// program source.
162167

163-
// TODO: required number of sub-groups, OpenCL 2.1:
164-
// PI_INVALID_WORK_GROUP_SIZE if local_work_size is specified and is not
165-
// consistent with the required number of sub-groups for kernel in the
166-
// program source.
168+
//Fallback
167169

168-
// Fallback
169170
constexpr pi_result Error = PI_INVALID_WORK_GROUP_SIZE;
170171
throw runtime_error(
171-
"OpenCL API failed. OpenCL API returns: " + codeToString(Error), Error);
172+
"OpenCL API failed. OpenCL API returns: " + codeToString(Error), Error);
172173
}
173174

174175
bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
@@ -218,9 +219,9 @@ bool handleInvalidWorkItemSize(const device_impl &DeviceImpl,
218219

219220
size_t MaxWISize[] = {0, 0, 0};
220221

221-
Plugin.call<PiApiKind::piDeviceGetInfo>(Device, PI_DEVICE_MAX_WORK_ITEM_SIZE,
222-
sizeof(MaxWISize), &MaxWISize,
223-
nullptr);
222+
Plugin.call<PiApiKind::piDeviceGetInfo>(
223+
Device, PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof(MaxWISize), &MaxWISize,
224+
nullptr);
224225
for (int i = 0; i < NDRDesc.Dims; i++) {
225226
if (NDRDesc.LocalSize[i] > MaxWISize[i])
226227
throw sycl::nd_range_error("Number of local work group number " +
@@ -238,7 +239,43 @@ bool handleError(pi_result Error, const device_impl &DeviceImpl,
238239
switch (Error) {
239240
case PI_INVALID_WORK_GROUP_SIZE:
240241
return handleInvalidWorkGroupSize(DeviceImpl, Kernel, NDRDesc);
241-
// TODO: Handle other error codes
242+
243+
case PI_INVALID_KERNEL_ARGS:
244+
throw sycl::nd_range_error(
245+
"The kernel argument values have not been specified "
246+
" OR "
247+
"a kernel argument declared to be a pointer to a type"
248+
" does not point to a named address space",
249+
PI_INVALID_KERNEL_ARGS);
250+
251+
case PI_INVALID_WORK_ITEM_SIZE:
252+
return handleInvalidWorkItemSize(DeviceImpl, NDRDesc);
253+
254+
case PI_IMAGE_FORMAT_NOT_SUPPORTED:
255+
throw sycl::nd_range_error(
256+
"image object is specified as an argument value"
257+
" and the image format is not supported by device associated"
258+
" with queue",
259+
PI_IMAGE_FORMAT_NOT_SUPPORTED);
260+
261+
case PI_MISALIGNED_SUB_BUFFER_OFFSET:
262+
throw sycl::nd_range_error(
263+
"a sub-buffer object is specified as the value for an argument "
264+
" that is a buffer object and the offset specified "
265+
"when the sub-buffer object is created is not aligned "
266+
"to CL_DEVICE_MEM_BASE_ADDR_ALIGN value for device associated"
267+
" with queue",
268+
PI_MISALIGNED_SUB_BUFFER_OFFSET);
269+
270+
case PI_MEM_OBJECT_ALLOCATION_FAILURE:
271+
throw sycl::nd_range_error(
272+
"failure to allocate memory for data store associated with image"
273+
" or "
274+
"buffer objects specified as arguments to kernel",
275+
PI_MEM_OBJECT_ALLOCATION_FAILURE);
276+
277+
// TODO: Handle other error codes
278+
242279
default:
243280
throw runtime_error(
244281
"OpenCL API failed. OpenCL API returns: " + codeToString(Error), Error);

0 commit comments

Comments
 (0)