-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][clang] Fix uses_aspects applied to function declarations #10164
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
AlexeySachkov
merged 2 commits into
intel:sycl
from
Fznamznon:private/mpodchis/fix-uses-aspects
Jul 10, 2023
Merged
Changes from all commits
Commits
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
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.
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 design document specifies this metadata is applied to function definitions - https://github.com/triSYCL/sycl/blob/sycl/unified/master/sycl/doc/design/OptionalDeviceFeatures.md
How does this work with redeclarations? What is finally attached to the function definition? IIRC there is some pass which propagates this metadata up the static call graph. What gets propagated now if we have different attribute arguments in different declarations
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 document seems to be assuming that the atribute can be applied to function declarations, see for example https://github.com/triSYCL/sycl/blob/sycl/unified/master/sycl/doc/design/OptionalDeviceFeatures.md#changes-to-dpc-headers . However it says,
For both
uses_aspects
anddevice_has
attibutes. We already has support fordevice_has
on declarations added by https://github.com/intel/llvm/pull/9611/files . I'm not sure why it is limited to definitions in the document, maybe we should change the wording to "function signature"? CC @gmlueck, @AlexeySachkov to clarify.When redeclarations appear, the most recent is referenced by the code. Meaning the metadata is generated based on attirbute value applied to the most recent declarations. Even in case like
I'm seeing only fp16 aspect on kernels and function declaration.
The pass seem to be updated by https://github.com/intel/llvm/pull/9611/files in generic way, so it seems to be working fine with declarations.
The metadata generated for the most recent redeclaration is propagated. When the most recent doesn't have the attribute, metadata is propagated from previous redeclaration.
The thing I find confusing for the end user, when attribute is applied to a redeclaration and the previous declaration had an attribute, the warning is emitted:
It seems to be saying that the attribute is ignored on the most recent declaration, however instead it seems to be ignored on the first declaration since the metadata is generated based on the latter declaration.
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
[[sycl::device_has]]
attribute is defined in the SYCL 2020 specification section 5.8 "Attributes for device code", which says this about attributes and redeclarations:Based on that wording, I think it is an error to redeclare a function with a different
[[sycl::device_has]]
attribute, and the compiler is supposed to diagnose this case.I think it is reasonable to treat the
[sycl_detail::uses_aspects]]
attribute in the same way.BTW, the links you have above are pointing to a different company's fork of our repo. When looking at our design documents, you should look at our own fork (not the triSYCL fork). For example, this is the link to our copy of the optional device features design document:
https://github.com/intel/llvm/blob/sycl/sycl/doc/design/OptionalDeviceFeatures.md
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.
OMG, I didn't notice that the first link posted by Elizabeth is to triSYCL repo. Thanks for pointing this out.
Well, apparently the compiler's behavior is different now. I would prefer implementing the diagnostic separately though.
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 didn't notice I checked the wrong link! I just opened the first search item on google. I apologize!
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 believe this is 'normal' clang attribute functionality. Warnings are usually generated on redeclarations but metadata is also usually from first declaration. So there is some bug there. Anyway based on the spec @gmlueck pasted above, it looks like we need to be parsing attribute arguments and generating this diagnostic accordingly. I agree that can be a separate patch since it is orthogonal to this PR.