Skip to content

[SYCL] Fix nightly CTS failure after e7defabd #14164

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 4 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions sycl/include/sycl/vector_preview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,15 +1031,15 @@ class SwizzleOp {
SwizzleOp &operator=(const vec<DataT, IdxNum> &Rhs) {
std::array<int, IdxNum> Idxs{Indexes...};
for (size_t I = 0; I < Idxs.size(); ++I) {
m_Vector[Idxs[I]] = Rhs.getValue(I);
(*m_Vector)[Idxs[I]] = Rhs.getValue(I);
}
return *this;
}

template <int IdxNum = getNumElements(), typename = EnableIfOneIndex<IdxNum>>
SwizzleOp &operator=(const DataT &Rhs) {
std::array<int, IdxNum> Idxs{Indexes...};
m_Vector[Idxs[0]] = Rhs;
(*m_Vector)[Idxs[0]] = Rhs;
return *this;
}

Expand All @@ -1048,15 +1048,15 @@ class SwizzleOp {
SwizzleOp &operator=(const DataT &Rhs) {
std::array<int, IdxNum> Idxs{Indexes...};
for (auto Idx : Idxs) {
m_Vector[Idx] = Rhs;
(*m_Vector)[Idx] = Rhs;
}
return *this;
}

template <int IdxNum = getNumElements(), typename = EnableIfOneIndex<IdxNum>>
SwizzleOp &operator=(DataT &&Rhs) {
std::array<int, IdxNum> Idxs{Indexes...};
m_Vector[Idxs[0]] = Rhs;
(*m_Vector)[Idxs[0]] = Rhs;
return *this;
}

Expand Down Expand Up @@ -1209,7 +1209,7 @@ class SwizzleOp {
SwizzleOp &operator=(const SwizzleOp<T1, T2, T3, T4, T5...> &Rhs) {
std::array<int, getNumElements()> Idxs{Indexes...};
for (size_t I = 0; I < Idxs.size(); ++I) {
m_Vector[Idxs[I]] = Rhs.getValue(I);
(*m_Vector)[Idxs[I]] = Rhs.getValue(I);
}
return *this;
}
Expand All @@ -1221,7 +1221,7 @@ class SwizzleOp {
SwizzleOp &operator=(SwizzleOp<T1, T2, T3, T4, T5...> &&Rhs) {
std::array<int, getNumElements()> Idxs{Indexes...};
for (size_t I = 0; I < Idxs.size(); ++I) {
m_Vector[Idxs[I]] = Rhs.getValue(I);
(*m_Vector)[Idxs[I]] = Rhs.getValue(I);
}
return *this;
}
Expand Down Expand Up @@ -1436,7 +1436,7 @@ class SwizzleOp {
std::array<int, getNumElements()> Idxs{Indexes...};
for (size_t I = 0; I < Idxs.size(); ++I) {
DataT Res = Op(m_Vector->getValue(Idxs[I]), Rhs.getValue(I));
m_Vector[Idxs[I]] = Res;
(*m_Vector)[Idxs[I]] = Res;
}
}

Expand Down
20 changes: 20 additions & 0 deletions sycl/test/basic_tests/vectors/vectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ int main() {
assert((!inputVec4.lo().as<sycl::vec<bool, 2>>()[0]));
assert((inputVec4.lo().as<sycl::vec<bool, 2>>()[1]));

// Check assignment operator for swizzles.
{
sycl::vec<int8_t, 2> inputVec1 = sycl::vec<int8_t, 2>(0, 1);
sycl::vec<int8_t, 2> inputVec2 = sycl::vec<int8_t, 2>(2, 3);
auto swiz1 = inputVec1.template swizzle<sycl::elem::s1, sycl::elem::s0>();
auto swiz2 = inputVec2.template swizzle<sycl::elem::s0, sycl::elem::s1>();

// Assign swizzle to swizzle.
swiz1 = swiz2;
assert(inputVec1[0] == 3 && inputVec1[1] == 2);

// Assign vec to swizzle.
swiz1 = sycl::vec<int8_t, 2>(0, 1);
assert(inputVec1[0] == 1 && inputVec1[1] == 0);

// Assign single element to swizzle.
swiz1 = (int8_t)5;
assert(inputVec1[0] == 5 && inputVec1[1] == 5);
}

// Check that [u]long[n] type aliases match vec<[u]int64_t, n> types.
assert((std::is_same<sycl::vec<std::int64_t, 2>, sycl::long2>::value));
assert((std::is_same<sycl::vec<std::int64_t, 3>, sycl::long3>::value));
Expand Down
Loading