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][ESIMD] Replace use of intrinsics with spirv functions for addc/subb #13093

Draft
wants to merge 27 commits into
base: sycl
Choose a base branch
from

Conversation

fineg74
Copy link
Contributor

@fineg74 fineg74 commented Mar 21, 2024

No description provided.

@@ -653,8 +653,6 @@ class ESIMDIntrinDescTable {
{"__spirv_ConvertFToBF16INTEL", {a(0)}}},
{"__devicelib_ConvertBF16ToFINTEL",
{"__spirv_ConvertBF16ToFINTEL", {a(0)}}},
{"addc", {"addc", {l(0)}}},
Copy link
Contributor

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

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the help of a macro would make it better: a) there will be no need for SFINAE and b) the templates would not require extra parameter T, which goes in very unusual order - after N - (usual order is <T, N>). Finally, passing simd_view as the 1 arg to vector+scalar op will require specifying only N, instead of <N, T>.
The idea is: (it may need some adaptation because of using SYCL_DEVICE_ONLY inside it:

#define __ESIMD_ADDC(T) \
template <int N> \
__ESIMD_API __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__ \
} \
/* OTHER 3 variants here (vec+scalar, scalar+vec, sccalar+scalar  */ \

__ESIMD_ADDC(uint8_t)
__ESIMD_ADDC(uint16_t)
__ESIMD_ADDC(uint32_t)
__ESIMD_ADDC(uint64_t)

Copy link
Contributor

@v-klochkov v-klochkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add 64-bit case too - it was the main inspiration/reason for support of ADDC/SUBB via SPIRV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants