Skip to content

[SYCL] Remove IsDeprecatedDeviceCopyable #16615

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
merged 2 commits into from
Jan 17, 2025

Conversation

aelovikov-intel
Copy link
Contributor

@aelovikov-intel aelovikov-intel commented Jan 14, 2025

This was discussed in
#15342 (comment) and the consensus seemed to be that we should drop it right away in a separate PR, do it here.

Technically, it is a breaking change that could also be considered a bugfix. An example of a class failing the updated check is

struct Kernel {
    Kernel(int);
    Kernel(const Kernel&) = default;
    Kernel& operator=(const Kernel&) { return *this; } // non-trivial
};

An additional minor reason (other than not being SYCL-conformant) to drop it right away is to save a tiny bit of compile time that is currently used to support something violating the spec.

This required some fixes in the reductions implementation to make sure the kernel we submit internally are actually device copyable.

This was discussed in
intel#15342 (comment) and the
consensus seemd to be that we should drop it right away in a separate
PR, do it here.

Technically, it is a breaking change that could also be considered a
bugfix. An example of a class failing the updated check is

```
struct Kernel {
    Kernel(int);
    Kernel(const Kernel&) = default;
    Kernel& operator=(const Kernel&) { return *this; } // non-trivial
};
```

An additional minor reason (other than not being SYCL-conformant) to
drop it right away is to save a tiny bit of compile time that is
currently used to support something violating the spec.
Comment on lines +75 to +78
template <typename... Ts>
struct is_device_copyable<sycl::detail::tuple<Ts...>>
: std::bool_constant<(... && is_device_copyable<Ts>::value)> {};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better way might be just making sycl::detail::tuple trivially copyable automatically whenever all the contained types are, by fixing the implementation, but I'm not sure how big such a change would be or how to approach it.

@aelovikov-intel
Copy link
Contributor Author

Ping

@aelovikov-intel aelovikov-intel merged commit a5e8209 into intel:sycl Jan 17, 2025
17 checks passed
@aelovikov-intel aelovikov-intel deleted the remove-trait branch January 17, 2025 18:06
@aelovikov-intel
Copy link
Contributor Author

aelovikov-intel commented Jan 18, 2025

Looks like this broke CTS. Root cause: https://godbolt.org/z/vqan5Y9xM, so the issue is either in the CTS or in the clang FE.

--- a/tests/handler/handler_invoke_api.h
+++ b/tests/handler/handler_invoke_api.h
@@ -43,6 +43,7 @@ struct TestConstants {
         offsetNdRange(offsetRange, offsetRange, offset),
         numWorkGroups(1),
         workGroupSize(defaultRange) {}
+  ~TestConstants() = default;
 };

 struct use_offset {

in CTS would make it buildable again.

@intel/dpcpp-cfe-reviewers , can you tell if clang's behavior is correct?

@elizabethandrews
Copy link
Contributor

Looks like this broke CTS. Root cause: https://godbolt.org/z/vqan5Y9xM, so the issue is either in the CTS or in the clang FE.

--- a/tests/handler/handler_invoke_api.h
+++ b/tests/handler/handler_invoke_api.h
@@ -43,6 +43,7 @@ struct TestConstants {
         offsetNdRange(offsetRange, offsetRange, offset),
         numWorkGroups(1),
         workGroupSize(defaultRange) {}
+  ~TestConstants() = default;
 };

 struct use_offset {

in CTS would make it buildable again.

@intel/dpcpp-cfe-reviewers , can you tell if clang's behavior is correct?

Hmm... It is unclear why the defaulted destructor changes the behavior in clang. I also noticed that removing the const member changes the behavior. There seems to be some underlying bug but it is unclear to me whether TestConstants is trivially copyable or not. I am looking at the standards now. Tom is also looking into this.

@elizabethandrews
Copy link
Contributor

Looks like this broke CTS. Root cause: https://godbolt.org/z/vqan5Y9xM, so the issue is either in the CTS or in the clang FE.

--- a/tests/handler/handler_invoke_api.h
+++ b/tests/handler/handler_invoke_api.h
@@ -43,6 +43,7 @@ struct TestConstants {
         offsetNdRange(offsetRange, offsetRange, offset),
         numWorkGroups(1),
         workGroupSize(defaultRange) {}
+  ~TestConstants() = default;
 };

 struct use_offset {

in CTS would make it buildable again.
@intel/dpcpp-cfe-reviewers , can you tell if clang's behavior is correct?

Hmm... It is unclear why the defaulted destructor changes the behavior in clang. I also noticed that removing the const member changes the behavior. There seems to be some underlying bug but it is unclear to me whether TestConstants is trivially copyable or not. I am looking at the standards now. Tom is also looking into this.

I discussed this with Tom and we think this is a Clang bug. Can you file a JIRA for it?

@tahonermann
Copy link
Contributor

std::is_trivially_copyable is an odd trait since it can be satisfied in so many ways. For example, a type that is trivially move-assignable but not trivially copy/move constructible or trivially copy-assignable satisfies it. I suggest avoiding it and using the more precise std::is_trivially_copy_constructible traits to specify the actual requirements needed.

@jsji
Copy link
Contributor

jsji commented Jan 21, 2025

I discussed this with Tom and we think this is a Clang bug. Can you file a JIRA for it?

64941, assigned to you first.

aelovikov-intel added a commit to aelovikov-intel/llvm that referenced this pull request Jan 23, 2025
…ntel#16615)

Restore (logically) previous condition while keeping the rest of
cleanups in place. Deprecation warning never worked, so I'm not even
trying to implement that.
steffenlarsen pushed a commit that referenced this pull request Jan 24, 2025
…16615) (#16744)

Restore (logically) previous condition while keeping the rest of
cleanups in place. Deprecation warning never worked, so I'm not even
trying to implement that.
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.

5 participants