From ff51f17df321e568d213719150489738f8d0d86c Mon Sep 17 00:00:00 2001 From: Eugene T Damiba Date: Tue, 29 Sep 2020 11:23:48 -0700 Subject: [PATCH 1/6] [SYCL] Added error handling for non-uniform work group size case Signed-off-by: Eugene T Damiba --- sycl/plugins/level_zero/pi_level_zero.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 65d3a29fcba06..87aa764488ff8 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -2953,11 +2953,20 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, zePrint("piEnqueueKernelLaunch: unsupported work_dim\n"); return PI_INVALID_VALUE; } - - assert(GlobalWorkSize[0] == (ZeThreadGroupDimensions.groupCountX * WG[0])); - assert(GlobalWorkSize[1] == (ZeThreadGroupDimensions.groupCountY * WG[1])); - assert(GlobalWorkSize[2] == (ZeThreadGroupDimensions.groupCountZ * WG[2])); - + + if(GlobalWorkSize[0] != (ZeThreadGroupDimensions.groupCountX * WG[0])) { + zePrint("piEnqueueKernelLaunch: invalid work_dim\n"); + return PI_INVALID_WORK_GROUP_SIZE; + } + if(GlobalWorkSize[1] != (ZeThreadGroupDimensions.groupCountY * WG[1])) { + zePrint("piEnqueueKernelLaunch: invalid work_dim\n"); + return PI_INVALID_WORK_GROUP_SIZE; + } + if(GlobalWorkSize[2] != (ZeThreadGroupDimensions.groupCountZ * WG[2])) { + zePrint("piEnqueueKernelLaunch: invalid work_dim\n"); + return PI_INVALID_WORK_GROUP_SIZE; + } + ZE_CALL(zeKernelSetGroupSize(Kernel->ZeKernel, WG[0], WG[1], WG[2])); // Get a new command list to be used on this call From 1ff860af4d30beebd706b95bd0953d1561c16f0f Mon Sep 17 00:00:00 2001 From: Eugene T Damiba Date: Wed, 30 Sep 2020 10:33:29 -0700 Subject: [PATCH 2/6] [SYCL] Added explicit error message for non uniform group size error. Signed-off-by: Eugene T Damiba --- sycl/plugins/level_zero/pi_level_zero.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 87aa764488ff8..a3befde736c59 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -2955,15 +2955,15 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, } if(GlobalWorkSize[0] != (ZeThreadGroupDimensions.groupCountX * WG[0])) { - zePrint("piEnqueueKernelLaunch: invalid work_dim\n"); + zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } if(GlobalWorkSize[1] != (ZeThreadGroupDimensions.groupCountY * WG[1])) { - zePrint("piEnqueueKernelLaunch: invalid work_dim\n"); + zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } if(GlobalWorkSize[2] != (ZeThreadGroupDimensions.groupCountZ * WG[2])) { - zePrint("piEnqueueKernelLaunch: invalid work_dim\n"); + zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } From 4e8f0e081fcd975d04178dfc52353aaa3c3da242 Mon Sep 17 00:00:00 2001 From: Eugene T Damiba Date: Wed, 30 Sep 2020 12:59:37 -0700 Subject: [PATCH 3/6] Incorporating code review comments Signed-off-by: Eugene T Damiba --- sycl/plugins/level_zero/pi_level_zero.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index a3befde736c59..ab8aaae12d58c 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -2954,6 +2954,7 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, return PI_INVALID_VALUE; } + // Error handling for non-uniform group size case if(GlobalWorkSize[0] != (ZeThreadGroupDimensions.groupCountX * WG[0])) { zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; From 69e79b615cdc48f8950cd80f8cf762f1f8f82dac Mon Sep 17 00:00:00 2001 From: Eugene T Damiba Date: Wed, 30 Sep 2020 13:41:02 -0700 Subject: [PATCH 4/6] Fixing format. Signed-off-by: Eugene T Damiba --- sycl/plugins/level_zero/pi_level_zero.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index ab8aaae12d58c..cc7df1ea3f89b 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -2953,21 +2953,21 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, zePrint("piEnqueueKernelLaunch: unsupported work_dim\n"); return PI_INVALID_VALUE; } - + // Error handling for non-uniform group size case - if(GlobalWorkSize[0] != (ZeThreadGroupDimensions.groupCountX * WG[0])) { + if (GlobalWorkSize[0] != (ZeThreadGroupDimensions.groupCountX * WG[0])) { zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } - if(GlobalWorkSize[1] != (ZeThreadGroupDimensions.groupCountY * WG[1])) { + if (GlobalWorkSize[1] != (ZeThreadGroupDimensions.groupCountY * WG[1])) { zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } - if(GlobalWorkSize[2] != (ZeThreadGroupDimensions.groupCountZ * WG[2])) { + if (GlobalWorkSize[2] != (ZeThreadGroupDimensions.groupCountZ * WG[2])) { zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } - + ZE_CALL(zeKernelSetGroupSize(Kernel->ZeKernel, WG[0], WG[1], WG[2])); // Get a new command list to be used on this call From 83d98116be1088717b8ffc2a0d74a9f64741d07c Mon Sep 17 00:00:00 2001 From: Eugene T Damiba Date: Wed, 30 Sep 2020 13:49:53 -0700 Subject: [PATCH 5/6] Fixing format. Signed-off-by: Eugene T Damiba --- sycl/plugins/level_zero/pi_level_zero.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index cc7df1ea3f89b..0a34bb205bae0 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -2956,15 +2956,18 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, // Error handling for non-uniform group size case if (GlobalWorkSize[0] != (ZeThreadGroupDimensions.groupCountX * WG[0])) { - zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); + zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a " + "multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize[1] != (ZeThreadGroupDimensions.groupCountY * WG[1])) { - zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); + zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a " + "multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize[2] != (ZeThreadGroupDimensions.groupCountZ * WG[2])) { - zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a multiple of the group size in the 3rd dimension\n"); + zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a " + "multiple of the group size in the 3rd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } From 02cc3d1e7e30acccf8efdac92ca44068d0c55a9b Mon Sep 17 00:00:00 2001 From: Eugene T Damiba Date: Thu, 1 Oct 2020 07:47:13 -0700 Subject: [PATCH 6/6] Incorporating latest code review comments Signed-off-by: Eugene T Damiba --- sycl/plugins/level_zero/pi_level_zero.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 0a34bb205bae0..bb545d40dcd51 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -2957,12 +2957,12 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, // Error handling for non-uniform group size case if (GlobalWorkSize[0] != (ZeThreadGroupDimensions.groupCountX * WG[0])) { zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a " - "multiple of the group size in the 3rd dimension\n"); + "multiple of the group size in the 1st dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize[1] != (ZeThreadGroupDimensions.groupCountY * WG[1])) { zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a " - "multiple of the group size in the 3rd dimension\n"); + "multiple of the group size in the 2nd dimension\n"); return PI_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize[2] != (ZeThreadGroupDimensions.groupCountZ * WG[2])) {