Skip to content

Commit

Permalink
[SYCL] Remove IsDeprecatedDeviceCopyable
Browse files Browse the repository at this point in the history
This was discussed in
#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.
  • Loading branch information
aelovikov-intel committed Jan 13, 2025
1 parent 1a7e2f0 commit aab026c
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions sycl/include/sycl/detail/is_device_copyable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,14 @@ struct is_device_copyable<T[N]> : is_device_copyable<T> {};
template <typename T>
inline constexpr bool is_device_copyable_v = is_device_copyable<T>::value;
namespace detail {
template <typename T, typename = void>
struct IsDeprecatedDeviceCopyable : std::false_type {};

// TODO: using C++ attribute [[deprecated]] or the macro __SYCL2020_DEPRECATED
// does not produce expected warning message for the type 'T'.
template <typename T>
struct __SYCL2020_DEPRECATED("This type isn't device copyable in SYCL 2020")
IsDeprecatedDeviceCopyable<
T, std::enable_if_t<std::is_trivially_copy_constructible_v<T> &&
std::is_trivially_destructible_v<T> &&
!is_device_copyable_v<T>>> : std::true_type {};

template <typename T, int N>
struct __SYCL2020_DEPRECATED("This type isn't device copyable in SYCL 2020")
IsDeprecatedDeviceCopyable<T[N]> : IsDeprecatedDeviceCopyable<T> {};

#ifdef __SYCL_DEVICE_ONLY__
// Checks that the fields of the type T with indices 0 to (NumFieldsToCheck -
// 1) are device copyable.
template <typename T, unsigned NumFieldsToCheck>
struct CheckFieldsAreDeviceCopyable
: CheckFieldsAreDeviceCopyable<T, NumFieldsToCheck - 1> {
using FieldT = decltype(__builtin_field_type(T, NumFieldsToCheck - 1));
static_assert(is_device_copyable_v<FieldT> ||
detail::IsDeprecatedDeviceCopyable<FieldT>::value,
static_assert(is_device_copyable_v<FieldT>,
"The specified type is not device copyable");
};

Expand All @@ -119,8 +102,7 @@ template <typename T, unsigned NumBasesToCheck>
struct CheckBasesAreDeviceCopyable
: CheckBasesAreDeviceCopyable<T, NumBasesToCheck - 1> {
using BaseT = decltype(__builtin_base_type(T, NumBasesToCheck - 1));
static_assert(is_device_copyable_v<BaseT> ||
detail::IsDeprecatedDeviceCopyable<BaseT>::value,
static_assert(is_device_copyable_v<BaseT>,
"The specified type is not device copyable");
};

Expand Down

0 comments on commit aab026c

Please sign in to comment.