-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Fix build issue that appeared in self-build #7881
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] Fix build issue that appeared in self-build #7881
Conversation
Define __SYCL_TYPE to empty unless compiling in SYCL mode
The same as #7811 , but for |
@romanovvlad, could you check if there are any other attributes which require this fix, please? |
sycl/include/sycl/detail/defines.hpp
Outdated
@@ -27,7 +27,7 @@ | |||
#define __SYCL_SPECIAL_CLASS | |||
#endif | |||
|
|||
#if __has_cpp_attribute(__sycl_detail__::sycl_type) | |||
#if __has_cpp_attribute(__sycl_detail__::sycl_type) && (defined __SYCL_DEVICE_ONLY__) |
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 wonder, can we update our attributes so __has_cpp_attribute
returns true
only for device compilation? Tagging @intel/dpcpp-cfe-reviewers
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 think you mean that some SYCL specific attributes can be enabled by the compiler only in SYCL device compilation mode and reported as unsupported in other modes (SYCL host or non-SYCL). Right?
I don't think we can change the semantic of __has_cpp_attribute
.
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 think you mean that some SYCL specific attributes can be enabled by the compiler only in SYCL device compilation mode and reported as unsupported in other modes (SYCL host or non-SYCL). Right?
Yes, thanks, that's what I meant. I would like us to simply rely on __has_cpp_attibute
alone, without need to check for __SYCL_DEVICE_ONLY__
.
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.
You can modify attribute definition to enable it only on device. You can silence the ignored attribute on host which is how we handle other device only attributes
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 will still have checks for attribute arg validity, see #7881 (comment)
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.
Hmm...technically that means attribute semantics is incorrect i.e. it is invalid code. I cannot recall off the top of my head how we handle this usually. @smanna12 @AaronBallman should we diagnose invalid attribute usage i.e. invalid argument when it is ignored on device? I vaguely remember a discussion about this once but I cannot recall the resolution
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.
Typically, when an attribute is ignored, we warn about the "unknown" attribute and that is it. e.g., [[no_unique_address]] is a standard attribute that accepts no arguments, but we don't support it on Windows because of , and so: https://godbolt.org/z/6Yh1jWx89
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.
Ok Thank you for confirming.
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.
@romanovvlad if this attribute is not required on host, you can modify the attribute definition as well as silence other diagnostics by not handling the attribute on host as you have already done. I think we can then remove SYCL_DEVICE_ONLY check as @AlexeySachkov suggested.
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 spend a bit of time looking into this. SYCL_DEVICE_ONLY check cannot be removed at the moment because __has_attribute
does not consider LangOpts when generating attributes in TableGen. This should be fixed in upstream clang if possible. We can do this as a separate task IMO.
@romanovvlad, I've fixed formatting, but I'd you to take a look at llvm-test-suite regressions. |
Do not see any other attributes that require the fix. |
@bader Those checks currently happen during both host and device compilations. As a possible quick solution we can ignore the attribute completely for SYCL host compilation(current version of the patch). Alternatively, I see that we have |
If we want to avoid attribute semantic checks as well using tablegen I think we will need bigger change where SYCL attributes are handled like we handle target specific attributes maybe. I don't know how to do this off the top off my head and if its worth it. The easy way to avoid semantic checks for attributes is what you have done in this PR - return early from handlers. IIRC we don't really do this for most SYCL device attributes. So at the moment, we are doing validity checks on host for most other device attributes as well I think. |
Define __SYCL_TYPE to empty unless compiling in SYCL device mode