Repository navigation
[SYCL] Make PFWG variables have automatic destructor semantics. - #23702
Open
inteltdelisle wants to merge 6 commits into
Open
inteltdelisle wants to merge 6 commits into
inteltdelisle wants to merge 6 commits into
Conversation
Variables declared inside parallel_for_work_group need to have global storage since local storage cannot be accessed across work items. Previously, these variables would also get global destructor semantics, i.e., using __cxa_atexit, which is incorrect for device code. This behaviour is now replaced with automatic variable semantics, i.e., destructors are executed once per work group at scope exit. Other changes: - Fixed work_group_static variables not being zero initialized when inside PFWG. - -ftrivial-auto-var-init now applies to work-group-scope locals. - Added defensive tests for work_group_static, to confirm previous behaviour is unchanged. Known limitation: Issue 23700 causes certain destructos to be run too many times, notably destructors for captured variables. There is still an existing diagnosis covering these destructors, so the problem is not silent. Once issue 23700 is fixed, the diagnostic warn_sycl_work_group_scope_dtor can be removed and tests should be added for captured variables. Signed-off-by: Delisle, Thierry <thierry.delisle@intel.com>
Signed-off-by: Delisle, Thierry <thierry.delisle@intel.com>
Contributor
|
@inteltdelisle is this PR ready for review? In our offline discussion, I believe you said another PR will need to go first before this. Will there be changes to this PR as a result? If this is not ready for review, please mark it as draft and ping when ready for review. Thank you! |
Contributor
Author
|
@elizabethandrews It depends if this is worth merging with the known limitation in the description. Arguably this PR still improves the current state of things. But it's also not consistently fixing all cases, where as previously non-trivial destructors were just generally better avoided. Honestly, either works for me. |
Contributor
Author
Signed-off-by: Delisle, Thierry <thierry.delisle@intel.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Variables declared inside parallel_for_work_group need to have global storage since local storage cannot be accessed across work items. Previously, these variables would also get global destructor semantics, i.e., using __cxa_atexit, which is incorrect for device code. This behaviour is now replaced with automatic variable semantics, i.e., destructors are executed once per work group at scope exit.
Other changes:
Known limitation: Issue #23700 causes certain destructos to be run too many times, notably destructors for captured variables. There is still an existing diagnosis covering these destructors, so the problem is not silent. Once issue 23700 is fixed, the diagnostic warn_sycl_work_group_scope_dtor can be removed and tests should be added for captured variables.