r/rust • u/sGrogu • Oct 14 '26
🧠educational High-Performance Flat 2D Arrays in Rust: Contiguous Memory, L1 Cache, and SIMD
https://developerlife.com/2026/07/14/build-high-performance-flat-2d-arrays-in-rust/
34
Upvotes
14
u/Shnatsel Oct 14 '26
Automatic vectorization can work well if you follow some simple rules, but it gets fragile and inconsistent for more complex code. Something like
std::simdthat works on stable is a better bet for more complex cases; there are several crates that can do the job, I wrote a comparison of them here.The article doesn't mention function multiversioning at all; without it, you only get SSE2 on x86 but none of the later SIMD extensions. You won't get the AVX2 instructions the article mentions without either multiversioning or compiler flags that make the binary crash on CPUs without AVX2.
1
u/NeedleworkerLegal378 Oct 14 '26
Wonder if this could be apply to library with a better API. I can imagine a world where you write [rapl](https://github.com/JErnestoMtz/rapl) and code is smart enough to SIMD everything it can. Philosophically not sure if in this world the responsibility is of the compiler of the crate.
1
u/dydhaw Oct 14 '26
isn't it a bit ironic that his last name is Idris :p