ID 758497
Date 4/11/2022
Public

Generating a Vectorization Report

A vectorization report shows what loops in your code were vectorized and explains why other loops were not vectorized. To generate a vectorization report, use the Qopt-report and Qopt-report-phase:vec compiler options.

Together with Qopt-report-phase:vec, Qopt-report:1 generates a report with the loops in your code that were vectorized while Qopt-report:2 generates a report with both the loops in your code that were vectorized and the reason that other loops were not vectorized.

To use these options:

1. In your project's property pages select Configuration Properties > Fortran > Diagnostics.

2. For Optimization Diagnostics Level, select Level 1 (/Qopt-report:1).

3. For Optimization Diagnostics Phase, select Vectorization (/Qopt-report-phase:vec).

Because vectorization is turned off with the O1 option, the compiler does not generate a vectorization report. To generate a vectorization report, build your project with the O2 option:

To set the O2 option:

1. In your project's property pages select Configuration Properties > Fortran > Optimization .

2. For Optimization, select Maximize Speed.

For the purpose of showing the report, we'll also replace the call to matvec() in driver.f90 with the equivalent Fortran code by defining the preprocessor macro NOFUNCCALL. To do this, add NOFUNCCALL with a semicolon to the list of user defined macros at Project > Properties > Fortran > Preprocessor > Preprocessor Definitions.

Rebuild your project and then run the executable (Debug > Start Without Debugging). Record the new execution time. The reduction in time is mostly due to auto-vectorization of the inner loop at line 32 in matvec.f90 noted in the Compiler Optimization Report window, as well as in the *.optrpt files in the object directory.

For example, the following message appears in matvec.optrpt and driver.optrpt:

LOOP BEGIN at matvec.f90(26,3)
matvec.f90(26,3):remark #15300: LOOP WAS VECTORIZED
LOOP END


NOTE:
Your line and column numbers may be different.

The Qopt-report:2 option returns a list that also includes loops that were not vectorized, along with the reason why the compiler did not vectorize them. Add the Qopt-report:2 option in the same way you added Qopt-report:1 above, instead selecting Level 2 (/Qopt-report:2).