3 ms·
Sum of elements in a 4-vector with SIMD in OpenGL/OpenCL style vector shuffle syntax: vec4 s1 = v + v.yxwz; // s1 = (v.x+v.y, v.y+v.x, v.z+v.w, v.w+v.z) ve
by exDM69 14y ago
Sum of elements in a 4-vector with SIMD in OpenGL/OpenCL style vector shuffle syntax:
vec4 s1 = v + v.yxwz; // s1 = (v.x+v.y, v.y+v.x, v.z+v.w, v.w+v.z)
vec4 sum = s1 + s1.zwxy; // sum = sum of v
More practical examples, related to 3d graphics: https://github.com/rikusalminen/threedee-simd https://github.com/rikusalminen/threedee-simd