Skip to content

[SYCL] vec abi unification and trivially copyable #9492

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

Merged
merged 30 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6883d86
test and tidy
cperkinsintel May 16, 2023
dd2ef1b
min functionality. incomplete headers tho
cperkinsintel May 16, 2023
fc31559
CMakeList to suppress warning
cperkinsintel May 16, 2023
9d2e2ed
removing SYCL_USE_VECTOR_EXT and adding VectorDataType
cperkinsintel May 17, 2023
eb2c2e6
some clean up
cperkinsintel May 17, 2023
5b46ab1
remove comment
cperkinsintel May 17, 2023
d58891d
stray comment
cperkinsintel May 17, 2023
a1ca45e
unused var warn
cperkinsintel May 17, 2023
9b3a18b
more uninitialized vars? why not seeing these when building locally?
cperkinsintel May 17, 2023
a6a933f
std::byte not convertible to uchar. adding cast to avoid initializati…
cperkinsintel May 19, 2023
471dc58
adjust windows test
cperkinsintel May 22, 2023
bde71ef
Merge branch 'sycl' into cperkins-vec-abi-unification
cperkinsintel Jul 6, 2023
e538116
checkpoint. overlooked constexpr contstructor.
cperkinsintel Jul 7, 2023
a40d764
cleanup. still a test failing though.
cperkinsintel Jul 7, 2023
8d71c2c
update generic_type_traits.hpp
cperkinsintel Jul 12, 2023
a744971
update vector_t, no need for late cast. Still having a conversion iss…
cperkinsintel Jul 13, 2023
9c1ade0
clang-format destroying code. Added the missing conversion.
cperkinsintel Jul 13, 2023
7261467
clang-format demands tribute
cperkinsintel Jul 13, 2023
4af50f7
copy constructor s.b. constexpr
cperkinsintel Jul 13, 2023
a47dba8
min macro from windows.h thwarted
cperkinsintel Jul 13, 2023
d97e2b1
Merge branch 'sycl' into cperkins-vec-abi-unification
cperkinsintel Jul 24, 2023
3410dd1
found and working around strange internal compiler error coming from …
cperkinsintel Jul 25, 2023
c6e3652
Merge branch 'sycl' into cperkins-vec-abi-unification
cperkinsintel Jul 25, 2023
50d33a3
abi symbols linux
cperkinsintel Jul 25, 2023
99ee99f
reviewer feedback
cperkinsintel Jul 26, 2023
0dd4021
host only uses std::array
cperkinsintel Jul 27, 2023
c558894
now that host is never using ext_vector_type, the __NO_EXT_VECTOR_TYP…
cperkinsintel Jul 27, 2023
a8a0a26
Steffen's kludge > Chris' kludge
cperkinsintel Jul 28, 2023
c3f9677
remove unneeded HAS_EXT_VECTOR_TYPEs
cperkinsintel Jul 31, 2023
47a38e3
merge conflict resolved
cperkinsintel Aug 1, 2023
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
16 changes: 12 additions & 4 deletions sycl/include/sycl/detail/vector_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ inline namespace _V1 {
namespace detail {

// 4.10.2.6 Memory layout and alignment
template <typename T, int N>
// due to MSVC the maximum alignment for sycl::vec is 64 and this proposed
// change is being brought to the spec committee.
constexpr size_t MaxVecAlignment = 64;
template <typename T, size_t N>
struct vector_alignment_impl
: std::conditional_t<N == 3, std::integral_constant<int, sizeof(T) * 4>,
std::integral_constant<int, sizeof(T) * N>> {};
: std::conditional_t<
N == 3,
std::integral_constant<size_t,
(std::min)(sizeof(T) * 4, MaxVecAlignment)>,
std::integral_constant<size_t,
(std::min)(sizeof(T) * N, MaxVecAlignment)>> {
};

template <typename T, int N>
template <typename T, size_t N>
struct vector_alignment
: vector_alignment_impl<std::remove_cv_t<std::remove_reference_t<T>>, N> {};
} // namespace detail
Expand Down
26 changes: 5 additions & 21 deletions sycl/include/sycl/half_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,28 +253,12 @@ using BIsRepresentationT = half;
// for vec because they are actually defined as an integer type under the
// hood. As a result half values will be converted to the integer and passed
// as a kernel argument which is expected to be floating point number.
template <int NumElements> struct half_vec {
alignas(
vector_alignment<StorageT, NumElements>::value) StorageT s[NumElements];

__SYCL_CONSTEXPR_HALF half_vec() : s{0.0f} { initialize_data(); }
template <typename... Ts,
typename = std::enable_if_t<(sizeof...(Ts) == NumElements) &&
(std::is_same_v<half, Ts> && ...)>>
__SYCL_CONSTEXPR_HALF half_vec(const Ts &...hs) : s{hs...} {}

constexpr void initialize_data() {
for (size_t i = 0; i < NumElements; ++i) {
s[i] = StorageT(0.0f);
}
}
};

using Vec2StorageT = half_vec<2>;
using Vec3StorageT = half_vec<3>;
using Vec4StorageT = half_vec<4>;
using Vec8StorageT = half_vec<8>;
using Vec16StorageT = half_vec<16>;
using Vec2StorageT = std::array<StorageT, 2>;
using Vec3StorageT = std::array<StorageT, 3>;
using Vec4StorageT = std::array<StorageT, 4>;
using Vec8StorageT = std::array<StorageT, 8>;
using Vec16StorageT = std::array<StorageT, 16>;
#endif

#ifndef __SYCL_DEVICE_ONLY__
Expand Down
Loading