Diagnostic 15011: loop was not vectorized: statement cannot be vectorized (Fortran)

 

Cause:

The loop contains a statement that cannot be mapped to SIMD instructions by the vectorizer. In the example below, the loop contains an assignment to a derived data type which is not directly vectorizable.

Example:

module my_mod
   integer, parameter :: N=1000
   type :: my_type
      integer :: c1
      real(8) :: c2
   end type my_type
   type(my_type), dimension(N) :: my_inst
end module my_mod

subroutine initialize(init_data)
   use my_mod
   implicit none
   integer :: i
   type(my_type), intent(in) :: init_data

   do i=1,N
      my_inst(i) = init_data
   enddo
end subroutine initialize

ifort -c -vec-report2 d_15011_1.f90

d_15011_1.f90(17): (col. 7) remark: loop was not vectorized: statement cannot be vectorized
 

Resolution Status:

If the derived type contained only scalars of the same length, e.g. integer(4) and real(4), the loop would be potentially vectorizable. In the present example, the loop may be vectorized if an assignment operator is defined for the derived type. The assignment operation can then be inlined:

module my_mod
   integer, parameter :: N=1000
   type :: my_type
      integer :: c1
      real(8) :: c2
   end type my_type
   type(my_type), dimension(N) :: my_inst
   interface assignment(=)
      module procedure assign_my_type
   end interface
contains
   subroutine assign_my_type(t2,t1)
      type(my_type), intent(in   ) :: t1
      type(my_type), intent(inout) :: t2
      t2%c1 = t1%c1
      t2%c2 = t1%c2
   end subroutine assign_my_type
end module my_mod

subroutine initialize(init_data)
   use my_mod
   implicit none
   integer :: i
   type(my_type), intent(in) :: init_data

   do i=1,N
      my_inst(i) = init_data
   enddo
end subroutine initialize

ifort -c -vec-report2 d_15011_2.f90 d

d_15011_2.f90(26): (col. 4) remark: LOOP WAS VECTORIZED
 

A defined assignment operator would also allow the loop to be vectorized if the derived type contained an array component. In this case, the assignment of the array component itself may be converted to a call to memcpy.

Back to the list of vectorization diagnostics for Intel Fortran

Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.