2 ms·
C++ compilers today already auto-vectorize simple loops, even without manual unrolling. For manual SIMD, I agree a built-in type would be best to abstract over
by yazzku 2y ago
C++ compilers today already auto-vectorize simple loops, even without manual unrolling. For manual SIMD, I agree a built-in type would be best to abstract over the 10 different HW APIs.
- neonsunset 2y agoThis is true, but it is also very brittle and cannot kick in where compiler cannot assert that e.g. source and destination do not alias, where it might change semantics or where there might be side-effects that the compiler cannot hoist out of the loop body on your behalf. Which is why most code that really cares about optimal HW utilization is vectorized explicitly - it's problematic to assert against potential regressions between compiler versions and addressing them is just as brittle.