Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: small numerical differences in floating point result between

Lawrence Kirby wrote:
> On Tue, 14 Dec 2004 20:34:14 -0500, JS wrote:
>
<snip>

> I think somebody else pointed out that recent Microsoft compilers set the
> FPU to 53 bits precision anyway. Another thing to consider is rounding
> mode. They may well be the same but this needs to be checked.
>

I doubt whether the compiler or more likely the linker ever
inserts code manipulating the precision or rounding bits.
I assume that the OS sets the FPU to a known state whenever
the OS boots up but I am not sure whether it does that
whenever a program starts or exits and it may be different
between various Windows's or AMD.
For the program designer, it is safest to set the FPU to
the precision and rounding mode he wants at the start of the
program but this requires ASM to the best of my knowledge.

The FPU precision setting does not affect floating point
addition, subtraction and multiplication but only
division and of the transcendentals it affects only the
square root, see my other post in this thread.
Unless you need many millions of floating point divisions
or square roots and do not need the accuracy, it probably
does not make much difference and you should use the
highest precision.

<snip>

> Lawrence

Jentje Goslinga


Report this thread to moderator Post Follow-up to this message
Old Post
Jentje Goslinga
12-16-04 08:57 AM


Re: small numerical differences in floating point result between
Jentje Goslinga wrote:
>
>
> Lawrence Kirby wrote: 
> <snip>
> 
> the 
>
> I doubt whether the compiler or more likely the linker ever
> inserts code manipulating the precision or rounding bits.
> I assume that the OS sets the FPU to a known state whenever
> the OS boots up but I am not sure whether it does that
> whenever a program starts or exits and it may be different
> between various Windows's or AMD.
> For the program designer, it is safest to set the FPU to
> the precision and rounding mode he wants at the start of the
> program but this requires ASM to the best of my knowledge.

AFAIK, this can be done in Fortran 95 using the TR 15580 extension, and
'natively' in Fortran 2003.

From my perspective, anything done in ASM is of little use, since it is
not portable in the slightest. Similar results to hand-coded ASM can be
obtained using heuristic tuning of a high-level language, such as in the
ATLAS implementation of BLAS; I find ATLAS on x86 to produce results
competitive, and in some cases faster than, Intel's Math Kernel Library.

cheers,

Rich

--
Dr Richard H D Townsend
Bartol Research Institute
University of Delaware

[ Delete VOID for valid email address ]

Report this thread to moderator Post Follow-up to this message
Old Post
Rich Townsend
12-16-04 08:57 AM


Re: small numerical differences in floating point result between
Tim Prince wrote:
> "Jentje Goslinga" <goslinga@telus.net> wrote in message
> news:41C10364.4080208@telus.net...

<earlier post snipped>
 
>
> This has been the expected convention for commercial Windows
compilers since
> MSVC 6.0, that 53-bit precision is set initially by each program.
Likewise,
> many compilers for various architectures have had compile time
switches to
> insert or link in code which sets gradual or abrupt underflow, ever since
> the distinction was invented.
> 
>
> Yes, 64-bit Windows is responsible for setting the FPU state before
passing
> control to a program.  Certain versions of freebsd may also do so.
32-bit
> Windows, and both 32- and 64-bit linux, simply let it default.

So you inherit the previous program's FPU settings.
Hmmmm...

>  I know of no
> OS which checks the CPU brand to determine the behavior.
> 
>
> The IEEE standard has always recommended provision of intrinsic
functions to
> accomplish this in a portable way, but those took may years to become
> incorporated in language standards.

<snip>

Thanks a lot.

Jentje Goslinga


Report this thread to moderator Post Follow-up to this message
Old Post
Jentje Goslinga
12-16-04 08:57 AM


Re: small numerical differences in floating point result between
Tim Prince wrote:

(someone wrote)
 

> No, default FPU settings are defined by the hardware,
> and don't depend on what came before.

If the OS doesn't set them before starting a program,
you get the values left by the program that set them
last.   I don't know which OS do and don't set them.

-- glen


Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
12-16-04 09:06 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:41 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.