-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL][ESIMD] Replace use of intrinsics with spirv functions for addc/subb #13093
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
Changes from 1 commit
608bb81
608721d
52ceded
7b90096
0e8b39a
875bcdb
9d9efa7
9b953dd
9bbb5d2
ad0cb74
a30f641
7b60952
d9a395c
e596e18
5cee161
1f4124f
43ecf76
a26049a
1a3e5f6
6e32c41
5d48b4e
c6e9852
a9eff15
5f99e62
257bad9
a2a2b5d
b7a027d
82702a5
ffe5c8f
5a949e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,10 +101,10 @@ __esimd_abs_common_internal(simd<TArg, SZ> src0) { | |
| } | ||
|
|
||
| template <typename TRes, typename TArg> | ||
| ESIMD_NODEBUG ESIMD_INLINE | ||
| std::enable_if_t<detail::is_esimd_scalar<TRes>::value && | ||
| detail::is_esimd_scalar<TArg>::value, | ||
| TRes> | ||
| ESIMD_NODEBUG | ||
| ESIMD_INLINE std::enable_if_t<detail::is_esimd_scalar<TRes>::value && | ||
| detail::is_esimd_scalar<TArg>::value, | ||
| TRes> | ||
| __esimd_abs_common_internal(TArg src0) { | ||
| simd<TArg, 1> Src0 = src0; | ||
| simd<TArg, 1> Result = __esimd_abs_common_internal<TArg>(Src0); | ||
|
|
@@ -641,8 +641,8 @@ __ESIMD_API RT trunc(float src0, Sat sat = {}) { | |
| /// @param src0 The input mask. | ||
| /// @return The packed mask as an <code>unsgined int</code> 32-bit value. | ||
| template <int N> | ||
| ESIMD_NODEBUG ESIMD_INLINE | ||
| std::enable_if_t<(N == 8 || N == 16 || N == 32), uint> | ||
| ESIMD_NODEBUG | ||
| ESIMD_INLINE std::enable_if_t<(N == 8 || N == 16 || N == 32), uint> | ||
| pack_mask(simd_mask<N> src0) { | ||
| return __esimd_pack_mask<N>(src0.data()); | ||
| } | ||
|
|
@@ -655,8 +655,8 @@ ESIMD_NODEBUG ESIMD_INLINE | |
| /// @param src0 The input packed mask. | ||
| /// @return The unpacked mask as a simd_mask object. | ||
| template <int N> | ||
| ESIMD_NODEBUG ESIMD_INLINE | ||
| std::enable_if_t<(N == 8 || N == 16 || N == 32), simd_mask<N>> | ||
| ESIMD_NODEBUG | ||
| ESIMD_INLINE std::enable_if_t<(N == 8 || N == 16 || N == 32), simd_mask<N>> | ||
| unpack_mask(uint src0) { | ||
| return __esimd_unpack_mask<N>(src0); | ||
| } | ||
|
|
@@ -698,10 +698,9 @@ ballot(simd<T, N> mask) { | |
| /// @return a vector of \c uint32_t, where each element is set to bit count of | ||
| /// the corresponding element of the source operand. | ||
| template <typename T, int N> | ||
| ESIMD_NODEBUG ESIMD_INLINE | ||
| std::enable_if_t<std::is_integral<T>::value && (sizeof(T) <= 4), | ||
| simd<uint32_t, N>> | ||
| cbit(simd<T, N> src) { | ||
| ESIMD_NODEBUG ESIMD_INLINE std::enable_if_t< | ||
| std::is_integral<T>::value && (sizeof(T) <= 4), simd<uint32_t, N>> | ||
| cbit(simd<T, N> src) { | ||
| return __esimd_cbit<T, N>(src.data()); | ||
| } | ||
|
|
||
|
|
@@ -1176,128 +1175,140 @@ bfn(T src0, T src1, T src2) { | |
|
|
||
| /// @} sycl_esimd_logical | ||
|
|
||
| /// Performs add with carry of 2 unsigned 32-bit vectors. | ||
| /// Performs add with carry of 2 unsigned integral vectors. | ||
| /// @tparam N size of the vectors | ||
| /// @param carry vector that is going to hold resulting carry flag | ||
| /// @param src0 first term | ||
| /// @param src1 second term | ||
| /// @return sum of 2 terms, carry flag is returned through \c carry parameter | ||
| template <int N> | ||
| __ESIMD_API __ESIMD_NS::simd<uint32_t, N> | ||
| addc(__ESIMD_NS::simd<uint32_t, N> &carry, __ESIMD_NS::simd<uint32_t, N> src0, | ||
| __ESIMD_NS::simd<uint32_t, N> src1) { | ||
| std::pair<__ESIMD_DNS::vector_type_t<uint32_t, N>, | ||
| __ESIMD_DNS::vector_type_t<uint32_t, N>> | ||
| Result = __esimd_addc<uint32_t, N>(src0.data(), src1.data()); | ||
|
|
||
| carry = Result.first; | ||
| return Result.second; | ||
| template <int N, typename T> | ||
| __ESIMD_API std::enable_if_t<!std::is_signed_v<T> && std::is_integral_v<T>, | ||
| __ESIMD_NS::simd<T, N>> | ||
| addc(__ESIMD_NS::simd<T, N> &carry, __ESIMD_NS::simd<T, N> src0, | ||
| __ESIMD_NS::simd<T, N> src1) { | ||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| std::pair<__ESIMD_DNS::vector_type_t<T, N>, __ESIMD_DNS::vector_type_t<T, N>> | ||
| Result = __spirv_IAddCarry<T, N>(src0.data(), src1.data()); | ||
|
|
||
| carry = Result.second; | ||
| return Result.first; | ||
| #else | ||
| return 0; | ||
| #endif // __SYCL_DEVICE_ONLY__ | ||
| } | ||
|
|
||
| /// Performs add with carry of a unsigned 32-bit vector and scalar. | ||
| /// Performs add with carry of a unsigned integral vector and scalar. | ||
| /// @tparam N size of the vectors | ||
| /// @param carry vector that is going to hold resulting carry flag | ||
| /// @param src0 first term | ||
| /// @param src1 second term | ||
| /// @return sum of 2 terms, carry flag is returned through \c carry parameter | ||
| template <int N> | ||
| __ESIMD_API __ESIMD_NS::simd<uint32_t, N> | ||
| addc(__ESIMD_NS::simd<uint32_t, N> &carry, __ESIMD_NS::simd<uint32_t, N> src0, | ||
| uint32_t src1) { | ||
| __ESIMD_NS::simd<uint32_t, N> Src1V = src1; | ||
| template <int N, typename T> | ||
|
||
| __ESIMD_API std::enable_if_t<!std::is_signed_v<T> && std::is_integral_v<T>, | ||
| __ESIMD_NS::simd<T, N>> | ||
| addc(__ESIMD_NS::simd<T, N> &carry, __ESIMD_NS::simd<T, N> src0, T src1) { | ||
| __ESIMD_NS::simd<T, N> Src1V = src1; | ||
| return addc(carry, src0, Src1V); | ||
| } | ||
|
|
||
| /// Performs add with carry of a unsigned 32-bit scalar and vector. | ||
| /// Performs add with carry of a unsigned integral scalar and vector. | ||
| /// @tparam N size of the vectors | ||
| /// @param carry vector that is going to hold resulting carry flag | ||
| /// @param src0 first term | ||
| /// @param src1 second term | ||
| /// @return sum of 2 terms, carry flag is returned through \c carry parameter | ||
| template <int N> | ||
| __ESIMD_API __ESIMD_NS::simd<uint32_t, N> | ||
| addc(__ESIMD_NS::simd<uint32_t, N> &carry, uint32_t src0, | ||
| __ESIMD_NS::simd<uint32_t, N> src1) { | ||
| __ESIMD_NS::simd<uint32_t, N> Src0V = src0; | ||
| template <int N, typename T> | ||
| __ESIMD_API std::enable_if_t<!std::is_signed_v<T> && std::is_integral_v<T>, | ||
| __ESIMD_NS::simd<T, N>> | ||
| addc(__ESIMD_NS::simd<T, N> &carry, T src0, __ESIMD_NS::simd<T, N> src1) { | ||
| __ESIMD_NS::simd<T, N> Src0V = src0; | ||
| return addc(carry, Src0V, src1); | ||
| } | ||
|
|
||
| /// Performs add with carry of a unsigned 32-bit scalars. | ||
| /// Performs add with carry of a unsigned integral scalars. | ||
| /// @tparam N size of the vectors | ||
| /// @param carry scalar that is going to hold resulting carry flag | ||
| /// @param src0 first term | ||
| /// @param src1 second term | ||
| /// @return sum of 2 terms, carry flag is returned through \c carry parameter | ||
| __ESIMD_API uint32_t addc(uint32_t &carry, uint32_t src0, uint32_t src1) { | ||
| __ESIMD_NS::simd<uint32_t, 1> CarryV = carry; | ||
| __ESIMD_NS::simd<uint32_t, 1> Src0V = src0; | ||
| __ESIMD_NS::simd<uint32_t, 1> Src1V = src1; | ||
| __ESIMD_NS::simd<uint32_t, 1> Res = addc(CarryV, Src0V, Src1V); | ||
| template <typename T> | ||
| __ESIMD_API std::enable_if_t<!std::is_signed_v<T> && std::is_integral_v<T>, T> | ||
| addc(T &carry, T src0, T src1) { | ||
| __ESIMD_NS::simd<T, 1> CarryV = carry; | ||
| __ESIMD_NS::simd<T, 1> Src0V = src0; | ||
| __ESIMD_NS::simd<T, 1> Src1V = src1; | ||
| __ESIMD_NS::simd<T, 1> Res = addc(CarryV, Src0V, Src1V); | ||
| carry = CarryV[0]; | ||
| return Res[0]; | ||
| } | ||
|
|
||
| /// Performs substraction with borrow of 2 unsigned 32-bit vectors. | ||
| /// Performs substraction with borrow of 2 unsigned integral vectors. | ||
| /// @tparam N size of the vectors | ||
| /// @param borrow vector that is going to hold resulting borrow flag | ||
| /// @param src0 first term | ||
| /// @param src1 second term | ||
| /// @return difference of 2 terms, borrow flag is returned through \c borrow | ||
| /// parameter | ||
| template <int N> | ||
| __ESIMD_API __ESIMD_NS::simd<uint32_t, N> | ||
| subb(__ESIMD_NS::simd<uint32_t, N> &borrow, __ESIMD_NS::simd<uint32_t, N> src0, | ||
| __ESIMD_NS::simd<uint32_t, N> src1) { | ||
| std::pair<__ESIMD_DNS::vector_type_t<uint32_t, N>, | ||
| __ESIMD_DNS::vector_type_t<uint32_t, N>> | ||
| Result = __esimd_subb<uint32_t, N>(src0.data(), src1.data()); | ||
|
|
||
| borrow = Result.first; | ||
| return Result.second; | ||
| template <int N, typename T> | ||
| __ESIMD_API std::enable_if_t<!std::is_signed_v<T> && std::is_integral_v<T>, | ||
| __ESIMD_NS::simd<T, N>> | ||
| subb(__ESIMD_NS::simd<T, N> &borrow, __ESIMD_NS::simd<T, N> src0, | ||
| __ESIMD_NS::simd<T, N> src1) { | ||
| #ifdef __SYCL_DEVICE_ONLY__ | ||
| std::pair<__ESIMD_DNS::vector_type_t<T, N>, __ESIMD_DNS::vector_type_t<T, N>> | ||
| Result = __spirv_ISubBorrow<T, N>(src0.data(), src1.data()); | ||
|
|
||
| borrow = Result.second; | ||
| return Result.first; | ||
| #else | ||
| return 0; | ||
| #endif // __SYCL_DEVICE_ONLY__ | ||
| } | ||
|
|
||
| /// Performs substraction with borrow of unsigned 32-bit vector and scalar. | ||
| /// Performs substraction with borrow of unsigned integral vector and scalar. | ||
| /// @tparam N size of the vectors | ||
| /// @param borrow vector that is going to hold resulting borrow flag | ||
| /// @param src0 first term | ||
| /// @param src1 second term | ||
| /// @return difference of 2 terms, borrow flag is returned through \c borrow | ||
| /// parameter | ||
| template <int N> | ||
| __ESIMD_API __ESIMD_NS::simd<uint32_t, N> | ||
| subb(__ESIMD_NS::simd<uint32_t, N> &borrow, __ESIMD_NS::simd<uint32_t, N> src0, | ||
| uint32_t src1) { | ||
| __ESIMD_NS::simd<uint32_t, N> Src1V = src1; | ||
| template <int N, typename T> | ||
| __ESIMD_API std::enable_if_t<!std::is_signed_v<T> && std::is_integral_v<T>, | ||
| __ESIMD_NS::simd<T, N>> | ||
| subb(__ESIMD_NS::simd<T, N> &borrow, __ESIMD_NS::simd<T, N> src0, T src1) { | ||
| __ESIMD_NS::simd<T, N> Src1V = src1; | ||
| return subb(borrow, src0, Src1V); | ||
| } | ||
|
|
||
| /// Performs substraction with borrow of unsigned 32-bit scalar and vector. | ||
| /// Performs substraction with borrow of unsigned integral scalar and vector. | ||
| /// @tparam N size of the vectors | ||
| /// @param borrow vector that is going to hold resulting borrow flag | ||
| /// @param src0 first term | ||
| /// @param src1 second term | ||
| /// @return difference of 2 terms, borrow flag is returned through \c borrow | ||
| /// parameter | ||
| template <int N> | ||
| __ESIMD_API __ESIMD_NS::simd<uint32_t, N> | ||
| subb(__ESIMD_NS::simd<uint32_t, N> &borrow, uint32_t src0, | ||
| __ESIMD_NS::simd<uint32_t, N> src1) { | ||
| __ESIMD_NS::simd<uint32_t, N> Src0V = src0; | ||
| template <int N, typename T> | ||
| __ESIMD_API std::enable_if_t<!std::is_signed_v<T> && std::is_integral_v<T>, | ||
| __ESIMD_NS::simd<T, N>> | ||
| subb(__ESIMD_NS::simd<T, N> &borrow, T src0, __ESIMD_NS::simd<T, N> src1) { | ||
| __ESIMD_NS::simd<T, N> Src0V = src0; | ||
| return subb(borrow, Src0V, src1); | ||
| } | ||
|
|
||
| /// Performs substraction with borrow of 2 unsigned 32-bit scalars. | ||
| /// Performs substraction with borrow of 2 unsigned integral scalars. | ||
| /// @tparam N size of the vectors | ||
| /// @param borrow scalar that is going to hold resulting borrow flag | ||
| /// @param src0 first term | ||
| /// @param src1 second term | ||
| /// @return difference of 2 terms, borrow flag is returned through \c borrow | ||
| /// parameter | ||
| __ESIMD_API uint32_t subb(uint32_t &borrow, uint32_t src0, uint32_t src1) { | ||
| __ESIMD_NS::simd<uint32_t, 1> BorrowV = borrow; | ||
| __ESIMD_NS::simd<uint32_t, 1> Src0V = src0; | ||
| __ESIMD_NS::simd<uint32_t, 1> Src1V = src1; | ||
| __ESIMD_NS::simd<uint32_t, 1> Res = subb(BorrowV, Src0V, Src1V); | ||
| template <typename T> | ||
| __ESIMD_API std::enable_if_t<!std::is_signed_v<T> && std::is_integral_v<T>, T> | ||
| subb(T &borrow, T src0, T src1) { | ||
| __ESIMD_NS::simd<T, 1> BorrowV = borrow; | ||
| __ESIMD_NS::simd<T, 1> Src0V = src0; | ||
| __ESIMD_NS::simd<T, 1> Src1V = src1; | ||
| __ESIMD_NS::simd<T, 1> Res = subb(BorrowV, Src0V, Src1V); | ||
| borrow = BorrowV[0]; | ||
| return Res[0]; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep the lowering in LowerESIMD.cpp for a while - see the reasoning in other PR: #12935
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed