File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -1817,11 +1817,16 @@ class SwizzleOp {
1817
1817
return Tmp.template convert <convertT, roundingMode>();
1818
1818
}
1819
1819
1820
- template <typename asT>
1821
- typename detail::enable_if_t <asT::getNumElements() == getNumElements(), asT>
1822
- as () const {
1820
+ template <typename asT> asT as () const {
1823
1821
// First materialize the swizzle to vec_t and then apply as() to it.
1824
1822
vec_t Tmp = *this ;
1823
+ static_assert ((sizeof (Tmp) == sizeof (asT)),
1824
+ " The new SYCL vec type must have the same storage size in "
1825
+ " bytes as this SYCL swizzled vec" );
1826
+ static_assert (
1827
+ detail::is_contained<asT, detail::gtl::vector_basic_list>::value,
1828
+ " asT must be SYCL vec of a different element type and "
1829
+ " number of elements specified by asT" );
1825
1830
return Tmp.template as <asT>();
1826
1831
}
1827
1832
Original file line number Diff line number Diff line change @@ -64,6 +64,12 @@ int main() {
64
64
unsigned long long ull_val = ull_vec.template swizzle <cl::sycl::elem::s0>();
65
65
assert (ull_val == ull_ref);
66
66
67
+ // Check that the function as() in swizzle vec class is working correctly
68
+ cl::sycl::vec<int8_t , 2 > inputVec = cl::sycl::vec<int8_t , 2 >(0 , 1 );
69
+ auto asVec =
70
+ inputVec.template swizzle <cl::sycl::elem::s0, cl::sycl::elem::s1>()
71
+ .template as <cl::sycl::vec<int16_t , 1 >>();
72
+
67
73
// Check that [u]long[n] type aliases match vec<[unsigned] long, n> types.
68
74
assert ((std::is_same<cl::sycl::vec<long , 2 >, cl::sycl::long2>::value));
69
75
assert ((std::is_same<cl::sycl::vec<long , 3 >, cl::sycl::long3>::value));
You can’t perform that action at this time.
0 commit comments