Skip to content

Commit f31df05

Browse files
authored
[SYCL] Improve diagnostics for invalid work group size with L0 backend. (#8378)
Prior to this change, when requesting more work items than available while using L0 as backend, the error message was quite vague and didn't really help users understand the problem. --------- Signed-off-by: Maronas, Marcos <[email protected]>
1 parent f292b05 commit f31df05

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

sycl/source/detail/error_handling/enqueue_kernel.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,17 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
5151
// versions. If this is an OpenCL backend, get the version.
5252
bool IsOpenCL = false; // Backend is any OpenCL version
5353
bool IsOpenCLV1x = false; // Backend is OpenCL 1.x
54-
bool IsOpenCLV20 = false; // Backend is OpenCL 2.0
55-
if (Platform.get_backend() == sycl::backend::opencl) {
54+
bool IsOpenCLVGE20 = false; // Backend is Greater or Equal to OpenCL 2.0
55+
bool IsLevelZero = false; // Backend is any OneAPI Level 0 version
56+
auto Backend = Platform.get_backend();
57+
if (Backend == sycl::backend::opencl) {
5658
std::string VersionString = DeviceImpl.get_info<info::device::version>();
5759
IsOpenCL = true;
5860
IsOpenCLV1x = (VersionString.find("1.") == 0);
59-
IsOpenCLV20 = (VersionString.find("2.0") == 0);
61+
IsOpenCLVGE20 =
62+
(VersionString.find("2.") == 0) || (VersionString.find("3.") == 0);
63+
} else if (Backend == sycl::backend::ext_oneapi_level_zero) {
64+
IsLevelZero = true;
6065
}
6166

6267
size_t CompileWGSize[3] = {0};
@@ -69,7 +74,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
6974
// PI_ERROR_INVALID_WORK_GROUP_SIZE if local_work_size is NULL and the
7075
// reqd_work_group_size attribute is used to declare the work-group size
7176
// for kernel in the program source.
72-
if (!HasLocalSize && (IsOpenCLV1x || IsOpenCLV20)) {
77+
if (!HasLocalSize && (IsOpenCLV1x || IsOpenCLVGE20)) {
7378
throw sycl::nd_range_error(
7479
"OpenCL 1.x and 2.0 requires to pass local size argument even if "
7580
"required work-group size was specified in the program source",
@@ -91,7 +96,6 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
9196
std::to_string(CompileWGSize[0]) + "}",
9297
PI_ERROR_INVALID_WORK_GROUP_SIZE);
9398
}
94-
if (IsOpenCL) {
9599
if (IsOpenCLV1x) {
96100
// OpenCL 1.x:
97101
// PI_ERROR_INVALID_WORK_GROUP_SIZE if local_work_size is specified and
@@ -110,8 +114,8 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
110114
"Total number of work-items in a work-group cannot exceed " +
111115
std::to_string(MaxWGSize),
112116
PI_ERROR_INVALID_WORK_GROUP_SIZE);
113-
} else {
114-
// OpenCL 2.x:
117+
} else if (IsOpenCLVGE20 || IsLevelZero) {
118+
// OpenCL 2.x or OneAPI Level Zero:
115119
// PI_ERROR_INVALID_WORK_GROUP_SIZE if local_work_size is specified and
116120
// the total number of work-items in the work-group computed as
117121
// local_work_size[0] * ... * local_work_size[work_dim - 1] is greater
@@ -128,10 +132,9 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
128132
"Total number of work-items in a work-group cannot exceed " +
129133
std::to_string(KernelWGSize) + " for this kernel",
130134
PI_ERROR_INVALID_WORK_GROUP_SIZE);
135+
} else {
136+
// TODO: Should probably have something similar for the other backends
131137
}
132-
} else {
133-
// TODO: Should probably have something similar for the other backends
134-
}
135138

136139
if (HasLocalSize) {
137140
// Is the global range size evenly divisible by the local workgroup size?

0 commit comments

Comments
 (0)