Skip to content

[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

Merged

Conversation

steffenlarsen
Copy link
Contributor

These changes expand the persistent device code cache to allow executable binaries produced by IGC for both OpenCL and L0 to be cached.

…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]>
@steffenlarsen steffenlarsen requested a review from a team as a code owner June 6, 2022 16:22
@aelovikov-intel aelovikov-intel changed the title [SYCL] Allows native OpenCL and L0 executable binaries in persistent cache [SYCL] Allow native OpenCL and L0 executable binaries in persistent cache Jun 6, 2022
Copy link
Contributor

@aelovikov-intel aelovikov-intel left a 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 :)

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{PI_DEVICE_BINARY_TYPE_NATIVE, 0x43544E49}}; // INTC native
{PI_DEVICE_BINARY_TYPE_NATIVE, 0x43544E49}}; // 'I', 'N', 'T', 'C' ; Intel native

Copy link
Contributor

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...

Copy link
Contributor Author

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.

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
Copy link
Contributor

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.

Copy link
Contributor Author

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?

// 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 =
Copy link
Contributor

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...

Copy link
Contributor Author

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.

{PI_DEVICE_BINARY_TYPE_LLVMIR_BITCODE, 0xDEC04342},
{PI_DEVICE_BINARY_TYPE_NATIVE, 0x43544E49}}; // INTC native

struct {
Copy link
Contributor

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?

Copy link
Contributor Author

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]>
@pvchupin pvchupin merged commit f0283fc into intel:sycl Jun 7, 2022
steffenlarsen added a commit to steffenlarsen/llvm that referenced this pull request Jun 7, 2022
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]>
pvchupin pushed a commit that referenced this pull request Jun 7, 2022
#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]>
steffenlarsen added a commit to steffenlarsen/llvm that referenced this pull request Jun 15, 2022
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]>
pvchupin pushed a commit that referenced this pull request Jun 15, 2022
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]>
@steffenlarsen steffenlarsen deleted the steffen/persistent_cache_igc_execs branch December 6, 2023 11:38
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