Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageJentje 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 ]
Post Follow-up to this messageTim 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
Post Follow-up to this messageTim 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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.