Use SIMD internally #145
Description
The sleef
library is available with the Boost software license (extremely permissive) and implements the libm intrinsics using SIMD instructions when possible. It currently supports:
This library currently supports several SIMD architectures :
- x86 - SSE2, SSE4.1, AVX, FMA4, AVX2+FMA3, AVX512F
- AArch64 - Advanced SIMD, SVE
- AArch32 - NEON
- PowerPC64 - VSX
libm
should use cfg(target_feature)
(stable) internally to detect the availability of SIMD instructions at compile-time and use them when it is possible and pays off.
We could add an unstable
cargo feature to libm
to enable using nightly only features to detect and use asimd
, neon
, vsx
, and AVX-512
(there are still unstable in core::arch
). Some asimd
, neon
, vsx
and AVX-512
intrinsics are already available in core::arch
in nightly, and it shouldn't be too difficult to add anyone that's missing.
As long as we include the proper contribution notice, and maybe dual license the library under the Boost license (this should be easily possible), we could reuse 1:1 the sleef implementation which competes performance wise with libm and intel's libraries. There is a commit under review to add Sleef to LLVM, but it has been stalled for over a year.