Vectorization

Vectorization and Code Optimization

Processor peak performance includes the speed-up provided by the vector instructions, but in order to exploit it you need specific programming techniques.

Auto-vectorization is the easiest and more portable way to get vectorization.

The compiler recognize several vectiorization options.

Main vectorization options:

Intel compiler
KNL -xMIC-AVX512
BDW -xCORE-AVX2
Disable -no-vec

Not all loops can be vectorized:

Some examples:

for (i=1; i<MAX; i++) {
   d[i] = e[i] – a[i-1];
   a[i] = b[i] + c[i];
}
    for (int i = 0; i < N; i++)   a[i] = foo(b[i]);