loop was not vectorized because it contains a reference to a non-vector intrinsic

Viewed 77

I am coding a large Fortran program where performance is extremely crucial. I'm using module to store common parameters and variables. But the problem is where ever there's a module variable is used for some kind of array operation the compiler doesn't vectorize it. Lets take this as an example,

module name
    integer :: p    
end module name


program name1
    use name
    real(kind=8) :: x(10,10), y(10)
    integer :: i,j 
    p=9
    do i=1,10
        do j =1,10
            x(i,j) = i+j
        enddo
    enddo

    y = x(:,p)*x(:,p-1)
    print *, y
end program name1

Now when I compile it on Cray (XC50) with ftn -eD file.f90, the produced .lst file shows,

   9.    program name1
   10.        ! implicit none
   11.        use name
   12.        real(kind=8) :: x(10,10), y(10)
   13.        integer :: i,j
   14.        do i=1,10
   15.            do j =1,10
   16.                x(i,j) = i+j
   17.            enddo
   18.        enddo
   19.
   20.        y = x(:,p)*x(:,p-1)
ftn-6263 ftn: VECTOR NAME1, File = test.f90, Line = 20
  A loop starting at line 20 was not vectorized because it contains a reference to a non-vector intrinsic on line 20.

   21.        print *, y
   22.    end program name1
   23.
   24.

I always thought that doing array operation with : will be easier for the compiler to vectorize it. But if using module variable is bad for vectorization then is it also bad to use module when performance is critical? Am I confusing something here? How to improve the performance for these cases?

0 Answers
Related