4 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 Scaevolus 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.
You still beat them with inline assembly, but you probably won't accelerate the code vectorwidth times anymore.
- raverbashing 14y agoExactly ICC is the best one, but GCC from 4.0 could do it "automatically" (being very loose about the term) And no one does inline assembly for that, they use intrinsics
- cwzwarich 14y ago> And no one does inline assembly for that, they use intrinsics Depends on your architecture. With ARM, compilers will often not set the alignment bits in vector loads and stores, and this can be a big performance hit depending on the microarchitecture. In general, compilers sometimes deal poorly with instructions that have particularly strange register constraints, or loads/stores with address writeback.
- raverbashing 14y agoGood point
- pjmlp 14y agoCommercial compiler vendors tend to invest more in code generation quality as open source developers. After all they need to provide reasons why you would buy them.
- potkor 14y agoThis paper from 2011 compares autovectorization in GCC against two proprietary compilers, from Intel and IBM: http://polaris.cs.uiuc.edu/~garzaran/doc/pact11.pdf http://polaris.cs.uiuc.edu/~garzaran/doc/pact11.pdf GCC got a 23% speedup vs 15% for XLC and 28% for ICC. GCC did well considering the proprietary compilers' narrow focus and corporate resources. BTW, Fortran compilers for the 1980's supers did autovectorization pretty well. Funny that we've made it so hard today.
- 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
- nwmcsween 14y agoGcc does not vectorize to simd ins without more work than just using intrins. Gcc will vectorize to word size though