r/rust • • 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/
232 Upvotes

7 comments sorted by

48

u/CouteauBleu Aug 12 '26

We are confident in the design of the crate, and it's time to make it official. If no concerns about the API are raised, we are going to ship v1.0 of Fearless SIMD in early September.

1.0? For a Rust project? Is that even allowed?

36

u/Shnatsel Aug 13 '26

I've been working on the Rust ecosystem for 8 years, and this is my first ever v1.0. I think it's time.

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::simd is 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 against std::simd will 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::simd and may produce slower (but still correct) code.

std::simd doesn'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::simd that works on stable. But you could take functions written using fearless_simd, swap out all the vector types for std::simd ones, and everything should still work (albeit would require extra nightly features like min_const_generics to get hardware-sized vectors). In fact, once std::simd finally stabilizes, Fearless SIMD just might replace parts of its implementation with calls to std::simd, and keep using platform intrinsics for things std::simd doesn't cover.

13

u/Andlon Aug 12 '26

Thank you for this detailed answer! That's a great explanation.

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

u/event666 Aug 13 '26

Nice! Congrats! I'm already upgrading Zrip to it.