Skip to content
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

[SYCL] Make sycl::marray trivially copyable #4885

Merged
merged 8 commits into from Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions sycl/include/CL/sycl/marray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,9 @@ template <typename Type, std::size_t NumElements> class marray {
typename = typename std::enable_if<sizeof...(ArgTN) == NumElements>::type>
constexpr marray(const ArgTN &... Args) : MData{Args...} {}

constexpr marray(const marray<Type, NumElements> &Rhs) {
for (std::size_t I = 0; I < NumElements; ++I) {
MData[I] = Rhs.MData[I];
}
}
constexpr marray(const marray<Type, NumElements> &Rhs) = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

I love C++! :-)


constexpr marray(marray<Type, NumElements> &&Rhs) {
for (std::size_t I = 0; I < NumElements; ++I) {
MData[I] = Rhs.MData[I];
}
}
constexpr marray(marray<Type, NumElements> &&Rhs) = default;

// Available only when: NumElements == 1
template <std::size_t Size = NumElements,
Expand All @@ -92,12 +84,7 @@ template <typename Type, std::size_t NumElements> class marray {

const_reference operator[](std::size_t index) const { return MData[index]; }

marray &operator=(const marray<Type, NumElements> &Rhs) {
for (std::size_t I = 0; I < NumElements; ++I) {
MData[I] = Rhs.MData[I];
}
return *this;
}
marray &operator=(const marray<Type, NumElements> &Rhs) = default;

// broadcasting operator
marray &operator=(const Type &Rhs) {
Expand Down
6 changes: 0 additions & 6 deletions sycl/include/CL/sycl/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2414,12 +2414,6 @@ struct is_device_copyable<std::tuple<T, Ts...>>
: detail::bool_constant<is_device_copyable<T>::value &&
is_device_copyable<std::tuple<Ts...>>::value> {};

// marray is device copyable if element type is device copyable
template <typename T, std::size_t N>
struct is_device_copyable<sycl::marray<T, N>,
std::enable_if_t<is_device_copyable<T>::value>>
: std::true_type {};

// vec is device copyable on host, on device vec is trivially copyable
// and therefore is device copyable too.
#ifndef __SYCL_DEVICE_ONLY__
Expand Down
2 changes: 2 additions & 0 deletions sycl/test/basic_tests/SYCL-2020-spec-constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ constexpr sycl::specialization_id<uint64_t> uint64_id(8);
constexpr sycl::specialization_id<float> float_id(10.0);
constexpr sycl::specialization_id<double> double_id(11.0);
constexpr sycl::marray<double, 5> ma;
constexpr sycl::marray<double, 5> mb(ma);
Copy link
Contributor

@vladimirlaz vladimirlaz Nov 17, 2021

Choose a reason for hiding this comment

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

It is not clear why these lines were added to the test?
They are not used in specialization constants and this test is for specialization constants.

Copy link
Author

Choose a reason for hiding this comment

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

Agree, I've moved the lines into marray.cpp test.

constexpr sycl::marray<double, 5> mc = ma;
constexpr sycl::specialization_id<sycl::marray<double, 5>> marray_id5(11.0);
constexpr sycl::specialization_id<sycl::marray<double, 1>> marray_id1(11.0);
constexpr sycl::specialization_id<sycl::marray<double, 5>> marray_id_def(ma);
Expand Down