Main Navigation

Secondary Navigation

Page Contents

Contents

Using Intel Vectorization Advisor for gcc

Intel Advisor provides the possibility to be used together with GNUs gcc as well.

Get Started

We closely follow here the analysis presented for the Intel compiler now using both, the module for Intel and the module for the latest GNU compiler:
module add intel/latest
module add gcc/latest
and compile the same program as specified here with gcc:
gcc -g -O3 simple01.c -fopt-info-vec -ftree-vectorize -o simple01_gcc
Using the GUI advixe-gui we immediately find out, that these options support SSE and SSE2 but no AVX instruction set.

Metric missing

Unfortunately the provided recommendations are not useful at all:

Metric missing

But reading the compiler manual (man gcc in a command window) or reading GNUS online Docu provides information to add support vor AVX. It's the additional option -mavx that adds support for AVX (version 1 with 256 bits) and -mavx2 that adds support for AVX2 (enhanced 256 bits).
Recommendation
missing Assembly missing
Both AVX and AVX2 use the 256 bit registers YMM. The difference between these versions do not have an effect for this simple example.

Unfortunately, changing to AVX512 is not just -mavx512, because there are several flavours of AVX512. Instead it is best to switch to an architecture dependent option, in our case -march=skylake-avx512. For completeness, the whole compilations sequence reads now

gcc -g -O3 simple01.c -fopt-info-vec -ftree-vectorize -march=skylake-avx512 -o simple01_gcc
and indeed, the examples uses now the AVX512 instruction set and the 512 bit wide ZMM registers.
Recommendation missing Assembly missing
Most important, the timings are almost equal to the Intel compiler though there is a slight difference, to me not explainable: While the Intel compiler uses the 32 bit loading assembly code vmovdqa64z.

For the moment we don't have to care about this difference, as both versions do the same work in almost identical time.