by codedokode · 1y ago · 0 comments
What I wanted is to write code in a more high-level language like this. For example, to compute a scalar product of a and b you write:
1..n | a[$1] * b[$1] | sum
Or maybe this: x = sum for i in 1 .. n: a[i] * b[i]
And the code gets automatically compiled into SIMD instructions for every existing architecture (and for large arrays, into a multi-thread computation).Of course, the compiler vectorizing code when it can as a general optimization is still useful, but when it's critical that some operations must be vectorized, explicit SIMD structures seem nice to have.
I think SWAR-C nailed the syntax (a vector ?: operator, for example).