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] Changes to vec/swizzle implementation #14789

Draft
wants to merge 87 commits into
base: sycl
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
1617c6c
[SYCL] Refactor vec/swizzle implementations, remove expression trees
aelovikov-intel Jul 25, 2024
5513578
Optimized non-bool/non-logical unary ops
aelovikov-intel Jul 30, 2024
43eb8ae
Some optimized logical binops
aelovikov-intel Jul 30, 2024
6d33c7a
Don't include `vector_traits.hpp`
aelovikov-intel Jul 30, 2024
621f4a8
Include `bfloat16` in `not_fp` check
aelovikov-intel Jul 30, 2024
d517b89
More comments
aelovikov-intel Jul 30, 2024
d61241f
Add Steffen's test, fix a bug it uncovered
aelovikov-intel Jul 30, 2024
4a6d061
Test for repeated indices, remove "preview" REQUIRE
aelovikov-intel Jul 30, 2024
4e16cb5
Remove stale TODO
aelovikov-intel Jul 30, 2024
b3889ed
copy-assignment for swizzle
aelovikov-intel Jul 30, 2024
5db502c
`[[maybe_unused]]` for an old buggy gcc
aelovikov-intel Aug 1, 2024
481050f
Disable swizzle->vec conversion for 1-elem swizzles
aelovikov-intel Aug 1, 2024
897f1f9
Update sycl/include/sycl/vector.hpp
aelovikov-intel Aug 2, 2024
1d28057
ConversionOperatorMixin generalization
aelovikov-intel Aug 2, 2024
b6ba6cd
[NFCI][SYCL] Simplify implementation of vec's variadic ctor
aelovikov-intel Jul 31, 2024
e0791f9
[SYCL] `sycl::vec::operator=` changes
aelovikov-intel Jul 31, 2024
9dce6df
[SYCL] XYZW/RGBA/INDEX_ACCESS swizzles should return swizzles
aelovikov-intel Jul 30, 2024
4a3d546
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel Aug 5, 2024
11755e8
Try to fix CUDA build
aelovikov-intel Aug 5, 2024
dc43ebc
Fixes for E2E failures
aelovikov-intel Aug 5, 2024
ad3c303
Fix CI failure on Win
aelovikov-intel Aug 5, 2024
328bb8f
Restrict variadic vec ctor to N > 1
aelovikov-intel Aug 7, 2024
74c8b80
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel Aug 8, 2024
05050bb
"untemplate" `vec::operator vector_t()`
aelovikov-intel Aug 8, 2024
9c38066
clang-format
aelovikov-intel Aug 8, 2024
072a9f4
Address review feedback
aelovikov-intel Aug 9, 2024
f4d722c
Add an option to make ConversionOperatorMixin provide `explicit` conv…
aelovikov-intel Aug 9, 2024
c96c0c7
Move `vec::convert` into `sycl/detail/vector_convert.hpp`
aelovikov-intel Aug 9, 2024
762e678
Standalone `sycl/vector.hpp`
aelovikov-intel Aug 9, 2024
238bf86
Infrastructure to make one-eleme swizzles return scalars
aelovikov-intel Aug 10, 2024
f546f21
Infrastructure to limit some of the binop mixins
aelovikov-intel Aug 9, 2024
682e614
Remove `detail/vector_traits.hpp` - not used anymore
aelovikov-intel Aug 12, 2024
e1b882c
`__SYCL_VEC_STANDALONE` for `sycl::half`
aelovikov-intel Aug 12, 2024
ed6752b
Remove non-standard `vec::operator=(swizzle)`
aelovikov-intel Aug 12, 2024
dd6e085
Explicit `operator vector_t` + limit hidden friends to `N > 1`
aelovikov-intel Aug 13, 2024
8eeb60d
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel Aug 13, 2024
9722abe
clang-format
aelovikov-intel Aug 16, 2024
9c51ef8
Improve `is_op_available`
aelovikov-intel Aug 16, 2024
fc4bf0a
Use `bool Enable` in binop mixins
aelovikov-intel Aug 16, 2024
554e6c0
Minor changes to mixins
aelovikov-intel Aug 19, 2024
529e4e7
Fix element type constraint on template swizzle ops
aelovikov-intel Aug 19, 2024
bb4fa54
Remove `VecT` from swizzle template op mixins
aelovikov-intel Aug 19, 2024
2bec5bd
`is_assignable_swizzle` -> `has_repeating_indexes` and inline `is_const`
aelovikov-intel Aug 19, 2024
ad31096
Remove `vec` from ADL for swizzles
aelovikov-intel Aug 19, 2024
1eb65f7
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel Aug 19, 2024
374b125
Big mixin refactor
aelovikov-intel Aug 20, 2024
f017dd7
Fix a bug
aelovikov-intel Aug 20, 2024
5619dd1
WIP last changes, vec full + partial swizzle
aelovikov-intel Aug 20, 2024
52cdb80
WIP last changes, part 2
aelovikov-intel Aug 20, 2024
f1da047
WIP
aelovikov-intel Aug 20, 2024
8401dc7
Another WIP
aelovikov-intel Aug 20, 2024
eca85a1
Some fixes
aelovikov-intel Aug 20, 2024
66f521e
math builtins fix
aelovikov-intel Aug 20, 2024
9c70691
WIP
aelovikov-intel Aug 21, 2024
6151948
Revert sycl/test-e2e/Regression/vec_rel_swizzle_ops.cpp changes
aelovikov-intel Aug 21, 2024
1455856
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel Aug 21, 2024
84b15e8
Revert some of the earlier tests' changes
aelovikov-intel Aug 21, 2024
5ef87a4
Revert/simplify now unnecessary changes in headers
aelovikov-intel Aug 21, 2024
9368c71
Revert sycl/include/sycl/detail/spirv.hpp changes
aelovikov-intel Aug 21, 2024
762cf75
More reverts/simplifications in e2e
aelovikov-intel Aug 21, 2024
82382e2
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel Aug 22, 2024
506e065
WIP experiments + extra restriction on operator bool
aelovikov-intel Aug 22, 2024
c434bd7
Regenerate check_device_code CHECKs
aelovikov-intel Aug 22, 2024
fd0be88
Revert some changes in stream.hpp
aelovikov-intel Aug 22, 2024
068c1e9
Revert changes in sycl/test/basic_tests/vectors/vectors.cpp
aelovikov-intel Aug 22, 2024
a75e9a1
Fix tests with multi_ptr's operator+ ambiguity
aelovikov-intel Aug 22, 2024
8f2c3aa
Fix failing test
aelovikov-intel Aug 22, 2024
c7b14bd
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel Aug 22, 2024
2786937
Regenerated CHECKs
aelovikov-intel Aug 22, 2024
0485c8f
is_explicitly_convertible and remove operator bool
aelovikov-intel Aug 22, 2024
c2f9fe7
Fix for multi_ptr's operator+
aelovikov-intel Aug 22, 2024
e96adef
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel Aug 23, 2024
3182a68
`from_incomplete` without uses
aelovikov-intel Aug 23, 2024
7f7b69b
WIP
aelovikov-intel Aug 23, 2024
3f13f11
`is_op_available<Self, Op>`
aelovikov-intel Aug 23, 2024
c2e3524
WIP2
aelovikov-intel Aug 23, 2024
7caf4e0
WIP3
aelovikov-intel Aug 23, 2024
9e767fb
WIP4
aelovikov-intel Aug 23, 2024
f2d808f
WIP5
aelovikov-intel Aug 23, 2024
e11ff45
Another WIP
aelovikov-intel Aug 23, 2024
4501bc1
Simplify `SwizzleBase`'s template parameters
aelovikov-intel Aug 23, 2024
fcb8899
Add EBO static_assert
aelovikov-intel Aug 23, 2024
7d4b83f
Workaround MSVC bug: https://godbolt.org/z/bMdn3hWds
aelovikov-intel Aug 26, 2024
7a3d644
Fix failing e2e tests (single source)
aelovikov-intel Aug 26, 2024
280bbb6
scalar named swizzles
aelovikov-intel Aug 26, 2024
dc9d597
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel Sep 3, 2024
5ebc90c
`vector_t` WIP change
aelovikov-intel Sep 4, 2024
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
40 changes: 12 additions & 28 deletions sycl/include/sycl/builtins_utils_vec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ struct is_valid_elem_type<marray<T, N>, Ts...>
template <typename T, int N, typename... Ts>
struct is_valid_elem_type<vec<T, N>, Ts...>
: std::bool_constant<check_type_in_v<T, Ts...>> {};
template <typename VecT, typename OperationLeftT, typename OperationRightT,
template <typename> class OperationCurrentT, int... Indexes,
typename... Ts>
struct is_valid_elem_type<SwizzleOp<VecT, OperationLeftT, OperationRightT,
OperationCurrentT, Indexes...>,
Ts...>
template <typename VecT, int... Indexes, typename... Ts>
struct is_valid_elem_type<Swizzle<VecT, Indexes...>, Ts...>
: std::bool_constant<check_type_in_v<typename VecT::element_type, Ts...>> {
};
template <typename ElementType, access::address_space Space,
Expand All @@ -48,10 +44,8 @@ template <typename T, size_t N>
struct num_elements<marray<T, N>> : std::integral_constant<size_t, N> {};
template <typename T, int N>
struct num_elements<vec<T, N>> : std::integral_constant<size_t, size_t(N)> {};
template <typename VecT, typename OperationLeftT, typename OperationRightT,
template <typename> class OperationCurrentT, int... Indexes>
struct num_elements<SwizzleOp<VecT, OperationLeftT, OperationRightT,
OperationCurrentT, Indexes...>>
template <typename VecT, int... Indexes>
struct num_elements<Swizzle<VecT, Indexes...>>
: std::integral_constant<size_t, sizeof...(Indexes)> {};

