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
Changes from 2 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 workgroup size {" + LocalWGSize +
"} is greater than global range size {" + GlobalWGSize +
"}"
: "Global work size {" + GlobalWGSize +
"} is not evenly divisible by localgroup size {" +
LocalWGSize + "}";
if (!HasStd20)
throw sycl::nd_range_error(
message.append(
Expand Down