2 ms·
Shuffles are what makes SIMD go. It's trivial to make simple repeated math ops done in parallel instead of 4 (SIMD vector width) times sequentially, but shuffli
by exDM69 14y ago
Shuffles are what makes SIMD go. It's trivial to make simple repeated math ops done in parallel instead of 4 (SIMD vector width) times sequentially, but shuffling vectors cleverly is where you can get big performance wins.
Basic example, doing addition of 4 values in 2 ALU operations:
vec4 sum(vec4 v) // return v.x+v.y+v.z+v.w repeated 4 times
{
vec4 temp = v + v.yxzw;
return temp + temp.zwxy; // did I get this right?
}
Practical examples: https://github.com/rikusalminen/threedee-simd https://github.com/rikusalminen/threedee-simd (work in progress)
Requires this: http://gruntthepeon.free.fr/ssemath/ http://gruntthepeon.free.fr/ssemath/