Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Loop not vectorized

Cabezon__Ruben
Beginner
737 Views

Hi all.

I have the following code:

    do i = npini,npend
       do k=1,nvi(i)
           <... calculations...>
       enddo
   enddo

and the optimization report says that "the loop was not vectorized: loop control variable was not identified. Explicitly compute the iteration count before executing the loop or try using canonical loop form from OpenMP specification"

npini and npend are global integers calculated in the main program. They are defining the limits of the loop for a straightforward MPI decomposition. So once calculated at the beginning (in function of the total number of iterations and the number of MPI processes) they never change.

The inner loop length is different for every iteration of the outer loop. nvi is an array of integers, calculated in another previous subroutine, that defines how many iterations are going to be performed in the inner loop for every iteration of the outer loop. nvi is not changed at any moment in this subroutine and once is calculated (in a previous subroutine) is not changed for the whole global iteration. Therefore, is also known. 

Any ideas why this is not vectorizing?

I confess, I thought that ifort won't vectorized this because npini, npend, and nvi are not defined as PARAMETER, but to my surprise intel compiler does compile the same structure in C++ and vectorizes the inner loop! So, I'm doing something wrong in Frotran...?

Thanks!!!

0 Kudos
2 Replies
Steve_Lionel
Honored Contributor III
737 Views

You would need to provide us with a compilable source. Think about giving the vectorizer some hints using ASSUME and/or LOOP_COUNT directives.

0 Kudos
jimdempseyatthecove
Honored Contributor III
737 Views

We would have to see the content of <... calculations ...> to have any idea as to why the loop cannot be vectorized.

Note, if you have any compiler directives specific to those DO loops please show them as well.

This may be a case of:

    ArrayC // row i, column k
    ArrayF(i,k) ! row k, column i

when you should be using

    ArrayF(k,i) ! row i, column k

IOW it cannot vectorize due your "vector" requires strided loades/stores.

Jim Dempsey

0 Kudos
Reply