Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Ensure that RTDeviceBinaryImage instances have a unique image …
…ID (#12526) **Problem:** Currently, the image id of an RTDeviceBinaryImage instance is simply the pointer value of the underlying pi_device_binary (in [getImageID(](https://github.com/intel/llvm/blob/sycl/sycl/source/detail/device_binary_image.hpp#L221))). However, consider the following scenario: 1) We create a device image 2) Put into cache 3) Destroy the image (when it goes out of scope) 4) Create another image that _happens to be created at the same memory address_ (thus having same image ID) This causes two instances of RTDeviceBinaryImage to share the same image id, which ends up causing a collision in the KernelProgramCache. **Solution (Proposed in this PR)** Have a counter in RTDeviceBinaryImage that increments upon instantiation of this class. The counter value is added to the image id to ensure that no two instances have the same ID. **Alternative Solutions** 1. Remove the entry from the KernelProgramCache when the image is destroyed. This solution would require more work as the KernelProgramCache, currently, [does not support arbitrary element-wise eviction](https://github.com/intel/llvm/blob/sycl/sycl/doc/design/KernelProgramCache.md#in-memory-cache-eviction) (eviction follows a LRU strategy when cache size exceeds the threshold). Moreover, I expect this to have additional performance overhead of having to lock the cache and evicting. The proposed solution is much more simpler.
- Loading branch information