Re: Are f.p. manipulation functions only used in initialization?
- From: Charles Coldwell <coldwell@xxxxxxxxx>
- Date: Sun, 27 Apr 2008 13:00:43 GMT
"James Van Buskirk" <not_valid@xxxxxxxxxxx> writes:
Setting the rounding of floating-point operations to less than the
default 80 bits can speed some programs by 2% or more. Note that some
mathematical libraries assume that extended precision (80 bit)
floating-point operations are enabled by default; routines in such
libraries could suffer significant loss of accuracy, typically through
so-called "catastrophic cancellation", when this option is used to set
the precision to less than extended precision."
Notably, on GNU/Linux (i.e. GNU glibc on Linux/x86)
/usr/include/fpu_control.h defines
#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
and
/* precision control */
#define _FPU_EXTENDED 0x300 /*libm requires double extended precision. */
#define _FPU_DOUBLE 0x200
#define _FPU_SINGLE 0x0
The comment next to _FPU_EXTENDED should be written in a bold,
blinking, red font. You will screw up all of the libm routines (such
as cos, sin, exp, log) if you change the FPU precision. Since Fortran
intrinsics are usually (always?) implemented in terms of libm
routines, you will threfore screw up the corresponding intrinsics.
About the only reason to change the FPU precision is if you are
writing your own libm, or software floating point (such as some of the
arbitrary precision work done by David H. Bailey and Yozo Hida), or
something similar.
C:\gfortran\james\archpi>test_status
4000C90FDAA22168C000
4000C90FDAA22168C000
027F
4000C90FDAA22168C235
4000C90FDAA22168C236
037F
So you can see that gfortran isn't setting precision control to b'11'
even with the -mpc80 switch in effect so that real(10) arithmetic
isn't working until I set the x87 control word by hand.
I think what is happening here is an OS dependency. It must be that
gfortran/Win32 is linking to a Win32 math library that depends on
having the FPU in double precision, not double extended precision.
You might check to see what happens to some of the trigonometric
intrinsics after you diddle the FPU mode.
So perhaps the double extended precision can't work on Win32 because
either the FPU is in double extended precision and the math library is
borken, or the FPU is in single precision and real*10 is borken.
Chip
--
Charles M. "Chip" Coldwell
"Turn on, log in, tune out"
GPG Key ID: 852E052F
GPG Key Fingerprint: 77E5 2B51 4907 F08A 7E92 DE80 AFA9 9A8F 852E 052F
.
- Follow-Ups:
- Re: Are f.p. manipulation functions only used in initialization?
- From: Greg Lindahl
- Re: Are f.p. manipulation functions only used in initialization?
- From: James Van Buskirk
- Re: Are f.p. manipulation functions only used in initialization?
- References:
- Are f.p. manipulation functions only used in initialization?
- From: James Van Buskirk
- Re: Are f.p. manipulation functions only used in initialization?
- From: Steven G. Kargl
- Re: Are f.p. manipulation functions only used in initialization?
- From: James Van Buskirk
- Are f.p. manipulation functions only used in initialization?
- Prev by Date: Re: Are f.p. manipulation functions only used in initialization?
- Next by Date: Pointers to derived type objects in COMMON
- Previous by thread: Re: Are f.p. manipulation functions only used in initialization?
- Next by thread: Re: Are f.p. manipulation functions only used in initialization?
- Index(es):
Relevant Pages
|
|