From 1a17853e7574e0b36f99798771dfe2c62bb83404 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:50:20 +0100 Subject: [PATCH] Command buffer testing fixes (#2081) Signed-off-by: Gorazd Sumkovski --- .../negative_command_buffer_copy.cpp | 28 +++++++++++++------ .../negative_command_buffer_copy_image.cpp | 9 +++++- .../negative_command_buffer_get_info.cpp | 24 +++++++++------- .../negative_command_nd_range_kernel.cpp | 16 +++++------ 4 files changed, 50 insertions(+), 27 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp index 20087b93..541ab516 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp @@ -40,7 +40,7 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest if (check_image_support) { - image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, + image = create_image_2d(context, CL_MEM_READ_WRITE, &format, img_width, img_height, 0, NULL, &error); test_error(error, "create_image_2d failed"); @@ -72,19 +72,31 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest return BasicCommandBufferTest::Skip() || command_buffer_multi_device; } +private: + static constexpr size_t num_channels = 4; + protected: - const size_t img_width = 512; - const size_t img_height = 512; - const size_t origin[3] = { 0, 0, 0 }; - const size_t region[3] = { img_width, img_height, 1 }; - const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + static constexpr size_t img_width = 512; + static constexpr size_t img_height = 512; + static constexpr size_t origin[3] = { 0, 0, 0 }; + static constexpr size_t region[3] = { img_width, img_height, 1 }; + static constexpr cl_image_format format = { CL_RGBA, CL_UNSIGNED_INT8 }; + static constexpr size_t data_size = + img_width * img_height * num_channels * sizeof(uint8_t); clMemWrapper image; clMemWrapper buffer; - const size_t data_size = img_width * img_height * sizeof(cl_char); clMemWrapper in_mem; clMemWrapper out_mem; }; +template +constexpr size_t CommandBufferCopyBaseTest::origin[3]; +template +constexpr size_t CommandBufferCopyBaseTest::region[3]; +template +constexpr cl_image_format + CommandBufferCopyBaseTest::format; + namespace { // CL_INVALID_COMMAND_QUEUE if command_queue is not NULL. @@ -226,7 +238,7 @@ struct CommandBufferCopyImageDifferentContexts context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); test_error(error, "Failed to create context"); - image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &formats, + image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &format, img_width, img_height, 0, NULL, &error); test_error(error, "create_image_2d failed"); diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy_image.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy_image.cpp index a6e5af2c..5103669e 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy_image.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy_image.cpp @@ -143,7 +143,7 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, nullptr, src_image, dst_image_ctx, origin, + command_buffer, nullptr, nullptr, src_image, out_mem_ctx, origin, region, 0, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_CONTEXT, @@ -192,6 +192,12 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest elements / 64, 64, 0, NULL, &error); test_error(error, "create_image_2d failed"); + out_mem_ctx = clCreateBuffer(context1, CL_MEM_WRITE_ONLY, + sizeof(cl_int) * num_elements + * buffer_size_multiplier, + nullptr, &error); + test_error(error, "clCreateBuffer failed"); + queue1 = clCreateCommandQueue(context1, device, 0, &error); test_error(error, "clCreateCommandQueue failed"); @@ -202,6 +208,7 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest clCommandQueueWrapper queue1; clMemWrapper src_image_ctx; clMemWrapper dst_image_ctx; + clMemWrapper out_mem_ctx; }; // CL_INVALID_SYNC_POINT_WAIT_LIST_KHR if sync_point_wait_list is NULL and diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_get_info.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_get_info.cpp index 1932ef54..e00ca293 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_get_info.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_get_info.cpp @@ -218,18 +218,22 @@ struct GetCommandBufferInfo : public BasicCommandBufferTest cl_int RunPropArrayInfoTest() { - std::vector properties; - properties.resize(number_of_properties); + if (0 != number_of_properties) + { + std::vector properties; + properties.resize(number_of_properties); - cl_int error = clGetCommandBufferInfoKHR( - command_buffer, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, - number_of_properties * sizeof(cl_command_buffer_properties_khr) - 1, - properties.data(), nullptr); + cl_int error = clGetCommandBufferInfoKHR( + command_buffer, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, + number_of_properties * sizeof(cl_command_buffer_properties_khr) + - 1, + properties.data(), nullptr); - test_failure_error_ret(error, CL_INVALID_VALUE, - "clGetCommandBufferInfoKHR should return " - "CL_INVALID_VALUE", - TEST_FAIL); + test_failure_error_ret(error, CL_INVALID_VALUE, + "clGetCommandBufferInfoKHR should return " + "CL_INVALID_VALUE", + TEST_FAIL); + } return TEST_PASS; } diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp index 2d532771..05774bc0 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp @@ -298,10 +298,10 @@ __kernel void printf_kernel() { } )"; - error = build_program_create_kernel_helper(context, &program, &kernel, - 1, &kernel_str, - "printf_kernel", nullptr); - test_error(error, "build_program_create_kernel_helper failed"); + error = + create_single_kernel_helper(context, &program, &kernel, 1, + &kernel_str, "printf_kernel", nullptr); + test_error(error, "create_single_kernel_helper failed"); return CL_SUCCESS; } @@ -407,10 +407,10 @@ enqueue_kernel(def_q, CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange, )"; std::string build_options = std::string(" ") + cl_std; - error = build_program_create_kernel_helper( - context, &program, &kernel, 1, &kernel_str, "enqueue_call_kernel", - build_options.c_str()); - test_error(error, "build_program_create_kernel_helper failed"); + error = create_single_kernel_helper(context, &program, &kernel, 1, + &kernel_str, "enqueue_call_kernel", + build_options.c_str()); + test_error(error, "create_single_kernel_helper failed"); return CL_SUCCESS; }