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

Linux compiler bug? (short sample program included)

stefan_m
Beginner
591 Views

Hi,

The simple program below performs a sum over diagonal entries in a 4-dimensional array of REAL numbers. The result should be 6.

When compiled via

ifort -r8 -O3 -o test test.f90

it gives get the correct result. However, when compiled to produce code with SSE3 via

ifort -r8 -O3 -xP -o test test.f90

the result is 1 instead of 6.

Same with ifort 9.1 and ifort 10.1, on Pentium 4 32 bit Scientific Linux 5.2 and Xeon 5160 64 bit ClusterVisionOS 2.1. Also with -xN instead of -xP on a Pentium M with OpenSUSE 10.3

Interestingly, when the order of the inner and outer loops is interchanged, the error does not appear anymore.

It would be great if someone could test this. Am I missing something?

Thanks, Stefan

-------------------------------

PROGRAM test
IMPLICIT NONE
REAL, DIMENSION(3, 2, 3, 2) :: a
a=0.0
a(1, 1, 1, 1)=1.0
a(2, 1, 2, 1)=1.0
a(3, 1, 3, 1)=1.0
a(1, 2, 1, 2)=1.0
a(2, 2, 2, 2)=1.0
a(3, 2, 3, 2)=1.0
PRINT *, f(a)
CONTAINS
FUNCTION f(a)
REAL :: f
REAL, DIMENSION(3, 2, 3, 2), INTENT(IN) :: a
INTEGER :: c, s
f=0.0
DO s=1, 2
DO c=1, 3
f=f+a(c, s, c, s)
END DO
END DO
END FUNCTION f
END PROGRAM test

0 Kudos
3 Replies
TimP
Honored Contributor III
591 Views

I found that ifort -O1 gave the same "correct" result as ifort -check. If you care to submit it in a problem report on premier.intel.com, it should be easy for a compiler expert to diagnose.

0 Kudos
stefan_m
Beginner
591 Views
Quoting - tim18

I found that ifort -O1 gave the same "correct" result as ifort -check. If you care to submit it in a problem report on premier.intel.com, it should be easy for a compiler expert to diagnose.

Many thanks. Can you confirm that you also got the wrong result with -O3 -xP (or similar options)? What compiler version were you using? I'll try to submit a problem report.

0 Kudos
TimP
Honored Contributor III
591 Views
Quoting - stefan_m

Many thanks. Can you confirm that you also got the wrong result with -O3 -xP (or similar options)? What compiler version were you using? I'll try to submit a problem report.

Yes, I found the same problem with ifort 10.1 and 11.0/044, using various options which imply auto-vectorization.

0 Kudos
Reply