Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Ensure that RTDeviceBinaryImage instances have a unique image ID #12526

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

uditagarwal97
Copy link
Contributor

@uditagarwal97 uditagarwal97 commented Jan 29, 2024

Problem:

Currently, the image id of an RTDeviceBinaryImage instance is simply the pointer value of the underlying pi_device_binary (in getImageID()). 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 (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.

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@steffenlarsen steffenlarsen merged commit 04ff5b8 into intel:sycl Jan 31, 2024
12 checks passed
@uditagarwal97 uditagarwal97 deleted the fix_multiple_kernel branch March 21, 2024 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants