Skip to content

Conversation

AndreiZibrov
Copy link
Contributor

@AndreiZibrov AndreiZibrov commented Oct 15, 2024

Previously (SYCL 1.2.1) kernel functions could be passed by value to sycl_kernel annotated functions. However, this functionality has been deprecated for a while and the runtime no longer has any interfaces allowing by-value kernel function passing. As such, we can be stricter about this argument requirement.


// SYCL 1.2.1
return KernelParamTy.getUnqualifiedType();
assert(KernelParamTy->isReferenceType() && "Since SYCL 2020 kernels must be passed by reference.");
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 a fan of the assert message. I think you can just say kernel must be passed by reference.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've changed it back. It seems like this assert gets hit before we issue a proper diagnostic for this kind of misuse.

if (! KernelParamTy->isReferenceType()) {
// passing by value. emit warning if using SYCL 2020 or greater
if (SemaRef.LangOpts.getSYCLVersion() >= LangOptions::SYCL_2020)
Diag(KernelFunc->getLocation(), diag::warn_sycl_pass_by_value_deprecated);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we still have a diagnostic for deprecation for this case, you cannot assert in GetSYCLKernelObjectType

Copy link
Contributor

Choose a reason for hiding this comment

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

I've changed this to be an error. That said, even with it being an error, it is still checked later than the assert, so I am still on the side of no assertions.

@steffenlarsen steffenlarsen requested review from a team as code owners July 29, 2025 13:58
@steffenlarsen steffenlarsen changed the title [SYCL] passing kernel by reference [SYCL] Disallow passing kernel by value for sycl_kernel attribute Jul 29, 2025
Signed-off-by: Larsen, Steffen <[email protected]>
Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

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

esimd test changes lgtm

@sarnex sarnex requested a review from a team July 29, 2025 15:07
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.

5 participants