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

Intel Fortran Compiler Mac OS X optimization bug

oacikgoz
Beginner
1,288 Views
The following code gives me inconsistent results. It runs fine with optimization turned off.
The screen output with optimization is (sometimes quits with SIGSEGV)
2.122514567798456E-314 2.122514567798456E-314
0.826680222897825 2.122514567798456E-314
Without optimization, I get the right numbers
-0.999305041735772 1.783280721696433E-003
3.474791321139148E-004 1.783280721696433E-003
Here is the code
PROGRAM main
IMPLICIT NONE
INTEGER :: i
REAL(8), DIMENSION(:), ALLOCATABLE :: xt
REAL(8), DIMENSION(:), ALLOCATABLE :: wt
ALLOCATE(xt(64))
ALLOCATE(wt(64))
xt(1) = - 0.999305041735772139456905624346D+00
xt(2) = - 0.996340116771955279346924500676D+00
xt(3) = - 0.991013371476744320739382383443D+00
xt(4) = - 0.983336253884625956931299302157D+00
xt(5) = - 0.973326827789910963741853507352D+00
xt(6) = - 0.961008799652053718918614121897D+00
xt(7) = - 0.946411374858402816062481491347D+00
xt(8) = - 0.929569172131939575821490154559D+00
xt(9) = - 0.910522137078502805756380668008D+00
xt(10) = - 0.889315445995114105853404038273D+00
xt(11) = - 0.865999398154092819760783385070D+00
xt(12) = - 0.840629296252580362751691544696D+00
xt(13) = - 0.813265315122797559741923338086D+00
xt(14) = - 0.783972358943341407610220525214D+00
xt(15) = - 0.752819907260531896611863774886D+00
xt(16) = - 0.719881850171610826848940217832D+00
xt(17) = - 0.685236313054233242563558371031D+00
xt(18) = - 0.648965471254657339857761231993D+00
xt(19) = - 0.611155355172393250248852971019D+00
xt(20) = - 0.571895646202634034283878116659D+00
xt(21) = - 0.531279464019894545658013903544D+00
xt(22) = - 0.489403145707052957478526307022D+00
xt(23) = - 0.446366017253464087984947714759D+00
xt(24) = - 0.402270157963991603695766771260D+00
xt(25) = - 0.357220158337668115950442615046D+00
xt(26) = - 0.311322871990210956157512698560D+00
xt(27) = - 0.264687162208767416373964172510D+00
xt(28) = - 0.217423643740007084149648748989D+00
xt(29) = - 0.169644420423992818037313629748D+00
xt(30) = - 0.121462819296120554470376463492D+00
xt(31) = - 0.729931217877990394495429419403D-01
xt(32) = - 0.243502926634244325089558428537D-01
xt(33) = 0.243502926634244325089558428537D-01
xt(34) = 0.729931217877990394495429419403D-01
xt(35) = 0.121462819296120554470376463492D+00
xt(36) = 0.169644420423992818037313629748D+00
xt(37) = 0.217423643740007084149648748989D+00
xt(38) = 0.264687162208767416373964172510D+00
xt(39) = 0.311322871990210956157512698560D+00
xt(40) = 0.357220158337668115950442615046D+00
xt(41) = 0.402270157963991603695766771260D+00
xt(42) = 0.446366017253464087984947714759D+00
xt(43) = 0.489403145707052957478526307022D+00
xt(44) = 0.531279464019894545658013903544D+00
xt(45) = 0.571895646202634034283878116659D+00
xt(46) = 0.611155355172393250248852971019D+00
xt(47) = 0.648965471254657339857761231993D+00
xt(48) = 0.685236313054233242563558371031D+00
xt(49) = 0.719881850171610826848940217832D+00
xt(50) = 0.752819907260531896611863774886D+00
xt(51) = 0.783972358943341407610220525214D+00
xt(52) = 0.813265315122797559741923338086D+00
xt(53) = 0.840629296252580362751691544696D+00
xt(54) = 0.865999398154092819760783385070D+00
xt(55) = 0.889315445995114105853404038273D+00
xt(56) = 0.910522137078502805756380668008D+00
xt(57) = 0.929569172131939575821490154559D+00
xt(58) = 0.946411374858402816062481491347D+00
xt(59) = 0.961008799652053718918614121897D+00
xt(60) = 0.973326827789910963741853507352D+00
xt(61) = 0.983336253884625956931299302157D+00
xt(62) = 0.991013371476744320739382383443D+00
xt(63) = 0.996340116771955279346924500676D+00
xt(64) = 0.999305041735772139456905624346D+00
wt(1) = 0.178328072169643294729607914497D-02
wt(2) = 0.414703326056246763528753572855D-02
wt(3) = 0.650445796897836285611736039998D-02
wt(4) = 0.884675982636394772303091465973D-02
wt(5) = 0.111681394601311288185904930192D-01
wt(6) = 0.134630478967186425980607666860D-01
wt(7) = 0.157260304760247193219659952975D-01
wt(8) = 0.179517157756973430850453020011D-01
wt(9) = 0.201348231535302093723403167285D-01
wt(10) = 0.222701738083832541592983303842D-01
wt(11) = 0.243527025687108733381775504091D-01
wt(12) = 0.263774697150546586716917926252D-01
wt(13) = 0.283396726142594832275113052002D-01
wt(14) = 0.302346570724024788679740598195D-01
wt(15) = 0.320579283548515535854675043479D-01
wt(16) = 0.338051618371416093915654821107D-01
wt(17) = 0.354722132568823838106931467152D-01
wt(18) = 0.370551285402400460404151018096D-01
wt(19) = 0.385501531786156291289624969468D-01
wt(20) = 0.399537411327203413866569261283D-01
wt(21) = 0.412625632426235286101562974736D-01
wt(22) = 0.424735151236535890073397679088D-01
wt(23) = 0.435837245293234533768278609737D-01
wt(24) = 0.445905581637565630601347100309D-01
wt(25) = 0.454916279274181444797709969713D-01
wt(26) = 0.462847965813144172959532492323D-01
wt(27) = 0.469681828162100173253262857546D-01
wt(28) = 0.475401657148303086622822069442D-01
wt(29) = 0.479993885964583077281261798713D-01
wt(30) = 0.483447622348029571697695271580D-01
wt(31) = 0.485754674415034269347990667840D-01
wt(32) = 0.486909570091397203833653907347D-01
wt(33) = 0.486909570091397203833653907347D-01
wt(34) = 0.485754674415034269347990667840D-01
wt(35) = 0.483447622348029571697695271580D-01
wt(36) = 0.479993885964583077281261798713D-01
wt(37) = 0.475401657148303086622822069442D-01
wt(38) = 0.469681828162100173253262857546D-01
wt(39) = 0.462847965813144172959532492323D-01
wt(40) = 0.454916279274181444797709969713D-01
wt(41) = 0.445905581637565630601347100309D-01
wt(42) = 0.435837245293234533768278609737D-01
wt(43) = 0.424735151236535890073397679088D-01
wt(44) = 0.412625632426235286101562974736D-01
wt(45) = 0.399537411327203413866569261283D-01
wt(46) = 0.385501531786156291289624969468D-01
wt(47) = 0.370551285402400460404151018096D-01
wt(48) = 0.354722132568823838106931467152D-01
wt(49) = 0.338051618371416093915654821107D-01
wt(50) = 0.320579283548515535854675043479D-01
wt(51) = 0.302346570724024788679740598195D-01
wt(52) = 0.283396726142594832275113052002D-01
wt(53) = 0.263774697150546586716917926252D-01
wt(54) = 0.243527025687108733381775504091D-01
wt(55) = 0.222701738083832541592983303842D-01
wt(56) = 0.201348231535302093723403167285D-01
wt(57) = 0.179517157756973430850453020011D-01
wt(58) = 0.157260304760247193219659952975D-01
wt(59) = 0.134630478967186425980607666860D-01
wt(60) = 0.111681394601311288185904930192D-01
wt(61) = 0.884675982636394772303091465973D-02
wt(62) = 0.650445796897836285611736039998D-02
wt(63) = 0.414703326056246763528753572855D-02
wt(64) = 0.178328072169643294729607914497D-02
WRITE(*,*) xt(1),wt(1)
xt=(xt+1.0D0)*0.5D0
WRITE(*,*) xt(1),wt(1)
END PROGRAM main
0 Kudos
1 Solution
Kevin_D_Intel
Employee
1,288 Views

