From 6a2c0b1cffe3a8f97b170c11f8263c962c91f276 Mon Sep 17 00:00:00 2001 From: gorazd-sumkovski-arm <161028652+gorazd-sumkovski-arm@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:51:46 +0100 Subject: [PATCH] Fix bug in `mutable_command_full_dispatch` (#2082) This test did not pass the `-cl-std=` flag when building the program. As a result, for an OpenCL 3.0 device, the program will be "compiled using the highest OpenCL C 1.x language version supported" by the device. However this will force uniform work-group sizes which leads to a `CL_INVALID_WORK_GROUP_SIZE` error. To fix this, use the `create_single_kernel_helper()` helper function which will automatically get the device version and pass that to `-cl-std=` when building the program. --------- Signed-off-by: Gorazd Sumkovski --- .../mutable_command_full_dispatch.cpp | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_full_dispatch.cpp b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_full_dispatch.cpp index fb1f24f4..ebf30a00 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_full_dispatch.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_full_dispatch.cpp @@ -100,22 +100,18 @@ struct MutableCommandFullDispatch : InfoMutableCommandBufferTest if ((available_caps & CL_MUTABLE_DISPATCH_EXEC_INFO_KHR) == 0) { - error = create_single_kernel_helper_create_program( - context, &program, 1, &kernel_str_no_svm); + error = create_single_kernel_helper(context, &program, &kernel, 1, + &kernel_str_no_svm, + "full_dispatch"); } else { - error = create_single_kernel_helper_create_program( - context, &program, 1, &kernel_str_svm); + error = + create_single_kernel_helper(context, &program, &kernel, 1, + &kernel_str_svm, "full_dispatch"); } test_error(error, "Failed to create program with source"); - error = clBuildProgram(program, 1, &device, nullptr, nullptr, nullptr); - test_error(error, "Failed to build program"); - - kernel = clCreateKernel(program, "full_dispatch", &error); - test_error(error, "Failed to create copy kernel"); - return CL_SUCCESS; } @@ -303,6 +299,11 @@ struct MutableCommandFullDispatch : InfoMutableCommandBufferTest }; size_t work_offset = 0; + /* Round the global work size up to nearest multiple of the local work + * size to ensure work group uniformity. */ + num_elements = + ((num_elements + group_size - 1) / group_size) * group_size; + cl_int error = clCommandNDRangeKernelKHR( command_buffer, nullptr, props, kernel, 1, &work_offset, &num_elements, &group_size, 0, nullptr, nullptr, &command); @@ -384,18 +385,23 @@ struct MutableCommandFullDispatch : InfoMutableCommandBufferTest dispatch_config.global_work_offset = &work_offset; } - if ((available_caps & CL_MUTABLE_DISPATCH_GLOBAL_SIZE_KHR) != 0) - { - num_elements /= 2; - dispatch_config.global_work_size = &num_elements; - } - if ((available_caps & CL_MUTABLE_DISPATCH_LOCAL_SIZE_KHR) != 0) { group_size /= 2; dispatch_config.local_work_size = &group_size; } + if ((available_caps & CL_MUTABLE_DISPATCH_GLOBAL_SIZE_KHR) != 0) + { + num_elements /= 2; + /* Round the global work size up to nearest multiple of the local + * work size to ensure work group uniformity. */ + num_elements = + ((num_elements + group_size - 1) / group_size) * group_size; + + dispatch_config.global_work_size = &num_elements; + } + cl_uint num_configs = 1; cl_command_buffer_update_type_khr config_types[1] = { CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR