Compute Max / Horizontal operation (AVX)
If you find yourself needing to do horizontal operations on vectors, especially if it’s inside an inner loop, then it’s usually a sign that you are approaching your SIMD implementation in the wrong way. SIMD likes to operate element-wise on vectors - “vertically” if you like, not horizontally. - SO
There is no horizontal max, and you need to test the elements vertically - X86 Instruction Wishlist
In general for any kind of vector horizontal reduction, extract / shuffle high half to line up with low, then vertical add (or min/max/or/and/xor/multiply/whatever); repeat until a there’s just a single element (with high garbage in the rest of the vector). - Peter Cordes
_mm256_cvtss_f32
Written on November 14, 2022, Last update on December 12, 2022
avx
c++
math