vectorisation reports required

I would like the pgfortran compiler to produce vectorisation reports for the following simple code:

program vec_test
  implicit none

  real, dimension(1:100) :: a, b, c
  integer :: i
  
  a(:) = 1.0
  b(:) = 2.3

  do i = 1, 100
     c(i) = a(i) + b(i) 
  end do

end program vec_test

I have used the following command to create vectorisation reports, but it doesn’t print anything useful:

[wadudm@oban ~/fortran]$ pgfortran -c -Mvect=simd -Minfo=vect -O3 -Mneginfo vec_test.f90 
vec_test:
      7, Memory set idiom, loop replaced by call to __c_mset4
      8, Memory set idiom, loop replaced by call to __c_mset4

Could anyone help me with information with creating useful vectorisation reports, much like how the Intel compiler creates vectorisation reports?

Thanks in advance,
Wadud.

Hi Wadud,

“-Minfo” is the correct option to enable compiler feedback including vectorization information. However in this case, the compiler is optimizing away the loop since you’re not using the results and why you’re not seeing any vectorization. To fix, print out at least one value from C. For example:

% cat vec_test.f90
program vec_test
   implicit none

   real, dimension(1:100) :: a, b, c
   integer :: i

   a(:) = 1.0
   b(:) = 2.3

   do i = 1, 100
      c(i) = a(i) + b(i)
   end do
   print *, "c=", c(1)
 end program vec_test

% pgfortran -c -Mvect=simd -Minfo=vect -O3 -Mneginfo vec_test.f90
vec_test:
     10, Generated an alternate version of the loop
         Generated vector simd code for the loop
         Generated vector simd code for the loop
% pgfortran -c -Mvect=simd -Minfo=all -O3 -Mneginfo vec_test.f90
vec_test:
      7, Memory set idiom, loop replaced by call to __c_mset4
      8, Memory set idiom, loop replaced by call to __c_mset4
     10, Generated an alternate version of the loop
         Generated vector simd code for the loop
         Generated 2 prefetch instructions for the loop
         Generated vector simd code for the loop
         Generated 2 prefetch instructions for the loop

Hope this helps,
Mat

Hi Mat,

Cheers for answering my question. That really caught me out!

I will close this ticket.

Regards,
Wadud.