-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[Offload] Erase entries from JIT cache when program is destroyed #148847
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -854,6 +854,9 @@ Error GenericDeviceTy::unloadBinary(DeviceImageTy *Image) { | |
return Err; | ||
} | ||
|
||
if (Image->getTgtImageBitcode()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forget how this works, we have the image passed in by the user and the one created by the backend right? I'm wondering if we should just check the magic bytes there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are compiling bitcode, then this will be set to a |
||
Plugin.getJIT().erase(*Image->getTgtImageBitcode(), Image->getDevice()); | ||
|
||
return unloadBinaryImpl(Image); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow in what cases this
Image
is not a unique one?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data Image points to happens to be inside
ol_program_impl_t
, but something similar to this:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the image can be created on the fly. In that case, we probably still want to cache that, but use a different key that can effectively tell the two images apart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JIT engine uses the Image address to identify input images; once the Image is dropped, we lose the ability to look it up in the cache, so there's no reason to keep the entry around. What use case are you thinking of?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but your case demonstrates that image address could be not unique, even for the "same" image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the image pointer is actually alive, it's a unique identifier for the JIT'ed binary. The issue only happens once the input image is free'd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-reading this thread and I think I worded things a bit confusingly; by "Image address" I mean
&Image
rather thanImage->ImageStart
.I'm not sure there's a key that we can use to uniquely identify Images across create/destroy boundaries, nor can I see a use case for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A SHA value based on the contents of the image could do it. In that way, even the image "handler" can be created and destroyed multiple times, the contents of the image is expected to be the same.
I'll not be the blocker here. This is less ideal but I'm fine with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to seriously rework the image handling as whole.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still unsure of why we need to keep them around after the backing image has been dropped. I can't see the user constantly recreating the same buffer many times with the same contents and expecting high performance.