diff --git a/test_conformance/extensions/cl_khr_command_buffer/main.cpp b/test_conformance/extensions/cl_khr_command_buffer/main.cpp index 5c7cddb9a4..cb459c4010 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/main.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/main.cpp @@ -68,12 +68,25 @@ test_definition test_list[] = { ADD_TEST(negative_release_command_buffer_invalid_command_buffer), ADD_TEST(negative_finalize_command_buffer_invalid_command_buffer), ADD_TEST(negative_finalize_command_buffer_not_recording_state), - ADD_TEST(negative_command_buffer_command_fill_queue_not_null), - ADD_TEST(negative_command_buffer_command_fill_context_not_same), - ADD_TEST(negative_command_buffer_command_fill_sync_points_null_or_num_zero), - ADD_TEST(negative_command_buffer_command_fill_invalid_command_buffer), - ADD_TEST(negative_command_buffer_command_fill_finalized_command_buffer), - ADD_TEST(negative_command_buffer_command_fill_mutable_handle_not_null), + ADD_TEST(negative_command_buffer_command_fill_buffer_queue_not_null), + ADD_TEST(negative_command_buffer_command_fill_buffer_context_not_same), + ADD_TEST( + negative_command_buffer_command_fill_buffer_sync_points_null_or_num_zero), + ADD_TEST( + negative_command_buffer_command_fill_buffer_invalid_command_buffer), + ADD_TEST( + negative_command_buffer_command_fill_buffer_finalized_command_buffer), + ADD_TEST( + negative_command_buffer_command_fill_buffer_mutable_handle_not_null), + ADD_TEST(negative_command_buffer_command_fill_image_queue_not_null), + ADD_TEST(negative_command_buffer_command_fill_image_context_not_same), + ADD_TEST( + negative_command_buffer_command_fill_image_sync_points_null_or_num_zero), + ADD_TEST(negative_command_buffer_command_fill_image_invalid_command_buffer), + ADD_TEST( + negative_command_buffer_command_fill_image_finalized_command_buffer), + ADD_TEST( + negative_command_buffer_command_fill_image_mutable_handle_not_null), ADD_TEST(negative_create_command_buffer_num_queues), ADD_TEST(negative_create_command_buffer_null_queues), ADD_TEST(negative_create_command_buffer_repeated_properties), diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_fill.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_fill.cpp index ec790dd9e9..e15fc39e94 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_fill.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_fill.cpp @@ -18,6 +18,7 @@ #include //-------------------------------------------------------------------------- +template struct CommandFillBaseTest : BasicCommandBufferTest { CommandFillBaseTest(cl_device_id device, cl_context context, @@ -43,14 +44,19 @@ struct CommandFillBaseTest : BasicCommandBufferTest bool Skip() override { - 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()); + 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 check_image_support; } protected: @@ -66,7 +72,8 @@ struct CommandFillBaseTest : BasicCommandBufferTest namespace { // CL_INVALID_COMMAND_QUEUE if command_queue is not NULL. -struct CommandBufferCommandFillQueueNotNull : public CommandFillBaseTest +struct CommandBufferCommandFillBufferQueueNotNull + : public CommandFillBaseTest { using CommandFillBaseTest::CommandFillBaseTest; @@ -101,9 +108,38 @@ struct CommandBufferCommandFillQueueNotNull : public CommandFillBaseTest } }; +// CL_INVALID_COMMAND_QUEUE if command_queue is not NULL. +struct CommandBufferCommandFillImageQueueNotNull + : public CommandFillBaseTest +{ + using CommandFillBaseTest::CommandFillBaseTest; + + cl_int Run() override + { + cl_int error = clCommandFillImageKHR(command_buffer, queue, src_image, + fill_color_1, origin, region, 0, + nullptr, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_COMMAND_QUEUE, + "clCommandFillImageKHR should return " + "CL_INVALID_COMMAND_QUEUE", + TEST_FAIL); + + return CL_SUCCESS; + } + + bool Skip() override + { + return CommandFillBaseTest::Skip() + || is_extension_available(device, + "cl_khr_command_buffer_multi_device"); + } +}; + // CL_INVALID_CONTEXT if the context associated with command_queue, // command_buffer, and buffer are not the same. -struct CommandBufferCommandFillContextNotSame : public CommandFillBaseTest +struct CommandBufferCommandFillBufferContextNotSame + : public CommandFillBaseTest { using CommandFillBaseTest::CommandFillBaseTest; @@ -118,9 +154,46 @@ struct CommandBufferCommandFillContextNotSame : public CommandFillBaseTest "CL_INVALID_CONTEXT", TEST_FAIL); - error = clCommandFillImageKHR(command_buffer, nullptr, dst_image_ctx, - fill_color_1, origin, region, 0, nullptr, - nullptr, nullptr); + return CL_SUCCESS; + } + + cl_int SetUp(int elements) override + { + cl_int error = CommandFillBaseTest::SetUp(elements); + test_error(error, "CommandFillBaseTest::SetUp failed"); + + context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); + test_error(error, "Failed to create context"); + + out_mem_ctx = + clCreateBuffer(context1, CL_MEM_WRITE_ONLY, + sizeof(cl_int) * num_elements, nullptr, &error); + test_error(error, "clCreateBuffer failed"); + + dst_image_ctx = create_image_2d(context1, CL_MEM_WRITE_ONLY, &formats, + 512, 512, 0, NULL, &error); + test_error(error, "create_image_2d failed"); + + return CL_SUCCESS; + } + + clContextWrapper context1; + clMemWrapper out_mem_ctx; + clMemWrapper dst_image_ctx; +}; + +// CL_INVALID_CONTEXT if the context associated with command_queue, +// command_buffer, and buffer are not the same. +struct CommandBufferCommandFillImageContextNotSame + : public CommandFillBaseTest +{ + using CommandFillBaseTest::CommandFillBaseTest; + + cl_int Run() override + { + cl_int error = clCommandFillImageKHR( + command_buffer, nullptr, dst_image_ctx, fill_color_1, origin, + region, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_CONTEXT, "clCommandFillImageKHR should return " @@ -159,8 +232,8 @@ struct CommandBufferCommandFillContextNotSame : public CommandFillBaseTest // 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 CommandBufferCommandFillSyncPointsNullOrNumZero - : public CommandFillBaseTest +struct CommandBufferCommandFillBufferSyncPointsNullOrNumZero + : public CommandFillBaseTest { using CommandFillBaseTest::CommandFillBaseTest; @@ -177,25 +250,59 @@ struct CommandBufferCommandFillSyncPointsNullOrNumZero "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", TEST_FAIL); - error = clCommandFillImageKHR(command_buffer, nullptr, dst_image, - fill_color_1, origin, region, 1, - &invalid_point, nullptr, nullptr); + + error = clCommandFillBufferKHR(command_buffer, nullptr, out_mem, + &pattern, sizeof(cl_int), 0, data_size(), + 1, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, - "clCommandFillImageKHR should return " + "clCommandFillBufferKHR 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 = clCommandFillBufferKHR(command_buffer, nullptr, out_mem, &pattern, sizeof(cl_int), 0, data_size(), - 1, nullptr, nullptr, nullptr); + 0, &point, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, "clCommandFillBufferKHR should return " "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 CommandBufferCommandFillImageSyncPointsNullOrNumZero + : public CommandFillBaseTest +{ + using CommandFillBaseTest::CommandFillBaseTest; + + cl_int Run() override + { + cl_sync_point_khr invalid_point = 0; + + cl_int error = clCommandFillImageKHR(command_buffer, nullptr, dst_image, + fill_color_1, origin, region, 1, + &invalid_point, nullptr, nullptr); + + test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, + "clCommandFillImageKHR should return " + "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", + TEST_FAIL); + + error = clCommandFillImageKHR(command_buffer, nullptr, dst_image, fill_color_1, origin, region, 1, nullptr, nullptr, nullptr); @@ -210,14 +317,6 @@ struct CommandBufferCommandFillSyncPointsNullOrNumZero nullptr, &point, nullptr); test_error(error, "clCommandBarrierWithWaitListKHR failed"); - error = clCommandFillBufferKHR(command_buffer, nullptr, out_mem, - &pattern, sizeof(cl_int), 0, data_size(), - 0, &point, nullptr, nullptr); - - test_failure_error_ret(error, CL_INVALID_SYNC_POINT_WAIT_LIST_KHR, - "clCommandFillBufferKHR should return " - "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR", - TEST_FAIL); error = clCommandFillImageKHR(command_buffer, nullptr, dst_image, fill_color_1, origin, region, 0, &point, @@ -233,9 +332,11 @@ struct CommandBufferCommandFillSyncPointsNullOrNumZero } }; + // CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid // command-buffer. -struct CommandBufferCommandFillInvalidCommandBuffer : public CommandFillBaseTest +struct CommandBufferCommandFillBufferInvalidCommandBuffer + : public CommandFillBaseTest { using CommandFillBaseTest::CommandFillBaseTest; @@ -250,7 +351,20 @@ struct CommandBufferCommandFillInvalidCommandBuffer : public CommandFillBaseTest "CL_INVALID_COMMAND_BUFFER_KHR", TEST_FAIL); - error = + return CL_SUCCESS; + } +}; + +// CL_INVALID_COMMAND_BUFFER_KHR if command_buffer is not a valid +// command-buffer. +struct CommandBufferCommandFillImageInvalidCommandBuffer + : public CommandFillBaseTest +{ + using CommandFillBaseTest::CommandFillBaseTest; + + cl_int Run() override + { + cl_int error = clCommandFillImageKHR(nullptr, nullptr, dst_image, fill_color_1, origin, region, 0, nullptr, nullptr, nullptr); @@ -264,8 +378,8 @@ struct CommandBufferCommandFillInvalidCommandBuffer : public CommandFillBaseTest }; // CL_INVALID_OPERATION if command_buffer has been finalized. -struct CommandBufferCommandFillFinalizedCommandBuffer - : public CommandFillBaseTest +struct CommandBufferCommandFillBufferFinalizedCommandBuffer + : public CommandFillBaseTest { using CommandFillBaseTest::CommandFillBaseTest; @@ -283,6 +397,23 @@ struct CommandBufferCommandFillFinalizedCommandBuffer "CL_INVALID_OPERATION", TEST_FAIL); + + return CL_SUCCESS; + } +}; + +// CL_INVALID_OPERATION if command_buffer has been finalized. +struct CommandBufferCommandFillImageFinalizedCommandBuffer + : public CommandFillBaseTest +{ + using CommandFillBaseTest::CommandFillBaseTest; + + cl_int Run() override + { + cl_int error = clFinalizeCommandBufferKHR(command_buffer); + test_error(error, "clFinalizeCommandBufferKHR failed"); + + error = clCommandFillImageKHR(command_buffer, nullptr, dst_image, fill_color_1, origin, region, 0, nullptr, nullptr, nullptr); @@ -297,7 +428,8 @@ struct CommandBufferCommandFillFinalizedCommandBuffer }; // CL_INVALID_VALUE if mutable_handle is not NULL. -struct CommandBufferCommandFillMutableHandleNotNull : public CommandFillBaseTest +struct CommandBufferCommandFillBufferMutableHandleNotNull + : public CommandFillBaseTest { using CommandFillBaseTest::CommandFillBaseTest; @@ -314,9 +446,24 @@ struct CommandBufferCommandFillMutableHandleNotNull : public CommandFillBaseTest "CL_INVALID_VALUE", TEST_FAIL); - error = clCommandFillImageKHR(command_buffer, nullptr, dst_image, - fill_color_1, origin, region, 0, nullptr, - nullptr, &mutable_handle); + + return CL_SUCCESS; + } +}; + +// CL_INVALID_VALUE if mutable_handle is not NULL. +struct CommandBufferCommandFillImageMutableHandleNotNull + : public CommandFillBaseTest +{ + using CommandFillBaseTest::CommandFillBaseTest; + + cl_int Run() override + { + cl_mutable_command_khr mutable_handle; + + cl_int error = clCommandFillImageKHR(command_buffer, nullptr, dst_image, + fill_color_1, origin, region, 0, + nullptr, nullptr, &mutable_handle); test_failure_error_ret(error, CL_INVALID_VALUE, "clCommandFillImageKHR should return " @@ -326,52 +473,102 @@ struct CommandBufferCommandFillMutableHandleNotNull : public CommandFillBaseTest return CL_SUCCESS; } }; + +} + +int test_negative_command_buffer_command_fill_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_fill_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); +} + +int test_negative_command_buffer_command_fill_buffer_context_not_same( + 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_fill_image_context_not_same( + 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_fill_buffer_sync_points_null_or_num_zero( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest< + CommandBufferCommandFillBufferSyncPointsNullOrNumZero>( + device, context, queue, num_elements); +} + +int test_negative_command_buffer_command_fill_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_fill_queue_not_null( +int test_negative_command_buffer_command_fill_buffer_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_command_fill_context_not_same( +int test_negative_command_buffer_command_fill_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_command_fill_sync_points_null_or_num_zero( +int test_negative_command_buffer_command_fill_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_command_fill_invalid_command_buffer( +int test_negative_command_buffer_command_fill_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_command_fill_finalized_command_buffer( +int test_negative_command_buffer_command_fill_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_command_fill_mutable_handle_not_null( +int test_negative_command_buffer_command_fill_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 e43516e07d..87eb803098 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/procs.h +++ b/test_conformance/extensions/cl_khr_command_buffer/procs.h @@ -153,23 +153,48 @@ extern int test_negative_finalize_command_buffer_invalid_command_buffer( extern int test_negative_finalize_command_buffer_not_recording_state( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_negative_command_buffer_command_fill_queue_not_null( +extern int test_negative_command_buffer_command_fill_buffer_queue_not_null( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_negative_command_buffer_command_fill_context_not_same( +extern int test_negative_command_buffer_command_fill_buffer_context_not_same( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); extern int -test_negative_command_buffer_command_fill_sync_points_null_or_num_zero( +test_negative_command_buffer_command_fill_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_fill_invalid_command_buffer( +extern int +test_negative_command_buffer_command_fill_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_fill_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_fill_image_queue_not_null( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_negative_command_buffer_command_fill_finalized_command_buffer( +extern int +test_negative_command_buffer_command_fill_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_command_fill_mutable_handle_not_null( +extern int test_negative_command_buffer_command_fill_image_context_not_same( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int +test_negative_command_buffer_command_fill_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_fill_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_fill_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_fill_image_mutable_handle_not_null( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); extern int test_negative_create_command_buffer_num_queues(