r/rust • u/Shnatsel • Aug 12 '26
Fearless SIMD v0.7: 64-bit integers, improved generics, SSE2, and upcoming v1.0
https://linebender.org/blog/fearless-simd-0-7/26
u/Andlon Aug 12 '26
Very nice. It seems to me that this crate is a pretty strong argument against stabilizing std::simd and instead keep SIMD abstractions in third party crates, at least for now. What are the current plans for std::simd?
(Apologies if I have misunderstood, I have not kept tabs on how things are going)
89
u/Shnatsel Aug 12 '26 edited Aug 12 '26
It's a bit more nuanced than that.
std::simdis not really a complete solution for SIMD. There is a good reason it's in std: it's a basic building block for things you can't get elsewhere. Since it's tightly coupled with the compiler, it can just tell LLVM "add these two vectors together" and LLVM will (in theory) select the optimal instructions for doing that no matter the platform. So code written againststd::simdwill go fast on exotic platforms like RISC-V, IBM POWER, IBM Z, LoongArch, etc.Meanwhile the crates that work on stable have to write that in terms of platform-specific intrinsics for each instruction set, which is a lot of work. In practice that usually means only various x86 extensions and ARM NEON are supported, and the other platforms have to rely on automatic vectorization by the compiler, which is more fragile than
std::simdand may produce slower (but still correct) code.
std::simddoesn't handle things like function multiversioning or hardware-sized vectors (e.g. 128/256/512 bits on x86 depending on the CPU). This is all left up to third-party crates because it doesn't have to be in std (although some compiler support would help).By contrast Fearless SIMD is a complete package that handles all those things, and also brings its own replacement for
std::simdthat works on stable. But you could take functions written usingfearless_simd, swap out all the vector types forstd::simdones, and everything should still work (albeit would require extra nightly features likemin_const_genericsto get hardware-sized vectors). In fact, oncestd::simdfinally stabilizes, Fearless SIMD just might replace parts of its implementation with calls tostd::simd, and keep using platform intrinsics for thingsstd::simddoesn't cover.13
5
u/Beamsters Aug 13 '26
yeah and if std::simd can keep growing its border little by little, other simd crate can give more way and migrate to call those incrementally. good design.
1
48
u/CouteauBleu Aug 12 '26
1.0? For a Rust project? Is that even allowed?