Repository navigation
[SYCL] Consistent is_device_copyable for sycl::accessor #23250
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?
Changes from all commits
54550f9
4771df0
4bc0a59
74cbd87
3b87544
7478b51
8d933d1
faecfa9
37e133a
82c5e91
47f7932
e966767
f011bd9
7b15c7c
0adb720
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,20 @@ static void EmitDeclInit(CodeGenFunction &CGF, const VarDecl &D, | |
| /// static storage duration. | ||
| static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D, | ||
| ConstantAddress Addr) { | ||
| // SYCL work-group scope variables (e.g. the kernel object of a | ||
| // parallel_for_work_group kernel) are local variables promoted to | ||
| // work-group local memory. There is no program exit on the device to run | ||
| // their destructor at, and SYCL 2020 requires the destructors of device | ||
| // copyable types to have no effect on the device, so don't register one. | ||
| if (CGF.getLangOpts().SYCLIsDevice) { | ||
|
Contributor
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. We have the scope attribute lookup in at least 3 locations in CodeGen now and the checks are not consistent. Can you factor the attribute lookup into a shared helper? If you would prefer not doing it in this PR, can you file an issue?
Contributor
Author
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. I will submit a follow-up issue + PR. |
||
| const SYCLScopeAttr *Scope = D.getAttr<SYCLScopeAttr>(); | ||
| if (!Scope) | ||
| if (const auto *RD = D.getType()->getAsCXXRecordDecl()) | ||
| Scope = RD->getAttr<SYCLScopeAttr>(); | ||
| if (Scope && Scope->isWorkGroup()) | ||
| return; | ||
| } | ||
|
|
||
| // Honor __attribute__((no_destroy)) and bail instead of attempting | ||
| // to emit a reference to a possibly nonexistent destructor, which | ||
| // in turn can cause a crash. This will result in a global constructor | ||
|
|
||
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.
We have a function in
addScopeAttrToLocalVarswhich adds an implicit scope attribute to PFWG locals. This would affect those cases as well right? Is that intended?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.
My current understanding is that
addScopeAttrToLocalVarscan cause linking errors if the destructor is non-trivial. This replaces the linking error with silently dropping the destructor. Once I have a concise reproduction for that case, I'll submit a separate issue to address that.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.
#23461