@@ -632,15 +632,6 @@ pi_result piDevicesGet(pi_platform Platform, pi_device_type DeviceType,
632
632
// Get number of devices supporting Level Zero
633
633
uint32_t ZeDeviceCount = 0 ;
634
634
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
- }
644
635
ZeDeviceCount = Platform->PiDevicesCache .size ();
645
636
646
637
const bool AskingForGPU = (DeviceType & PI_DEVICE_TYPE_GPU);
@@ -710,19 +701,12 @@ pi_result piDeviceRelease(pi_device Device) {
710
701
assert (Device);
711
702
// TODO: OpenCL says root-device ref-count remains unchanged (1),
712
703
// 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.
726
710
727
711
return PI_SUCCESS;
728
712
}
0 commit comments