From 509138cfd23eea794fb593e29c510b6440ce987d Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Fri, 5 Apr 2024 22:49:00 +0200 Subject: [PATCH 01/10] Added negative tests for clCommandCopy*KHR --- .../cl_khr_command_buffer/CMakeLists.txt | 1 + .../extensions/cl_khr_command_buffer/main.cpp | 8 +- .../negative_command_buffer_copy.cpp | 503 ++++++++++++++++++ .../extensions/cl_khr_command_buffer/procs.h | 19 + 4 files changed, 530 insertions(+), 1 deletion(-) create mode 100644 test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp diff --git a/test_conformance/extensions/cl_khr_command_buffer/CMakeLists.txt b/test_conformance/extensions/cl_khr_command_buffer/CMakeLists.txt index 8a4a116a9..0a09378ad 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/CMakeLists.txt +++ b/test_conformance/extensions/cl_khr_command_buffer/CMakeLists.txt @@ -16,6 +16,7 @@ set(${MODULE_NAME}_SOURCES command_buffer_test_barrier.cpp command_buffer_test_event_info.cpp command_buffer_finalize.cpp + negative_command_buffer_copy.cpp ) set_gnulike_module_compile_flags("-Wno-sign-compare") diff --git a/test_conformance/extensions/cl_khr_command_buffer/main.cpp b/test_conformance/extensions/cl_khr_command_buffer/main.cpp index 4ecb08065..733090b5b 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/main.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/main.cpp @@ -63,7 +63,13 @@ test_definition test_list[] = { ADD_TEST(event_info_context), ADD_TEST(event_info_reference_count), ADD_TEST(finalize_invalid), - ADD_TEST(finalize_empty) + ADD_TEST(finalize_empty), + ADD_TEST(negative_command_buffer_copy_queue_not_null), + ADD_TEST(negative_command_buffer_copy_different_contexts), + ADD_TEST(negative_command_buffer_copy_sync_points_null_or_num_zero), + ADD_TEST(negative_command_buffer_copy_invalid_command_buffer), + ADD_TEST(negative_command_buffer_copy_finalized_command_buffer), + ADD_TEST(negative_command_buffer_copy_mutable_handle_not_null), }; int main(int argc, const char *argv[]) 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 new file mode 100644 index 000000000..f68be0b6d --- /dev/null +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp @@ -0,0 +1,503 @@ +// +// Copyright (c) 2024 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "basic_command_buffer.h" +#include "procs.h" +#include + +//-------------------------------------------------------------------------- +namespace { + +// CL_INVALID_COMMAND_QUEUE if command_queue is not NULL. +struct CommandBufferCopyQueueNotNull : public BasicCommandBufferTest +{ + using BasicCommandBufferTest::BasicCommandBufferTest; + + cl_int Run() override + { + cl_int error = + clCommandCopyBufferKHR(command_buffer, queue, in_mem, out_mem, 0, 0, + data_size(), 0, nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_COMMAND_QUEUE, + "clCommandCopyBufferKHR should return " + "CL_INVALID_COMMAND_QUEUE", + TEST_FAIL); + + const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; + + error = clCommandCopyBufferRectKHR( + command_buffer, queue, in_mem, out_mem, origin, origin, region, 0, + 0, 0, 0, 0, nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_COMMAND_QUEUE, + "clCommandCopyBufferRectKHR should return " + "CL_INVALID_COMMAND_QUEUE", + TEST_FAIL); + + const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + clMemWrapper image = create_image_2d( + context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); + test_error(error, "create_image_2d failed"); + clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, + data_size(), nullptr, &error); + test_error(error, "Unable to create buffer"); + + error = clCommandCopyImageToBufferKHR(command_buffer, queue, image, + buffer, origin, region, 0, 0, + nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_COMMAND_QUEUE, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_COMMAND_QUEUE", + TEST_FAIL); + + return CL_SUCCESS; + } +}; + +// CL_INVALID_CONTEXT if the context associated with command_queue, +// command_buffer, src_buffer, and dst_buffer are not the same. +struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest +{ + CommandBufferCopyDifferentContexts(cl_device_id device, cl_context context, + cl_command_queue queue) + : BasicCommandBufferTest(device, context, queue), in_mem_ctx(nullptr), + out_mem_ctx(nullptr), image_ctx(nullptr), buffer_ctx(nullptr), + image(nullptr), buffer(nullptr), context1(nullptr) + {} + + cl_int SetUp(int elements) override + { + cl_int error = BasicCommandBufferTest::SetUp(elements); + test_error(error, "BasicCommandBufferTest::SetUp failed"); + + context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); + test_error(error, "Failed to create context"); + + in_mem_ctx = + clCreateBuffer(context1, CL_MEM_READ_ONLY, + sizeof(cl_int) * num_elements, nullptr, &error); + test_error(error, "clCreateBuffer failed"); + + out_mem_ctx = + clCreateBuffer(context1, CL_MEM_WRITE_ONLY, + sizeof(cl_int) * num_elements, nullptr, &error); + test_error(error, "clCreateBuffer failed"); + + const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &formats, 512, + 512, 0, NULL, &error); + + test_error(error, "create_image_2d failed"); + buffer_ctx = clCreateBuffer(context1, CL_MEM_READ_WRITE, data_size(), + nullptr, &error); + test_error(error, "Unable to create buffer"); + + image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, 512, 512, + 0, NULL, &error); + + test_error(error, "create_image_2d failed"); + buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, data_size(), + nullptr, &error); + test_error(error, "Unable to create buffer"); + + return CL_SUCCESS; + } + + cl_int Run() override + { + cl_int error = clCommandCopyBufferKHR( + command_buffer, nullptr, in_mem_ctx, out_mem, 0, 0, data_size(), 0, + nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_CONTEXT, + "clCommandCopyBufferKHR should return " + "CL_INVALID_CONTEXT", + TEST_FAIL); + + const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; + + error = clCommandCopyBufferRectKHR( + command_buffer, nullptr, in_mem_ctx, out_mem, origin, origin, + region, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_CONTEXT, + "clCommandCopyBufferRectKHR should return " + "CL_INVALID_CONTEXT", + TEST_FAIL); + + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, + image_ctx, buffer, origin, region, + 0, 0, nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_CONTEXT, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_CONTEXT", + TEST_FAIL); + + error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, + out_mem_ctx, 0, 0, data_size(), 0, + nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_CONTEXT, + "clCommandCopyBufferKHR should return " + "CL_INVALID_CONTEXT", + TEST_FAIL); + + error = clCommandCopyBufferRectKHR( + command_buffer, nullptr, in_mem, out_mem_ctx, origin, origin, + region, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_CONTEXT, + "clCommandCopyBufferRectKHR should return " + "CL_INVALID_CONTEXT", + TEST_FAIL); + + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, + buffer_ctx, origin, region, 0, 0, + nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_CONTEXT, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_CONTEXT", + TEST_FAIL); + + + return CL_SUCCESS; + } + clMemWrapper in_mem_ctx; + clMemWrapper out_mem_ctx; + clMemWrapper image_ctx; + clMemWrapper buffer_ctx; + clMemWrapper image; + clMemWrapper buffer; + clContextWrapper context1; +}; + +// CL_INVALID_SYNC_POINT_WAIT_LIST_KHR if sync_point_wait_list is NULL and +// num_sync_points_in_wait_list is > 0, +// or sync_point_wait_list is not NULL and num_sync_points_in_wait_list is 0, +// or if synchronization-point objects in sync_point_wait_list are not valid +// synchronization-points. +struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest +{ + using BasicCommandBufferTest::BasicCommandBufferTest; + + cl_int Run() override + { + cl_int error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, + out_mem, 0, 0, data_size(), 1, + nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyBufferKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; + + error = clCommandCopyBufferRectKHR( + command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, + 0, 0, 0, 1, nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyBufferRectKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + clMemWrapper image = create_image_2d( + context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); + test_error(error, "create_image_2d failed"); + clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, + data_size(), nullptr, &error); + test_error(error, "Unable to create buffer"); + + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, + buffer, origin, region, 0, 1, + nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + cl_sync_point_khr point = 1; + std::vector sync_points; + sync_points.push_back(point); + + error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, + 0, 0, data_size(), 0, sync_points.data(), + nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyBufferKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + error = clCommandCopyBufferRectKHR( + command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, + 0, 0, 0, 0, sync_points.data(), nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyBufferRectKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + error = clCommandCopyImageToBufferKHR( + command_buffer, nullptr, image, buffer, origin, region, 0, 0, + sync_points.data(), nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + cl_sync_point_khr* invalid_point = nullptr; + std::vector invalid_sync_points; + invalid_sync_points.push_back(invalid_point); + + error = clCommandCopyBufferKHR( + command_buffer, nullptr, in_mem, out_mem, 0, 0, data_size(), 1, + *invalid_sync_points.data(), nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyBufferKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + error = clCommandCopyBufferRectKHR( + command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, + 0, 0, 0, 1, *invalid_sync_points.data(), nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyBufferRectKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + error = clCommandCopyImageToBufferKHR( + command_buffer, nullptr, image, buffer, origin, region, 0, 1, + *invalid_sync_points.data(), nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + return CL_SUCCESS; + } +}; + +// CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid +// command-buffer. +struct CommandBufferCopyInvalidCommandBuffer : public BasicCommandBufferTest +{ + using BasicCommandBufferTest::BasicCommandBufferTest; + + cl_int Run() override + { + cl_int error = + clCommandCopyBufferKHR(nullptr, nullptr, in_mem, out_mem, 0, 0, + data_size(), 0, nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_COMMAND_BUFFER_KHR, + "clCommandCopyBufferKHR should return " + "CL_INVALID_COMMAND_BUFFER_KHR", + TEST_FAIL); + + const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; + + error = clCommandCopyBufferRectKHR(nullptr, nullptr, in_mem, out_mem, + origin, origin, region, 0, 0, 0, 0, + 0, nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_COMMAND_BUFFER_KHR, + "clCommandCopyBufferRectKHR should return " + "CL_INVALID_COMMAND_BUFFER_KHR", + TEST_FAIL); + + const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + clMemWrapper image = create_image_2d( + context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); + test_error(error, "create_image_2d failed"); + clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, + data_size(), nullptr, &error); + test_error(error, "Unable to create buffer"); + + error = clCommandCopyImageToBufferKHR(nullptr, nullptr, image, buffer, + origin, region, 0, 0, nullptr, + nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_COMMAND_BUFFER_KHR, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_COMMAND_BUFFER_KHR", + TEST_FAIL); + + return CL_SUCCESS; + } +}; + +// CL_INVALID_OPERATION if command_buffer has been finalized. +struct CommandBufferCopyFinalizedCommandBuffer : public BasicCommandBufferTest +{ + using BasicCommandBufferTest::BasicCommandBufferTest; + + cl_int Run() override + { + cl_int error = clFinalizeCommandBufferKHR(command_buffer); + test_error(error, "clFinalizeCommandBufferKHR failed"); + + error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, + 0, 0, data_size(), 0, nullptr, nullptr, + nullptr); + + test_failure_error_ret(error, CL_INVALID_OPERATION, + "clCommandCopyBufferKHR should return " + "CL_INVALID_OPERATION", + TEST_FAIL); + + const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; + + error = clCommandCopyBufferRectKHR( + command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, + 0, 0, 0, 0, nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_OPERATION, + "clCommandCopyBufferRectKHR should return " + "CL_INVALID_OPERATION", + TEST_FAIL); + + const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + clMemWrapper image = create_image_2d( + context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); + test_error(error, "create_image_2d failed"); + clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, + data_size(), nullptr, &error); + test_error(error, "Unable to create buffer"); + + error = clCommandCopyImageToBufferKHR(nullptr, nullptr, image, buffer, + origin, region, 0, 0, nullptr, + nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_OPERATION, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_OPERATION", + TEST_FAIL); + + return CL_SUCCESS; + } +}; + +// CL_INVALID_VALUE if mutable_handle is not NULL. +struct CommandBufferCopyMutableHandleNotNull : public BasicCommandBufferTest +{ + using BasicCommandBufferTest::BasicCommandBufferTest; + + cl_int Run() override + { + cl_mutable_command_khr mutable_handle; + + cl_int error = clCommandCopyBufferKHR( + command_buffer, nullptr, in_mem, out_mem, 0, 0, data_size(), 0, + nullptr, nullptr, &mutable_handle); + + test_failure_error_ret(error, CL_INVALID_VALUE, + "clCommandCopyBufferKHR should return " + "CL_INVALID_VALUE", + TEST_FAIL); + + const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; + + error = clCommandCopyBufferRectKHR( + command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, + 0, 0, 0, 0, nullptr, nullptr, &mutable_handle); + + test_failure_error_ret(error, CL_INVALID_VALUE, + "clCommandCopyBufferRectKHR should return " + "CL_INVALID_VALUE", + TEST_FAIL); + + const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + clMemWrapper image = create_image_2d( + context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); + test_error(error, "create_image_2d failed"); + clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, + data_size(), nullptr, &error); + test_error(error, "Unable to create buffer"); + + error = clCommandCopyImageToBufferKHR( + command_buffer, nullptr, image, buffer, origin, region, 0, 0, + nullptr, nullptr, &mutable_handle); + + test_failure_error_ret(error, CL_INVALID_VALUE, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_VALUE", + TEST_FAIL); + + return CL_SUCCESS; + } +}; +}; + +int test_negative_command_buffer_copy_queue_not_null(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest(device, context, queue, + num_elements); +} + +int test_negative_command_buffer_copy_different_contexts(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_copy_sync_points_null_or_num_zero( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_copy_invalid_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_copy_finalized_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_copy_mutable_handle_not_null( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} diff --git a/test_conformance/extensions/cl_khr_command_buffer/procs.h b/test_conformance/extensions/cl_khr_command_buffer/procs.h index ce121ceac..f15ae8cb8 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/procs.h +++ b/test_conformance/extensions/cl_khr_command_buffer/procs.h @@ -140,5 +140,24 @@ extern int test_finalize_invalid(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); extern int test_finalize_empty(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); +// Command-buffer negative tests +extern int test_negative_command_buffer_copy_queue_not_null( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_negative_command_buffer_copy_different_contexts( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_negative_command_buffer_copy_sync_points_null_or_num_zero( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_negative_command_buffer_copy_invalid_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_negative_command_buffer_copy_finalized_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_negative_command_buffer_copy_mutable_handle_not_null( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); #endif // CL_KHR_COMMAND_BUFFER_PROCS_H From d76c94d22d069bd63e397d1c176cbc5672415492 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Thu, 18 Apr 2024 12:15:20 +0200 Subject: [PATCH 02/10] Removed constructor and added initializers on declaration line --- .../negative_command_buffer_copy.cpp | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 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 f68be0b6d..06ee6e434 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 @@ -72,12 +72,7 @@ struct CommandBufferCopyQueueNotNull : public BasicCommandBufferTest // command_buffer, src_buffer, and dst_buffer are not the same. struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest { - CommandBufferCopyDifferentContexts(cl_device_id device, cl_context context, - cl_command_queue queue) - : BasicCommandBufferTest(device, context, queue), in_mem_ctx(nullptr), - out_mem_ctx(nullptr), image_ctx(nullptr), buffer_ctx(nullptr), - image(nullptr), buffer(nullptr), context1(nullptr) - {} + using BasicCommandBufferTest::BasicCommandBufferTest; cl_int SetUp(int elements) override { @@ -178,13 +173,13 @@ struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest return CL_SUCCESS; } - clMemWrapper in_mem_ctx; - clMemWrapper out_mem_ctx; - clMemWrapper image_ctx; - clMemWrapper buffer_ctx; - clMemWrapper image; - clMemWrapper buffer; - clContextWrapper context1; + clMemWrapper in_mem_ctx = nullptr; + clMemWrapper out_mem_ctx = nullptr; + clMemWrapper image_ctx = nullptr; + clMemWrapper buffer_ctx = nullptr; + clMemWrapper image = nullptr; + clMemWrapper buffer = nullptr; + clContextWrapper context1 = nullptr; }; // CL_INVALID_SYNC_POINT_WAIT_LIST_KHR if sync_point_wait_list is NULL and From a0d973311ff75cb7ba39ed4eb7807a8a4dcf0eb4 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Wed, 8 May 2024 11:28:17 +0200 Subject: [PATCH 03/10] Added minor correction --- .../negative_command_buffer_copy.cpp | 78 ++++++++++--------- 1 file changed, 43 insertions(+), 35 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 06ee6e434..6204518ba 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 @@ -193,81 +193,89 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest cl_int Run() override { - cl_int error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, - out_mem, 0, 0, data_size(), 1, - nullptr, nullptr, nullptr); + cl_int error = CL_SUCCESS; + const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; + const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + clMemWrapper image = create_image_2d( + context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); + test_error(error, "create_image_2d failed"); + clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, + data_size(), nullptr, &error); + test_error(error, "Unable to create buffer"); + + + cl_sync_point_khr invalid_point = 0; + std::vector invalid_sync_points; + invalid_sync_points.push_back(&invalid_point); + + error = clCommandCopyBufferKHR( + command_buffer, nullptr, in_mem, out_mem, 0, 0, data_size(), 1, + *invalid_sync_points.data(), nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferKHR should return " "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); - const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; - error = clCommandCopyBufferRectKHR( command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, - 0, 0, 0, 1, nullptr, nullptr, nullptr); + 0, 0, 0, 1, *invalid_sync_points.data(), nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferRectKHR should return " "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); - const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; - clMemWrapper image = create_image_2d( - context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); - test_error(error, "create_image_2d failed"); - clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, - data_size(), nullptr, &error); - test_error(error, "Unable to create buffer"); - - error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, - buffer, origin, region, 0, 1, - nullptr, nullptr, nullptr); + error = clCommandCopyImageToBufferKHR( + command_buffer, nullptr, image, buffer, origin, region, 0, 1, + *invalid_sync_points.data(), nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyImageToBufferKHR should return " "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); - cl_sync_point_khr point = 1; - std::vector sync_points; - sync_points.push_back(point); error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, - 0, 0, data_size(), 0, sync_points.data(), - nullptr, nullptr); + 0, 0, data_size(), 1, nullptr, nullptr, + nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferKHR should return " "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); + error = clCommandCopyBufferRectKHR( command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, - 0, 0, 0, 0, sync_points.data(), nullptr, nullptr); + 0, 0, 0, 1, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferRectKHR should return " "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); - error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, image, buffer, origin, region, 0, 0, - sync_points.data(), nullptr, nullptr); + + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, + buffer, origin, region, 0, 1, + nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyImageToBufferKHR should return " "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); - cl_sync_point_khr* invalid_point = nullptr; - std::vector invalid_sync_points; - invalid_sync_points.push_back(invalid_point); - error = clCommandCopyBufferKHR( - command_buffer, nullptr, in_mem, out_mem, 0, 0, data_size(), 1, - *invalid_sync_points.data(), nullptr, nullptr); + cl_sync_point_khr point; + std::vector sync_points; + error = clCommandBarrierWithWaitListKHR(command_buffer, nullptr, 0, + nullptr, &point, nullptr); + test_error(error, "clCommandBarrierWithWaitListKHR failed"); + sync_points.push_back(point); + + error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, + 0, 0, data_size(), 0, sync_points.data(), + nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferKHR should return " @@ -276,7 +284,7 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest error = clCommandCopyBufferRectKHR( command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, - 0, 0, 0, 1, *invalid_sync_points.data(), nullptr, nullptr); + 0, 0, 0, 0, sync_points.data(), nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferRectKHR should return " @@ -284,8 +292,8 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, image, buffer, origin, region, 0, 1, - *invalid_sync_points.data(), nullptr, nullptr); + command_buffer, nullptr, image, buffer, origin, region, 0, 0, + sync_points.data(), nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyImageToBufferKHR should return " From c29e6f8e1b01081438d865a5c3fc3708e04981e7 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Tue, 21 May 2024 07:54:41 +0200 Subject: [PATCH 04/10] Minor review changes --- .../cl_khr_command_buffer/CMakeLists.txt | 2 +- .../negative_command_buffer_copy.cpp | 40 +++++++++---------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/CMakeLists.txt b/test_conformance/extensions/cl_khr_command_buffer/CMakeLists.txt index a9dd2415e..740e96282 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/CMakeLists.txt +++ b/test_conformance/extensions/cl_khr_command_buffer/CMakeLists.txt @@ -17,7 +17,7 @@ set(${MODULE_NAME}_SOURCES command_buffer_test_event_info.cpp command_buffer_finalize.cpp negative_command_buffer_create.cpp -negative_command_buffer_copy.cpp + negative_command_buffer_copy.cpp negative_command_buffer_get_info.cpp ) 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 6204518ba..d54bde3c8 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 @@ -205,12 +205,10 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest cl_sync_point_khr invalid_point = 0; - std::vector invalid_sync_points; - invalid_sync_points.push_back(&invalid_point); - error = clCommandCopyBufferKHR( - command_buffer, nullptr, in_mem, out_mem, 0, 0, data_size(), 1, - *invalid_sync_points.data(), nullptr, nullptr); + error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, + 0, 0, data_size(), 1, &invalid_point, + nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferKHR should return " @@ -219,16 +217,16 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest error = clCommandCopyBufferRectKHR( command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, - 0, 0, 0, 1, *invalid_sync_points.data(), nullptr, nullptr); + 0, 0, 0, 1, &invalid_point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferRectKHR should return " "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); - error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, image, buffer, origin, region, 0, 1, - *invalid_sync_points.data(), nullptr, nullptr); + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, + buffer, origin, region, 0, 1, + &invalid_point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyImageToBufferKHR should return " @@ -267,15 +265,13 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest cl_sync_point_khr point; - std::vector sync_points; error = clCommandBarrierWithWaitListKHR(command_buffer, nullptr, 0, nullptr, &point, nullptr); test_error(error, "clCommandBarrierWithWaitListKHR failed"); - sync_points.push_back(point); - error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, - 0, 0, data_size(), 0, sync_points.data(), - nullptr, nullptr); + error = + clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, 0, + 0, data_size(), 0, &point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferKHR should return " @@ -284,16 +280,16 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest error = clCommandCopyBufferRectKHR( command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, - 0, 0, 0, 0, sync_points.data(), nullptr, nullptr); + 0, 0, 0, 0, &point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferRectKHR should return " "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); - error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, image, buffer, origin, region, 0, 0, - sync_points.data(), nullptr, nullptr); + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, + buffer, origin, region, 0, 0, + &point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyImageToBufferKHR should return " @@ -391,9 +387,9 @@ struct CommandBufferCopyFinalizedCommandBuffer : public BasicCommandBufferTest data_size(), nullptr, &error); test_error(error, "Unable to create buffer"); - error = clCommandCopyImageToBufferKHR(nullptr, nullptr, image, buffer, - origin, region, 0, 0, nullptr, - nullptr, nullptr); + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, + buffer, origin, region, 0, 0, + nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_OPERATION, "clCommandCopyImageToBufferKHR should return " @@ -453,7 +449,7 @@ struct CommandBufferCopyMutableHandleNotNull : public BasicCommandBufferTest return CL_SUCCESS; } }; -}; +} int test_negative_command_buffer_copy_queue_not_null(cl_device_id device, cl_context context, From 774794d1f024e3e47e10a546d607a72c6fabc471 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Wed, 22 May 2024 11:19:28 +0200 Subject: [PATCH 05/10] Added checking for IMAGE support, divided tests by copyBuffer and copyImage --- .../extensions/cl_khr_command_buffer/main.cpp | 25 +- .../negative_command_buffer_copy.cpp | 425 ++++++++++++------ .../extensions/cl_khr_command_buffer/procs.h | 38 +- 3 files changed, 349 insertions(+), 139 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/main.cpp b/test_conformance/extensions/cl_khr_command_buffer/main.cpp index aa9972961..0c74c7bb2 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/main.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/main.cpp @@ -85,12 +85,25 @@ test_definition test_list[] = { ADD_TEST(negative_command_ndrange_kernel_mutable_handle_not_null), ADD_TEST(negative_command_ndrange_kernel_not_support_printf), ADD_TEST(negative_command_ndrange_kernel_with_enqueue_call), - ADD_TEST(negative_command_buffer_copy_queue_not_null), - ADD_TEST(negative_command_buffer_copy_different_contexts), - ADD_TEST(negative_command_buffer_copy_sync_points_null_or_num_zero), - ADD_TEST(negative_command_buffer_copy_invalid_command_buffer), - ADD_TEST(negative_command_buffer_copy_finalized_command_buffer), - ADD_TEST(negative_command_buffer_copy_mutable_handle_not_null), + ADD_TEST(negative_command_buffer_command_copy_buffer_queue_not_null), + ADD_TEST(negative_command_buffer_command_copy_buffer_different_contexts), + ADD_TEST( + negative_command_buffer_command_copy_buffer_sync_points_null_or_num_zero), + ADD_TEST( + negative_command_buffer_command_copy_buffer_invalid_command_buffer), + ADD_TEST( + negative_command_buffer_command_copy_buffer_finalized_command_buffer), + ADD_TEST( + negative_command_buffer_command_copy_buffer_mutable_handle_not_null), + ADD_TEST(negative_command_buffer_command_copy_image_queue_not_null), + ADD_TEST(negative_command_buffer_command_copy_image_different_contexts), + ADD_TEST( + negative_command_buffer_command_copy_image_sync_points_null_or_num_zero), + ADD_TEST(negative_command_buffer_command_copy_image_invalid_command_buffer), + ADD_TEST( + negative_command_buffer_command_copy_image_finalized_command_buffer), + ADD_TEST( + negative_command_buffer_command_copy_image_mutable_handle_not_null), ADD_TEST(negative_get_command_buffer_info_invalid_command_buffer), ADD_TEST(negative_get_command_buffer_info_not_supported_param_name), ADD_TEST(negative_get_command_buffer_info_queues), 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 d54bde3c8..c5e116f85 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 @@ -15,15 +15,64 @@ // #include "basic_command_buffer.h" #include "procs.h" -#include //-------------------------------------------------------------------------- +template +struct CommandBufferCopyBaseTest : BasicCommandBufferTest +{ + CommandBufferCopyBaseTest(cl_device_id device, cl_context context, + cl_command_queue queue) + : BasicCommandBufferTest(device, context, queue) + {} + + cl_int SetUp(int elements) override + { + cl_int error = BasicCommandBufferTest::SetUp(elements); + test_error(error, "BasicCommandBufferTest::SetUp failed"); + + image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, 512, 512, + 0, NULL, &error); + test_error(error, "create_image_2d failed"); + + buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, data_size(), + nullptr, &error); + test_error(error, "Unable to create buffer"); + + return CL_SUCCESS; + } + + bool Skip() override + { + if (check_image_support) + { + cl_bool image_support; + + cl_int error = + clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, + sizeof(image_support), &image_support, nullptr); + test_error(error, + "clGetDeviceInfo for CL_DEVICE_IMAGE_SUPPORT failed"); + + return (!image_support || BasicCommandBufferTest::Skip()); + } + return BasicCommandBufferTest::Skip(); + } + +protected: + const size_t origin[3] = { 0, 0, 0 }; + const size_t region[3] = { 512, 512, 1 }; + const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + clMemWrapper image; + clMemWrapper buffer; +}; + namespace { // CL_INVALID_COMMAND_QUEUE if command_queue is not NULL. -struct CommandBufferCopyQueueNotNull : public BasicCommandBufferTest +struct CommandBufferCopyBufferQueueNotNull + : public CommandBufferCopyBaseTest { - using BasicCommandBufferTest::BasicCommandBufferTest; + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; cl_int Run() override { @@ -36,8 +85,6 @@ struct CommandBufferCopyQueueNotNull : public BasicCommandBufferTest "CL_INVALID_COMMAND_QUEUE", TEST_FAIL); - const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; - error = clCommandCopyBufferRectKHR( command_buffer, queue, in_mem, out_mem, origin, origin, region, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr); @@ -47,17 +94,21 @@ struct CommandBufferCopyQueueNotNull : public BasicCommandBufferTest "CL_INVALID_COMMAND_QUEUE", TEST_FAIL); - const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; - clMemWrapper image = create_image_2d( - context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); - test_error(error, "create_image_2d failed"); - clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, - data_size(), nullptr, &error); - test_error(error, "Unable to create buffer"); + return CL_SUCCESS; + } +}; - error = clCommandCopyImageToBufferKHR(command_buffer, queue, image, - buffer, origin, region, 0, 0, - nullptr, nullptr, nullptr); +// CL_INVALID_COMMAND_QUEUE if command_queue is not NULL. +struct CommandBufferCopyImageQueueNotNull + : public CommandBufferCopyBaseTest +{ + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; + + cl_int Run() override + { + cl_int error = clCommandCopyImageToBufferKHR( + command_buffer, queue, image, buffer, origin, region, 0, 0, nullptr, + nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_COMMAND_QUEUE, "clCommandCopyImageToBufferKHR should return " @@ -70,13 +121,14 @@ struct CommandBufferCopyQueueNotNull : public BasicCommandBufferTest // CL_INVALID_CONTEXT if the context associated with command_queue, // command_buffer, src_buffer, and dst_buffer are not the same. -struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest +struct CommandBufferCopyBufferDifferentContexts + : public CommandBufferCopyBaseTest { - using BasicCommandBufferTest::BasicCommandBufferTest; + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; cl_int SetUp(int elements) override { - cl_int error = BasicCommandBufferTest::SetUp(elements); + cl_int error = CommandBufferCopyBaseTest::SetUp(elements); test_error(error, "BasicCommandBufferTest::SetUp failed"); context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); @@ -95,20 +147,12 @@ struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); - test_error(error, "create_image_2d failed"); + buffer_ctx = clCreateBuffer(context1, CL_MEM_READ_WRITE, data_size(), nullptr, &error); test_error(error, "Unable to create buffer"); - image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, 512, 512, - 0, NULL, &error); - - test_error(error, "create_image_2d failed"); - buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, data_size(), - nullptr, &error); - test_error(error, "Unable to create buffer"); - return CL_SUCCESS; } @@ -123,7 +167,6 @@ struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest "CL_INVALID_CONTEXT", TEST_FAIL); - const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; error = clCommandCopyBufferRectKHR( command_buffer, nullptr, in_mem_ctx, out_mem, origin, origin, @@ -134,14 +177,6 @@ struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest "CL_INVALID_CONTEXT", TEST_FAIL); - error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, - image_ctx, buffer, origin, region, - 0, 0, nullptr, nullptr, nullptr); - - test_failure_error_ret(error, CL_INVALID_CONTEXT, - "clCommandCopyImageToBufferKHR should return " - "CL_INVALID_CONTEXT", - TEST_FAIL); error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem_ctx, 0, 0, data_size(), 0, @@ -161,6 +196,65 @@ struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest "CL_INVALID_CONTEXT", TEST_FAIL); + + return CL_SUCCESS; + } + clMemWrapper in_mem_ctx = nullptr; + clMemWrapper out_mem_ctx = nullptr; + clMemWrapper image_ctx = nullptr; + clMemWrapper buffer_ctx = nullptr; + clContextWrapper context1 = nullptr; +}; + +// CL_INVALID_CONTEXT if the context associated with command_queue, +// command_buffer, src_buffer, and dst_buffer are not the same. +struct CommandBufferCopyImageDifferentContexts + : public CommandBufferCopyBaseTest +{ + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; + + cl_int SetUp(int elements) override + { + cl_int error = CommandBufferCopyBaseTest::SetUp(elements); + test_error(error, "BasicCommandBufferTest::SetUp failed"); + + context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); + test_error(error, "Failed to create context"); + + in_mem_ctx = + clCreateBuffer(context1, CL_MEM_READ_ONLY, + sizeof(cl_int) * num_elements, nullptr, &error); + test_error(error, "clCreateBuffer failed"); + + out_mem_ctx = + clCreateBuffer(context1, CL_MEM_WRITE_ONLY, + sizeof(cl_int) * num_elements, nullptr, &error); + test_error(error, "clCreateBuffer failed"); + + image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &formats, 512, + 512, 0, NULL, &error); + test_error(error, "create_image_2d failed"); + + buffer_ctx = clCreateBuffer(context1, CL_MEM_READ_WRITE, data_size(), + nullptr, &error); + test_error(error, "Unable to create buffer"); + + + return CL_SUCCESS; + } + + cl_int Run() override + { + cl_int error = clCommandCopyImageToBufferKHR( + command_buffer, nullptr, image_ctx, buffer, origin, region, 0, 0, + nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_CONTEXT, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_CONTEXT", + TEST_FAIL); + + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, buffer_ctx, origin, region, 0, 0, nullptr, nullptr, nullptr); @@ -177,8 +271,6 @@ struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest clMemWrapper out_mem_ctx = nullptr; clMemWrapper image_ctx = nullptr; clMemWrapper buffer_ctx = nullptr; - clMemWrapper image = nullptr; - clMemWrapper buffer = nullptr; clContextWrapper context1 = nullptr; }; @@ -187,28 +279,18 @@ struct CommandBufferCopyDifferentContexts : public BasicCommandBufferTest // or sync_point_wait_list is not NULL and num_sync_points_in_wait_list is 0, // or if synchronization-point objects in sync_point_wait_list are not valid // synchronization-points. -struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest +struct CommandBufferCopyBufferSyncPointsNullOrNumZero + : public CommandBufferCopyBaseTest { - using BasicCommandBufferTest::BasicCommandBufferTest; + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; cl_int Run() override { - cl_int error = CL_SUCCESS; - const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; - const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; - clMemWrapper image = create_image_2d( - context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); - test_error(error, "create_image_2d failed"); - clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, - data_size(), nullptr, &error); - test_error(error, "Unable to create buffer"); - - cl_sync_point_khr invalid_point = 0; - error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, - 0, 0, data_size(), 1, &invalid_point, - nullptr, nullptr); + cl_int error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, + out_mem, 0, 0, data_size(), 1, + &invalid_point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferKHR should return " @@ -224,15 +306,6 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); - error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, - buffer, origin, region, 0, 1, - &invalid_point, nullptr, nullptr); - - test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, - "clCommandCopyImageToBufferKHR should return " - "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", - TEST_FAIL); - error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, 0, 0, data_size(), 1, nullptr, nullptr, @@ -254,16 +327,6 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest TEST_FAIL); - error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, - buffer, origin, region, 0, 1, - nullptr, nullptr, nullptr); - - test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, - "clCommandCopyImageToBufferKHR should return " - "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", - TEST_FAIL); - - cl_sync_point_khr point; error = clCommandBarrierWithWaitListKHR(command_buffer, nullptr, 0, nullptr, &point, nullptr); @@ -287,6 +350,49 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); + return CL_SUCCESS; + } +}; + +// CL_INVALID_SYNC_POINT_WAIT_LIST_KHR if sync_point_wait_list is NULL and +// num_sync_points_in_wait_list is > 0, +// or sync_point_wait_list is not NULL and num_sync_points_in_wait_list is 0, +// or if synchronization-point objects in sync_point_wait_list are not valid +// synchronization-points. +struct CommandBufferCopyImageSyncPointsNullOrNumZero + : public CommandBufferCopyBaseTest +{ + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; + + cl_int Run() override + { + cl_sync_point_khr invalid_point = 0; + + cl_int error = clCommandCopyImageToBufferKHR( + command_buffer, nullptr, image, buffer, origin, region, 0, 1, + &invalid_point, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, + buffer, origin, region, 0, 1, + nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandCopyImageToBufferKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + + cl_sync_point_khr point; + error = clCommandBarrierWithWaitListKHR(command_buffer, nullptr, 0, + nullptr, &point, nullptr); + test_error(error, "clCommandBarrierWithWaitListKHR failed"); + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, buffer, origin, region, 0, 0, &point, nullptr, nullptr); @@ -302,9 +408,10 @@ struct CommandBufferCopySyncPointsNullOrNumZero : public BasicCommandBufferTest // CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid // command-buffer. -struct CommandBufferCopyInvalidCommandBuffer : public BasicCommandBufferTest +struct CommandBufferCopyBufferInvalidCommandBuffer + : public CommandBufferCopyBaseTest { - using BasicCommandBufferTest::BasicCommandBufferTest; + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; cl_int Run() override { @@ -317,8 +424,6 @@ struct CommandBufferCopyInvalidCommandBuffer : public BasicCommandBufferTest "CL_INVALID_COMMAND_BUFFER_KHR", TEST_FAIL); - const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; - error = clCommandCopyBufferRectKHR(nullptr, nullptr, in_mem, out_mem, origin, origin, region, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr); @@ -328,17 +433,22 @@ struct CommandBufferCopyInvalidCommandBuffer : public BasicCommandBufferTest "CL_INVALID_COMMAND_BUFFER_KHR", TEST_FAIL); - const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; - clMemWrapper image = create_image_2d( - context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); - test_error(error, "create_image_2d failed"); - clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, - data_size(), nullptr, &error); - test_error(error, "Unable to create buffer"); + return CL_SUCCESS; + } +}; + +// CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid +// command-buffer. +struct CommandBufferCopyImageInvalidCommandBuffer + : public CommandBufferCopyBaseTest +{ + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; - error = clCommandCopyImageToBufferKHR(nullptr, nullptr, image, buffer, - origin, region, 0, 0, nullptr, - nullptr, nullptr); + cl_int Run() override + { + cl_int error = clCommandCopyImageToBufferKHR( + nullptr, nullptr, image, buffer, origin, region, 0, 0, nullptr, + nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_COMMAND_BUFFER_KHR, "clCommandCopyImageToBufferKHR should return " @@ -350,9 +460,10 @@ struct CommandBufferCopyInvalidCommandBuffer : public BasicCommandBufferTest }; // CL_INVALID_OPERATION if command_buffer has been finalized. -struct CommandBufferCopyFinalizedCommandBuffer : public BasicCommandBufferTest +struct CommandBufferCopyBufferFinalizedCommandBuffer + : public CommandBufferCopyBaseTest { - using BasicCommandBufferTest::BasicCommandBufferTest; + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; cl_int Run() override { @@ -368,7 +479,6 @@ struct CommandBufferCopyFinalizedCommandBuffer : public BasicCommandBufferTest "CL_INVALID_OPERATION", TEST_FAIL); - const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; error = clCommandCopyBufferRectKHR( command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, @@ -379,13 +489,21 @@ struct CommandBufferCopyFinalizedCommandBuffer : public BasicCommandBufferTest "CL_INVALID_OPERATION", TEST_FAIL); - const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; - clMemWrapper image = create_image_2d( - context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); - test_error(error, "create_image_2d failed"); - clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, - data_size(), nullptr, &error); - test_error(error, "Unable to create buffer"); + return CL_SUCCESS; + } +}; + +// CL_INVALID_OPERATION if command_buffer has been finalized. +struct CommandBufferCopyImageFinalizedCommandBuffer + : public CommandBufferCopyBaseTest +{ + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; + + cl_int Run() override + { + cl_int error = clFinalizeCommandBufferKHR(command_buffer); + test_error(error, "clFinalizeCommandBufferKHR failed"); + error = clCommandCopyImageToBufferKHR(command_buffer, nullptr, image, buffer, origin, region, 0, 0, @@ -401,9 +519,10 @@ struct CommandBufferCopyFinalizedCommandBuffer : public BasicCommandBufferTest }; // CL_INVALID_VALUE if mutable_handle is not NULL. -struct CommandBufferCopyMutableHandleNotNull : public BasicCommandBufferTest +struct CommandBufferCopyBufferMutableHandleNotNull + : public CommandBufferCopyBaseTest { - using BasicCommandBufferTest::BasicCommandBufferTest; + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; cl_int Run() override { @@ -418,7 +537,6 @@ struct CommandBufferCopyMutableHandleNotNull : public BasicCommandBufferTest "CL_INVALID_VALUE", TEST_FAIL); - const size_t origin[3] = { 0, 0, 0 }, region[3] = { 512, 512, 1 }; error = clCommandCopyBufferRectKHR( command_buffer, nullptr, in_mem, out_mem, origin, origin, region, 0, @@ -429,15 +547,22 @@ struct CommandBufferCopyMutableHandleNotNull : public BasicCommandBufferTest "CL_INVALID_VALUE", TEST_FAIL); - const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; - clMemWrapper image = create_image_2d( - context, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); - test_error(error, "create_image_2d failed"); - clMemWrapper buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, - data_size(), nullptr, &error); - test_error(error, "Unable to create buffer"); - error = clCommandCopyImageToBufferKHR( + return CL_SUCCESS; + } +}; + +// CL_INVALID_VALUE if mutable_handle is not NULL. +struct CommandBufferCopyImageMutableHandleNotNull + : public CommandBufferCopyBaseTest +{ + using CommandBufferCopyBaseTest::CommandBufferCopyBaseTest; + + cl_int Run() override + { + cl_mutable_command_khr mutable_handle; + + cl_int error = clCommandCopyImageToBufferKHR( command_buffer, nullptr, image, buffer, origin, region, 0, 0, nullptr, nullptr, &mutable_handle); @@ -451,52 +576,98 @@ struct CommandBufferCopyMutableHandleNotNull : public BasicCommandBufferTest }; } -int test_negative_command_buffer_copy_queue_not_null(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) +int test_negative_command_buffer_command_copy_buffer_queue_not_null( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_command_copy_image_queue_not_null( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) { - return MakeAndRunTest(device, context, queue, - num_elements); + return MakeAndRunTest( + device, context, queue, num_elements); } -int test_negative_command_buffer_copy_different_contexts(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) +int test_negative_command_buffer_command_copy_buffer_different_contexts( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_command_copy_image_different_contexts( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_command_copy_buffer_sync_points_null_or_num_zero( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_command_copy_image_sync_points_null_or_num_zero( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_command_copy_buffer_invalid_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_command_copy_image_invalid_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) { - return MakeAndRunTest( + return MakeAndRunTest( device, context, queue, num_elements); } -int test_negative_command_buffer_copy_sync_points_null_or_num_zero( +int test_negative_command_buffer_command_copy_buffer_finalized_command_buffer( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) { - return MakeAndRunTest( + return MakeAndRunTest( device, context, queue, num_elements); } -int test_negative_command_buffer_copy_invalid_command_buffer( +int test_negative_command_buffer_command_copy_image_finalized_command_buffer( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) { - return MakeAndRunTest( + return MakeAndRunTest( device, context, queue, num_elements); } -int test_negative_command_buffer_copy_finalized_command_buffer( +int test_negative_command_buffer_command_copy_buffer_mutable_handle_not_null( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) { - return MakeAndRunTest( + return MakeAndRunTest( device, context, queue, num_elements); } -int test_negative_command_buffer_copy_mutable_handle_not_null( +int test_negative_command_buffer_command_copy_image_mutable_handle_not_null( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) { - return MakeAndRunTest( + return MakeAndRunTest( device, context, queue, num_elements); } diff --git a/test_conformance/extensions/cl_khr_command_buffer/procs.h b/test_conformance/extensions/cl_khr_command_buffer/procs.h index a7f3e9a9d..799e44800 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/procs.h +++ b/test_conformance/extensions/cl_khr_command_buffer/procs.h @@ -200,22 +200,48 @@ extern int test_negative_command_ndrange_kernel_not_support_printf( extern int test_negative_command_ndrange_kernel_with_enqueue_call( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_negative_command_buffer_copy_queue_not_null( +extern int test_negative_command_buffer_command_copy_buffer_queue_not_null( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_negative_command_buffer_copy_different_contexts( +extern int test_negative_command_buffer_command_copy_buffer_different_contexts( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_negative_command_buffer_copy_sync_points_null_or_num_zero( +extern int +test_negative_command_buffer_command_copy_buffer_sync_points_null_or_num_zero( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int +test_negative_command_buffer_command_copy_buffer_invalid_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int +test_negative_command_buffer_command_copy_buffer_finalized_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int +test_negative_command_buffer_command_copy_buffer_mutable_handle_not_null( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_negative_command_buffer_copy_invalid_command_buffer( +extern int test_negative_command_buffer_command_copy_image_queue_not_null( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_negative_command_buffer_copy_finalized_command_buffer( +extern int test_negative_command_buffer_command_copy_image_different_contexts( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_negative_command_buffer_copy_mutable_handle_not_null( +extern int +test_negative_command_buffer_command_copy_image_sync_points_null_or_num_zero( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int +test_negative_command_buffer_command_copy_image_invalid_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int +test_negative_command_buffer_command_copy_image_finalized_command_buffer( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int +test_negative_command_buffer_command_copy_image_mutable_handle_not_null( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); extern int test_negative_get_command_buffer_info_invalid_command_buffer( From ac87eda6b60421e6477b283d41374b8084374230 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Wed, 22 May 2024 13:40:13 +0200 Subject: [PATCH 06/10] Added if (check_image_support) to SetUp before creating images --- .../negative_command_buffer_copy.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 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 c5e116f85..75615aa72 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 @@ -30,13 +30,16 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest cl_int error = BasicCommandBufferTest::SetUp(elements); test_error(error, "BasicCommandBufferTest::SetUp failed"); - image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, 512, 512, - 0, NULL, &error); - test_error(error, "create_image_2d failed"); + if (check_image_support) + { + image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, 512, + 512, 0, NULL, &error); + test_error(error, "create_image_2d failed"); - buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, data_size(), - nullptr, &error); - test_error(error, "Unable to create buffer"); + buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, data_size(), + nullptr, &error); + test_error(error, "Unable to create buffer"); + } return CL_SUCCESS; } From 4cccb1c3c8c0ca5377f64dc01551d1200fd9d3f3 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Thu, 23 May 2024 07:53:10 +0200 Subject: [PATCH 07/10] Added minor corrections --- .../negative_command_buffer_copy.cpp | 23 ------------------- 1 file changed, 23 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 75615aa72..e287e1a41 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 @@ -147,15 +147,6 @@ struct CommandBufferCopyBufferDifferentContexts sizeof(cl_int) * num_elements, nullptr, &error); test_error(error, "clCreateBuffer failed"); - const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; - image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &formats, 512, - 512, 0, NULL, &error); - test_error(error, "create_image_2d failed"); - - buffer_ctx = clCreateBuffer(context1, CL_MEM_READ_WRITE, data_size(), - nullptr, &error); - test_error(error, "Unable to create buffer"); - return CL_SUCCESS; } @@ -204,8 +195,6 @@ struct CommandBufferCopyBufferDifferentContexts } clMemWrapper in_mem_ctx = nullptr; clMemWrapper out_mem_ctx = nullptr; - clMemWrapper image_ctx = nullptr; - clMemWrapper buffer_ctx = nullptr; clContextWrapper context1 = nullptr; }; @@ -224,16 +213,6 @@ struct CommandBufferCopyImageDifferentContexts context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); test_error(error, "Failed to create context"); - in_mem_ctx = - clCreateBuffer(context1, CL_MEM_READ_ONLY, - sizeof(cl_int) * num_elements, nullptr, &error); - test_error(error, "clCreateBuffer failed"); - - out_mem_ctx = - clCreateBuffer(context1, CL_MEM_WRITE_ONLY, - sizeof(cl_int) * num_elements, nullptr, &error); - test_error(error, "clCreateBuffer failed"); - image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &formats, 512, 512, 0, NULL, &error); test_error(error, "create_image_2d failed"); @@ -270,8 +249,6 @@ struct CommandBufferCopyImageDifferentContexts return CL_SUCCESS; } - clMemWrapper in_mem_ctx = nullptr; - clMemWrapper out_mem_ctx = nullptr; clMemWrapper image_ctx = nullptr; clMemWrapper buffer_ctx = nullptr; clContextWrapper context1 = nullptr; From 1010816cffde73456d48866e040f9a2f26cc9963 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Mon, 3 Jun 2024 11:18:06 +0200 Subject: [PATCH 08/10] Added check for command_buffer_multi_device --- .../cl_khr_command_buffer/negative_command_buffer_copy.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 e287e1a41..3f032173e 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 @@ -46,6 +46,8 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest bool Skip() override { + bool command_buffer_multi_device = is_extension_available( + device, "cl_khr_command_buffer_multi_device"); if (check_image_support) { cl_bool image_support; @@ -56,9 +58,10 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest test_error(error, "clGetDeviceInfo for CL_DEVICE_IMAGE_SUPPORT failed"); - return (!image_support || BasicCommandBufferTest::Skip()); + return (!image_support || BasicCommandBufferTest::Skip() + || command_buffer_multi_device); } - return BasicCommandBufferTest::Skip(); + return BasicCommandBufferTest::Skip() || command_buffer_multi_device; } protected: From cb6b38b935e78b02054576e67ed218a8a6aef3e0 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Tue, 11 Jun 2024 11:27:49 +0200 Subject: [PATCH 09/10] Added correction with memory --- .../negative_command_buffer_copy.cpp | 57 ++++++++++--------- 1 file changed, 30 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 3f032173e..2138824bc 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 @@ -32,11 +32,11 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest if (check_image_support) { - image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, 512, - 512, 0, NULL, &error); + image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, + img_width, img_height, 0, NULL, &error); test_error(error, "create_image_2d failed"); - buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, data_size(), + buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, data_size, nullptr, &error); test_error(error, "Unable to create buffer"); } @@ -65,11 +65,16 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest } 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] = { 512, 512, 1 }; + const size_t region[3] = { img_width, img_height, 1 }; const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; clMemWrapper image; clMemWrapper buffer; + const size_t data_size = img_width * img_height * sizeof(cl_char); + clMemWrapper in_mem; + clMemWrapper out_mem; }; namespace { @@ -84,7 +89,7 @@ struct CommandBufferCopyBufferQueueNotNull { cl_int error = clCommandCopyBufferKHR(command_buffer, queue, in_mem, out_mem, 0, 0, - data_size(), 0, nullptr, nullptr, nullptr); + data_size, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_COMMAND_QUEUE, "clCommandCopyBufferKHR should return " @@ -140,14 +145,12 @@ struct CommandBufferCopyBufferDifferentContexts context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); test_error(error, "Failed to create context"); - in_mem_ctx = - clCreateBuffer(context1, CL_MEM_READ_ONLY, - sizeof(cl_int) * num_elements, nullptr, &error); + in_mem_ctx = clCreateBuffer(context1, CL_MEM_READ_ONLY, data_size, + nullptr, &error); test_error(error, "clCreateBuffer failed"); - out_mem_ctx = - clCreateBuffer(context1, CL_MEM_WRITE_ONLY, - sizeof(cl_int) * num_elements, nullptr, &error); + out_mem_ctx = clCreateBuffer(context1, CL_MEM_WRITE_ONLY, data_size, + nullptr, &error); test_error(error, "clCreateBuffer failed"); return CL_SUCCESS; @@ -156,7 +159,7 @@ struct CommandBufferCopyBufferDifferentContexts cl_int Run() override { cl_int error = clCommandCopyBufferKHR( - command_buffer, nullptr, in_mem_ctx, out_mem, 0, 0, data_size(), 0, + command_buffer, nullptr, in_mem_ctx, out_mem, 0, 0, data_size, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_CONTEXT, @@ -176,8 +179,8 @@ struct CommandBufferCopyBufferDifferentContexts error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, - out_mem_ctx, 0, 0, data_size(), 0, - nullptr, nullptr, nullptr); + out_mem_ctx, 0, 0, data_size, 0, nullptr, + nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_CONTEXT, "clCommandCopyBufferKHR should return " @@ -216,11 +219,11 @@ 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, 512, - 512, 0, NULL, &error); + image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &formats, + img_width, img_height, 0, NULL, &error); test_error(error, "create_image_2d failed"); - buffer_ctx = clCreateBuffer(context1, CL_MEM_READ_WRITE, data_size(), + buffer_ctx = clCreateBuffer(context1, CL_MEM_READ_WRITE, data_size, nullptr, &error); test_error(error, "Unable to create buffer"); @@ -272,7 +275,7 @@ struct CommandBufferCopyBufferSyncPointsNullOrNumZero cl_sync_point_khr invalid_point = 0; cl_int error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, - out_mem, 0, 0, data_size(), 1, + out_mem, 0, 0, data_size, 1, &invalid_point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, @@ -290,9 +293,9 @@ struct CommandBufferCopyBufferSyncPointsNullOrNumZero TEST_FAIL); - error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, - 0, 0, data_size(), 1, nullptr, nullptr, - nullptr); + error = + clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, 0, + 0, data_size, 1, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferKHR should return " @@ -317,7 +320,7 @@ struct CommandBufferCopyBufferSyncPointsNullOrNumZero error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, 0, - 0, data_size(), 0, &point, nullptr, nullptr); + 0, data_size, 0, &point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandCopyBufferKHR should return " @@ -400,7 +403,7 @@ struct CommandBufferCopyBufferInvalidCommandBuffer { cl_int error = clCommandCopyBufferKHR(nullptr, nullptr, in_mem, out_mem, 0, 0, - data_size(), 0, nullptr, nullptr, nullptr); + data_size, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_COMMAND_BUFFER_KHR, "clCommandCopyBufferKHR should return " @@ -453,9 +456,9 @@ struct CommandBufferCopyBufferFinalizedCommandBuffer cl_int error = clFinalizeCommandBufferKHR(command_buffer); test_error(error, "clFinalizeCommandBufferKHR failed"); - error = clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, - 0, 0, data_size(), 0, nullptr, nullptr, - nullptr); + error = + clCommandCopyBufferKHR(command_buffer, nullptr, in_mem, out_mem, 0, + 0, data_size, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_OPERATION, "clCommandCopyBufferKHR should return " @@ -512,7 +515,7 @@ struct CommandBufferCopyBufferMutableHandleNotNull cl_mutable_command_khr mutable_handle; cl_int error = clCommandCopyBufferKHR( - command_buffer, nullptr, in_mem, out_mem, 0, 0, data_size(), 0, + command_buffer, nullptr, in_mem, out_mem, 0, 0, data_size, 0, nullptr, nullptr, &mutable_handle); test_failure_error_ret(error, CL_INVALID_VALUE, From c4c0c4134bd3fccce1894de63d18827fed4f901e Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Tue, 11 Jun 2024 12:56:01 +0200 Subject: [PATCH 10/10] Added initialization of in_mem and out_mem --- .../negative_command_buffer_copy.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 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 2138824bc..211ffc4d6 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 @@ -30,6 +30,14 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest cl_int error = BasicCommandBufferTest::SetUp(elements); test_error(error, "BasicCommandBufferTest::SetUp failed"); + in_mem = clCreateBuffer(context, CL_MEM_READ_WRITE, data_size, nullptr, + &error); + test_error(error, "clCreateBuffer failed"); + + out_mem = clCreateBuffer(context, CL_MEM_READ_WRITE, data_size, nullptr, + &error); + test_error(error, "Unable to create buffer"); + if (check_image_support) { image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, @@ -140,7 +148,7 @@ struct CommandBufferCopyBufferDifferentContexts cl_int SetUp(int elements) override { cl_int error = CommandBufferCopyBaseTest::SetUp(elements); - test_error(error, "BasicCommandBufferTest::SetUp failed"); + test_error(error, "CommandBufferCopyBaseTest::SetUp failed"); context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); test_error(error, "Failed to create context"); @@ -214,7 +222,7 @@ struct CommandBufferCopyImageDifferentContexts cl_int SetUp(int elements) override { cl_int error = CommandBufferCopyBaseTest::SetUp(elements); - test_error(error, "BasicCommandBufferTest::SetUp failed"); + test_error(error, "CommandBufferCopyBaseTest::SetUp failed"); context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); test_error(error, "Failed to create context");