@@ -211,14 +211,77 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
211211 " PI backend failed. PI backend returns: " + codeToString (Error), Error);
212212}
213213
214+ bool handleInvalidWorkItemSize (const device_impl &DeviceImpl,
215+ const NDRDescT &NDRDesc) {
216+
217+ const plugin &Plugin = DeviceImpl.getPlugin ();
218+ RT::PiDevice Device = DeviceImpl.getHandleRef ();
219+
220+ size_t MaxWISize[] = {0 , 0 , 0 };
221+
222+ Plugin.call <PiApiKind::piDeviceGetInfo>(
223+ Device, PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES, sizeof (MaxWISize), &MaxWISize,
224+ nullptr );
225+ for (unsigned I = 0 ; I < NDRDesc.Dims ; I++) {
226+ if (NDRDesc.LocalSize [I] > MaxWISize[I])
227+ throw sycl::nd_range_error (
228+ " Number of work-items in a work-group exceed limit for dimension " +
229+ std::to_string (I) + " : " + std::to_string (NDRDesc.LocalSize [I]) +
230+ " > " + std::to_string (MaxWISize[I]),
231+ PI_INVALID_WORK_ITEM_SIZE);
232+ }
233+ return 0 ;
234+ }
235+
214236bool handleError (pi_result Error, const device_impl &DeviceImpl,
215237 pi_kernel Kernel, const NDRDescT &NDRDesc) {
216238 assert (Error != PI_SUCCESS &&
217239 " Success is expected to be handled on caller side" );
218240 switch (Error) {
219241 case PI_INVALID_WORK_GROUP_SIZE:
220242 return handleInvalidWorkGroupSize (DeviceImpl, Kernel, NDRDesc);
221- // TODO: Handle other error codes
243+
244+ case PI_INVALID_KERNEL_ARGS:
245+ throw sycl::nd_range_error (
246+ " The kernel argument values have not been specified "
247+ " OR "
248+ " a kernel argument declared to be a pointer to a type." ,
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 buffer objects specified as arguments to kernel" ,
274+ PI_MEM_OBJECT_ALLOCATION_FAILURE);
275+
276+ case PI_INVALID_IMAGE_SIZE:
277+ throw sycl::nd_range_error (
278+ " image object is specified as an argument value and the image "
279+ " dimensions (image width, height, specified or compute row and/or "
280+ " slice pitch) are not supported by device associated with queue" ,
281+ PI_INVALID_IMAGE_SIZE);
282+
283+ // TODO: Handle other error codes
284+
222285 default :
223286 throw runtime_error (
224287 " OpenCL API failed. OpenCL API returns: " + codeToString (Error), Error);
0 commit comments