Re: Are f.p. manipulation functions only used in initialization?
- From: "James Van Buskirk" <not_valid@xxxxxxxxxxx>
- Date: Sat, 26 Apr 2008 16:24:59 -0600
"Steven G. Kargl" <kargl@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:fv086u$roe$1@xxxxxxxxxxxxxxxxxxxxxxxxxx
Appears to work for me. Perhaps, it's an OS problem.
Thank you for testing. Maybe an OS problem or a regression. What
version are you using? I'm on 20080421.
I ran into another problem that may be with the documentation. In:
http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options
It says:
"-mpc32
-mpc64
-mpc80
Set 80387 floating-point precision to 32, 64 or 80 bits. When
-mpc32 is specified, the significands of results of floating-point
operations are rounded to 24 bits (single precision); -mpc64 rounds
the the significands of results of floating-point operations to 53
bits (double precision) and -mpc80 rounds the significands of results
of floating-point operations to 64 bits (extended double precision),
which is the default. When this option is used, floating-point
operations in higher precisions are not available to the programmer
without setting the FPU control word explicitly.
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."
My reading of this is that precision control should be set to
b'11' = Extended Precision, but I must be reading the wrong part
of the manual because I get:
C:\gfortran\james\archpi>c:\gfortran\win64\bin\x86_64-pc-mingw32-gfortran -v
Using built-in specs.
Target: x86_64-pc-mingw32
Configured with:
.../../trunk/configure --prefix=/home/FX/irun64 --build=i586-pc-
mingw32 --target=x86_64-pc-mingw32 --with-gmp=/home/FX/local --enable-languages=
c,fortran --disable-werror --disable-nls --enable-threads
Thread model: win32
gcc version 4.4.0 20080421 (experimental) [trunk revision 134506] (GCC)
C:\gfortran\james\archpi>type test_status.f90
program test_status
implicit none
interface
function status()
integer(selected_int_kind(4)) status
end function status
subroutine control(cw)
integer(selected_int_kind(4)) cw
end subroutine control
end interface
real(10) x
real(10) y
integer(selected_int_kind(2)) array(10)
integer(selected_int_kind(4)) old_control
x = 1
x = 4*atan(x)
y = x-nearest(x,-1.0_10)
y = x+y
array = transfer(x,array)
write(*,'(10z2.2)') array(size(array):1:-1)
array = transfer(y,array)
write(*,'(10z2.2)') array(size(array):1:-1)
old_control = status()
write(*,'(z4.4)') old_control
call control(ior(old_control,int(z'0300',kind(old_control))))
x = 1
x = 4*atan(x)
y = x-nearest(x,-1.0_10)
y = x+y
array = transfer(x,array)
write(*,'(10z2.2)') array(size(array):1:-1)
array = transfer(y,array)
write(*,'(10z2.2)') array(size(array):1:-1)
write(*,'(z4.4)') status()
call control(old_control)
end program test_status
C:\gfortran\james\archpi>type status.s
.text
..globl _status_
.def _status_; .scl 2; .type 32; .endef
_status_:
fstcw 8(%rsp)
movzwl 8(%rsp), %eax
ret
..globl _control_
.def _control_; .scl 2; .type 32; .endef
_control_:
fldcw (%rcx)
ret
C:\gfortran\james\archpi>c:\gfortran\win64\bin\x86_64-pc-mingw32-gfortran -mpc80
test_status.f90 status.s -otest_status
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. Probably I'm
just missing something in the documentation somewhere but it can sure
be hard to find it from a standing start.
--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end
.
- Follow-Ups:
- Re: Are f.p. manipulation functions only used in initialization?
- From: Charles Coldwell
- Re: 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?
- 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
- 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: Re: Are f.p. manipulation functions only used in initialization?
- 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
|