PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

Fortran associativity rules
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Doug Baker



Joined: 25 Aug 2005
Posts: 4

PostPosted: Tue Jul 15, 2008 7:57 am    Post subject: Fortran associativity rules Reply with quote

Scanned the forum for this topic and did not see anything, sorry if I missed it and this is a repeat.

We have been using Fortran on many platforms and had converted some of our simulations from Sun Solaris Sparcworks to PGI 5.2 back some time ago. There are numeric shifts but nothing that we could not live with.

Recently we received new Linux RHE4 devices with PGI 7.0 installed. What I thought would be a trivial task of just switching out our current RH9 devices running 5.2 with RHE4 devices running 7.0 was not a drop in.

I was hoping that the new compiler and machine would match the results generated on the 5.0 devices but they do not. Tracing down to see where we get our first numeric shifts indicates differences in how associative rules are applied for both multiplication and division.

Sample code snip (actual values pulled from a complex run used in sample):

PROGRAM WHAT
REAL A1, B1, C1, Z1
REAL A2, B2, C2, Z2
A1 = 24955.289062500
B1 = 0.998889029
C1 = 0.999865353

A2 = 46.095016
B2 = 4.7642002
C2 = .20989881

Z1 = A1 / B1 / C1
write (6,1) Z1
1 format ( 'Division : A1 / B1 / C1 = Z1 ',F20.9)

Z1 = (A1 / B1) / C1
write (6,2) Z1
2 format ( 'Division : (A1 / B1) / C1 = Z1 ',F20.9)

Z1 = A1 / (B1 / C1)
write (6,3) Z1
3 format ( 'Division : A1 / (B1 / C1) = Z1 ',F20.9)

Z2 = A2 * B2 * C2
write (6,10) Z2
10 format (/,'Muliplication : A2 * B2 * C2 = Z2 ',F20.9)

Z2 = (A2 * B2) * C2
write (6,11) Z2
11 format ( 'Muliplication : (A2 * B2) * C2 = Z2 ',F20.9)

Z2 = A2 * (B2 * C2)
write (6,12) Z2
12 format ( 'Muliplication : A2 * (B2 * C2) = Z2 ',F20.9)

END

Using new RHE4 and PGI 7.2 (pgf77) :

Division : A1 / B1 / C1 = Z1 24986.408203125
Division : (A1 / B1) / C1 = Z1 24986.410156250
Division : A1 / (B1 / C1) = Z1 24979.679687500

Muliplication : A2 * B2 * C2 = Z2 46.095012665
Muliplication : (A2 * B2) * C2 = Z2 46.095012665
Muliplication : A2 * (B2 * C2) = Z2 46.095016479

Using older RH9 and PGI 5.0 :

Division : A1 / B1 / C1 = Z1 24986.408203125
Division : (A1 / B1) / C1 = Z1 24986.408203125
Division : A1 / (B1 / C1) = Z1 24979.679687500

Muliplication : A2 * B2 * C2 = Z2 46.095016479
Muliplication : (A2 * B2) * C2 = Z2 46.095016479
Muliplication : A2 * (B2 * C2) = Z2 46.095016479

We have literally tens of millions of lines of code that represent every engine Pratt & Whitney has ever created and modifying the code is not even a remote possibility at this point.

Any suggestions on how to handle this situation where converting from 5.2 to 7.0 is altering our results? I have attempted several of the compiler options, pretty much anything that even hinted it might help but to no avail.

thanks,
Doug
Back to top
View user's profile
hongyon



Joined: 19 Jul 2004
Posts: 551

PostPosted: Tue Jul 15, 2008 11:24 am    Post subject: Reply with quote

Hi,

We need to know what compilers and options you are using.
32-bit, 32-bit (-tp px???), 64-bit, ??? Which version did you compare with 5.0 or 5.2?


Hongyon
Back to top
View user's profile
La00



Joined: 27 May 2008
Posts: 16

PostPosted: Tue Jul 15, 2008 10:53 pm    Post subject: Reply with quote

If you compile your program with -tp piii (or with any other -tp option without SSE2 support) then you will get the same result as on PGI 5.x

Last edited by La00 on Wed Jul 16, 2008 11:30 pm; edited 1 time in total
Back to top
View user's profile
Doug Baker



Joined: 25 Aug 2005
Posts: 4

PostPosted: Wed Jul 16, 2008 11:24 am    Post subject: Reply with quote

Thanks for the guidance ... The new device does appear to be 64 bit but looked to be compiling for 32 bit already:

pgf77 -V

pgf77 7.0-6 32-bit target on x86-64 Linux
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.

I went through and recompiled the libraries using the first suggesition of -tp=px and that indeed did match results for the older 5.2 compiler.

I had tried -tp=core2 and tp=core2-64 which did not help but had not tried the generic pentium options.

At this point, I think we are good.

Thanks!
Doug
Back to top
View user's profile
Doug Baker



Joined: 25 Aug 2005
Posts: 4

PostPosted: Wed Jul 16, 2008 12:02 pm    Post subject: Reply with quote

Of course I am now questioning what the "correct" answer is at this point. Changing the code to higher precision r*8 variables and using the -r8 option yields yet another answer.

Division : A1 / B1 / C1 = Z1 24986.408845424
Division : (A1 / B1) / C1 = Z1 24986.408845424
Division : A1 / (B1 / C1) = Z1 24979.680608439

Muliplication : A2 * B2 * C2 = Z2 46.095013814
Muliplication : (A2 * B2) * C2 = Z2 46.095013814
Muliplication : A2 * (B2 * C2) = Z2 46.095013814
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group