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] Add missing aliases to swizzles #13040

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 VecT::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,
decltype(X)::vector_t>);
steffenlarsen marked this conversation as resolved.
Show resolved Hide resolved
#endif // __SYCL_DEVICE_ONLY__
});
return 0;
}
Loading