LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-21-2012, 09:12 AM   #1
nareshUN
LQ Newbie
 
Registered: May 2008
Posts: 2

Rep: Reputation: 0
Unhappy same fortran code but giving different results for the 32 bit vs 64 bit machine


I have a fortran code that i ran on both 32 bit and 64 bit machine. I used gfortran to compile the code in both the machines.

However, I am getting different results but could not understand why is it.

I know that there is a high precison for real in 64 bit machine and I set all the real variables to that precision but still the problem persists.
 
Old 02-21-2012, 09:37 AM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I don't know how gfortran uses floating point on X86 and X86_64 architectures, but typical compilers do something that causes big rounding difference.

All X86 and X86_64 systems have a legacy floating point system in which it is most efficient to compute many intermediate results in 80 bit precision and only reduce the precision to the 64 or 32 bit precision specified by the high level language at certain points in the code.

Most X86 and all X86_64 systems have a newer floating point system, which is easier to generate code for than legacy and often runs faster than legacy (more so in X86_64 than X86). In that newer floating point system the 64 or 32 bit precision specified by the high level language is used at every step.

Typical compilers use legacy for X86, but use the newer system for X86_64. That means X86 code has extra precision for certain intermediate steps (chosen unpredictably by the compiler) while X86_64 consistently has the requested precision.

Quote:
Originally Posted by nareshUN View Post
I know that there is a high precison for real in 64 bit machine and I set all the real variables to that precision but still the problem persists.
There are two primary precisions, 32 bit and 64 bit (regardless of whether the architecture is 32 bit or 64 bit). Some languages (I'm not sure about fortran) have syntax for specifying the 80 bit precision, but if you are using the newer floating point specifying 80 bit precision is accepted syntax but ignored. If using legacy floating point, 80 bit will be used in some steps even if not specified.

Some rounding differences would be possible even between two architectures or compilers using exactly the same precision at every step. Some algorithms magnify most rounding errors, so expecting the same answer from two different compilations of the same floating point code is often unreasonable.

Last edited by johnsfine; 02-21-2012 at 09:46 AM.
 
Old 02-21-2012, 10:18 AM   #3
nareshUN
LQ Newbie
 
Registered: May 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Hi, Thanks for the information.

The results i obtained from both the machines vary by 10%.
Is it normal to have such a difference.

Also the results obtained by 32 bit machine is high dependable than 64 bit.
 
Old 02-21-2012, 11:33 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by nareshUN View Post
The results i obtained from both the machines vary by 10%.
Is it normal to have such a difference.
A big difference, like that, in final results from a tiny difference in rounding usually indicates a flaw in the algorithm. But it could indicate a fundamental difficulty in the required computation.

If you have any reasonably accurate model of weather, and you make tiny changes in rounding early in the model, the impact of those changes is more likely to start to grow rather than to damp out. If the changes start to grow, they are almost certain to continue to grow until they overwhelm the answer. That is not a problem in the model, but a fundamental characteristic of the system being modeled.

I work on a circuit simulator product. One problem sometimes modeled is the startup behavior of an electrical oscillator. As with weather simulation, the tiniest difference in voltage early, even a difference equivalent to a single electron, can overwhelm the detailed behavior of the startup and totally change the final phase of the result. A well designed oscillator reaches a stable frequency and amplitude that is highly resistant to tiny startup differences and reaches that stability in an amount of time that is moderately resistant. But the phase of the result is totally dependent on micro detail of early conditions that are impossible to model correctly.

I have worked in other areas of modeling in which the fundamental system being modeled did not inherently magnify rounding errors, but the system of equations chosen to represent the model unnecessarily included sub expressions such as the difference between nearly equal quantities. So the model responded to rounding differences as if the problem were chaotic, even though the problem (at least on the time scale modeled) was not chaotic.

Quote:
Also the results obtained by 32 bit machine is high dependable than 64 bit.
What does that mean? Between two different results, how do you know which (if either) is more reliable?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Crashes in throwing exceptions if code compiled in 32 bit explicity on 64 bit system gaurav.rustagi Programming 10 01-30-2012 06:11 AM
[SOLVED] building shared libary in 32 bit mode on 64 bit machine using -m32 option gaurav.rustagi Linux - Software 3 01-24-2012 09:03 AM
[SOLVED] building shared libary in 32 bit mode on 64 bit machine using -m32 option gaurav.rustagi Linux - Newbie 1 01-24-2012 07:54 AM
segmantation fault on a 64 bit machine caused by binary compiled on a 32 bit machine ninofattore Linux - Newbie 1 10-13-2011 01:48 PM
[SOLVED] Red Hat Enterprise Desktop 5.3 on 64 bit machine need 32-bit library file hhs1982 Linux - Newbie 4 06-29-2010 11:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration