Slashdot Mirror


Comparing G++ and Intel Compilers and Vectorized Code

Nerval's Lobster writes "A compiler can take your C++ loops and create vectorized assembly code for you. It's obviously important that you RTFM and fully understand compiler options (especially since the defaults may not be what you want or think you're getting), but even then, do you trust that the compiler is generating the best code for you? Developer and editor Jeff Cogswell compares the g++ and Intel compilers when it comes to generating vectorized code, building off a previous test that examined the g++ compiler's vectorization abilities, and comes to some definite conclusions. 'The g++ compiler did well up against the Intel compiler,' he wrote. 'I was troubled by how different the generated assembly code was between the 4.7 and 4.8.1 compilers—not just with the vectorization but throughout the code.' Do you agree?"

6 of 225 comments (clear)

  1. Documentation is King by jpschaaf · · Score: 3, Interesting

    For better or worse, I've always given the intel compiler the benefit of the doubt. They have access to documents that the GCC folks don't.

    1. Re:Documentation is King by Runaway1956 · · Score: 4, Interesting

      Yep, they have access to some cool documents. It took a lot of work to document the fact that the intel compiler was actually crippling code if it was run on AMD processors. I mean, some suspicious, somewhat paranoid people suspected that intel was crippling code on AMD processors, but it took a good deal of work to actually demonstrate it.

      That is just one of the many reasons I don't use Intel.

      --
      "Windows is like the faint smell of piss in a subway: it's there, and there's nothing you can do about it." - Charlie Br
  2. Very different code by Anonymous Coward · · Score: 4, Interesting

    I have worked on a couple of projects that compiled and ran perfectly with GCC 4.6 and 4.7. They no longer run when compiled with the latest versions of GCC. No warnings, no errors during compilation, they simply crash when run. It's the same source code, so something has changed. The same code, when compiled with multiple versions of Clang, runs perfectly. The GCC developers are doing something different and it is causing problems. Now it may be that a very well hidden bug is lurking in the code and the latest GCC is exposing that in some way, but this code worked perfectly for years under older versions of the compiler so it's been a nasty surprise.

  3. Vectorized factorials! by Mr+Z · · Score: 4, Interesting

    One amusing thing I discovered is that GCC 4.8.0 will actually unroll and vectorize this simple factorial function: Just look at that output!

  4. Why is this still a topic? by excelsior_gr · · Score: 3, Interesting

    This is 2013 (almost 2014!) why are we talking about vectorization? Why don't people write code in vector notation in the first place anyway? If Matlab and Fortran could implement this 25 years ago, I am sure we are ready to move on now...

  5. Re:Not sure why it's troubling. by loufoque · · Score: 3, Interesting

    Explicit vectorization is indeed much more reliable than automatic vectorization, and it will always deliver better performance.

    Interestingly, there seems to be quite a few abstraction layer libraries for SIMD. There are also at least Boost.SIMD (part of NT2 [1]) and Vc [2].
    Several array-handling libraries (NT2 [1], Eigen [3]) also a leverage SIMD explicitly.
    Alternatively there are plenty of languages based on C with explicit SIMD programming, like the Intel SPMD Compiler [4].

    If you're interested in SIMD, there is also apparently a workshop being held soon on this subject in Orlando [5].

    [1] https://github.com/MetaScale/nt2
    [2] http://code.compeng.uni-frankfurt.de/projects/vc/
    [3] http://eigen.tuxfamily.org/index.php?title=Main_Page
    [4] http://ispc.github.io/
    [5] https://sites.google.com/site/wpmvp2014/