From 5cba00ce248c1983ba88de507379379f6ab33324 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 9 Apr 2024 15:12:54 +0200 Subject: [PATCH 1/7] Added new query for semaphores test to verify device handle list --- .../cl_khr_semaphore/test_semaphores.cpp | 68 ++++++++++++++++--- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp index 36bb8ad5c8..3d2ccdb165 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #define FLUSH_DELAY_S 5 @@ -115,7 +116,7 @@ static int semaphore_cross_queue_helper(cl_device_id deviceID, &wait_event); test_error(err, "Could not wait semaphore"); - // Finish queue_1 and queue_2 + // Finish queue_1 and queue_2 err = clFinish(queue_1); test_error(err, "Could not finish queue"); @@ -133,7 +134,7 @@ static int semaphore_cross_queue_helper(cl_device_id deviceID, return TEST_PASS; } -// Confirm that a signal followed by a wait will complete successfully +// Confirm that a signal followed by a wait will complete successfully int test_semaphores_simple_1(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { @@ -586,9 +587,39 @@ int test_semaphores_multi_wait(cl_device_id deviceID, cl_context context, int test_semaphores_queries(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - cl_int err; + cl_int err = CL_SUCCESS; - if (!is_extension_available(deviceID, "cl_khr_semaphore")) + cl_platform_id platform_id = 0; + cl_uint num_devices = 0; + // find out what platform the harness is using. + err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), + &platform_id, nullptr); + test_error(err, "clGetDeviceInfo failed"); + + err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 0, nullptr, + &num_devices); + test_error(err, "clGetDeviceIDs failed"); + + std::vector devices(num_devices); + cl_device_id capable_device = deviceID; + + err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, num_devices, + &devices[0], nullptr); + test_error(err, "clGetDeviceIDs failed"); + + // if possible use device other than the one from harness + for (size_t i = 0; i < devices.size(); ++i) + { + if (deviceID != devices[i] + && is_extension_available(capable_device, "cl_khr_semaphore")) + { + capable_device = devices[i]; + break; + } + } + + if (deviceID == capable_device + && !is_extension_available(capable_device, "cl_khr_semaphore")) { log_info("cl_khr_semaphore is not supported on this platoform. " "Skipping test.\n"); @@ -596,15 +627,19 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, } // Obtain pointers to semaphore's API - GET_PFN(deviceID, clCreateSemaphoreWithPropertiesKHR); - GET_PFN(deviceID, clGetSemaphoreInfoKHR); - GET_PFN(deviceID, clRetainSemaphoreKHR); - GET_PFN(deviceID, clReleaseSemaphoreKHR); + GET_PFN(capable_device, clCreateSemaphoreWithPropertiesKHR); + GET_PFN(capable_device, clGetSemaphoreInfoKHR); + GET_PFN(capable_device, clRetainSemaphoreKHR); + GET_PFN(capable_device, clReleaseSemaphoreKHR); // Create binary semaphore cl_semaphore_properties_khr sema_props[] = { static_cast(CL_SEMAPHORE_TYPE_KHR), static_cast(CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)capable_device, + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, 0 }; cl_semaphore_khr sema = @@ -623,6 +658,11 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, // value SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 1); + // Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns the + // same device id the semaphore was created with + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id, + capable_device); + err = clRetainSemaphoreKHR(sema); test_error(err, "Could not retain semaphore"); SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 2); @@ -633,8 +673,14 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, // Confirm that querying CL_SEMAPHORE_PROPERTIES_KHR returns the same // properties the semaphore was created with - SEMAPHORE_PARAM_TEST_ARRAY(CL_SEMAPHORE_PROPERTIES_KHR, - cl_semaphore_properties_khr, 3, sema_props); + size_t size; + err = clGetSemaphoreInfoKHR(sema, CL_SEMAPHORE_PROPERTIES_KHR, 0, nullptr, + &size); + test_error(err, "Unable to get CL_SEMAPHORE_PROPERTIES_KHR from semaphore"); + + SEMAPHORE_PARAM_TEST_ARRAY( + CL_SEMAPHORE_PROPERTIES_KHR, cl_semaphore_properties_khr, + size / sizeof(cl_semaphore_properties_khr), sema_props); // Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the unsignaled // state @@ -745,4 +791,4 @@ int test_semaphores_import_export_fd(cl_device_id deviceID, cl_context context, err = clReleaseSemaphoreKHR(sema_2); test_error(err, "Could not release semaphore"); return TEST_PASS; -} \ No newline at end of file +} From 5f0cb00f40ffe045df720e3465da8f5efd58e233 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 9 Apr 2024 15:38:55 +0200 Subject: [PATCH 2/7] Correction for extected macro argument --- .../extensions/cl_khr_semaphore/test_semaphores.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp index 3d2ccdb165..101eb7c0ee 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp @@ -673,14 +673,8 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, // Confirm that querying CL_SEMAPHORE_PROPERTIES_KHR returns the same // properties the semaphore was created with - size_t size; - err = clGetSemaphoreInfoKHR(sema, CL_SEMAPHORE_PROPERTIES_KHR, 0, nullptr, - &size); - test_error(err, "Unable to get CL_SEMAPHORE_PROPERTIES_KHR from semaphore"); - - SEMAPHORE_PARAM_TEST_ARRAY( - CL_SEMAPHORE_PROPERTIES_KHR, cl_semaphore_properties_khr, - size / sizeof(cl_semaphore_properties_khr), sema_props); + SEMAPHORE_PARAM_TEST_ARRAY(CL_SEMAPHORE_PROPERTIES_KHR, + cl_semaphore_properties_khr, 5, sema_props); // Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the unsignaled // state From 1dfd7fdcd6034b85d4fd391c619d9b90bc871d1c Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Thu, 11 Apr 2024 19:37:51 +0200 Subject: [PATCH 3/7] Corrections related to code review --- .../extensions/cl_khr_semaphore/test_semaphores.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp index 101eb7c0ee..45fda5dc7c 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp @@ -604,16 +604,16 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, cl_device_id capable_device = deviceID; err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, num_devices, - &devices[0], nullptr); + devices.data(), nullptr); test_error(err, "clGetDeviceIDs failed"); // if possible use device other than the one from harness - for (size_t i = 0; i < devices.size(); ++i) + for (auto device : devices) { - if (deviceID != devices[i] + if (deviceID != device && is_extension_available(capable_device, "cl_khr_semaphore")) { - capable_device = devices[i]; + capable_device = device; break; } } From 9bcb1229d234eae1485aeaed7eaf89e13c4bf4ee Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Mon, 22 Apr 2024 10:56:38 +0200 Subject: [PATCH 4/7] correction related to code review --- .../cl_khr_semaphore/test_semaphores.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp index 45fda5dc7c..5ad08e1d49 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp @@ -83,7 +83,7 @@ static int semaphore_cross_queue_helper(cl_device_id deviceID, if (!is_extension_available(deviceID, "cl_khr_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -142,7 +142,7 @@ int test_semaphores_simple_1(cl_device_id deviceID, cl_context context, if (!is_extension_available(deviceID, "cl_khr_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -204,7 +204,7 @@ int test_semaphores_simple_2(cl_device_id deviceID, cl_context context, if (!is_extension_available(deviceID, "cl_khr_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -296,7 +296,7 @@ int test_semaphores_reuse(cl_device_id deviceID, cl_context context, if (!is_extension_available(deviceID, "cl_khr_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -439,7 +439,7 @@ int test_semaphores_multi_signal(cl_device_id deviceID, cl_context context, if (!is_extension_available(deviceID, "cl_khr_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -515,7 +515,7 @@ int test_semaphores_multi_wait(cl_device_id deviceID, cl_context context, if (!is_extension_available(deviceID, "cl_khr_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -621,7 +621,7 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, if (deviceID == capable_device && !is_extension_available(capable_device, "cl_khr_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -696,7 +696,7 @@ int test_semaphores_import_export_fd(cl_device_id deviceID, cl_context context, if (!is_extension_available(deviceID, "cl_khr_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -704,7 +704,7 @@ int test_semaphores_import_export_fd(cl_device_id deviceID, cl_context context, if (!is_extension_available(deviceID, "cl_khr_external_semaphore_sync_fd")) { log_info("cl_khr_external_semaphore_sync_fd is not supported on this " - "platoform. Skipping test.\n"); + "platform. Skipping test.\n"); return TEST_SKIPPED_ITSELF; } From f47e7430f23e03204033546c625990997487e97a Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 23 Apr 2024 17:44:33 +0200 Subject: [PATCH 5/7] corrected device id while testing extension --- .../extensions/cl_khr_semaphore/test_semaphores.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp index 5ad08e1d49..0942eac414 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp @@ -611,7 +611,7 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, for (auto device : devices) { if (deviceID != device - && is_extension_available(capable_device, "cl_khr_semaphore")) + && is_extension_available(device, "cl_khr_semaphore")) { capable_device = device; break; From d7b3edc21aceb03abdc04565fa99d09ad12b90a2 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 28 May 2024 09:52:15 +0200 Subject: [PATCH 6/7] Correction related to code review --- .../extensions/cl_khr_semaphore/test_semaphores.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp index 0942eac414..ac8c81b541 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp @@ -674,7 +674,7 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, // Confirm that querying CL_SEMAPHORE_PROPERTIES_KHR returns the same // properties the semaphore was created with SEMAPHORE_PARAM_TEST_ARRAY(CL_SEMAPHORE_PROPERTIES_KHR, - cl_semaphore_properties_khr, 5, sema_props); + cl_semaphore_properties_khr, 6, sema_props); // Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the unsignaled // state From 367ea9fec0bb0e4d0ff4e8e024f6061733700ce4 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Mon, 3 Jun 2024 08:57:34 +0200 Subject: [PATCH 7/7] Correction related to code review --- .../cl_khr_semaphore/test_semaphores.cpp | 44 +++---------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp index ac8c81b541..ec4f752b0b 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp @@ -589,37 +589,7 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, { cl_int err = CL_SUCCESS; - cl_platform_id platform_id = 0; - cl_uint num_devices = 0; - // find out what platform the harness is using. - err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), - &platform_id, nullptr); - test_error(err, "clGetDeviceInfo failed"); - - err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 0, nullptr, - &num_devices); - test_error(err, "clGetDeviceIDs failed"); - - std::vector devices(num_devices); - cl_device_id capable_device = deviceID; - - err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, num_devices, - devices.data(), nullptr); - test_error(err, "clGetDeviceIDs failed"); - - // if possible use device other than the one from harness - for (auto device : devices) - { - if (deviceID != device - && is_extension_available(device, "cl_khr_semaphore")) - { - capable_device = device; - break; - } - } - - if (deviceID == capable_device - && !is_extension_available(capable_device, "cl_khr_semaphore")) + if (!is_extension_available(deviceID, "cl_khr_semaphore")) { log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); @@ -627,10 +597,10 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, } // Obtain pointers to semaphore's API - GET_PFN(capable_device, clCreateSemaphoreWithPropertiesKHR); - GET_PFN(capable_device, clGetSemaphoreInfoKHR); - GET_PFN(capable_device, clRetainSemaphoreKHR); - GET_PFN(capable_device, clReleaseSemaphoreKHR); + GET_PFN(deviceID, clCreateSemaphoreWithPropertiesKHR); + GET_PFN(deviceID, clGetSemaphoreInfoKHR); + GET_PFN(deviceID, clRetainSemaphoreKHR); + GET_PFN(deviceID, clReleaseSemaphoreKHR); // Create binary semaphore cl_semaphore_properties_khr sema_props[] = { @@ -638,7 +608,7 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, static_cast(CL_SEMAPHORE_TYPE_BINARY_KHR), static_cast( CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), - (cl_semaphore_properties_khr)capable_device, + (cl_semaphore_properties_khr)deviceID, CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, 0 }; @@ -661,7 +631,7 @@ int test_semaphores_queries(cl_device_id deviceID, cl_context context, // Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns the // same device id the semaphore was created with SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id, - capable_device); + deviceID); err = clRetainSemaphoreKHR(sema); test_error(err, "Could not retain semaphore");