From cd6e0b9878211306ef6848f2b237ba795f6f54f9 Mon Sep 17 00:00:00 2001 From: Robert Szafarczyk Date: Tue, 21 Oct 2025 15:27:54 +0100 Subject: [PATCH 1/4] [SYCL] Add missing operators to sycl::vec specialization The SYCL spec allows the following operators for sycl::vec: Comparison: ==, !=, <, <=, >, >= Bitwise: &, |, ^, ~, &=, |=, ^= This spec revision was introduced in the SYCL-Docs PR #674. --- sycl/include/sycl/detail/vector_arith.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sycl/include/sycl/detail/vector_arith.hpp b/sycl/include/sycl/detail/vector_arith.hpp index 380691c0b1906..55a2e6f66bbb7 100644 --- a/sycl/include/sycl/detail/vector_arith.hpp +++ b/sycl/include/sycl/detail/vector_arith.hpp @@ -674,7 +674,10 @@ template class vec_arith : public VecOperators>::template CombineImpl< std::bit_or, std::bit_and, std::bit_xor, - std::bit_not> { + std::bit_not, std::equal_to, std::not_equal_to, + std::less, std::greater, std::less_equal, + std::greater_equal, OpAssign>, + OpAssign>, OpAssign>> { protected: // NumElements can never be zero. Still using the redundant check to avoid // incomplete type errors. From 748584013f8020ea00045a60f9e9559d28bd37b4 Mon Sep 17 00:00:00 2001 From: Robert Szafarczyk Date: Tue, 21 Oct 2025 16:09:51 +0100 Subject: [PATCH 2/4] [SYCL] Add missing operators to the swizzle sycl::vec class --- sycl/include/sycl/vector.hpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/sycl/include/sycl/vector.hpp b/sycl/include/sycl/vector.hpp index cf923d1a9f821..75fa99e370d59 100644 --- a/sycl/include/sycl/vector.hpp +++ b/sycl/include/sycl/vector.hpp @@ -133,7 +133,8 @@ template class ScalarConversionOperatorsMixIn { template inline constexpr bool is_fundamental_or_half_or_bfloat16 = std::is_fundamental_v || std::is_same_v, half> || - std::is_same_v, ext::oneapi::bfloat16>; + std::is_same_v, ext::oneapi::bfloat16> || + std::is_same_v, std::byte>; // Per SYCL specification sycl::vec has different ctors available based on the // number of elements. Without C++20's concepts we'd have to use partial @@ -1143,12 +1144,12 @@ class SwizzleOp : public detail::NamedSwizzlesMixinBoth< return Tmp RELLOGOP Rhs; \ } - __SYCL_RELLOGOP(==, (!detail::is_byte_v)) - __SYCL_RELLOGOP(!=, (!detail::is_byte_v)) - __SYCL_RELLOGOP(>, (!detail::is_byte_v)) - __SYCL_RELLOGOP(<, (!detail::is_byte_v)) - __SYCL_RELLOGOP(>=, (!detail::is_byte_v)) - __SYCL_RELLOGOP(<=, (!detail::is_byte_v)) + __SYCL_RELLOGOP(==, true) + __SYCL_RELLOGOP(!=, true) + __SYCL_RELLOGOP(>, true) + __SYCL_RELLOGOP(<, true) + __SYCL_RELLOGOP(>=, true) + __SYCL_RELLOGOP(<=, true) __SYCL_RELLOGOP(&&, (!detail::is_byte_v && !detail::is_vgenfloat_v)) __SYCL_RELLOGOP(||, (!detail::is_byte_v && !detail::is_vgenfloat_v)) #undef __SYCL_RELLOGOP @@ -1527,8 +1528,8 @@ class SwizzleOp : public detail::NamedSwizzlesMixinBoth< m_RightOperation(std::move(Rhs.m_RightOperation)) {} // Either performing CurrentOperation on results of left and right operands - // or reading values from actual vector. Perform implicit type conversion when - // the number of elements == 1 + // or reading values from actual vector. Always perform explicit type conversion + // because std::byte operators are strongly typed. template CommonDataT getValue(EnableIfOneIndex Index) const { @@ -1537,8 +1538,8 @@ class SwizzleOp : public detail::NamedSwizzlesMixinBoth< return (*m_Vector)[Idxs[Index]]; } auto Op = OperationCurrentT(); - return Op(m_LeftOperation.getValue(Index), - m_RightOperation.getValue(Index)); + return Op(static_cast(m_LeftOperation.getValue(Index)), + static_cast(m_RightOperation.getValue(Index))); } template @@ -1548,8 +1549,8 @@ class SwizzleOp : public detail::NamedSwizzlesMixinBoth< return (*m_Vector)[Idxs[Index]]; } auto Op = OperationCurrentT(); - return Op(m_LeftOperation.getValue(Index), - m_RightOperation.getValue(Index)); + return Op(static_cast(m_LeftOperation.getValue(Index)), + static_cast(m_RightOperation.getValue(Index))); } template