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

ifort gives wrong answer for simple addition!

Boris_B_
Einsteiger
653Aufrufe
Here is a program to add 1 twenty times. Answer should be 20, but ifort 10.1 with default optimization gives 74 - try it please:

real a,c
a=1.
c=0.0
do i=1,20
c=a+c
end do
write(*,*)'sum=',c
end

Switching off optimization gives the right answer. Help appreciated.
0 Kudos
5 Antworten
TimP
Geehrter Beitragender III
653Aufrufe
What's worse, it still does that in more recent versions, but the problem goes away when diagnostics are set.
Of course, it's associated with vectorization of sum reduction.
You're certainly entitled to file a problem report.
Steven_L_Intel1
Mitarbeiter
653Aufrufe
I can reproduce this in the latest 11.0, but the beta of 11.1 chooses not to vectorize this and gets the right answer. I will report this to the developers.

Edit: Even if vectorization is forced in 11.1 the answer is correct. I have reported this as issue DPD200111340.
TimP
Geehrter Beitragender III
653Aufrufe
I can reproduce this in the latest 11.0, but the beta of 11.1 chooses not to vectorize this and gets the right answer. I will report this to the developers.

Edit: Even if vectorization is forced in 11.1 the answer is correct. I have reported this as issue DPD200118979.
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Beta Build 20081213 Package ID: l_cprof_b_11.1.016
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.

ifort: NOTE: The Beta evaluation period for this product ends on 28-jul-2009 UTC.
Intel Fortran 11.1-2332
bb.f90(4): (col. 1) remark: LOOP WAS VECTORIZED.
GNU ld (Linux/GNU Binutils) 2.19.50.0.1.20081007
tim@tim-t61:~/src/net> ./a.out
sum= 74.00000

Doesn't attempt vectorization if -fp-model source is set.
Steven_L_Intel1
Mitarbeiter
653Aufrufe
Interesting. I had tried IA-32. I'll add that to my notes.
Steven_L_Intel1
Mitarbeiter
653Aufrufe
This bug did get fixed for 11.1. Sorry for the late notice.
Antworten