Skip to content

Commit b48f41a

Browse files
[NFC][SYCL] Refactor EnableIfSwizzleVec in sycl/stream.hpp (#16906)
1 parent 3987f3a commit b48f41a

File tree

1 file changed

+14
-29
lines changed

1 file changed

+14
-29
lines changed

sycl/include/sycl/stream.hpp

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
1919
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
2020
#include <sycl/detail/owner_less_base.hpp> // for OwnerLessBase
21-
#include <sycl/ext/oneapi/bfloat16.hpp> // for bfloat16
22-
#include <sycl/group.hpp> // for group
23-
#include <sycl/h_item.hpp> // for h_item
24-
#include <sycl/half_type.hpp> // for half, operator-, operator<
25-
#include <sycl/handler.hpp> // for handler
26-
#include <sycl/item.hpp> // for item
27-
#include <sycl/nd_item.hpp> // for nd_item
28-
#include <sycl/nd_range.hpp> // for nd_range
29-
#include <sycl/property_list.hpp> // for property_list
30-
#include <sycl/range.hpp> // for range
31-
#include <sycl/vector.hpp> // for vec, SwizzleOp
21+
#include <sycl/detail/type_traits/vec_marray_traits.hpp>
22+
#include <sycl/ext/oneapi/bfloat16.hpp> // for bfloat16
23+
#include <sycl/group.hpp> // for group
24+
#include <sycl/h_item.hpp> // for h_item
25+
#include <sycl/half_type.hpp> // for half, operator-, operator<
26+
#include <sycl/handler.hpp> // for handler
27+
#include <sycl/item.hpp> // for item
28+
#include <sycl/nd_item.hpp> // for nd_item
29+
#include <sycl/nd_range.hpp> // for nd_range
30+
#include <sycl/property_list.hpp> // for property_list
31+
#include <sycl/range.hpp> // for range
3232

3333
#include <cstddef> // for size_t, byte
3434
#include <memory> // for hash, shared_ptr
@@ -745,23 +745,6 @@ inline void writeHItem(GlobalBufAccessorT &GlobalFlushBuf,
745745
Len += append(Buf + Len, "\n)");
746746
write(GlobalFlushBuf, FlushBufferSize, WIOffset, Buf, Len);
747747
}
748-
749-
template <typename> struct IsSwizzleOp : std::false_type {};
750-
751-
template <typename VecT, typename OperationLeftT, typename OperationRightT,
752-
template <typename> class OperationCurrentT, int... Indexes>
753-
struct IsSwizzleOp<sycl::detail::SwizzleOp<
754-
VecT, OperationLeftT, OperationRightT, OperationCurrentT, Indexes...>>
755-
: std::true_type {
756-
using T = typename VecT::element_type;
757-
using Type = typename sycl::vec<T, (sizeof...(Indexes))>;
758-
};
759-
760-
template <typename T>
761-
using EnableIfSwizzleVec =
762-
typename std::enable_if_t<IsSwizzleOp<T>::value,
763-
typename IsSwizzleOp<T>::Type>;
764-
765748
} // namespace detail
766749

767750
enum class stream_manipulator {
@@ -1310,7 +1293,9 @@ inline const stream &operator<<(const stream &Out,
13101293
return Out;
13111294
}
13121295

1313-
template <typename T, typename RT = detail::EnableIfSwizzleVec<T>>
1296+
template <typename T,
1297+
typename RT = std::enable_if_t<detail::is_swizzle_v<T>,
1298+
detail::simplify_if_swizzle_t<T>>>
13141299
inline const stream &operator<<(const stream &Out, const T &RHS) {
13151300
RT V = RHS;
13161301
Out << V;

0 commit comments

Comments
 (0)