Skip to content

[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

Merged

Conversation

romanovvlad
Copy link
Contributor

@romanovvlad romanovvlad commented Dec 28, 2022

Define __SYCL_TYPE to empty unless compiling in SYCL device mode

Define __SYCL_TYPE to empty unless compiling in SYCL mode
@romanovvlad romanovvlad requested a review from a team as a code owner December 28, 2022 16:00
@romanovvlad
Copy link
Contributor Author

The same as #7811 , but for SYCL_TYPE

@bader
Copy link
Contributor

bader commented Dec 28, 2022

The same as #7811 , but for SYCL_TYPE

@romanovvlad, could you check if there are any other attributes which require this fix, please?

@@ -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__)
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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__.

Copy link
Contributor

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

Copy link
Contributor Author

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)

Copy link
Contributor

@elizabethandrews elizabethandrews Jan 3, 2023

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

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@bader bader temporarily deployed to aws December 28, 2022 22:43 — with GitHub Actions Inactive
@bader bader temporarily deployed to aws December 28, 2022 23:18 — with GitHub Actions Inactive
@bader
Copy link
Contributor

bader commented Dec 28, 2022

@romanovvlad, I've fixed formatting, but I'd you to take a look at llvm-test-suite regressions.

@romanovvlad
Copy link
Contributor Author

The same as #7811 , but for SYCL_TYPE

@romanovvlad, could you check if there are any other attributes which require this fix, please?

Do not see any other attributes that require the fix.

@romanovvlad romanovvlad requested a review from a team as a code owner January 3, 2023 11:49
@romanovvlad
Copy link
Contributor Author

@bader
The test failures happen because of our diagnostics for [[sycl::device_has(...)]], they check that the argument is a type marked by [[__sycl_detail__::sycl_type(x)]]. But since in this patch we do not mark enum class aspect with this attribute, the FE says that the type is invalid.

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 SilentlyIgnoreSYCLIsHost flag in Attr.td which is likely supposed to address this, but currently it silences <<>> attribute ignored warning only while other diagnostics take place. We could try to adjust FE to skip all diagnostics if this flag is enabled.

@romanovvlad romanovvlad temporarily deployed to aws January 3, 2023 13:13 — with GitHub Actions Inactive
@romanovvlad romanovvlad temporarily deployed to aws January 3, 2023 14:49 — with GitHub Actions Inactive
@elizabethandrews
Copy link
Contributor

Alternatively, I see that we have SilentlyIgnoreSYCLIsHost flag in Attr.td which is likely supposed to address this, but currently it silences <<>> attribute ignored warning only while other diagnostics take place. We could try to adjust FE to skip all diagnostics if this flag is enabled.

SilentlyIgnoreSYCLIsHost was implemented to avoid diagnosing "unknown attribute" error only. Earlier, host compilation pass would throw this warning confusing users compiling their SYCL program.

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.

@romanovvlad romanovvlad temporarily deployed to aws January 3, 2023 19:16 — with GitHub Actions Inactive
@romanovvlad romanovvlad temporarily deployed to aws January 3, 2023 20:16 — with GitHub Actions Inactive
@romanovvlad romanovvlad temporarily deployed to aws January 4, 2023 12:30 — with GitHub Actions Inactive
@romanovvlad romanovvlad temporarily deployed to aws January 4, 2023 13:00 — with GitHub Actions Inactive
@romanovvlad romanovvlad merged commit 45b5267 into intel:sycl Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants