[PATCH v2] libstdc++: add ARM SVE support to std::experimental::simd
Matthias Kretz
m.kretz@gsi.de
Wed Mar 27 10:30:12 GMT 2024
On Wednesday, 27 March 2024 11:07:14 CET Richard Sandiford wrote:
> I'm still worried about:
>
> #if _GLIBCXX_SIMD_HAVE_SVE
> constexpr inline int __sve_vectorized_size_bytes = __ARM_FEATURE_SVE_BITS
> / 8; #else
> constexpr inline int __sve_vectorized_size_bytes = 0;
> #endif
>
> and the direct use __ARM_FEATURE_SVE_BITS elsewhere, for the reasons
> discussed here (including possible ODR problems):
>
> https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640037.html
> https://gcc.gnu.org/pipermail/gcc-patches/2024-January/643734.html
>
> Logically the vector length should be a template parameter rather than
> an invariant. Has this been resolved? If not, it feels like a blocker
> to me (sorry).
The vector length is always a template parameter to all user-facing API. Some
examples
1. on aarch64 the following is independent of SVE flags (and status quo):
simd<float> is an alias for
simd<float, simd_abi::_VecBuiltin<16>
fixed_size_simd<float, 4> is supposed to be ABI-stable anyway (passed via
the stack, alignof == sizeof).
2. with -msve-vector-bits=512:
native_simd<float> is an alias for
simd<float, simd_abi::_SveAbi<64, 64>>
simd<float, simd_abi::deduce_t<float, 4>> is an alias for
simd<float, simd_abi::_SveAbi<16, 64>>
3. with -msve-vector-bits=256:
native_simd<float> is an alias for
simd<float, simd_abi::_SveAbi<32, 32>>
simd<float, simd_abi::deduce_t<float, 4>> is an alias for
simd<float, simd_abi::_SveAbi<16, 32>>
Implementation functions are either [[gnu::always_inline]] or tagged with the
ABI tag type and the __odr_helper template argument (to ensure not-inlined
inline functions have unique names).
Does that make __ARM_FEATURE_SVE_BITS usage indirect enough?
Also for context, please consider that this is std::*experimental*::simd. The
underlying ISO document will likely get retracted at some point and the whole
API and implementation (hopefully) superseded by C++26. The main purpose of
the spec and implementation is to gather experience.
Best,
Matthias
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Center for Heavy Ion Research https://gsi.de
std::simd
──────────────────────────────────────────────────────────────────────────
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20240327/9a5e73b3/attachment-0001.sig>
More information about the Libstdc++
mailing list