// Utilty trait for checking that the number of elements in T is in Ns.
Expand All @@ -64,10 +58,8 @@ constexpr bool is_valid_size_v = is_valid_size<T, Ns...>::value;

// Utility for converting a swizzle to a vector or preserve the type if it isn't
// a swizzle.
template <typename VecT, typename OperationLeftT, typename OperationRightT,
template <typename> class OperationCurrentT, int... Indexes>
struct simplify_if_swizzle<SwizzleOp<VecT, OperationLeftT, OperationRightT,
OperationCurrentT, Indexes...>> {
template <typename VecT, int... Indexes>
struct simplify_if_swizzle<Swizzle<VecT, Indexes...>> {
using type = vec<typename VecT::element_type, sizeof...(Indexes)>;
};

Expand All @@ -83,10 +75,8 @@ template <typename T, size_t N> struct same_size_signed_int<marray<T, N>> {
template <typename T, int N> struct same_size_signed_int<vec<T, N>> {
using type = vec<typename same_size_signed_int<T>::type, N>;
};
template <typename VecT, typename OperationLeftT, typename OperationRightT,
template <typename> class OperationCurrentT, int... Indexes>
struct same_size_signed_int<SwizzleOp<VecT, OperationLeftT, OperationRightT,
OperationCurrentT, Indexes...>> {
template <typename VecT, int... Indexes>
struct same_size_signed_int<Swizzle<VecT, Indexes...>> {
// Converts to vec for simplicity.
using type =
vec<typename same_size_signed_int<typename VecT::element_type>::type,
Expand All @@ -99,10 +89,8 @@ template <typename T, size_t N> struct same_size_unsigned_int<marray<T, N>> {
template <typename T, int N> struct same_size_unsigned_int<vec<T, N>> {
using type = vec<typename same_size_unsigned_int<T>::type, N>;
};
template <typename VecT, typename OperationLeftT, typename OperationRightT,
template <typename> class OperationCurrentT, int... Indexes>
struct same_size_unsigned_int<SwizzleOp<VecT, OperationLeftT, OperationRightT,
OperationCurrentT, Indexes...>> {
template <typename VecT, int... Indexes>
struct same_size_unsigned_int<Swizzle<VecT, Indexes...>> {
// Converts to vec for simplicity.
using type =
vec<typename same_size_unsigned_int<typename VecT::element_type>::type,
Expand All @@ -122,12 +110,8 @@ template <typename NewElemT, typename T, int N>
struct change_elements<NewElemT, vec<T, N>> {
using type = vec<typename change_elements<NewElemT, T>::type, N>;
};
template <typename NewElemT, typename VecT, typename OperationLeftT,
typename OperationRightT, template <typename> class OperationCurrentT,
int... Indexes>
struct change_elements<NewElemT,
SwizzleOp<VecT, OperationLeftT, OperationRightT,
OperationCurrentT, Indexes...>> {
template <typename NewElemT, typename VecT, int... Indexes>
struct change_elements<NewElemT, Swizzle<VecT, Indexes...>> {
// Converts to vec for simplicity.
using type =
vec<typename change_elements<NewElemT, typename VecT::element_type>::type,
Expand Down
32 changes: 16 additions & 16 deletions sycl/include/sycl/detail/image_accessor_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ UnnormalizeCoordinates(const T &Coords, const range<3> &Range) {
template <typename T>
std::enable_if_t<IsValidCoordType<T>::value, vec<T, 2>>
UnnormalizeCoordinates(const vec<T, 2> &Coords, const range<3> &Range) {
return {Coords.x() * Range[0], Coords.y() * Range[1]};
return {Coords[0] * Range[0], Coords[1] * Range[1]};
}

template <typename T>
std::enable_if_t<IsValidCoordType<T>::value, vec<T, 4>>
UnnormalizeCoordinates(const vec<T, 4> &Coords, const range<3> &Range) {
return {Coords.x() * Range[0], Coords.y() * Range[1], Coords.z() * Range[2],
0};
return {Coords[0] * Range[0], Coords[1] * Range[1], Coords[2] * Range[2], 0};
}

// Converts the Coordinates from any dimensions into float4.
Expand Down Expand Up @@ -96,15 +95,15 @@ template <typename T>
std::enable_if_t<std::is_integral_v<T>, size_t>
getImageOffset(const vec<T, 2> &Coords, const id<3> ImgPitch,
const uint8_t ElementSize) {
return Coords.x() * ElementSize + Coords.y() * ImgPitch[0];
return Coords[0] * ElementSize + Coords[1] * ImgPitch[0];
}

template <typename T>
std::enable_if_t<std::is_integral_v<T>, size_t>
getImageOffset(const vec<T, 4> &Coords, const id<3> ImgPitch,
const uint8_t ElementSize) {
return Coords.x() * ElementSize + Coords.y() * ImgPitch[0] +
Coords.z() * ImgPitch[1];
return Coords[0] * ElementSize + Coords[1] * ImgPitch[0] +
Coords[2] * ImgPitch[1];
}

// Process float4 Coordinates and return the appropriate Pixel
Expand Down Expand Up @@ -142,7 +141,7 @@ vec<T, 4> readPixel(T *Ptr, const image_channel_order ChannelOrder,
case image_channel_order::r:
case image_channel_order::rx:
Pixel.x() = Ptr[0];
Pixel.w() = 1;
Pixel.w() = T{1};
break;
case image_channel_order::intensity:
Pixel.x() = Ptr[0];
Expand All @@ -154,13 +153,13 @@ vec<T, 4> readPixel(T *Ptr, const image_channel_order ChannelOrder,
Pixel.x() = Ptr[0];
Pixel.y() = Ptr[0];
Pixel.z() = Ptr[0];
Pixel.w() = 1.0;
Pixel.w() = T{1};
break;
case image_channel_order::rg:
case image_channel_order::rgx:
Pixel.x() = Ptr[0];
Pixel.y() = Ptr[1];
Pixel.w() = 1.0;
Pixel.w() = T{1};
break;
case image_channel_order::ra:
Pixel.x() = Ptr[0];
Expand All @@ -176,7 +175,7 @@ vec<T, 4> readPixel(T *Ptr, const image_channel_order ChannelOrder,
Pixel.x() = Ptr[0];
Pixel.y() = Ptr[1];
Pixel.z() = Ptr[2];
Pixel.w() = 1.0;
Pixel.w() = T{1};
}
break;
case image_channel_order::rgba:
Expand Down Expand Up @@ -356,7 +355,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
// Assuming: (float)c / 31.0f; c represents the 5-bit integer.
// (float)c / 63.0f; c represents the 6-bit integer.
// PixelData.x will be of type std::uint16_t.
ushort4 Temp(PixelData.x());
ushort4 Temp(static_cast<ChannelType>(PixelData.x()));
ushort4 MaskBits(0xF800 /*r:bits 11-15*/, 0x07E0 /*g:bits 5-10*/,
0x001F /*b:bits 0-4*/, 0x0000);
ushort4 ShiftBits(11, 5, 0, 0);
Expand All @@ -372,7 +371,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,

// Extracting each 5-bit channel data.
// PixelData.x will be of type std::uint16_t.
ushort4 Temp(PixelData.x());
ushort4 Temp(static_cast<ChannelType>(PixelData.x()));
ushort4 MaskBits(0x7C00 /*r:bits 10-14*/, 0x03E0 /*g:bits 5-9*/,
0x001F /*b:bits 0-4*/, 0x0000);
ushort4 ShiftBits(10, 5, 0, 0);
Expand All @@ -383,7 +382,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
case image_channel_type::unorm_int_101010: {
// Extracting each 10-bit channel data.
// PixelData.x will be of type std::uint32_t.
uint4 Temp(PixelData.x());
uint4 Temp(static_cast<ChannelType>(PixelData.x()));
uint4 MaskBits(0x3FF00000 /*r:bits 20-29*/, 0x000FFC00 /*g:bits 10-19*/,
0x000003FF /*b:bits 0-9*/, 0x00000000);
uint4 ShiftBits(20, 10, 0, 0);
Expand Down Expand Up @@ -587,8 +586,9 @@ convertWriteData(const float4 WriteData,
// location from the first element.
// For CL_UNORM_SHORT_555, bit 15 is undefined, R is in bits 14:10, G
// in bits 9:5 and B in bits 4:0
PixelData.x() =
(PixelData.x() << 10) | (PixelData.y() << 5) | PixelData.z();
PixelData.x() = (PixelData.x() << static_cast<std::uint16_t>(10)) |
(PixelData.y() << static_cast<std::uint16_t>(5)) |
PixelData.z();
return PixelData.convert<ChannelType>();
}
case image_channel_type::unorm_int_101010:
Expand All @@ -600,7 +600,7 @@ convertWriteData(const float4 WriteData,
processFloatDataToPixel<std::uint32_t>(WriteData, 1023.0f);
PixelData = sycl::min(PixelData, static_cast<ChannelType>(0x3ff));
PixelData.x() =
(PixelData.x() << 20) | (PixelData.y() << 10) | PixelData.z();
(PixelData.x() << 20u) | (PixelData.y() << 10u) | PixelData.z();
return PixelData.convert<ChannelType>();
}
case image_channel_type::signed_int8:
Expand Down
Loading