Skip to content

Commit c49d494

Browse files
[SYCL] Fix USM free for descendent devices (#6733)
Now that use of descendent devices of context members is supported, we cannot rely on always choosing the only device in single-device contexts. Remove this branch to always fetch the device from the platform.
1 parent 0f4a0f3 commit c49d494

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8173,15 +8173,10 @@ static pi_result USMFreeHelper(pi_context Context, void *Ptr,
81738173
PI_ERROR_INVALID_DEVICE);
81748174
} else {
81758175
pi_device Device;
8176-
if (Context->Devices.size() == 1) {
8177-
Device = Context->Devices[0];
8178-
PI_ASSERT(Device->ZeDevice == ZeDeviceHandle, PI_ERROR_INVALID_DEVICE);
8179-
} else {
8180-
// All devices in the context are of the same platform.
8181-
auto Platform = Context->getPlatform();
8182-
Device = Platform->getDeviceFromNativeHandle(ZeDeviceHandle);
8183-
PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE);
8184-
}
8176+
// All context member devices or their descendants are of the same platform.
8177+
auto Platform = Context->getPlatform();
8178+
Device = Platform->getDeviceFromNativeHandle(ZeDeviceHandle);
8179+
PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE);
81858180

81868181
auto DeallocationHelper =
81878182
[Context, Device, Ptr, OwnZeMemHandle](

0 commit comments

Comments
 (0)