Skip to content

[SYCL] Fix for native_specialization_constant() #9085

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
merged 11 commits into from
Apr 26, 2023

Conversation

KornevNikita
Copy link
Contributor

@KornevNikita KornevNikita commented Apr 17, 2023

If MBinImage is nullptr, it leads to SIGSEGV.
This patch fixes ProgramManager::link() function, so MBinImage will not be nullptr.
Also changes link() signature to accept a single device image instead of vector,
because we use it to pass the vector of one image, so it makes no sense.

@KornevNikita KornevNikita requested a review from a team as a code owner April 17, 2023 14:55
@@ -112,6 +112,8 @@ class device_image_impl {
bool all_specialization_constant_native() const noexcept {
// Specialization constants are natively supported in JIT mode on backends,
// that are using SPIR-V as IR
if (!MBinImage)
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this actually always the correct value to return here? Looking at the test example, shouldn't it depend on the binary image used for this? It seems like the actual issue is that we're losing track of this information after compile & link. Am I missing something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original issue is segmentation fault because of quering nullptr: MBinImage->getRawData() - I thought MBinImage was meant to be nullptr, and we just need to check it. Do you think it shouldn't?

BTW yes, native_specialization_constant() depends on the binary image.

Copy link
Contributor

Choose a reason for hiding this comment

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

MBinImage might have been meant to be nullptr in this "input -> compile -> link" case in terms of its other uses in the code, but then checking it like that doesn't seem to be sufficient for native_specialization_constant(). I would expect native_specialization_constant() to return true in the added test case if it was true for the original input kernel_bundle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I tried to preserve BinImage during the linking so there is no nullptr. Looks like it works, but need to get CI results 16bfd69

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, CI passed. I'm wondering if we should do something in case MBinImage is nullptr - should there be an assert/exception?

Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly, an assertion won't do because we can still have a nullptr MBinImage if the kernel bundle is created via interop, so that case should be handled as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I made some experiments, and I'm not sure if such case is even possible now, as the only one way to get the interop bundle - use make_kernel(), but is it possible to use spec constant with such kernel? I made a plug for now.

@KornevNikita KornevNikita temporarily deployed to aws April 17, 2023 18:15 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 17, 2023 20:06 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 19, 2023 16:12 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 19, 2023 19:15 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 20, 2023 10:30 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 20, 2023 12:42 — with GitHub Actions Inactive
@KornevNikita KornevNikita changed the title [SYCL] Tiny fix for native_specialization_constant() [SYCL] Fix for native_specialization_constant() Apr 20, 2023
@KornevNikita KornevNikita temporarily deployed to aws April 20, 2023 19:04 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 20, 2023 23:36 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 21, 2023 12:27 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 21, 2023 13:49 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 21, 2023 14:47 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 21, 2023 15:49 — with GitHub Actions Inactive
@KornevNikita
Copy link
Contributor Author

TEST 'SYCL :: Regression/same_unnamed_kernels.cpp' is unrelated

@KornevNikita
Copy link
Contributor Author

@sergey-semenov take one more look, please.
@intel/sycl-language-enabling-triage take a look please

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.

Small nit, but otherwise it LGTM.

@KornevNikita KornevNikita temporarily deployed to aws April 25, 2023 13:14 — with GitHub Actions Inactive
@KornevNikita KornevNikita temporarily deployed to aws April 25, 2023 14:58 — with GitHub Actions Inactive
@steffenlarsen
Copy link
Contributor

Failed Tests (1):
SYCL :: Regression/same_unnamed_kernels.cpp - Reported in #9174. Test has since been disabled.

@steffenlarsen steffenlarsen merged commit 41344ed into intel:sycl Apr 26, 2023
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