Skip to content

Commit 2e0dbc1

Browse files
committed
removed invalidation logic
Signed-off-by: Byoungro So <[email protected]>
1 parent e2db14d commit 2e0dbc1

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -632,15 +632,6 @@ pi_result piDevicesGet(pi_platform Platform, pi_device_type DeviceType,
632632
// Get number of devices supporting Level Zero
633633
uint32_t ZeDeviceCount = 0;
634634
std::lock_guard<std::mutex> Lock(Platform->PiDevicesCacheMutex);
635-
// As soon as there was a call to piDeviceRelease(), the entire cache is
636-
// invalidated by setting the flag CacheInvalidated. We just need to
637-
// re-initialize cached pi_devices to reuse them.
638-
if (Platform->CacheInvalidated) {
639-
for (const pi_device CachedDevice : Platform->PiDevicesCache) {
640-
CachedDevice->initialize();
641-
}
642-
Platform->CacheInvalidated = false;
643-
}
644635
ZeDeviceCount = Platform->PiDevicesCache.size();
645636

646637
const bool AskingForGPU = (DeviceType & PI_DEVICE_TYPE_GPU);
@@ -710,19 +701,12 @@ pi_result piDeviceRelease(pi_device Device) {
710701
assert(Device);
711702
// TODO: OpenCL says root-device ref-count remains unchanged (1),
712703
// but when would we free the device's data?
713-
if (--(Device->RefCount) == 0) {
714-
// We invalidate the entire cache as soon as any device is released.
715-
// The saved pi_devices in cache is still intact but flag CacheInvalided
716-
// will not allow the entire cached devices to be reused without
717-
// re-initializing them.
718-
// TODO: This means the cached pi_device live until the program ends.
719-
// If L0 RT does not do its own cleanup for Ze_Device_Handle upon tear-down,
720-
// we need to figure out a way to call
721-
// ZE_CALL(zeCommandListDestroy(Device->ZeCommandListInit));
722-
pi_platform Platform = Device->Platform;
723-
std::lock_guard<std::mutex> Lock(Platform->PiDevicesCacheMutex);
724-
Platform->CacheInvalidated = true;
725-
}
704+
--(Device->RefCount);
705+
// TODO: All cached pi_devices live until the program ends.
706+
// If L0 RT does not do its own cleanup for Ze_Device_Handle upon tear-down,
707+
// we need to figure out a way to call here
708+
// ZE_CALL(zeCommandListDestroy(Device->ZeCommandListInit)); and,
709+
// in piDevicesGet(), we need to call initialize for each cached pi_device.
726710

727711
return PI_SUCCESS;
728712
}

sycl/plugins/level_zero/pi_level_zero.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ struct _pi_platform {
7474
// Cache pi_devices for reuse
7575
std::vector<pi_device> PiDevicesCache;
7676
std::mutex PiDevicesCacheMutex;
77-
// Flag to indicate PiDevicesCache is invalidated
78-
// This flag is used in piDeviceRelease to invalidate the entire cache
79-
// whenever there is a call to piDeviceRelease for any cached device.
80-
// This flag is used in piDevicesGet to reuse the cache
81-
// without expensive calls to L0 RT.
82-
bool CacheInvalidated = false;
8377
};
8478

8579
struct _pi_device : _pi_object {

0 commit comments

Comments
 (0)