At optimization, the program fails with 11.1.067 related to the known incompatibility with linker in Xcode 3.2.2 and later. See this sticky post more details about the known linker incompatibility.

Your program runs correctly at optimization when using the advertised work around (see below): -use-asm

Your program also produces correct results without this work around when using the latest 11.1.089 update (see below) which contains a patch for this known linker incompatibility.

Using use-asm work around with 11.1.067:

$ ifort -V u78427.f90 -use-asm
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090827 Package ID: m_cprof_p_11.1.067

Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2582

@(#)PROGRAM:ld PROJECT:ld64-97.2
Library search paths:

$ ./a.out

-0.999305041735772 1.783280721696433E-003
3.474791321139148E-004 1.783280721696433E-003


No work around needed with 11.1.089:

$ ifort -V u78427.f90

Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20100806 Package ID: m_cprof_p_11.1.089
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2755

@(#)PROGRAM:ld PROJECT:ld64-97.2
Library search paths:

$ ./a.out
-0.999305041735772 1.783280721696433E-003
3.474791321139148E-004 1.783280721696433E-003

View solution in original post

0 Kudos
5 Replies
oacikgoz
Beginner
1,288 Views
Could someone please confirm this bug?
If you decide to do so, compile the above code once with flag -O0 and once with no flags. Default optimization screws it up.
I'm curious if the linux compiler has the same problem.
Thanks.
0 Kudos
david_car
New Contributor I
1,288 Views
Works fine on Linux.
david@server:/tmp$ ifort --version
ifort (IFORT) 11.1 20100806
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
david@server:/tmp$ ifort --versionifort (IFORT) 11.1 20100806Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

0 Kudos
oacikgoz
Beginner
1,288 Views
Very interesting, maybe it's a bug that is fixed. I noticed I have a different version of ifort
ifort (IFORT) 11.1 20090827
I will download the newer version and give it a shot.
Thanks!
0 Kudos
Kevin_D_Intel
Employee
1,289 Views

At optimization, the program fails with 11.1.067 related to the known incompatibility with linker in Xcode 3.2.2 and later. See this sticky post more details about the known linker incompatibility.

Your program runs correctly at optimization when using the advertised work around (see below): -use-asm

Your program also produces correct results without this work around when using the latest 11.1.089 update (see below) which contains a patch for this known linker incompatibility.

Using use-asm work around with 11.1.067:

$ ifort -V u78427.f90 -use-asm
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20090827 Package ID: m_cprof_p_11.1.067

Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2582

@(#)PROGRAM:ld PROJECT:ld64-97.2
Library search paths:

$ ./a.out

-0.999305041735772 1.783280721696433E-003
3.474791321139148E-004 1.783280721696433E-003


No work around needed with 11.1.089:

$ ifort -V u78427.f90

Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20100806 Package ID: m_cprof_p_11.1.089
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

Intel Fortran 11.1-2755

@(#)PROGRAM:ld PROJECT:ld64-97.2
Library search paths:

$ ./a.out
-0.999305041735772 1.783280721696433E-003
3.474791321139148E-004 1.783280721696433E-003

0 Kudos
oacikgoz
Beginner
1,288 Views
Thank you very much for your input! I spent so much time trying to fix my code. It ended up being a bug in the compiler+xcode. Now it all makes sense.
0 Kudos
Reply