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

Wip vec #17787

Draft
wants to merge 3 commits into
base: sycl
Choose a base branch
from
Draft

Wip vec #17787

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
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@

#ifndef __SYCL_USE_LIBSYCL8_VEC_IMPL
#if defined(__INTEL_PREVIEW_BREAKING_CHANGES)
// Several specification changes need to be implemented together to keep CTS
// passing. We'll switch to `0` once they all land.
// `__SYCL_USE_PLAIN_ARRAY_AS_VEC_STORAGE` needs to be changed to use this
// `__SYCL_USE_LIBSYCL8_VEC_IMPL` at that time as well.
#define __SYCL_USE_LIBSYCL8_VEC_IMPL 1
#define __SYCL_USE_LIBSYCL8_VEC_IMPL 0
#else
#define __SYCL_USE_LIBSYCL8_VEC_IMPL 1
#endif
Expand Down
20 changes: 10 additions & 10 deletions sycl/include/sycl/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@

// See vec::DataType definitions for more details
#ifndef __SYCL_USE_PLAIN_ARRAY_AS_VEC_STORAGE
#if defined(__INTEL_PREVIEW_BREAKING_CHANGES)
#define __SYCL_USE_PLAIN_ARRAY_AS_VEC_STORAGE 1
#else
#define __SYCL_USE_PLAIN_ARRAY_AS_VEC_STORAGE 0
#endif
#define __SYCL_USE_PLAIN_ARRAY_AS_VEC_STORAGE !__SYCL_USE_LIBSYCL8_VEC_IMPL
#endif

#if !defined(__HAS_EXT_VECTOR_TYPE__) && defined(__SYCL_DEVICE_ONLY__)
Expand Down Expand Up @@ -309,8 +305,13 @@ template <typename Self> class ConversionToVecMixin {

public:
operator vec_ty() const {
vec_ty res{*static_cast<const Self *>(this)};
return res;
auto &self = *static_cast<const Self *>(this);
if constexpr (vec_ty::size() == 1)
// Avoid recursion by explicitly going through `vec(const DataT &)` ctor.
return vec_ty{static_cast<typename vec_ty::element_type>(self)};
else
// Uses `vec`'s variadic ctor.
return vec_ty{self};
}
};

Expand Down Expand Up @@ -398,9 +399,8 @@ class __SYCL_EBO Swizzle
public ApplyIf<sizeof...(Indexes) == 1,
ScalarConversionOperatorsMixIn<
Swizzle<IsConstVec, DataT, VecSize, Indexes...>>>,
public ApplyIf<sizeof...(Indexes) != 1,
ConversionToVecMixin<
Swizzle<IsConstVec, DataT, VecSize, Indexes...>>>,
public ConversionToVecMixin<
Swizzle<IsConstVec, DataT, VecSize, Indexes...>>,
public NamedSwizzlesMixinBoth<
Swizzle<IsConstVec, DataT, VecSize, Indexes...>> {
using Base = SwizzleBase<Swizzle<IsConstVec, DataT, VecSize, Indexes...>>;
Expand Down
7 changes: 1 addition & 6 deletions sycl/test/basic_tests/vectors/assign.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TODO: Remove `__SYCL_USE_LIBSYCL8_VEC_IMPL` once it's auto-set.
// RUN: %clangxx -fsycl -fsyntax-only %s -fpreview-breaking-changes -D__SYCL_USE_LIBSYCL8_VEC_IMPL=0
// RUN: %clangxx -fsycl -fsyntax-only %s -fpreview-breaking-changes
// RUN: %clangxx -fsycl -fsyntax-only %s

#include <sycl/sycl.hpp>
Expand Down Expand Up @@ -55,11 +54,7 @@ static_assert( !std::is_assignable_v<vec<half, 2>, sw_double_2>)
static_assert( std::is_assignable_v<vec<float, 1>, half>);
static_assert( std::is_assignable_v<vec<float, 1>, float>);
static_assert( std::is_assignable_v<vec<float, 1>, double>);
#if __SYCL_DEVICE_ONLY__
static_assert(EXCEPT_IN_PREVIEW std::is_assignable_v<vec<float, 1>, vec<half, 1>>);
#else
static_assert(EXCEPT_IN_PREVIEW std::is_assignable_v<vec<float, 1>, vec<half, 1>>);
#endif
static_assert( std::is_assignable_v<vec<float, 1>, vec<float, 1>>);
static_assert( std::is_assignable_v<vec<float, 1>, vec<double, 1>>);
static_assert(EXCEPT_IN_PREVIEW std::is_assignable_v<vec<float, 1>, sw_half_1>);
Expand Down
7 changes: 3 additions & 4 deletions sycl/test/basic_tests/vectors/cxx_conversions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TODO: Remove `__SYCL_USE_LIBSYCL8_VEC_IMPL` once it's auto-set.
// RUN: %clangxx -fsycl -fsyntax-only %s -fpreview-breaking-changes -D__SYCL_USE_LIBSYCL8_VEC_IMPL=0
// RUN: %clangxx -fsycl -fsyntax-only %s -fpreview-breaking-changes
// RUN: %clangxx -fsycl -fsyntax-only %s

#include <sycl/sycl.hpp>
Expand Down Expand Up @@ -53,7 +52,7 @@ using sw_double_2 = decltype(std::declval<vec<double, 4>>().swizzle<1, 2>());
static_assert( std::is_invocable_v<decltype(f_half_v1), half>);
static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_half_v1), float>);
static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_half_v1), double>);
static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_half_v1), sw_half_1>);
static_assert( std::is_invocable_v<decltype(f_half_v1), sw_half_1>);
static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_half_v1), sw_float_1>);
static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_half_v1), sw_double_1>);
static_assert( std::is_invocable_v<decltype(f_half_v1), vec<half, 1>>);
Expand All @@ -64,7 +63,7 @@ static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_float_v1), half>)
static_assert( std::is_invocable_v<decltype(f_float_v1), float>);
static_assert( std::is_invocable_v<decltype(f_float_v1), double>);
static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_float_v1), sw_half_1>);
static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_float_v1), sw_float_1>);
static_assert( std::is_invocable_v<decltype(f_float_v1), sw_float_1>);
static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_float_v1), sw_double_1>);
static_assert(EXCEPT_IN_PREVIEW std::is_invocable_v<decltype(f_float_v1), vec<half, 1>>);
static_assert( std::is_invocable_v<decltype(f_float_v1), vec<float, 1>>);
Expand Down
Loading
Loading