Skip to content

[SYCL] vec abi changes behind -fpreview-breaking-changes flag #11697

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
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
11d0d87
Revert "[SYCL] Fix sycl::vec unary ops (#10722)"
cperkinsintel Oct 16, 2023
10cc604
Revert "[SYCL] vec abi unification and trivially copyable (#9492)"
cperkinsintel Oct 16, 2023
a5aca2f
initial commit. macros and flag values will be changing. Unary ops ne…
cperkinsintel Oct 17, 2023
f0236d5
unary ops initial
cperkinsintel Oct 17, 2023
d29b8b9
operator()! for old vec
cperkinsintel Oct 17, 2023
381a310
std::byte ? needs windows testing
cperkinsintel Oct 18, 2023
ab7a09d
switch to renamed preview macro/flag
cperkinsintel Oct 27, 2023
20e2822
test updates
cperkinsintel Oct 27, 2023
2a20f3c
clang-format and stray comment removed
cperkinsintel Oct 27, 2023
ee4b4e0
win fix and overlooked test directive restored
cperkinsintel Oct 27, 2023
6e6d9d8
stray comment removal
cperkinsintel Oct 27, 2023
e921385
reviewer feedback
cperkinsintel Oct 31, 2023
0fe7670
overlooked reviewer feedback
cperkinsintel Oct 31, 2023
14ef56f
more reviewer feedback
cperkinsintel Nov 1, 2023
113d7d4
is_same_v, remove debug code
cperkinsintel Nov 1, 2023
4e76c15
::value -> _v
cperkinsintel Nov 1, 2023
7029146
file reorganization
cperkinsintel Nov 2, 2023
3e66cb8
resolve merge conflicts
cperkinsintel Nov 2, 2023
8330e61
Merge branch 'sycl' into cperkins-vec-abi-behind-preview-flag
cperkinsintel Nov 3, 2023
59fcb4c
merge conflicts resolved
cperkinsintel Nov 3, 2023
400126e
clang-format sings and we all stop to listen
cperkinsintel Nov 3, 2023
93acf20
clang-format. huh.
cperkinsintel Nov 3, 2023
88e76ff
resolve merge conflicts
cperkinsintel Nov 8, 2023
8c018b3
resolve merge conflicts
cperkinsintel Nov 8, 2023
eaf1e80
returning to single file for types.hpp as requested.
cperkinsintel Nov 9, 2023
efe220a
injected file no longer needed
cperkinsintel Nov 9, 2023
43a18e9
clean up and reorg defined. interim commit
cperkinsintel Nov 10, 2023
2796e59
interim cleanup commit
cperkinsintel Nov 10, 2023
383a3bf
clang-format demands a sacrifice
cperkinsintel Nov 10, 2023
6a36bd4
remove/fix comments
cperkinsintel Nov 13, 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
5 changes: 5 additions & 0 deletions sycl/include/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,13 @@ template <typename T, int dimensions = 1,
typename std::enable_if_t<(dimensions > 0) && (dimensions <= 3)>>
class buffer : public detail::buffer_plain,
public detail::OwnerLessBase<buffer<T, dimensions, AllocatorT>> {
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
static_assert(is_device_copyable_v<T>,
"Underlying type of a buffer must be device copyable!");
#else
static_assert(!std::is_same_v<T, std::string>,
"'std::string' is not a device copyable type");
#endif

public:
using value_type = T;
Expand Down
7 changes: 7 additions & 0 deletions sycl/include/sycl/detail/vector_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ inline namespace _V1 {
namespace detail {

// 4.10.2.6 Memory layout and alignment
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
// 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;
Expand All @@ -28,6 +29,12 @@ struct vector_alignment_impl
std::integral_constant<size_t,
(std::min)(sizeof(T) * N, MaxVecAlignment)>> {
};
#else
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>> {};
#endif

template <typename T, size_t N>
struct vector_alignment
Expand Down
30 changes: 27 additions & 3 deletions sycl/include/sycl/half_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ using Vec3StorageT = StorageT __attribute__((ext_vector_type(3)));
using Vec4StorageT = StorageT __attribute__((ext_vector_type(4)));
using Vec8StorageT = StorageT __attribute__((ext_vector_type(8)));
using Vec16StorageT = StorageT __attribute__((ext_vector_type(16)));
#else
#else // SYCL_DEVICE_ONLY
using StorageT = detail::host_half_impl::half;
// No need to extract underlying data type for built-in functions operating on
// host
Expand All @@ -259,13 +259,37 @@ 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.

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
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
#else // __INTEL_PREVIEW_BREAKING_CHANGES
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>;
#endif // __INTEL_PREVIEW_BREAKING_CHANGES
#endif // SYCL_DEVICE_ONLY

#ifndef __SYCL_DEVICE_ONLY__
class half {
Expand Down
Loading