From ff11594593295e7c8f0272d2bd27e8b9c9bb95ad Mon Sep 17 00:00:00 2001 From: Vyacheslav N Klochkov Date: Thu, 3 Dec 2020 15:39:18 -0800 Subject: [PATCH 1/4] [SYCL] Make the nd_range error message a bit more informative Signed-off-by: Vyacheslav N Klochkov --- .../detail/error_handling/enqueue_kernel.cpp | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/sycl/source/detail/error_handling/enqueue_kernel.cpp b/sycl/source/detail/error_handling/enqueue_kernel.cpp index ab846466161ca..f35d73db85b2d 100644 --- a/sycl/source/detail/error_handling/enqueue_kernel.cpp +++ b/sycl/source/detail/error_handling/enqueue_kernel.cpp @@ -83,8 +83,15 @@ 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) { @@ -185,11 +192,21 @@ 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( From aed7e1b619fbe1c4555dc3ce1a9a651fada54a92 Mon Sep 17 00:00:00 2001 From: Vyacheslav N Klochkov Date: Thu, 3 Dec 2020 15:44:02 -0800 Subject: [PATCH 2/4] Fix clang-format --- .../detail/error_handling/enqueue_kernel.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sycl/source/detail/error_handling/enqueue_kernel.cpp b/sycl/source/detail/error_handling/enqueue_kernel.cpp index f35d73db85b2d..b5df4a8d77425 100644 --- a/sycl/source/detail/error_handling/enqueue_kernel.cpp +++ b/sycl/source/detail/error_handling/enqueue_kernel.cpp @@ -83,9 +83,8 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, NDRDesc.LocalSize[1] != CompileWGSize[1] || NDRDesc.LocalSize[2] != CompileWGSize[2]) throw sycl::nd_range_error( - "The specified local size {" + - std::to_string(NDRDesc.LocalSize[0]) + ", " + - std::to_string(NDRDesc.LocalSize[1]) + ", " + + "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 {" + @@ -192,10 +191,10 @@ 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 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]) + ", " + @@ -203,10 +202,11 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, std::string message = LocalExceedsGlobal ? "Local workgroup size {" + LocalWGSize + - "} is greater than global range size {" + GlobalWGSize + "}" + "} is greater than global range size {" + GlobalWGSize + + "}" : "Global work size {" + GlobalWGSize + - "} is not evenly divisible by localgroup size {" + - LocalWGSize + "}"; + "} is not evenly divisible by localgroup size {" + + LocalWGSize + "}"; if (!HasStd20) throw sycl::nd_range_error( message.append( From e05a86f5e1e37c41bc9d4783d537c51e8a614ba9 Mon Sep 17 00:00:00 2001 From: Vyacheslav N Klochkov Date: Fri, 4 Dec 2020 10:51:04 -0800 Subject: [PATCH 3/4] Updated a LIT test, updated the output message per reviewer's comment --- sycl/source/detail/error_handling/enqueue_kernel.cpp | 4 ++-- sycl/test/on-device/basic_tests/reqd_work_group_size.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sycl/source/detail/error_handling/enqueue_kernel.cpp b/sycl/source/detail/error_handling/enqueue_kernel.cpp index b5df4a8d77425..9bf28938ac95d 100644 --- a/sycl/source/detail/error_handling/enqueue_kernel.cpp +++ b/sycl/source/detail/error_handling/enqueue_kernel.cpp @@ -201,11 +201,11 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, std::to_string(NDRDesc.GlobalSize[2]); std::string message = LocalExceedsGlobal - ? "Local workgroup size {" + LocalWGSize + + ? "Local work-group size {" + LocalWGSize + "} is greater than global range size {" + GlobalWGSize + "}" : "Global work size {" + GlobalWGSize + - "} is not evenly divisible by localgroup size {" + + "} is not evenly divisible by local work-group size {" + LocalWGSize + "}"; if (!HasStd20) throw sycl::nd_range_error( diff --git a/sycl/test/on-device/basic_tests/reqd_work_group_size.cpp b/sycl/test/on-device/basic_tests/reqd_work_group_size.cpp index a447b2f078c9e..b904fe2ba616c 100644 --- a/sycl/test/on-device/basic_tests/reqd_work_group_size.cpp +++ b/sycl/test/on-device/basic_tests/reqd_work_group_size.cpp @@ -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: " From 5f45c708679846e52b2c0dc50a2d90a33fda57f9 Mon Sep 17 00:00:00 2001 From: Vyacheslav N Klochkov Date: Fri, 4 Dec 2020 16:49:20 -0800 Subject: [PATCH 4/4] Updated the expected diagnostics in one more LIT test - parallel_for_range.cpp --- .../detail/error_handling/enqueue_kernel.cpp | 4 ++-- .../basic_tests/parallel_for_range.cpp | 20 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sycl/source/detail/error_handling/enqueue_kernel.cpp b/sycl/source/detail/error_handling/enqueue_kernel.cpp index 9bf28938ac95d..a0fddcae908e0 100644 --- a/sycl/source/detail/error_handling/enqueue_kernel.cpp +++ b/sycl/source/detail/error_handling/enqueue_kernel.cpp @@ -203,10 +203,10 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, LocalExceedsGlobal ? "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 + "}"; + LocalWGSize + "}. "; if (!HasStd20) throw sycl::nd_range_error( message.append( diff --git a/sycl/test/on-device/basic_tests/parallel_for_range.cpp b/sycl/test/on-device/basic_tests/parallel_for_range.cpp index c03c30ba28f2c..eee2e2ddf61a5 100644 --- a/sycl/test/on-device/basic_tests/parallel_for_range.cpp +++ b/sycl/test/on-device/basic_tests/parallel_for_range.cpp @@ -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; @@ -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 " @@ -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 " @@ -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 " @@ -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 "