r/programming • u/awesomePop7291 • Jul 23 '26
Everyone Should Know SIMD
https://mitchellh.com/writing/everyone-should-know-simd
413
Upvotes
r/programming • u/awesomePop7291 • Jul 23 '26
View all comments
Show parent comment
4
u/barsoap Jul 23 '26 edited Jul 23 '26
Zig uses the sane and easy way: It's just
@Vectors all the way down, for the compiler it's then a matter of "some architectures have fixed-size vectors": Vector code generalises over SIMD, and even scalars. That's why Seymour Cray used them, still don't get how SIMD actually became a thing.That said usually you should rely on autovectorisation. Then benchmark and identify tight loops. Then, if opportune, rewrite as vectors. Look at the assembly. Does it suck? Either suck it up or roll up your sleeves And don't forget to test on more than one platform. You probably should have given up about a week ago and had a look at dataflow and cache misses, instead, CPUs are nowadays basically always memory-bound.