-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Allow native OpenCL and L0 executable binaries in persistent cache #6256
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] Allow native OpenCL and L0 executable binaries in persistent cache #6256
Conversation
…cache These changes expand the persistent device code cache to allow executable binaries produced by IGC for both OpenCL and L0 to be cached. Signed-off-by: Larsen, Steffen <[email protected]>
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 not a numbers magician, so focusing on layout/readability/comments here :)
sycl/source/detail/pi.cpp
Outdated
RT::PiDeviceBinaryType getBinaryImageFormat(const unsigned char *ImgData, | ||
size_t ImgSize) { | ||
struct { | ||
RT::PiDeviceBinaryType Fmt; | ||
const uint32_t Magic; | ||
} Fmts[] = {{PI_DEVICE_BINARY_TYPE_SPIRV, 0x07230203}, | ||
{PI_DEVICE_BINARY_TYPE_LLVMIR_BITCODE, 0xDEC04342}}; | ||
{PI_DEVICE_BINARY_TYPE_LLVMIR_BITCODE, 0xDEC04342}, | ||
{PI_DEVICE_BINARY_TYPE_NATIVE, 0x43544E49}}; // INTC native |
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.
{PI_DEVICE_BINARY_TYPE_NATIVE, 0x43544E49}}; // INTC native | |
{PI_DEVICE_BINARY_TYPE_NATIVE, 0x43544E49}}; // 'I', 'N', 'T', 'C' ; Intel native |
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.
Maybe it would need an extra clang-format on top of the suggestion...
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 moved it above the definition as otherwise the formatting was awful.
sycl/source/detail/pi.cpp
Outdated
for (const auto &Fmt : Fmts) { | ||
if (Hdr == Fmt.Magic) | ||
return Fmt.Fmt; | ||
} | ||
|
||
// ELF files we need to be parsed separately. The header type ends at 18 |
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.
Something strange with the first sentence.
And possibly the 2nd better be written as "... ends after 18 bytes", but that one is up to you.
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.
You're right, that was not a very well constructed sentence. Better now?
sycl/source/detail/pi.cpp
Outdated
// ELF files we need to be parsed separately. The header type ends at 18 | ||
// bytes. | ||
if (Hdr == 0x464c457F && ImgSize >= 18) { | ||
detail::remove_const_t<decltype(ELFFmts[0].Magic)> HdrType = |
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 not sure how this type is better than auto
...
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.
Very good question. I just went with the same structure as the outer case, but it has been changed to uint16_t
as the return type of getELFHeaderType
is explicit anyway.
sycl/source/detail/pi.cpp
Outdated
{PI_DEVICE_BINARY_TYPE_LLVMIR_BITCODE, 0xDEC04342}, | ||
{PI_DEVICE_BINARY_TYPE_NATIVE, 0x43544E49}}; // INTC native | ||
|
||
struct { |
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.
Can we move this to line 722 please?
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.
Sure. It has been moved. It could potentially also be moved into the following check, though I further indentation may make it harder to read.
Signed-off-by: Larsen, Steffen <[email protected]>
intel#6256 changed the binary format used by the PersistentDeviceCodeCache tests to be a parameter, however the tests would be setting the format after the image had been initialized, which causes the image to think it is still the old format after changing the binary format of the PI image to the format read from the GTest parameter. With these changes the format will be set immediately from the parameter rather than deferring it to during setup. Additionally it fixes the SetUp and TearDown overrides. Signed-off-by: Larsen, Steffen <[email protected]>
#6256 changed the binary format used by the PersistentDeviceCodeCache tests to be a parameter, however the tests would be setting the format after the image had been initialized, which causes the image to think it is still the old format after changing the binary format of the PI image to the format read from the GTest parameter. With these changes the format will be set immediately from the parameter rather than deferring it to during setup. Additionally it fixes the SetUp and TearDown overrides. Signed-off-by: Larsen, Steffen <[email protected]>
Following the changes in intel#6256 this commit allows executable device binaries with ZEBIN format to be cached persistently. Signed-off-by: Larsen, Steffen <[email protected]>
Following the changes in #6256 this commit allows executable device binaries with ZEBIN format to be cached persistently. Signed-off-by: Larsen, Steffen <[email protected]>
These changes expand the persistent device code cache to allow executable binaries produced by IGC for both OpenCL and L0 to be cached.