From 4b7f11ed751fa3993475115fa3aec39a398fd727 Mon Sep 17 00:00:00 2001 From: piotr-wozniak-mobica Date: Wed, 13 Sep 2023 14:41:05 +0200 Subject: [PATCH 1/4] UT for commandFillBuffer --- tests/test_openclhpp.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index 72a5a8e0..e40d93dc 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -407,6 +407,7 @@ void setUp(void) cl::pfn_clRetainCommandBufferKHR = ::clRetainCommandBufferKHR; cl::pfn_clReleaseCommandBufferKHR = ::clReleaseCommandBufferKHR; cl::pfn_clGetCommandBufferInfoKHR = ::clGetCommandBufferInfoKHR; + cl::pfn_clCommandFillBufferKHR = ::clCommandFillBufferKHR; #endif #if defined(cl_khr_semaphore) cl::pfn_clCreateSemaphoreWithPropertiesKHR = ::clCreateSemaphoreWithPropertiesKHR; @@ -484,6 +485,7 @@ void tearDown(void) cl::pfn_clRetainCommandBufferKHR = nullptr; cl::pfn_clReleaseCommandBufferKHR = nullptr; cl::pfn_clGetCommandBufferInfoKHR = nullptr; + cl::pfn_clCommandFillBufferKHR = nullptr; #endif #if defined(cl_khr_semaphore) cl::pfn_clCreateSemaphoreWithPropertiesKHR = nullptr; @@ -3604,6 +3606,44 @@ void testCommandBufferInfoKHRCommandQueues(void) TEST_ASSERT_EQUAL_PTR(make_command_queue(2), command_queues[2]()); #endif } + +cl_int clCommandFillBufferKHR_testcommandFillBuffer(cl_command_buffer_khr command_buffer, cl_command_queue command_queue, cl_mem buffer, + const void* pattern, size_t pattern_size, size_t offset, size_t size, cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, cl_sync_point_khr* sync_point, cl_mutable_command_khr* mutable_handle, int num_calls) +{ + (void)size; + (void)num_calls; + (void)sync_point; + TEST_ASSERT_EQUAL(command_buffer,commandBufferKhrPool[0]()); + TEST_ASSERT_EQUAL(buffer,bufferPool[0]()); + TEST_ASSERT_EQUAL(pattern_size, sizeof(float)); + TEST_ASSERT_EQUAL(offset, 0); + TEST_ASSERT_EQUAL(num_sync_points_in_wait_list, 1); + TEST_ASSERT_EQUAL(*(float*)pattern, 0); + TEST_ASSERT_EQUAL(*sync_point_wait_list, 0); + TEST_ASSERT_EQUAL_PTR(mutable_handle, nullptr); + return 0; +} + +void testcommandFillBuffer(void) +{ +#if defined(cl_khr_command_buffer) + cl_int ret = CL_INVALID_CONTEXT; + float pattern = 0; + size_t offset = 0; + size_t size = sizeof(pattern); + cl_sync_point_khr sync_point = 0; + cl::vector sync_points_vec = {sync_point}; + cl::MutableCommandKhr* mutable_handle = nullptr; + cl::CommandQueue* command_queue = nullptr; + + clCommandFillBufferKHR_StubWithCallback(clCommandFillBufferKHR_testcommandFillBuffer); + ret = commandBufferKhrPool[0].commandFillBuffer(bufferPool[0], pattern, offset, size, &sync_points_vec, + &sync_point, mutable_handle, command_queue); + TEST_ASSERT_EQUAL(ret, CL_SUCCESS); +#endif +} + // Tests for Device::GetInfo static cl_int clGetInfo_testDeviceGetInfoCLDeviceVendorId( cl_device_id device, cl_device_info param_name, size_t param_value_size, From bf69cb7c1e6bbb241a0dcb134b8c32fdbd177d11 Mon Sep 17 00:00:00 2001 From: piotr-wozniak-mobica Date: Thu, 14 Sep 2023 13:42:02 +0200 Subject: [PATCH 2/4] UT for commandFillImage --- tests/test_openclhpp.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index e40d93dc..3b65f384 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -408,6 +408,7 @@ void setUp(void) cl::pfn_clReleaseCommandBufferKHR = ::clReleaseCommandBufferKHR; cl::pfn_clGetCommandBufferInfoKHR = ::clGetCommandBufferInfoKHR; cl::pfn_clCommandFillBufferKHR = ::clCommandFillBufferKHR; + cl::pfn_clCommandFillImageKHR = ::clCommandFillImageKHR; #endif #if defined(cl_khr_semaphore) cl::pfn_clCreateSemaphoreWithPropertiesKHR = ::clCreateSemaphoreWithPropertiesKHR; @@ -486,6 +487,7 @@ void tearDown(void) cl::pfn_clReleaseCommandBufferKHR = nullptr; cl::pfn_clGetCommandBufferInfoKHR = nullptr; cl::pfn_clCommandFillBufferKHR = nullptr; + cl::pfn_clCommandFillImageKHR = nullptr; #endif #if defined(cl_khr_semaphore) cl::pfn_clCreateSemaphoreWithPropertiesKHR = nullptr; @@ -3613,7 +3615,6 @@ cl_int clCommandFillBufferKHR_testcommandFillBuffer(cl_command_buffer_khr comman { (void)size; (void)num_calls; - (void)sync_point; TEST_ASSERT_EQUAL(command_buffer,commandBufferKhrPool[0]()); TEST_ASSERT_EQUAL(buffer,bufferPool[0]()); TEST_ASSERT_EQUAL(pattern_size, sizeof(float)); @@ -3622,6 +3623,7 @@ cl_int clCommandFillBufferKHR_testcommandFillBuffer(cl_command_buffer_khr comman TEST_ASSERT_EQUAL(*(float*)pattern, 0); TEST_ASSERT_EQUAL(*sync_point_wait_list, 0); TEST_ASSERT_EQUAL_PTR(mutable_handle, nullptr); + TEST_ASSERT_NOT_EQUAL(sync_point, nullptr); return 0; } @@ -3644,6 +3646,41 @@ void testcommandFillBuffer(void) #endif } +static cl_int clcommandFillImageKHR_testcommandFillImage(cl_command_buffer_khr command_buffer, cl_command_queue command_queue, cl_mem image, const void* fill_color, +const size_t* origin, const size_t* region, cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, cl_sync_point_khr* sync_point, cl_mutable_command_khr* mutable_handle, int num_calls) +{ + (void)num_calls; + TEST_ASSERT_EQUAL(command_buffer, commandBufferKhrPool[0]()); + TEST_ASSERT_EQUAL_PTR(command_queue,nullptr); + TEST_ASSERT_EQUAL(origin[0], 16); + TEST_ASSERT_EQUAL(region[0], 512); + TEST_ASSERT_EQUAL(num_sync_points_in_wait_list, 1); + TEST_ASSERT_EQUAL(*sync_point_wait_list, 0); + TEST_ASSERT_EQUAL_PTR(mutable_handle, nullptr); + TEST_ASSERT_NOT_EQUAL(sync_point, nullptr); + return 0; +} + +void testcommandFillImage(void) +{ +#if defined(cl_khr_command_buffer) + cl_int ret = CL_INVALID_CONTEXT; + cl_float4 Color = { 0.5f, 0.75f, 1.0f, 1.0f }; + const std::array origin = {16, 32, 0}; + const std::array region = {512, 512, 0}; + cl_sync_point_khr sync_point = 0; + const cl::vector sync_points_vec = {sync_point}; + cl::MutableCommandKhr* mutable_handle = nullptr; + const cl::CommandQueue* command_queue = nullptr; + + clCommandFillImageKHR_StubWithCallback(clcommandFillImageKHR_testcommandFillImage); + ret = commandBufferKhrPool[0].commandFillImage(image2DPool[0], Color, origin, region, &sync_points_vec, + &sync_point, mutable_handle, command_queue); + TEST_ASSERT_EQUAL(ret, CL_SUCCESS); +#endif +} + // Tests for Device::GetInfo static cl_int clGetInfo_testDeviceGetInfoCLDeviceVendorId( cl_device_id device, cl_device_info param_name, size_t param_value_size, From 3e1b7f7abafb683661d0f0bf96ea2c874e153ecd Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Thu, 12 Oct 2023 13:19:30 +0200 Subject: [PATCH 3/4] UTs for commandFillBuffer, commandFillImage --- tests/test_openclhpp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index 3b65f384..4da07c19 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -3627,7 +3627,7 @@ cl_int clCommandFillBufferKHR_testcommandFillBuffer(cl_command_buffer_khr comman return 0; } -void testcommandFillBuffer(void) +void testCommandFillBuffer(void) { #if defined(cl_khr_command_buffer) cl_int ret = CL_INVALID_CONTEXT; @@ -3662,7 +3662,7 @@ const size_t* origin, const size_t* region, cl_uint num_sync_points_in_wait_list return 0; } -void testcommandFillImage(void) +void testCommandFillImage(void) { #if defined(cl_khr_command_buffer) cl_int ret = CL_INVALID_CONTEXT; From ad5ea8c78f2af3f6c7d0dc1931b7f1f6d7590522 Mon Sep 17 00:00:00 2001 From: Kamil Goras Date: Tue, 17 Oct 2023 13:58:45 +0200 Subject: [PATCH 4/4] Added corrections --- tests/test_openclhpp.cpp | 52 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp index 4da07c19..584bd244 100644 --- a/tests/test_openclhpp.cpp +++ b/tests/test_openclhpp.cpp @@ -3609,57 +3609,62 @@ void testCommandBufferInfoKHRCommandQueues(void) #endif } -cl_int clCommandFillBufferKHR_testcommandFillBuffer(cl_command_buffer_khr command_buffer, cl_command_queue command_queue, cl_mem buffer, - const void* pattern, size_t pattern_size, size_t offset, size_t size, cl_uint num_sync_points_in_wait_list, - const cl_sync_point_khr* sync_point_wait_list, cl_sync_point_khr* sync_point, cl_mutable_command_khr* mutable_handle, int num_calls) +static cl_int clCommandFillBufferKHR_testcommandFillBuffer(cl_command_buffer_khr command_buffer, cl_command_queue command_queue, cl_mem buffer, + const void* pattern, size_t pattern_size, size_t offset, size_t size, cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, cl_sync_point_khr* sync_point, cl_mutable_command_khr* mutable_handle, int num_calls) { - (void)size; + TEST_ASSERT_EQUAL(512, size); (void)num_calls; TEST_ASSERT_EQUAL(command_buffer,commandBufferKhrPool[0]()); - TEST_ASSERT_EQUAL(buffer,bufferPool[0]()); + TEST_ASSERT_EQUAL(buffer, bufferPool[0]()); TEST_ASSERT_EQUAL(pattern_size, sizeof(float)); TEST_ASSERT_EQUAL(offset, 0); - TEST_ASSERT_EQUAL(num_sync_points_in_wait_list, 1); - TEST_ASSERT_EQUAL(*(float*)pattern, 0); - TEST_ASSERT_EQUAL(*sync_point_wait_list, 0); + TEST_ASSERT_EQUAL(num_sync_points_in_wait_list, 2); + TEST_ASSERT_EQUAL(*(float*)pattern, 256); + TEST_ASSERT_EQUAL(sync_point_wait_list[0], 1); + TEST_ASSERT_EQUAL(sync_point_wait_list[1], 2); TEST_ASSERT_EQUAL_PTR(mutable_handle, nullptr); TEST_ASSERT_NOT_EQUAL(sync_point, nullptr); - return 0; + *sync_point = 5; + + return CL_SUCCESS; } void testCommandFillBuffer(void) { #if defined(cl_khr_command_buffer) cl_int ret = CL_INVALID_CONTEXT; - float pattern = 0; + float pattern = 256; size_t offset = 0; - size_t size = sizeof(pattern); + size_t size = 512; cl_sync_point_khr sync_point = 0; - cl::vector sync_points_vec = {sync_point}; - cl::MutableCommandKhr* mutable_handle = nullptr; - cl::CommandQueue* command_queue = nullptr; + cl::vector sync_points_vec = {1, 2}; clCommandFillBufferKHR_StubWithCallback(clCommandFillBufferKHR_testcommandFillBuffer); ret = commandBufferKhrPool[0].commandFillBuffer(bufferPool[0], pattern, offset, size, &sync_points_vec, - &sync_point, mutable_handle, command_queue); + &sync_point, nullptr, nullptr); TEST_ASSERT_EQUAL(ret, CL_SUCCESS); + TEST_ASSERT_EQUAL(5, sync_point); #endif } static cl_int clcommandFillImageKHR_testcommandFillImage(cl_command_buffer_khr command_buffer, cl_command_queue command_queue, cl_mem image, const void* fill_color, -const size_t* origin, const size_t* region, cl_uint num_sync_points_in_wait_list, - const cl_sync_point_khr* sync_point_wait_list, cl_sync_point_khr* sync_point, cl_mutable_command_khr* mutable_handle, int num_calls) + const size_t* origin, const size_t* region, cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, cl_sync_point_khr* sync_point, cl_mutable_command_khr* mutable_handle, int num_calls) { (void)num_calls; TEST_ASSERT_EQUAL(command_buffer, commandBufferKhrPool[0]()); TEST_ASSERT_EQUAL_PTR(command_queue,nullptr); TEST_ASSERT_EQUAL(origin[0], 16); TEST_ASSERT_EQUAL(region[0], 512); - TEST_ASSERT_EQUAL(num_sync_points_in_wait_list, 1); - TEST_ASSERT_EQUAL(*sync_point_wait_list, 0); + TEST_ASSERT_EQUAL(num_sync_points_in_wait_list, 2); + TEST_ASSERT_EQUAL(sync_point_wait_list[0], 1); + TEST_ASSERT_EQUAL(sync_point_wait_list[1], 4); TEST_ASSERT_EQUAL_PTR(mutable_handle, nullptr); TEST_ASSERT_NOT_EQUAL(sync_point, nullptr); - return 0; + *sync_point = 5; + + return CL_SUCCESS; } void testCommandFillImage(void) @@ -3670,14 +3675,13 @@ void testCommandFillImage(void) const std::array origin = {16, 32, 0}; const std::array region = {512, 512, 0}; cl_sync_point_khr sync_point = 0; - const cl::vector sync_points_vec = {sync_point}; - cl::MutableCommandKhr* mutable_handle = nullptr; - const cl::CommandQueue* command_queue = nullptr; + const cl::vector sync_points_vec = {1, 4}; clCommandFillImageKHR_StubWithCallback(clcommandFillImageKHR_testcommandFillImage); ret = commandBufferKhrPool[0].commandFillImage(image2DPool[0], Color, origin, region, &sync_points_vec, - &sync_point, mutable_handle, command_queue); + &sync_point, nullptr, nullptr); TEST_ASSERT_EQUAL(ret, CL_SUCCESS); + TEST_ASSERT_EQUAL(5, sync_point); #endif }