Vectorization Samples

These samples illustrate loops that can and cannot vectorize and explain how to use the vectorization report diagnostics.

These samples are designed for IA-32 and Intel® 64 architectures only. Do not compile them on IA-64 architectures.

See Included Samples for other samples included with the compiler.

Sample files and locations

Source

Locations

vec_sample.f90

novec_sample.f90

Linux* and Mac OS* X

<install-dir>/samples/vec_samples/

Windows*

<install-dir>\samples\vec_samples\

Description

These samples are not meant to generate executable binaries. Instead, the samples are designed to illustrate loops the compiler will or will not vectorize.

Compile the vectorizing sample

You must include the -c (Linux and Mac OS X) or /c (Windows) option when compiling the sample. This sample will not generate an valid executable.

Platform

Commands

Linux and Mac OS X

ifort -c -xPT -vec-report3 vec_sample.f90

Windows

ifort /c /QxPT /Qvec-report:3 vec_sample.f90

Because the compilation commands shown above includes the -vec-report (Linux and Mac OS X) or /Qvec-report (Windows) option the compiler generates status message about the vectorization process. The following sample output shows typical vectorization diagnostics messages.

Sample Vectorization Messages

vec_sample.f90(101): (col. 3) remark: LOOP WAS VECTORIZED.

vec_sample.f90(89): (col. 3) remark: LOOP WAS VECTORIZED.

vec_sample.f90(71): (col. 3) remark: LOOP WAS VECTORIZED.

vec_sample.f90(56): (col. 3) remark: loop was not vectorized: not inner loop.

vec_sample.f90(57): (col. 5) remark: loop was not vectorized: not inner loop.

vec_sample.f90(59): (col. 7) remark: LOOP WAS VECTORIZED.

vec_sample.f90(45): (col. 3) remark: LOOP WAS VECTORIZED.

vec_sample.f90(35): (col. 3) remark: LOOP WAS VECTORIZED.

Compile the non-vectorizing sample

You must include the -c (Linux and Mac OS X) or /c (Windows) when compiling the sample. This sample will not generate a valid executable.

Platform

Commands

Linux and Mac OS X

ifort -c -xPT -vec-report3 novec_sample.f90

Windows

ifort /c /QxPT /Qvec-report:3 novec_sample.f90

The following sample output shows typical vectorization diagnostics messages.

Sample Vectorization Messages

novec_sample.f90(44): (col. 3) remark: loop was not vectorized: vectorization possible but seems inefficient.

novec_sample.f90(34): (col. 3) remark: loop was not vectorized: existence of vector dependence.

novec_sample.f90(35): (col. 5) remark: vector dependence: proven FLOW dependence between y line 35, and y line 35.