Diagnostic 15541: Loop was not vectorized: outer loop was not auto-vectorized: consider using SIMD directive.

By Devorah Hayman, Published: 10/30/2014, Last Updated: 09/24/2015

Product Version: Intel® Visual Fortran Compiler XE 15.0 or a later version

Cause:

The vectorization report generated when using Visual Fortran Compiler's optimization options ( /O2 /Qopt-report:2 /Qopt-report-phase:vec ) states that loop was not vectorized due to vector dependence - outer loop depends on inner loop.

Example:

An example below will generate the following remark in optimization report:

subroutine foo(a, n1, n)
        implicit none
        integer :: n, n1
        integer :: i, j
	real :: a(n,n1)
      
        do i=1,n
            a(j,i) = a(j-1,i)+1 
			  
            do j=1,n
                a(j,i) = a(j-1,i)+1       
            end do
        end do
end subroutine foo

ifort -c /O2 /Qopt-report:2 /Qopt-report-phase:vec /Qopt-report-file:stdout f15541.f90

(ifort -c -O2 -qopt-report2  f15541.f90 for Linux)

Begin optimization report for: FOO

    Report from: Interprocedural optimizations [ipo]

INLINE REPORT: (FOO) [1] f15541.f90(1,12)

    Report from: Loop nest, Vector & Auto-parallelization optimizations [loop, vec, par]

LOOP BEGIN at f15541.f90(7,9)
   remark #15541: outer loop was not auto-vectorized: consider using SIMD directive

   LOOP BEGIN at f15541.f90(10,13)
   <Multiversioned v1>
      remark #25228: Loop multiversioned for Data Dependence
      remark #15344: loop was not vectorized: vector dependence prevents vectorization. First dependence is shown below. Use level 5 report for details
      remark #15346: vector dependence: assumed FLOW dependence between  line 11 and  line 11
      remark #25439: unrolled with remainder by 2
      remark #25456: Number of Array Refs Scalar Replaced In Loop: 3
   LOOP END

   LOOP BEGIN at f15541.f90(10,13)
   <Remainder, Multiversioned v1>
      remark #25456: Number of Array Refs Scalar Replaced In Loop: 1
   LOOP END

   LOOP BEGIN at f15541.f90(10,13)
   <Multiversioned v2>
      remark #15304: loop was not vectorized: non-vectorizable loop instance from multiversioning
      remark #25439: unrolled with remainder by 2
      remark #25456: Number of Array Refs Scalar Replaced In Loop: 3
   LOOP END

   LOOP BEGIN at f15541.f90(10,13)
   <Remainder, Multiversioned v2>
      remark #25456: Number of Array Refs Scalar Replaced In Loop: 1
   LOOP END
LOOP END

 

Resolution:

Using !DIR$ SIMD directive results in outer loop being vectorized, as shown:

subroutine foo(a, n1, n)
        implicit none
        integer :: n, n1
        integer :: i, j
	real :: a(n,n1)
      !DIR$ SIMD  
        do i=1,n
	  a(j,i) = a(j-1,i)+1 
			  
            do j=1,n
                a(j,i) = a(j-1,i)+1       
            end do
        end do
end subroutine foo

ifort -c /O2 /Qopt-report:2 /Qopt-report-phase:vec /Qopt-report-file:stdout f15541.f90
(ifort -c -O2 -qopt-report2  f15541.f90 for Linux)

Begin optimization report for: FOO

    Report from: Interprocedural optimizations [ipo]

INLINE REPORT: (FOO) [1] f15541.f90(1,12)


    Report from: Loop nest, Vector & Auto-parallelization optimizations [loop, vec, par]


LOOP BEGIN at f15541.f90(7,9)
   remark #15301: SIMD LOOP WAS VECTORIZED

   LOOP BEGIN at f15541.f90(10,13)
      remark #25456: Number of Array Refs Scalar Replaced In Loop: 1
   LOOP END
LOOP END

LOOP BEGIN at f15541.f90(7,9)
<Remainder loop for vectorization>

   LOOP BEGIN at f15541.f90(10,13)
      remark #25456: Number of Array Refs Scalar Replaced In Loop: 2
   LOOP END
LOOP END

 

See also:

Requirements for Vectorizable Loops

Vectorization Essentials

Vectorization and Optimization Reports

Back to the list of vectorization diagnostics for Intel® Fortran

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804