Diagnostic 15552: loop was not vectorized with "simd"

By Devorah Hayman,

Published: 06/29/2015   Last Updated: 09/13/2018

Product Version:  Intel® Fortran Compiler 15.0 and above

Cause:

When  a loop contains a conditional statement which controls the assignment of a scalar value AND the scalar value is referenced AFTER the loop exits. The vectorization report generated using Intel® Fortran Compiler's optimization and vectorization report options includes non-vectorized loop instance:

Windows* OS:  /O2  /Qopt-report:2  /Qopt-report-phase:vec    

Linux OS or OS X:  -O2 -qopt-report2  -qopt-report-phase=vec

Example:

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

subroutine f13379( a, b, n )  
  implicit none 
  integer, intent(in)               :: n
  integer, intent(in),  dimension(n) :: a
  integer, intent(out),dimension(n) :: b
   
  integer                           :: i, x=10  
   
!$omp simd  
  do i=1,n  
    if( a(i) > 0 ) then 
     x = i                    !...here is the scalar assignment 
    end if 
    b(i) = x  
  end do 
!... reference the scalar outside of the loop  
  write(*,*) "last value of x: ", x  
end subroutine f13379

$ ifort -c  -O2 -qopt-report2 -qopenmp-simd -qopt-report-file=stderr -qopt-report-phase=vec f13379.f90

LOOP BEGIN at f13379.f90(12,3)

   remark #15316:simd loop was not vectorized: scalar assignment in simd loop is prohibited, consider private, lastprivate or reduction clauses 

   remark #15552: loop was not vectorized with "simd"

LOOP END

Resolution:

Using !$omp simd lastprivate(x)  instead of !$omp simd will have x initialized for each subroutine in executable code.

Example

subroutine f13379( a, b, n )  
  implicit none 
  integer, intent(in)               :: n
  integer, intent(in),  dimension(n) :: a
  integer, intent(out),dimension(n) :: b
   
  integer                           :: i, x=10  
   
!$omp simd lastprivate(x)  
  do i=1,n  
    if( a(i) > 0 ) then 
     x = i                    !...here is the scalar assignment 
    end if 
    b(i) = x  
  end do 
!... reference the scalar outside of the loop  
  write(*,*) "last value of x: ", x  
end subroutine f13379

$ ifort -c  -O2 -qopt-report2 -qopenmp-simd -qopt-report-file=stderr -qopt-report-phase=vec f13379.f90


Begin optimization report for: F13379

    Report from: Vector optimizations [vec]

LOOP BEGIN at f13379.f90(10,3)
   remark #15301: SIMD LOOP WAS VECTORIZED
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

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.