-
Notifications
You must be signed in to change notification settings - Fork 744
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] disallow mutable lambdas #1785
[SYCL] disallow mutable lambdas #1785
Conversation
@vzakhari, @Pennycook: could you please answer here? |
@AlexeySachkov, did you want to contact @v-klochkov instead of me? |
I think the interfaces should be consistent. If |
@cperkinsintel Please, click on "ready for review" button once it's ready for review. |
1eada98
to
15c522e
Compare
7887e98
to
52a534d
Compare
It the result of mis-click (accidentally clicked 'Ready for review' button, which did not ask for any confirmations after the click). |
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 don't think changing all the tests in the CFE is the right idea. While I am fine fixing a bunch of them, we should still ensure the old behavior still works. This many file changes is likely unnecessary and just distracting review-wise.
Additionally, I think we should warn in both cases based on the SYCL version. So in 1.2.1, we should warn like we do with other language compatibility items (such as allowing C++11 features in 03, etc). In the newer one, we should warn to change it.
clang/lib/Sema/SemaSYCL.cpp
Outdated
@@ -730,7 +730,13 @@ getKernelInvocationKind(FunctionDecl *KernelCallerFunc) { | |||
} | |||
|
|||
static CXXRecordDecl *getKernelObjectType(FunctionDecl *Caller) { | |||
return (*Caller->param_begin())->getType()->getAsCXXRecordDecl(); | |||
auto KernelParam = (*Caller->param_begin()); |
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.
auto KernelParam = (*Caller->param_begin()); | |
auto KernelParamTy = (*Caller->param_begin())->getType(); |
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.
thanks for catching that. Done.
@erichkeane - There is a test that ensures that the SYCL 1.2 and SYCL 2020 versions are both supported: clang/test/CodeGenSYCL/kernel-by-reference.cpp Also I agree about emitting a warning. But that seems out-of-scope for this change. How does the clang front end want to handle different versions of the SYCL runtime headers? Is this the only place we'll encounter differences? I think opening a ticket for it might be better. |
I would think it is exactly in scope of this change, but I'll leave that to the code owners to make that decision. Since we have a test that makes sure both works, I don't really see much value in changing the other 100+ tests, but I'll again leave that to the code owners to decide. |
This adds const-correctness to a bit of the visitor, as brought up in review on intel#1785.
This adds const-correctness to a bit of the visitor, as brought up in review on #1785.
02d8f7c
to
29ffe63
Compare
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 OK with the runtime part.
@Fznamznon @elizabethandrews @premanandrao as code owners of the front-end, could one of you review that side of it? I had to update all those ersatz test kernels to bring them up to date with the new const-ref requirement on their lambdas. That touches a lot files, but the change is trivial, just avoids deferred maintenance. Other than that, the FE changes are very small. |
I am fine with the source code changes; it is just the volume of test changes that I was uncomfortable with. |
Signed-off-by: Chris Perkins <[email protected]>
Signed-off-by: Chris Perkins <[email protected]>
Signed-off-by: Chris Perkins <[email protected]>
Signed-off-by: Chris Perkins <[email protected]>
bfd5f8b
to
000286a
Compare
I've rebased, updated the conflicted test, and incorporated in @erichkeane latest request. Should be good to go. |
… generate some more discussion Signed-off-by: Chris Perkins <[email protected]>
Signed-off-by: Chris Perkins <[email protected]>
Signed-off-by: Chris Perkins <[email protected]>
Signed-off-by: Chris Perkins <[email protected]>
@erichkeane - Ok, I've added the second diagnostic, moved the emitting of it to its own function called from |
@@ -1127,7 +1127,9 @@ def OpenMP : DiagGroup<"openmp", [ | |||
]>; | |||
|
|||
// SYCL warnings | |||
def SyclStrict : DiagGroup<"sycl-strict">; | |||
def Sycl2017Conform : DiagGroup<"sycl-2017-conform">; |
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.
perhaps sycl-2017-compat to be more consistent with c++98-compat, et al?
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.
yes, good call. Done.
clang/lib/Sema/SemaSYCL.cpp
Outdated
@@ -1948,6 +1971,7 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc, | |||
if (LC.capturesThis() && LC.isImplicit()) | |||
Diag(LC.getLocation(), diag::err_implicit_this_capture); | |||
} | |||
diagKernelCallerSpecConformance(*this, KernelCallerFunc); |
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.
The comment I had made in the past was to move the checks from 1969 into their own function as soon as we had a 2nd thing to check. So please make 1 function that checks both:
checkKernel? Anyone wanna bikeshed for me? @elizabethandrews @premanandrao ?
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.
checkKernelParameters?
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.
checkKernelAndCaller ?
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.
checkKernelCompat ?
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.
checkKernelParameters?
Its not really the Parameters, to the kernel, its the kernel object itself (plus the caller).
checkKernelAndCaller ?
Probably good enough for now. Presumably someone will come up with a better idea in the future and we can rename it.
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.
done.
Signed-off-by: Chris Perkins <[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.
2 nits, otherwise LGTM.
} | ||
|
||
// check that calling kernel conforms to spec | ||
QualType KernelParamTy = (*Caller->param_begin())->getType(); |
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.
Probably want an assert here that Caller->param_size() >=1.
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.
done
Signed-off-by: Chris Perkins <[email protected]>
This reverts commit a43dcc2.
…rogram * upstream/sycl: (609 commits) [SYCL] Fix fail in the post commit testing (intel#2210) [SYCL] Materialize shadow local variables for byval arguments before use (intel#2200) [SYCL] Support lambda functions passed to reduction (intel#2190) [SYCL][USM] Improve USM Allocator. (intel#2026) [SYCL] Disallow mutable lambdas (intel#1785) [SYCL][ESIMD] Setup compilation pipeline for ESIMD (intel#2134) [SYCL] Fix not found kernel due to empty kernel name when using set_arg(s) (intel#2181) [SYCL] Fixed check for set_arg (intel#2203) Refactor indirect access calls to minimize invocations. (intel#2185) [SYCL][NFC] Fix potential null-pointer access (intel#2197) [SYCL] Propagate attributes from transitive calls to kernel (intel#1878) [SYCL] Fix warnings from static analysis tool (intel#2193) [SYCL][NFC] Fix ac_float test for compilation with FE optimizations (intel#2184) [GitHub Actions] Uplift clang-format version to 10 (intel#2194) [SYCL][ESIMD] Pass to replace simd* parameters with native llvm vectors. (intel#2097) [SYCL][NFC] Fixed SYCL_PI_TRACE output while selecting a device. (intel#2192) [SYCL][FPGA] New spec for controlling load-store units in FPGAs (intel#2158) [SYCL][Doc] Clarify reqd_sub_group_size (intel#2103) [SYCL] Remove noreturn function attribute (intel#2165) [SYCL] Aligned set_arg behaviour with SYCL specification (intel#2159) ...
…rogram * upstream/sycl: [SYCL] Add barrier before leader guard in LowerWGSCope pass (intel#2208) [SYCL] Add prototype of atomic_ref<T*> (intel#2177) Revert "[SYCL] Disallow mutable lambdas (intel#1785)" (intel#2213)
@cperkinsintel : This got reverted, so you need to update this to figure out why it caused a bunch of test failures. |
I guess he already did, see #2259 |
Ah, i see! He didn't mention this PR# so I guess it didn't get picked up. |
With the latest changes in the SYCL spec kernel lambdas (and functors) must be const references. Have updated the SYCL headers and tests with this change. Also had to make a minor adjustment to the kernel generation code in Clang and update many of the SemaSYCL tests, because their mock kernel defs needed to be updated as well.
Signed-off-by: Chris Perkins [email protected]