-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL] Disallow passing kernel by value for sycl_kernel attribute #15702
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
base: sycl
Are you sure you want to change the base?
Conversation
clang/lib/Sema/SemaSYCL.cpp
Outdated
|
||
// SYCL 1.2.1 | ||
return KernelParamTy.getUnqualifiedType(); | ||
assert(KernelParamTy->isReferenceType() && "Since SYCL 2020 kernels must be passed by reference."); |
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 fan of the assert message. I think you can just say kernel must be passed by reference.
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've changed it back. It seems like this assert gets hit before we issue a proper diagnostic for this kind of misuse.
clang/lib/Sema/SemaSYCL.cpp
Outdated
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); |
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.
If we still have a diagnostic for deprecation for this case, you cannot assert in GetSYCLKernelObjectType
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'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.
Signed-off-by: Larsen, Steffen <[email protected]>
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.
esimd test changes lgtm
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.