Define SubDevicesScopeGuarded in the harness and remove duplicate copies (#2379)

Signed-off-by: Kévin Petit <kpet@free.fr>
This commit is contained in:
Kévin Petit
2025-04-21 11:16:17 +01:00
committed by GitHub
parent 90524879e4
commit 9fc0d23b4c
5 changed files with 20 additions and 83 deletions

View File

@@ -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<cl_device_id> sub_devices;
};
#endif // _typeWrappers_h