From 42773225950c825af44ae0aa44501d9e112f3f16 Mon Sep 17 00:00:00 2001 From: Michal Babej Date: Wed, 22 May 2024 18:03:55 +0300 Subject: [PATCH 1/2] fix bugs in negative command_buffer tests - CL_INVALID_VALUE from command_queue != NULL should only be returned if the device doesn't support cl_khr_command_buffer_multi_device - some tests enqueued commands with multiple invalid arguments, e.g. clCommandCopyImageToBufferKHR with two images and invalid sync points. AFAIK the order of argument checking is not defined, so multiple errors can be returned for such API calls, but the tests assumed only one error. Fix the tests to be unambiguous. --- .../negative_command_buffer_barrier.cpp | 6 +++ .../negative_command_buffer_copy_image.cpp | 41 +++++++++++-------- .../negative_command_buffer_svm_mem.cpp | 6 +++ .../negative_command_nd_range_kernel.cpp | 10 ++++- 4 files changed, 43 insertions(+), 20 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_barrier.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_barrier.cpp index 14f828cd5d..41e5e14ece 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_barrier.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_barrier.cpp @@ -37,6 +37,12 @@ struct CommandBufferBarrierNotNullQueue : public BasicCommandBufferTest return CL_SUCCESS; } + + bool Skip() override + { + return is_extension_available(device, + "cl_khr_command_buffer_multi_device"); + } }; // CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid 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 843c0d54e1..80bb3b0245 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 @@ -28,15 +28,20 @@ struct CommandCopyBaseTest : BasicCommandBufferTest cl_int SetUp(int elements) override { + num_elements = elements; + origin[0] = origin[1] = origin[2] = 0; + region[0] = elements / 64; + region[1] = 64; + region[2] = 1; cl_int error = BasicCommandBufferTest::SetUp(elements); test_error(error, "BasicCommandBufferTest::SetUp failed"); - src_image = create_image_2d(context, CL_MEM_READ_ONLY, &formats, 512, - 512, 0, NULL, &error); + src_image = create_image_2d(context, CL_MEM_READ_ONLY, &formats, + elements / 64, 64, 0, NULL, &error); test_error(error, "create_image_2d failed"); - dst_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats, 512, - 512, 0, NULL, &error); + dst_image = create_image_2d(context, CL_MEM_WRITE_ONLY, &formats, + elements / 64, 64, 0, NULL, &error); test_error(error, "create_image_2d failed"); return CL_SUCCESS; @@ -58,8 +63,8 @@ struct CommandCopyBaseTest : BasicCommandBufferTest clMemWrapper src_image; clMemWrapper dst_image; const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; - const size_t origin[3] = { 0, 0, 0 }; - const size_t region[3] = { 512, 512, 1 }; + size_t origin[3]; + size_t region[3]; }; namespace { @@ -81,7 +86,7 @@ struct CommandBufferCopyImageQueueNotNull : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR(command_buffer, queue, src_image, - dst_image, origin, region, 0, 0, + out_mem, origin, region, 0, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_COMMAND_QUEUE, @@ -119,8 +124,8 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, src_image_ctx, dst_image, origin, region, - 0, 0, nullptr, nullptr, nullptr); + command_buffer, nullptr, src_image_ctx, out_mem, origin, region, 0, + 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_CONTEXT, "clCommandCopyImageToBufferKHR should return " @@ -159,7 +164,7 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, src_image, dst_image, origin, region, 0, 0, + command_buffer, nullptr, src_image, out_mem, origin, region, 0, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_CONTEXT, @@ -179,11 +184,11 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest test_error(error, "Failed to create context"); src_image_ctx = create_image_2d(context1, CL_MEM_READ_ONLY, &formats, - 512, 512, 0, NULL, &error); + elements / 64, 64, 0, NULL, &error); test_error(error, "create_image_2d failed"); dst_image_ctx = create_image_2d(context1, CL_MEM_WRITE_ONLY, &formats, - 512, 512, 0, NULL, &error); + elements / 64, 64, 0, NULL, &error); test_error(error, "create_image_2d failed"); queue1 = clCreateCommandQueue(context1, device, 0, &error); @@ -220,7 +225,7 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, src_image, dst_image, origin, region, 0, 1, + command_buffer, nullptr, src_image, out_mem, origin, region, 0, 1, &invalid_point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, @@ -239,7 +244,7 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, src_image, dst_image, origin, region, 0, 1, + command_buffer, nullptr, src_image, out_mem, origin, region, 0, 1, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, @@ -263,7 +268,7 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, src_image, dst_image, origin, region, 0, 0, + command_buffer, nullptr, src_image, out_mem, origin, region, 0, 0, &point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, @@ -294,7 +299,7 @@ struct CommandBufferCopyImageInvalidCommandBuffer : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR(nullptr, nullptr, src_image, - dst_image, origin, region, 0, 0, + out_mem, origin, region, 0, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_COMMAND_BUFFER_KHR, @@ -327,7 +332,7 @@ struct CommandBufferCopyImageFinalizedCommandBuffer : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, src_image, dst_image, origin, region, 0, 0, + command_buffer, nullptr, src_image, out_mem, origin, region, 0, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_OPERATION, @@ -358,7 +363,7 @@ struct CommandBufferCopyImageMutableHandleNotNull : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, src_image, dst_image, origin, region, 0, 0, + command_buffer, nullptr, src_image, out_mem, origin, region, 0, 0, nullptr, nullptr, &mutable_handle); test_failure_error_ret(error, CL_INVALID_VALUE, diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_svm_mem.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_svm_mem.cpp index 4d4e2cfb77..77f4494497 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_svm_mem.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_svm_mem.cpp @@ -50,6 +50,12 @@ struct CommandBufferCommandSVMQueueNotNull : public BasicSVMCommandBufferTest } const cl_char pattern_1 = 0x14; + + bool Skip() override + { + return is_extension_available(device, + "cl_khr_command_buffer_multi_device"); + } }; // 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_nd_range_kernel.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp index e44e38c09c..a4762e3369 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 @@ -38,6 +38,12 @@ struct CommandNDRangeKernelQueueNotNull : public BasicCommandBufferTest return CL_SUCCESS; } + + bool Skip() override + { + return is_extension_available(device, + "cl_khr_command_buffer_multi_device"); + } }; // CL_INVALID_CONTEXT if the context associated with command_queue, @@ -108,7 +114,7 @@ struct CommandNDRangeKerneSyncPointsNullOrNumZero cl_sync_point_khr invalid_point = 0; cl_sync_point_khr* invalid_sync_points[] = { &invalid_point }; cl_int error = clCommandNDRangeKernelKHR( - command_buffer, nullptr, nullptr, kernel, 0, nullptr, &num_elements, + command_buffer, nullptr, nullptr, kernel, 1, nullptr, &num_elements, nullptr, 1, invalid_sync_points[0], nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, @@ -134,7 +140,7 @@ struct CommandNDRangeKerneSyncPointsNullOrNumZero cl_sync_point_khr* sync_points[] = { &point }; error = clCommandNDRangeKernelKHR( - command_buffer, nullptr, nullptr, kernel, 0, nullptr, &num_elements, + command_buffer, nullptr, nullptr, kernel, 1, nullptr, &num_elements, nullptr, 0, sync_points[0], nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, From c82367623edb63b3d75d5873a5f81454eb601bb1 Mon Sep 17 00:00:00 2001 From: Michal Babej Date: Thu, 6 Jun 2024 15:02:23 +0300 Subject: [PATCH 2/2] fix issues found by review --- .../cl_khr_command_buffer/negative_command_buffer_barrier.cpp | 1 + .../cl_khr_command_buffer/negative_command_buffer_svm_mem.cpp | 1 + .../cl_khr_command_buffer/negative_command_nd_range_kernel.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_barrier.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_barrier.cpp index 41e5e14ece..6e682aa381 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_barrier.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_barrier.cpp @@ -40,6 +40,7 @@ struct CommandBufferBarrierNotNullQueue : public BasicCommandBufferTest bool Skip() override { + if (BasicCommandBufferTest::Skip()) return true; return is_extension_available(device, "cl_khr_command_buffer_multi_device"); } diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_svm_mem.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_svm_mem.cpp index 77f4494497..b5d2355b2a 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_svm_mem.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_svm_mem.cpp @@ -53,6 +53,7 @@ struct CommandBufferCommandSVMQueueNotNull : public BasicSVMCommandBufferTest bool Skip() override { + if (BasicSVMCommandBufferTest::Skip()) return true; return is_extension_available(device, "cl_khr_command_buffer_multi_device"); } 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 a4762e3369..ccbefd85f8 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 @@ -41,6 +41,7 @@ struct CommandNDRangeKernelQueueNotNull : public BasicCommandBufferTest bool Skip() override { + if (BasicCommandBufferTest::Skip()) return true; return is_extension_available(device, "cl_khr_command_buffer_multi_device"); }