I came across a blog from a 2 years ago that compared different implementations of dot product. It had a couple interesting points. The cost of functional programming in #Swift was huge (31x on M1 and 198x on x86). I did an equivalent test in #Rust and the cost was 1x (on M2). That lets programmers use the high level abstractions without dreading the performance costs.
Rust:
left.iter().zip(right.iter())
.map(|(&l, &r)| l * r )
.sum::<f64>()
eclecticlight.co/2021/08/04/wh…
When idiomatic code is slower, and how to Accelerate
Benchmarking 32-bit Float vector dot-product calculations using Swift, NEON assembly, and Apple’s SIMD libraries, on Intel and M1 Macs.The Eclectic Light Company