Skip to content

Commit

Permalink
SYCL: Make is_device_copyable future-proof (#6009)
Browse files Browse the repository at this point in the history
* SYCL: Make is_device_copyable future-proof

* Try Damien's suggestion

Co-authored-by: Damien L-G <dalg24+github@gmail.com>

---------

Co-authored-by: Damien L-G <dalg24+github@gmail.com>
  • Loading branch information
masterleinad and dalg24 committed Mar 27, 2023
1 parent 79b824e commit a7a2d71
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion core/src/SYCL/Kokkos_SYCL_Instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,29 @@ struct sycl::is_device_copyable<
Kokkos::Experimental::Impl::SYCLFunctionWrapper<Functor, Storage, false>>
: std::true_type {};

// FIXME_SYCL Remove when this specialization when specializations for
// sycl::device_copyable also apply to const-qualified types.
template <typename>
struct NonTriviallyCopyableAndDeviceCopyable {
NonTriviallyCopyableAndDeviceCopyable(
const NonTriviallyCopyableAndDeviceCopyable&) {}
};

template <typename T>
struct is_device_copyable<NonTriviallyCopyableAndDeviceCopyable<T>>
: std::true_type {};

static_assert(
!std::is_trivially_copyable_v<
NonTriviallyCopyableAndDeviceCopyable<void>> &&
is_device_copyable_v<NonTriviallyCopyableAndDeviceCopyable<void>>);

template <typename Functor, typename Storage>
struct sycl::is_device_copyable<
const Kokkos::Experimental::Impl::SYCLFunctionWrapper<Functor, Storage,
false>>
false>,
std::enable_if_t<!sycl::is_device_copyable_v<
const NonTriviallyCopyableAndDeviceCopyable<Functor>>>>
: std::true_type {};
#endif
#endif

0 comments on commit a7a2d71

Please sign in to comment.