Skip to content

Commit 10cc604

Browse files
committed
Revert "[SYCL] vec abi unification and trivially copyable (intel#9492)"
This reverts commit 531aabf.
1 parent 11d0d87 commit 10cc604

File tree

10 files changed

+173
-191
lines changed

10 files changed

+173
-191
lines changed

sycl/include/sycl/detail/vector_traits.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,12 @@ inline namespace _V1 {
1616
namespace detail {
1717

1818
// 4.10.2.6 Memory layout and alignment
19-
// due to MSVC the maximum alignment for sycl::vec is 64 and this proposed
20-
// change is being brought to the spec committee.
21-
constexpr size_t MaxVecAlignment = 64;
22-
template <typename T, size_t N>
19+
template <typename T, int N>
2320
struct vector_alignment_impl
24-
: std::conditional_t<
25-
N == 3,
26-
std::integral_constant<size_t,
27-
(std::min)(sizeof(T) * 4, MaxVecAlignment)>,
28-
std::integral_constant<size_t,
29-
(std::min)(sizeof(T) * N, MaxVecAlignment)>> {
30-
};
21+
: std::conditional_t<N == 3, std::integral_constant<int, sizeof(T) * 4>,
22+
std::integral_constant<int, sizeof(T) * N>> {};
3123

32-
template <typename T, size_t N>
24+
template <typename T, int N>
3325
struct vector_alignment
3426
: vector_alignment_impl<std::remove_cv_t<std::remove_reference_t<T>>, N> {};
3527
} // namespace detail

sycl/include/sycl/half_type.hpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,28 @@ using BIsRepresentationT = half;
259259
// for vec because they are actually defined as an integer type under the
260260
// hood. As a result half values will be converted to the integer and passed
261261
// as a kernel argument which is expected to be floating point number.
262+
template <int NumElements> struct half_vec {
263+
alignas(
264+
vector_alignment<StorageT, NumElements>::value) StorageT s[NumElements];
262265

263-
using Vec2StorageT = std::array<StorageT, 2>;
264-
using Vec3StorageT = std::array<StorageT, 3>;
265-
using Vec4StorageT = std::array<StorageT, 4>;
266-
using Vec8StorageT = std::array<StorageT, 8>;
267-
using Vec16StorageT = std::array<StorageT, 16>;
266+
__SYCL_CONSTEXPR_HALF half_vec() : s{0.0f} { initialize_data(); }
267+
template <typename... Ts,
268+
typename = std::enable_if_t<(sizeof...(Ts) == NumElements) &&
269+
(std::is_same_v<half, Ts> && ...)>>
270+
__SYCL_CONSTEXPR_HALF half_vec(const Ts &...hs) : s{hs...} {}
271+
272+
constexpr void initialize_data() {
273+
for (size_t i = 0; i < NumElements; ++i) {
274+
s[i] = StorageT(0.0f);
275+
}
276+
}
277+
};
278+
279+
using Vec2StorageT = half_vec<2>;
280+
using Vec3StorageT = half_vec<3>;
281+
using Vec4StorageT = half_vec<4>;
282+
using Vec8StorageT = half_vec<8>;
283+
using Vec16StorageT = half_vec<16>;
268284
#endif
269285

270286
#ifndef __SYCL_DEVICE_ONLY__

0 commit comments

Comments
 (0)