Search code examples
avxavx2icc

intel icpc compilation with -xhost option : AVX activated?


I am using icpc compiler to see the speed up of my code usually compiled with g++.

The processor on which I compile belongs to Intel's Sandy Bridge architecture, so I want to use AVX vectorization.

Someone told that the "-xhost" flag with icpc could allow me to benefit automatically from AVX vectorization : is this the case ?

If not, could you tell the flag(s) to put with icpc to activate AVX.

Last question: could I benefit from AVX2 too ? and if yes, how ?

Thanks


Solution

  • To benefit from AVX2 you need a 4th generation Intel Coree(R) processor, built upon Haswell architecture.

    Your CPU supports only AVX. You can instruct the compiler to use it as you mentioned by using "-xHost" compilation flag. This tells the compiler to use the highest SIMD like instructions available on your host machine. You can also use "-mavx" flag.

    Be aware although that if you generate code using AVX, you will be able to run it only on machines that have AVX (later than Sandy Bridge).

    To check if the compiler has generated AVX code, dump the assemblies and look for the YMM registers. Those are AVX specific.For more info look here.

    Cheers!