-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] disallow mutable lambdas #1785
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
romanovvlad
merged 19 commits into
intel:sycl
from
cperkinsintel:cperkins-no-mutable-kernel-func
Jul 29, 2020
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
cac4b4a
disallow mutable lambdas
cperkinsintel c2f7712
kernel lambdas and functors must be const references
cperkinsintel 12b985a
new test discovered after rebase
cperkinsintel 56deb78
clang formation
cperkinsintel 62a01b7
clang format.
cperkinsintel 68e3892
excerpts of kernel def in sycl codegen tests updated with const and ref
cperkinsintel edb3a90
clang-formatter
cperkinsintel 49a226f
best to not assert with both SYCL 2020 and SYCL 1.2
cperkinsintel d0b8b21
feedback from review - remove redundant ->getType() call
cperkinsintel 750aa5f
rebase (again). no more const casting
cperkinsintel bc3bdb3
clang-formatf
cperkinsintel c697445
clang coding guidelines
cperkinsintel 000286a
rebase and update test
cperkinsintel c87f7b7
adding warning diagnostic when sycl 1.2 encountered. Expect this will…
cperkinsintel ed43c1b
updated diagnostics - sycl version aware, diff messaging
cperkinsintel aa6423c
second diagnostic, reorg, grouping of warnings.
cperkinsintel 64b8d7e
updated tests with flag to suppress conformance warning
cperkinsintel 29e916f
feedback from review
cperkinsintel ab280a4
nits
cperkinsintel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -729,7 +729,38 @@ getKernelInvocationKind(FunctionDecl *KernelCallerFunc) { | |
} | ||
|
||
static const CXXRecordDecl *getKernelObjectType(FunctionDecl *Caller) { | ||
return (*Caller->param_begin())->getType()->getAsCXXRecordDecl(); | ||
QualType KernelParamTy = (*Caller->param_begin())->getType(); | ||
// In SYCL 2020 kernels are now passed by reference. | ||
if (KernelParamTy->isReferenceType()) | ||
return KernelParamTy->getPointeeCXXRecordDecl(); | ||
|
||
// SYCL 1.2.1 | ||
return KernelParamTy->getAsCXXRecordDecl(); | ||
} | ||
|
||
static void checkKernelAndCaller(Sema &SemaRef, FunctionDecl *Caller, | ||
const CXXRecordDecl *KernelObj) { | ||
// check captures | ||
if (KernelObj->isLambda()) { | ||
for (const LambdaCapture &LC : KernelObj->captures()) | ||
if (LC.capturesThis() && LC.isImplicit()) | ||
SemaRef.Diag(LC.getLocation(), diag::err_implicit_this_capture); | ||
} | ||
|
||
// check that calling kernel conforms to spec | ||
assert(Caller->param_size() >= 1 && "missing kernel function argument."); | ||
QualType KernelParamTy = (*Caller->param_begin())->getType(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if (KernelParamTy->isReferenceType()) { | ||
// passing by reference, so emit warning if not using SYCL 2020 | ||
if (SemaRef.LangOpts.SYCLVersion < 2020) | ||
SemaRef.Diag(Caller->getLocation(), | ||
diag::warn_sycl_pass_by_reference_future); | ||
} else { | ||
// passing by value. emit warning if using SYCL 2020 or greater | ||
if (SemaRef.LangOpts.SYCLVersion > 2017) | ||
SemaRef.Diag(Caller->getLocation(), | ||
diag::warn_sycl_pass_by_value_deprecated); | ||
} | ||
} | ||
|
||
/// Creates a kernel parameter descriptor | ||
|
@@ -1943,11 +1974,8 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc, | |
constructKernelName(*this, KernelCallerFunc, MC); | ||
StringRef KernelName(getLangOpts().SYCLUnnamedLambda ? StableName | ||
: CalculatedName); | ||
if (KernelObj->isLambda()) { | ||
for (const LambdaCapture &LC : KernelObj->captures()) | ||
if (LC.capturesThis() && LC.isImplicit()) | ||
Diag(LC.getLocation(), diag::err_implicit_this_capture); | ||
} | ||
|
||
checkKernelAndCaller(*this, KernelCallerFunc, KernelObj); | ||
SyclKernelFieldChecker checker(*this); | ||
SyclKernelDeclCreator kernel_decl( | ||
*this, checker, KernelName, KernelObj->getLocation(), | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.