9 ms·
> 30 years? ICC already does automatic vectorization pretty well. LLVM and GCC have implementations that need more tuning. I bet they'll be solid within 5 years
by exDM69 14y ago
> 30 years? ICC already does automatic vectorization pretty well. LLVM and GCC have implementations that need more tuning. I bet they'll be solid within 5 years.
Unfortunately, the automatic vectorization compilers do is not very smart and is targeted at simple scalar loops in existing code bases. In many cases, a decent programmer can easily outperform the compiler with simple SIMD tricks, especially in cases where you can use clever vector shuffling tricks (e.g. sum of 4 numbers with 2 additions + 2 vector shuffles).
To get the best of both worlds, use compiler/machine specific intrinsic functions or vector extensions with a smart optimizing compiler. Clang's vector extensions work really well.
- raverbashing 14y agoHow would you sum 4 numbers with 2 adds + 2 shuffles (sorry, I'm rusty in SIMD) But remember, similar (old, but simpler) tricks were adopted by compilers, like xor to load 0, lea to do math (not sure about this one), shifts instead of multiply/divide etc
- exDM69 14y agoSum 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