Skip to content

Commit 9c662e2

Browse files
authored
[SYCL] Change trivially_copyable to device_copyable for fill and copy (#8826)
`cgh.fill(...)` was failing when `T` is a `sycl::vec` type, since `sycl::vec` types have no specialization for `std::is_trivially_copyable`. Since `device_copyable` is a sycl superset of trivially copyable we should use this instead in sycl headers. Related spec change: KhronosGroup/SYCL-Docs#425
1 parent 3024161 commit 9c662e2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

sycl/include/sycl/handler.hpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,8 @@ class __SYCL_EXPORT handler {
22762276
"Invalid accessor target for the copy method.");
22772277
static_assert(isValidModeForDestinationAccessor(AccessMode),
22782278
"Invalid accessor mode for the copy method.");
2279+
static_assert(is_device_copyable<T_Src>::value,
2280+
"Pattern must be device copyable");
22792281
// Make sure data shared_ptr points to is not released until we finish
22802282
// work with it.
22812283
CGData.MSharedPtrStorage.push_back(Src);
@@ -2345,6 +2347,8 @@ class __SYCL_EXPORT handler {
23452347
"Invalid accessor target for the copy method.");
23462348
static_assert(isValidModeForDestinationAccessor(AccessMode),
23472349
"Invalid accessor mode for the copy method.");
2350+
static_assert(is_device_copyable<T_Src>::value,
2351+
"Pattern must be device copyable");
23482352
#ifndef __SYCL_DEVICE_ONLY__
23492353
if (MIsHost) {
23502354
// TODO: Temporary implementation for host. Should be handled by memory
@@ -2505,12 +2509,12 @@ class __SYCL_EXPORT handler {
25052509
///
25062510
/// \param Ptr is the pointer to the memory to fill
25072511
/// \param Pattern is the pattern to fill into the memory. T should be
2508-
/// trivially copyable.
2512+
/// device copyable.
25092513
/// \param Count is the number of times to fill Pattern into Ptr.
25102514
template <typename T> void fill(void *Ptr, const T &Pattern, size_t Count) {
25112515
throwIfActionIsCreated();
2512-
static_assert(std::is_trivially_copyable<T>::value,
2513-
"Pattern must be trivially copyable");
2516+
static_assert(is_device_copyable<T>::value,
2517+
"Pattern must be device copyable");
25142518
parallel_for<class __usmfill<T>>(range<1>(Count), [=](id<1> Index) {
25152519
T *CastedPtr = static_cast<T *>(Ptr);
25162520
CastedPtr[Index] = Pattern;
@@ -2757,15 +2761,15 @@ class __SYCL_EXPORT handler {
27572761
/// \param Dest is a USM pointer to the destination memory.
27582762
/// \param DestPitch is the pitch of the rows in \param Dest.
27592763
/// \param Pattern is the pattern to fill into the memory. T should be
2760-
/// trivially copyable.
2764+
/// device copyable.
27612765
/// \param Width is the width in number of elements of the 2D region to fill.
27622766
/// \param Height is the height in number of rows of the 2D region to fill.
27632767
template <typename T>
27642768
void ext_oneapi_fill2d(void *Dest, size_t DestPitch, const T &Pattern,
27652769
size_t Width, size_t Height) {
27662770
throwIfActionIsCreated();
2767-
static_assert(std::is_trivially_copyable<T>::value,
2768-
"Pattern must be trivially copyable");
2771+
static_assert(is_device_copyable<T>::value,
2772+
"Pattern must be device copyable");
27692773
if (Width > DestPitch)
27702774
throw sycl::exception(sycl::make_error_code(errc::invalid),
27712775
"Destination pitch must be greater than or equal "

0 commit comments

Comments
 (0)