Skip to content

Commit 5d1d2ba

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (#1)
2 parents c40f925 + be42ff7 commit 5d1d2ba

File tree

4 files changed

+73
-5
lines changed

4 files changed

+73
-5
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ using pi_bitfield = pi_uint64;
6969
//
7070
typedef enum {
7171
PI_SUCCESS = CL_SUCCESS,
72-
PI_RESULT_INVALID_KERNEL_NAME = CL_INVALID_KERNEL_NAME,
72+
PI_INVALID_KERNEL_NAME = CL_INVALID_KERNEL_NAME,
7373
PI_INVALID_OPERATION = CL_INVALID_OPERATION,
7474
PI_INVALID_KERNEL = CL_INVALID_KERNEL,
7575
PI_INVALID_QUEUE_PROPERTIES = CL_INVALID_QUEUE_PROPERTIES,
@@ -91,6 +91,11 @@ typedef enum {
9191
PI_COMPILER_NOT_AVAILABLE = CL_COMPILER_NOT_AVAILABLE,
9292
PI_PROFILING_INFO_NOT_AVAILABLE = CL_PROFILING_INFO_NOT_AVAILABLE,
9393
PI_DEVICE_NOT_FOUND = CL_DEVICE_NOT_FOUND,
94+
PI_INVALID_WORK_ITEM_SIZE = CL_INVALID_WORK_ITEM_SIZE,
95+
PI_INVALID_KERNEL_ARGS = CL_INVALID_KERNEL_ARGS,
96+
PI_INVALID_IMAGE_SIZE = CL_INVALID_IMAGE_SIZE,
97+
PI_IMAGE_FORMAT_NOT_SUPPORTED = CL_IMAGE_FORMAT_NOT_SUPPORTED,
98+
PI_MEM_OBJECT_ALLOCATION_FAILURE = CL_MEM_OBJECT_ALLOCATION_FAILURE,
9499
PI_ERROR_UNKNOWN = -999
95100
} _pi_result;
96101

@@ -106,7 +111,7 @@ typedef enum {
106111
PI_PLATFORM_INFO_NAME = CL_PLATFORM_NAME,
107112
PI_PLATFORM_INFO_PROFILE = CL_PLATFORM_PROFILE,
108113
PI_PLATFORM_INFO_VENDOR = CL_PLATFORM_VENDOR,
109-
PI_PLATFORM_INFO_VERSION = CL_PLATFORM_VERSION,
114+
PI_PLATFORM_INFO_VERSION = CL_PLATFORM_VERSION
110115
} _pi_platform_info;
111116

112117
typedef enum {

sycl/source/detail/error_handling/enqueue_kernel.cpp

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
214236
bool 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);

sycl/source/detail/program_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ RT::PiKernel program_impl::get_pi_kernel(const string_class &KernelName) const {
384384
const detail::plugin &Plugin = getPlugin();
385385
RT::PiResult Err = Plugin.call_nocheck<PiApiKind::piKernelCreate>(
386386
MProgram, KernelName.c_str(), &Kernel);
387-
if (Err == PI_RESULT_INVALID_KERNEL_NAME) {
387+
if (Err == PI_INVALID_KERNEL_NAME) {
388388
throw invalid_object_error(
389389
"This instance of program does not contain the kernel requested",
390390
Err);

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ ProgramManager::getKernelSetId(OSModuleHandle M,
927927
return ModuleKSIdIt->second;
928928

929929
throw runtime_error("No kernel named " + KernelName + " was found",
930-
PI_RESULT_INVALID_KERNEL_NAME);
930+
PI_INVALID_KERNEL_NAME);
931931
}
932932

933933
void ProgramManager::dumpImage(const RTDeviceBinaryImage &Img,

0 commit comments

Comments
 (0)