From 9fc0d23b4cfccd84be8927363a77107dc554de30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Petit?= Date: Mon, 21 Apr 2025 11:16:17 +0100 Subject: [PATCH] Define SubDevicesScopeGuarded in the harness and remove duplicate copies (#2379) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Petit --- test_common/harness/typeWrappers.h | 20 ++++++++++++++++ test_conformance/api/testBase.h | 20 ---------------- test_conformance/compiler/testBase.h | 23 ------------------- .../cl_khr_semaphore/semaphore_base.h | 20 ---------------- .../test_semaphores_negative_wait_signal.cpp | 20 ---------------- 5 files changed, 20 insertions(+), 83 deletions(-) diff --git a/test_common/harness/typeWrappers.h b/test_common/harness/typeWrappers.h index ad11b480..ef57f6d7 100644 --- a/test_common/harness/typeWrappers.h +++ b/test_common/harness/typeWrappers.h @@ -377,4 +377,24 @@ public: size_t getSize() const { return allocsize; }; }; +// scope guard helper to ensure proper releasing of sub devices +struct SubDevicesScopeGuarded +{ + SubDevicesScopeGuarded(const cl_int dev_count) + { + sub_devices.resize(dev_count); + } + ~SubDevicesScopeGuarded() + { + for (auto &device : sub_devices) + { + cl_int err = clReleaseDevice(device); + if (err != CL_SUCCESS) + log_error("\n Releasing sub-device failed \n"); + } + } + + std::vector sub_devices; +}; + #endif // _typeWrappers_h diff --git a/test_conformance/api/testBase.h b/test_conformance/api/testBase.h index beb3c924..02f76e94 100644 --- a/test_conformance/api/testBase.h +++ b/test_conformance/api/testBase.h @@ -27,24 +27,4 @@ #include #include -// scope guard helper to ensure proper releasing of sub devices -struct SubDevicesScopeGuarded -{ - SubDevicesScopeGuarded(const cl_int dev_count) - { - sub_devices.resize(dev_count); - } - ~SubDevicesScopeGuarded() - { - for (auto &device : sub_devices) - { - cl_int err = clReleaseDevice(device); - if (err != CL_SUCCESS) - log_error("\n Releasing sub-device failed \n"); - } - } - - std::vector sub_devices; -}; - #endif // _testBase_h diff --git a/test_conformance/compiler/testBase.h b/test_conformance/compiler/testBase.h index 70c42b5d..9a9591b7 100644 --- a/test_conformance/compiler/testBase.h +++ b/test_conformance/compiler/testBase.h @@ -45,27 +45,4 @@ } -// scope guard helper to ensure proper releasing of sub devices -struct SubDevicesScopeGuarded -{ - SubDevicesScopeGuarded(const cl_int dev_count) - { - sub_devices.resize(dev_count); - } - ~SubDevicesScopeGuarded() - { - for (auto &device : sub_devices) - { - cl_int err = clReleaseDevice(device); - if (err != CL_SUCCESS) - log_error("\n Releasing sub-device failed \n"); - } - } - - std::vector sub_devices; -}; - #endif // _testBase_h - - - diff --git a/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h b/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h index 6e88b22c..372bdd1e 100644 --- a/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h +++ b/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h @@ -24,26 +24,6 @@ #include "harness/testHarness.h" #include "harness/typeWrappers.h" -// scope guard helper to ensure proper releasing of sub devices -struct SubDevicesScopeGuarded -{ - SubDevicesScopeGuarded(const cl_int dev_count) - { - sub_devices.resize(dev_count); - } - ~SubDevicesScopeGuarded() - { - for (auto &device : sub_devices) - { - cl_int err = clReleaseDevice(device); - if (err != CL_SUCCESS) - log_error("\n Releasing sub-device failed \n"); - } - } - - std::vector sub_devices; -}; - struct SemaphoreBase { SemaphoreBase(cl_device_id device): device(device) {} diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait_signal.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait_signal.cpp index 9e0ed193..8087c703 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait_signal.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait_signal.cpp @@ -30,26 +30,6 @@ enum class RunMode RM_SIGNAL }; -// scope guard helper to ensure proper releasing of sub devices -struct SubDevicesScopeGuarded -{ - SubDevicesScopeGuarded(const cl_int dev_count) - { - sub_devices.resize(dev_count); - } - ~SubDevicesScopeGuarded() - { - for (auto& device : sub_devices) - { - cl_int err = clReleaseDevice(device); - if (err != CL_SUCCESS) - log_error("\n Releasing sub-device failed \n"); - } - } - - std::vector sub_devices; -}; - // the device associated with command_queue is not same as one of the devices // specified by CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR at the time of creating one // or more of sema_objects.