Learn Rust the Dangerous Way
cliffle.com
cliffle.com
It would be nice to have a sort of autovec-or-error annotation for preventing this.
It defines a generic `Simd<T, N>` type, expressing "This is a vector of T elements (such as i8), and is present in chunks of N". Methods that are easily vectorisable are defined on it, so if you can express what you want to do with one, you'll get well defined vectorised operations. Maybe not as perfect as you could hand write if you know what you're doing, but it _does_ guarantee to use vector instructions, so you're not at the behest of the compiler recognising a loop idiom.
https://www.godbolt.org/z/MW8WeYjGo
Not sure why Rust needs a lot of experimenting tbh, it's been in Clang since forever.
https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaP...
(As opposed to the non-dangerous way which means writing safe code to begin with and mentioning unsafe as the exception)
Only the 100% Rust-safe implementation uses auto-vectorization and is at 0.73% of the RUNTIME of the C code. (https://cliffle.com/p/dangerust/6/#performance-evaluation)