Cause:
Reduction idioms can be recognized by the compiler and vectorized in simple cases.The compiler is unable to vectorize more complex constructs and emits a warning message:
Example:
integer function minIndex(x,n) implicit none real, intent(in), dimension(n) :: x real :: minValue integer, intent(in ) :: n integer :: i minValue = 999. minIndex = -1 do i=1,n if(x(i).lt.100. .and. x(i).lt.minValue) then minValue = x(i) minIndex = i endif enddo end function minIndex
> ifort -c -vec-report2 d_15032_1.f90
d_15032_1.f90(13): (col. 10) remark: loop was not vectorized: unsupported reduction
Resolution:
If a reduction idiom is not supported by the vectorizer, adding a SIMD directive will not help. However, if you are able to simplify your reduction construct, the compiler may vectorize it. In the above example, one of the conditions can be moved outside the loop, which allows the simplified loop to be vectorized:
integer function minIndex(x,n) implicit none real, intent(in), dimension(n) :: x real :: minValue integer, intent(in ) :: n integer :: i minValue = 999. minIndex = -1 do i=1,n if(x(i).lt.minValue) then minValue = x(i) minIndex = i endif enddo if(minValue.ge.100.) then minValue = 999. minIndex=-1 endif end function minIndex
> ifort -c -vec-report2 d_15032_2.f90
d_15032_2.f90(11): (col. 4) remark: LOOP WAS VECTORIZED