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:
In your project's property pages select Configuration Properties> C/C++> Diagnostics [Intel C++].
For Optimization Diagnostics Level, select Level 1 (/Qopt-report:1).
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:
In your project's property pages select Configuration Properties> C/C++> Optimization .
For Optimization, select Maximize Speed.
For the purpose of showing the report, we'll also replace the call to matvec()
in Driver.c with the equivalent C 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> C/C++> 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 150 noted in the Compiler Optimization Report window, as well as in the *.optrpt files in the object directory.
For example, the following messages appear in driver.optrpt:
LOOP BEGIN at Driver.c(145,2) Driver.c(145,2):remark #25460: No loop optimizations reported LOOP BEGIN at Driver.c(148,3) Driver.c(148,3):remark #25460: No loop optimizations reported LOOP BEGIN at Driver.c(150,4) Driver.c(150,4):remark #15300: LOOP WAS VECTORIZED LOOP END
Note
Your line and column numbers may be different.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).
Rebuild your project.
The vectorization report indicates that the loop at line 45 in Multiply.c did not vectorize because it is not the innermost loop of the loop nest. Two versions (main and reminder) of the innermost loop at line 55 were generated, but neither version was vectorized.
The following messages appear in Multiply.optrpt and Driver.optrpt:
LOOP BEGIN at Multiply.c(45,2) Multiply.c(45,2):remark #15541: outer loop was not auto-vectorized: consider using SIMD directive LOOP BEGIN at Multiply.c(55,3) Multiply.c(55,3):remark #15344: loop was not vectorized: vector dependence prevents vectorization. First dependence is shown below. Use level 5 report for details Multiply.c(55,3):remark #15346: vector dependence: assumed FLOW dependence between b line 56 and b line 56 LOOP END LOOP BEGIN at Multiply.c(55,3) Remainder LOOP END LOOP END