Why not Vec2 and Vec3 for Rust Std

Vec2 and Vec3 are very common in the crates and programs, and each of the crates have their own implementation

So, is it necessary to implement a Vec2 and Vec3 in Std?

Questions about changing Rust / std are generally better suited for IRLO.

To answer your question pedantically, it's clearly not necessary (but may be desirable).

Generally additions such as this get tried out in the ecosystem first, and then if popular enough, considered for inclusion (or reimplementation) in std. In this case you're probably talking about tinyvec or arrayvec or smallvec.

There's still lots of choices for them. For example, some crates want struct Vec3<T>(T, T, T);, some want struct Vec3<T>([T; 3]);, and some actually want struct Vec3<T>(Simd<T, 4>) -- making it bigger so it's one simd register.

If all the various crates ever agree on something, them maybe they could be in std, but they could also agree on one common crate and that would be fine too.

So my bet would be on them never getting into the standard library.

10 Likes

When are std::simd and AVX512 support themselves going to be stabilized?

There's AVX512 support via intrinsics already, and if you tell Rust that your CPU has AVX-512 support via -C target-cpu=x86-64-v4, it'll use AVX512 for autovectorization and std::simd.

Actually stabilizing std::simd will take some work - it's being tracked in Tracking Issue for RFC 2948: Portable SIMD · Issue #86656 · rust-lang/rust · GitHub which has a link to GitHub - rust-lang/project-portable-simd: Portable SIMD project group if you've got time and willingness to help out.

Edit: I missed that AVX512 intrinsics aren't stable. Compiler use of AVX512 is stable, however.

4 Likes

The intrinsics specifically for AVX512 aren't stable. E.g. _mm512_fmadd_pd. Am I missing something? The mask types themselves aren't stable.

Sorry, I'd missed that the intrinsics are unstable for AVX512 specifically - Tracking issue for stable SIMD in Rust · Issue #48556 · rust-lang/rust · GitHub is marked as the tracking issue for that. I see no blockers called out for the AVX-512 intrinsics there, so I suspect that you could push them to stabilization via Stabilizing Features - Rust Compiler Development Guide like any other feature that's not got blockers called out.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.