Skip to content

[SYCL][NFC] Make the nd_range error message a bit more informative #2860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions sycl/source/detail/error_handling/enqueue_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,14 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
NDRDesc.LocalSize[1] != CompileWGSize[1] ||
NDRDesc.LocalSize[2] != CompileWGSize[2])
throw sycl::nd_range_error(
"Specified local size doesn't match the required work-group size "
"specified in the program source",
"The specified local size {" + std::to_string(NDRDesc.LocalSize[0]) +
", " + std::to_string(NDRDesc.LocalSize[1]) + ", " +
std::to_string(NDRDesc.LocalSize[2]) +
"} doesn't match the required work-group size specified "
"in the program source {" +
std::to_string(CompileWGSize[0]) + ", " +
std::to_string(CompileWGSize[1]) + ", " +
std::to_string(CompileWGSize[2]) + "}",
PI_INVALID_WORK_GROUP_SIZE);
}
if (IsOpenCL) {
Expand Down Expand Up @@ -185,11 +191,22 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,
Opts.find("-cl-std=CL2.0") != string_class::npos;
const bool RequiresUniformWGSize =
Opts.find("-cl-uniform-work-group-size") != string_class::npos;
std::string LocalWGSize = std::to_string(NDRDesc.LocalSize[0]) +
", " +
std::to_string(NDRDesc.LocalSize[1]) +
", " + std::to_string(NDRDesc.LocalSize[2]);
std::string GlobalWGSize =
std::to_string(NDRDesc.GlobalSize[0]) + ", " +
std::to_string(NDRDesc.GlobalSize[1]) + ", " +
std::to_string(NDRDesc.GlobalSize[2]);
std::string message =
LocalExceedsGlobal
? "Local workgroup size greater than global range size. "
: "Global_work_size not evenly divisible by "
"local_work_size. ";
? "Local work-group size {" + LocalWGSize +
"} is greater than global range size {" + GlobalWGSize +
"}. "
: "Global work size {" + GlobalWGSize +
"} is not evenly divisible by local work-group size {" +
LocalWGSize + "}. ";
if (!HasStd20)
throw sycl::nd_range_error(
message.append(
Expand Down
20 changes: 12 additions & 8 deletions sycl/test/on-device/basic_tests/parallel_for_range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ int main() {
"thrown\n";
return 1; // We shouldn't be here, exception is expected
} catch (nd_range_error &E) {
if (string_class(E.what()).find("Specified local size doesn't match "
"the required work-group size "
"specified in the program source") ==
string_class::npos) {
if (string_class(E.what()).find("The specified local size {8, 8, 8} "
"doesn't match the required work-group "
"size specified in the program source "
"{4, 4, 4}") == string_class::npos) {
std::cerr
<< "Test case ReqdWGSizeNegativeA failed: unexpected exception: "
<< E.what() << std::endl;
Expand Down Expand Up @@ -670,7 +670,8 @@ int main() {
}
} catch (nd_range_error &E) {
if (string_class(E.what()).find(
"Global_work_size not evenly divisible by local_work_size. "
"Global work size {100, 1, 1} is not evenly divisible "
"by local work-group size {3, 1, 1}. "
"Non-uniform work-groups are not allowed by when "
"-cl-uniform-work-group-size flag is used. Underlying "
"OpenCL 2.x implementation supports this feature, but it is "
Expand Down Expand Up @@ -720,7 +721,8 @@ int main() {
}
} catch (nd_range_error &E) {
if (string_class(E.what()).find(
"Global_work_size not evenly divisible by local_work_size. "
"Global work size {16, 33, 100} is not evenly divisible by "
"local work-group size {5, 3, 2}. "
"Non-uniform work-groups are not allowed by when "
"-cl-uniform-work-group-size flag is used. Underlying "
"OpenCL 2.x implementation supports this feature, but it is "
Expand Down Expand Up @@ -773,7 +775,8 @@ int main() {
}
} catch (nd_range_error &E) {
if (string_class(E.what()).find(
"Local workgroup size greater than global range size. "
"Local work-group size {17, 1, 1} is greater than global range "
"size {16, 1, 1}. "
"Non-uniform work-groups are not allowed by when "
"-cl-uniform-work-group-size flag is used. Underlying "
"OpenCL 2.x implementation supports this feature, but it is "
Expand Down Expand Up @@ -824,7 +827,8 @@ int main() {
}
} catch (nd_range_error &E) {
if (string_class(E.what()).find(
"Local workgroup size greater than global range size. "
"Local work-group size {7, 2, 2} is greater than global range "
"size {6, 6, 6}. "
"Non-uniform work-groups are not allowed by when "
"-cl-uniform-work-group-size flag is used. Underlying "
"OpenCL 2.x implementation supports this feature, but it is "
Expand Down
5 changes: 3 additions & 2 deletions sycl/test/on-device/basic_tests/reqd_work_group_size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ int main() {
return 1; // We shouldn't be here, exception is expected
} catch (nd_range_error &E) {
if (string_class(E.what()).find(
"Specified local size doesn't match the required work-group size "
"specified in the program source") == string_class::npos) {
"The specified local size {8, 8, 8} doesn't match the required "
"work-group size specified in the program source {4, 4, 4}") ==
string_class::npos) {
std::cerr
<< "Test case ReqdWGSizeNegativeA failed: unexpected nd_range_error "
"exception: "
Expand Down