Skip to content

Commit 02d4a8d

Browse files
authored
[UR] Retain and release device handles for sub-devices (#17977)
Follow up from #17931, additional fix for URT-903.
1 parent 010c310 commit 02d4a8d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

unified-runtime/source/adapters/opencl/device.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ struct ur_device_handle_t_ {
2828
RefCount = 1;
2929
if (Parent) {
3030
Type = Parent->Type;
31+
[[maybe_unused]] auto Res = clRetainDevice(CLDevice);
32+
assert(Res == CL_SUCCESS);
3133
} else {
3234
[[maybe_unused]] auto Res = clGetDeviceInfo(
3335
CLDevice, CL_DEVICE_TYPE, sizeof(cl_device_type), &Type, nullptr);
@@ -41,6 +43,8 @@ struct ur_device_handle_t_ {
4143
// exactly once. However, to prevent issues with the OpenCL handle being
4244
// reused, CLDevice must still be alive here.
4345
Platform->SubDevices.erase(CLDevice);
46+
[[maybe_unused]] auto Res = clReleaseDevice(CLDevice);
47+
assert(Res == CL_SUCCESS);
4448
}
4549
if (ParentDevice && IsNativeHandleOwned) {
4650
clReleaseDevice(CLDevice);

0 commit comments

Comments
 (0)