Skip to content

Commit

Permalink
[SYCL] Add missing aliases to swizzles (#13040)
Browse files Browse the repository at this point in the history
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 <steffen.larsen@intel.com>
  • Loading branch information
steffenlarsen committed Mar 18, 2024
1 parent 0643862 commit 82bfffe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sycl/include/sycl/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,11 @@ class SwizzleOp {

public:
using element_type = DataT;
using value_type = DataT;

#ifdef __SYCL_DEVICE_ONLY__
using vector_t = typename vec_t::vector_t;
#endif // __SYCL_DEVICE_ONLY__

const DataT &operator[](int i) const {
std::array<int, getNumElements()> Idxs{Indexes...};
Expand Down
17 changes: 17 additions & 0 deletions sycl/test/basic_tests/vectors/swizzle_aliases.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %clangxx -fsycl -fsyntax-only %s

#include <sycl/sycl.hpp>

int main() {
sycl::queue Q;
Q.single_task([]() {
sycl::vec<int, 4> X{1};
static_assert(std::is_same_v<decltype(X.swizzle<0>())::element_type, int>);
static_assert(std::is_same_v<decltype(X.swizzle<0>())::value_type, int>);
#ifdef __SYCL_DEVICE_ONLY__
static_assert(std::is_same_v<decltype(X.swizzle<0>())::vector_t,
sycl::vec<int, 1>::vector_t>);
#endif // __SYCL_DEVICE_ONLY__
});
return 0;
}

0 comments on commit 82bfffe

Please sign in to comment.