Skip to content

Commit 2d9d5ef

Browse files
authored
[SYCL][NFC] Make the nd_range error message a bit more informative (#2860)
Signed-off-by: Vyacheslav N Klochkov <[email protected]>
1 parent c62860f commit 2d9d5ef

File tree

3 files changed

+37
-15
lines changed

3 files changed

+37
-15
lines changed

sycl/source/detail/error_handling/enqueue_kernel.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,14 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
8383
NDRDesc.LocalSize[1] != CompileWGSize[1] ||
8484
NDRDesc.LocalSize[2] != CompileWGSize[2])
8585
throw sycl::nd_range_error(
86-
"Specified local size doesn't match the required work-group size "
87-
"specified in the program source",
86+
"The specified local size {" + std::to_string(NDRDesc.LocalSize[0]) +
87+
", " + std::to_string(NDRDesc.LocalSize[1]) + ", " +
88+
std::to_string(NDRDesc.LocalSize[2]) +
89+
"} doesn't match the required work-group size specified "
90+
"in the program source {" +
91+
std::to_string(CompileWGSize[0]) + ", " +
92+
std::to_string(CompileWGSize[1]) + ", " +
93+
std::to_string(CompileWGSize[2]) + "}",
8894
PI_INVALID_WORK_GROUP_SIZE);
8995
}
9096
if (IsOpenCL) {
@@ -185,11 +191,22 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
185191
Opts.find("-cl-std=CL2.0") != string_class::npos;
186192
const bool RequiresUniformWGSize =
187193
Opts.find("-cl-uniform-work-group-size") != string_class::npos;
194+
std::string LocalWGSize = std::to_string(NDRDesc.LocalSize[0]) +
195+
", " +
196+
std::to_string(NDRDesc.LocalSize[1]) +
197+
", " + std::to_string(NDRDesc.LocalSize[2]);
198+
std::string GlobalWGSize =
199+
std::to_string(NDRDesc.GlobalSize[0]) + ", " +
200+
std::to_string(NDRDesc.GlobalSize[1]) + ", " +
201+
std::to_string(NDRDesc.GlobalSize[2]);
188202
std::string message =
189203
LocalExceedsGlobal
190-
? "Local workgroup size greater than global range size. "
191-
: "Global_work_size not evenly divisible by "
192-
"local_work_size. ";
204+
? "Local work-group size {" + LocalWGSize +
205+
"} is greater than global range size {" + GlobalWGSize +
206+
"}. "
207+
: "Global work size {" + GlobalWGSize +
208+
"} is not evenly divisible by local work-group size {" +
209+
LocalWGSize + "}. ";
193210
if (!HasStd20)
194211
throw sycl::nd_range_error(
195212
message.append(

sycl/test/on-device/basic_tests/parallel_for_range.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ int main() {
5757
"thrown\n";
5858
return 1; // We shouldn't be here, exception is expected
5959
} catch (nd_range_error &E) {
60-
if (string_class(E.what()).find("Specified local size doesn't match "
61-
"the required work-group size "
62-
"specified in the program source") ==
63-
string_class::npos) {
60+
if (string_class(E.what()).find("The specified local size {8, 8, 8} "
61+
"doesn't match the required work-group "
62+
"size specified in the program source "
63+
"{4, 4, 4}") == string_class::npos) {
6464
std::cerr
6565
<< "Test case ReqdWGSizeNegativeA failed: unexpected exception: "
6666
<< E.what() << std::endl;
@@ -670,7 +670,8 @@ int main() {
670670
}
671671
} catch (nd_range_error &E) {
672672
if (string_class(E.what()).find(
673-
"Global_work_size not evenly divisible by local_work_size. "
673+
"Global work size {100, 1, 1} is not evenly divisible "
674+
"by local work-group size {3, 1, 1}. "
674675
"Non-uniform work-groups are not allowed by when "
675676
"-cl-uniform-work-group-size flag is used. Underlying "
676677
"OpenCL 2.x implementation supports this feature, but it is "
@@ -720,7 +721,8 @@ int main() {
720721
}
721722
} catch (nd_range_error &E) {
722723
if (string_class(E.what()).find(
723-
"Global_work_size not evenly divisible by local_work_size. "
724+
"Global work size {16, 33, 100} is not evenly divisible by "
725+
"local work-group size {5, 3, 2}. "
724726
"Non-uniform work-groups are not allowed by when "
725727
"-cl-uniform-work-group-size flag is used. Underlying "
726728
"OpenCL 2.x implementation supports this feature, but it is "
@@ -773,7 +775,8 @@ int main() {
773775
}
774776
} catch (nd_range_error &E) {
775777
if (string_class(E.what()).find(
776-
"Local workgroup size greater than global range size. "
778+
"Local work-group size {17, 1, 1} is greater than global range "
779+
"size {16, 1, 1}. "
777780
"Non-uniform work-groups are not allowed by when "
778781
"-cl-uniform-work-group-size flag is used. Underlying "
779782
"OpenCL 2.x implementation supports this feature, but it is "
@@ -824,7 +827,8 @@ int main() {
824827
}
825828
} catch (nd_range_error &E) {
826829
if (string_class(E.what()).find(
827-
"Local workgroup size greater than global range size. "
830+
"Local work-group size {7, 2, 2} is greater than global range "
831+
"size {6, 6, 6}. "
828832
"Non-uniform work-groups are not allowed by when "
829833
"-cl-uniform-work-group-size flag is used. Underlying "
830834
"OpenCL 2.x implementation supports this feature, but it is "

sycl/test/on-device/basic_tests/reqd_work_group_size.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ int main() {
9999
return 1; // We shouldn't be here, exception is expected
100100
} catch (nd_range_error &E) {
101101
if (string_class(E.what()).find(
102-
"Specified local size doesn't match the required work-group size "
103-
"specified in the program source") == string_class::npos) {
102+
"The specified local size {8, 8, 8} doesn't match the required "
103+
"work-group size specified in the program source {4, 4, 4}") ==
104+
string_class::npos) {
104105
std::cerr
105106
<< "Test case ReqdWGSizeNegativeA failed: unexpected nd_range_error "
106107
"exception: "

0 commit comments

Comments
 (0)