Skip to content

Commit 82bfffe

Browse files
[SYCL] Add missing aliases to swizzles (#13040)
Vector swizzles are currently missing the value_type and vector_t aliases, as should be inherited from vec. This commit adds these aliases. --------- Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 0643862 commit 82bfffe

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

sycl/include/sycl/types.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,11 @@ class SwizzleOp {
17901790

17911791
public:
17921792
using element_type = DataT;
1793+
using value_type = DataT;
1794+
1795+
#ifdef __SYCL_DEVICE_ONLY__
1796+
using vector_t = typename vec_t::vector_t;
1797+
#endif // __SYCL_DEVICE_ONLY__
17931798

17941799
const DataT &operator[](int i) const {
17951800
std::array<int, getNumElements()> Idxs{Indexes...};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %clangxx -fsycl -fsyntax-only %s
2+
3+
#include <sycl/sycl.hpp>
4+
5+
int main() {
6+
sycl::queue Q;
7+
Q.single_task([]() {
8+
sycl::vec<int, 4> X{1};
9+
static_assert(std::is_same_v<decltype(X.swizzle<0>())::element_type, int>);
10+
static_assert(std::is_same_v<decltype(X.swizzle<0>())::value_type, int>);
11+
#ifdef __SYCL_DEVICE_ONLY__
12+
static_assert(std::is_same_v<decltype(X.swizzle<0>())::vector_t,
13+
sycl::vec<int, 1>::vector_t>);
14+
#endif // __SYCL_DEVICE_ONLY__
15+
});
16+
return 0;
17+
}

0 commit comments

Comments
 (0)