1

I'm trying to vectorize the loops in a Fortran program with gfortran and the Intel Xeon CPU.

Previously, the vectorization was implemented by constating

!VOCL LOOP,NOVREC
!DIR$ IVDEP

which could have worked on a Fujitsu before the loop. But these don't work anymore.

Does anyone have ideas how to vectorize the loop.

Since I'm a newbie for this, it would be perfect if you can show an example to test the result

Here's the code I use to test if it works

        PROGRAM VECT_TEST
        IMPLICIT NONE

        INTEGER :: L(10)
        INTEGER :: I

        DO I = 1, 10
          L(I) = I
        END DO

!VOCL LOOP,NOVREC
!DIR$ IVDEP
        DO I = 1, 10
          L(I)=L(I) + 1
        END DO

        END PROGRAM

With a test command

gfortran vect_test.f -fopt-info-all -O3

I got the error output like this

vect_test.f:18:0: note: ===vect_slp_analyze_bb=== vect_test.f:18:0: note: === vect_analyze_data_refs === vect_test.f:18:0: note: not vectorized: not enough data-refs in basic block.

4

1 Answer 1

3

Your program is useless, the compiler optimizes everything away. If you print the content of the array at the end and make the array larger, it will actually vectorize the loop:

PROGRAM VECT_TEST
IMPLICIT NONE

INTEGER :: L(1024)
INTEGER :: I

DO I = 1, 1024
  L(I) = I
END DO

DO I = 1, 1024
  L(I)=L(I) + 1
END DO

PRINT *, L

END PROGRAM

compile:

gfortran vec.f90 -ftree-vectorizer-verbose=1  -O3

Analyzing loop at vec.f90:13


Vectorizing loop at vec.f90:13

vec.f90:13: note: LOOP VECTORIZED.
Analyzing loop at vec.f90:7


Vectorizing loop at vec.f90:7

vec.f90:7: note: LOOP VECTORIZED.
vec.f90:1: note: vectorized 2 loops in function.
Sign up to request clarification or add additional context in comments.

1 Comment

Well okay. This command doesn't print any message on my computer but I got the same result with -fopt-info -O3. Thanks a lot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.