The vectorization report can provide information about loops that could take advantage of Intel® Streaming SIMD Extensions (Intel® SSE3, SSE2, and SSE) vectorization, and it is available on systems based on IA-32 and Intel® 64 architectures.
See Using Parallelism for information on other vectorization options.
The -vec-report (Linux* and Mac OS* X) or /Qvec-report (Windows*) option directs the compiler to generate the vectorization reports with different levels of information. Specify a value of 3 to generate the maximum diagnostic details.
Operating System |
Command |
---|---|
Linux and Mac OS X |
ifort -c -xSSSE3 -vec-report3 sample.f90 |
Windows |
ifort /c /QxSSSE3 /Qvec-report:3 sample.f90 |
where -c (Linux and Mac OS X) or /c (Windows) instructs the compiler to compile the example without generating an executable.
Linux and Mac OS X: The space between the option and the phase is optional.
Windows: The colon between the option and phase is optional.
The following example results illustrate the type of information generated by the vectorization report:
Example results |
---|
sample.f90(27) : (col. 9) remark: loop was not vectorized: not inner loop. sample.f90(28) : (col. 11) remark: LOOP WAS VECTORIZED. sample.f90(31) : (col. 9) remark: loop was not vectorized: not inner loop. sample.f90(32) : (col. 11) remark: LOOP WAS VECTORIZED. sample.f90(37) : (col. 10) remark: loop was not vectorized: not inner loop. sample.f90(38) : (col. 12) remark: loop was not vectorized: not inner loop. sample.f90(40) : (col. 14) remark: loop was not vectorized: vectorization possible but seems inefficient. sample.f90(46) : (col. 10) remark: loop was not vectorized: not inner loop. sample.f90(47) : (col. 12) remark: loop was not vectorized: contains unvectorizable statement at line 48. |
If the compiler reports "r;Loop was not vectorized" because of the existence of vector dependence, then you should analyze the loop for vector dependence. If you determine there is no legitimate vector dependence, then the message indicates that the compiler was assuming the pointers or arrays in the loop were dependent, which implies the pointers or arrays were aliased. Use memory disambiguation techniques to resolve these cases.
There are three major types of vector dependence: FLOW, ANTI, and OUTPUT.
There are a number of situations where the vectorization report may indicate vector dependencies. The following situations will sometimes be reported as vector dependencies, non-unit stride, low trip count, and complex subscript expression.
Non-Unit Stride
The report might indicate that a loop could not be vectorized when the memory is accessed in a non-Unit Stride manner. This means that nonconsecutive memory locations are being accessed in the loop. In such cases, see if loop interchange can help or if it is practical. If not then you can force vectorization sometimes through vector always directive; however, you should verify improvement.
See Understanding Runtime Performance for more information about non-unit stride conditions.
The vectorization reports are generated during the final compilation phase, which is when the executable is generated; therefore, there are certain option combinations you cannot use if you are attempting to generate a report. If you use the following option combinations, the compiler issues a warning and does not generate a report:
-c or -ipo or -x with -vec-report (Linux* and Mac OS* X) and /c or /Qipo or /Qx with /Qvec-report (Windows*)
-c or -ax with -vec-report (Linux and Mac OS X) and /c or /Qax with /Qvec-report (Windows)
The following example commands can generate vectorization reports:
Operating System |
Command Examples |
---|---|
Linux and Mac OS X |
ifort -xSSSE3 -vec-report3 sample.f90 ifort -xSSSE3 -ipo -vec-report3 sample.f90 |
Windows |
ifort /QxSSSE3 /Qvec-report:3 sample.f90 ifort /QxSSSE3 /Qipo /Qvec-report:3 sample.f90 |
You might consider changing existing code to allow vectorization under the following conditions:
The vectorization report indicates that the program "contains unvectorizable statement at line XXX".
The vectorization report states there is a "vector dependence: proven FLOW dependence between 'r;variable' line XXX, and 'r;variable' line XXX" or "loop was not vectorized: existence of vector dependence." Generally, these conditions indicate true loop dependencies are stopping vectorization. In such cases, consider changing the loop algorithm.
For example, consider the two equivalent algorithms producing identical output below. "Foo" will not vectorize due to the FLOW dependence but "bar" does vectorize.
Example |
---|
subroutine foo(y) implicit none integer :: i real :: y(10) do i=2,10 y (i) = y (i-1)+1 end do end subroutine foo subroutine bar(y) implicit none integer :: i real :: y(10) do i=2,10 y (i) = y (1)+i end do end subroutine bar |
Unsupported loop structures may prevent vectorization. An example of an unsupported loop structure is a loop index variable that requires complex computation. Change the structure to remove function calls to loop limits and other excessive computation for loop limits.
Example |
---|
function func(n) implicit none integer :: func, n func = n*n-1 end function func subroutine unsupported_loop_structure(y,n) implicit none integer :: i,n, func real :: y(n) do i=0,func(n) y(i) = y(i) * 2.0 end do end subroutine unsupported_loop_structure |
Non-unit stride access might cause the report to state that "vectorization possible but seems inefficient". Try to restructure the loop to access the data in a unit-stride manner (for example, apply loop interchange), or try directive .
Using mixed data types in the body of a loop might prevent vectorization. In the case of mixed data types, the vectorization report might state something similar to "loop was not vectorized: condition too complex".
The following example code demonstrates a loop that cannot vectorize due to mixed data types within the loop. For example, withinborder is an integer while all other data types in loop are not. Simply changing the withinborder data type will allow this loop to vectorize.
Example |
---|
subroutine howmany_close(x,y,n) implicit none integer :: i,n,withinborder real :: x(n), y(n), dist withinborder=0 do i=0,100 dist=sqrt(x(i)*x(i) + y(i)*y(i)) if (dist<5) withinborder= withinborder+1 end do end subroutine howmany_close |