As exemplified by Jed Brown's answer to Costs of lookups versus calculations, using vectorized vs non-vectorized floating point operations results in much faster code. Many modern compilers claim that they can perform automatic vectorization. How do I which parts of my code are being successfully vectorized?


3 Answers 3


With the Intel compiler of any modern vintage, -O3 -vec-report3. Optimization level three guarantees that it's trying to vectorize, and the vector report will tell you what it's doing.

The GNU page on vectorization says that it's on by default at optimization level 3, but I can't find the equivalent of vec-report.

  • $\begingroup$ Thanks for the quick response. I didn't know about -vec-report3. Do you have a compiler preference when it comes to this type of thing (automatic vectorization)? $\endgroup$ Commented Jun 13, 2012 at 19:54
  • $\begingroup$ Intel compilers are really good, but only for intel chips. You just have to add all the right pragmas (#pragma ivdep is easiest) GCC 4.7 has gotten a lot better but looking over some code with a colleague it still has bugs (like no vectorization inside openmp pragmas). $\endgroup$
    – aterrel
    Commented Jun 13, 2012 at 20:44
  • 1
    $\begingroup$ I would advise double checking how the Intel compiler does with vectorization on AMD chips. I'm not 100% sure that the problems of old still exist. $\endgroup$
    – Bill Barth
    Commented Jun 13, 2012 at 22:18
  • 2
    $\begingroup$ @BillBarth Yes, still an issue. See the Optimization Notice (in many place, e.g. software.intel.com/sites/products/collateral/hpc/compilers/…). AMD won the court battle requiring Intel to disclose that they are anti-competitive, not to make them stop being. en.wikipedia.org/wiki/Intel_C%2B%2B_Compiler#Criticism Agner Fog on workarounds: agner.org/optimize/blog/read.php?i=49 $\endgroup$
    – Jed Brown
    Commented Jun 14, 2012 at 13:28
  • $\begingroup$ @JedBrown, sure SSE is still weird, but what's the story with AVX? Those links indicate that things should be fine (since both companies implement AVX), but I haven't tested it on a Bulldozer machine. $\endgroup$
    – Bill Barth
    Commented Jun 14, 2012 at 18:07

Within the GNU compiler collection, you have the option -ftree-vectorizer-verbose=n where n is a number between 0 and 6 which will print information similar to icc/ifort.


With GNU compilers, adding -Wa,-ahl=asm.s will dump the generated assembly code to asm.s.

With Intel compilers, adding -fcode-asm -Faasm.s will dump the generated code to asm.s.

You can then inspect the assembly code and look for vector float point operations.

  • $\begingroup$ I completely agree that inspecting assembly output is the only reliable way to determine if code is actually vectorized. There is nothing that requires compilers to be honest about their claims to vectorize code. $\endgroup$ Commented Apr 13, 2013 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.