how *not* to use denormalised numbers?
Anton Shterenlikht
mexas@bris.ac.uk
Tue Nov 10 16:27:00 GMT 2015
>From nmm1@hermes.cam.ac.uk Tue Nov 10 15:51:26 2015
>
>On Nov 10 2015, Steve Kargl wrote:
>>
>>Although I haven't checked, you'll probably need to use the
>>IEEE arithmetic modules to control subnormal numbers or use
>>C interop and fenv features to manipulate the FPU.
>
>I agree. I would hope that the default is to use the 'native' mode,
>whatever that is, on the grounds that changing the mode is bad news
>for interoperability with C and some libraries,
I'm confused:
$ cat z.f90
use ieee_arithmetic
logical :: gradual
write (*,*) "Support underflow control:", &
ieee_support_underflow_control()
call ieee_get_underflow_mode( gradual )
write (*,*) "Gradual underflow:", gradual
write (*,*) "Support denormals:", ieee_support_denormal()
! flip underflow mode
call ieee_set_underflow_mode( .not. gradual )
call ieee_get_underflow_mode( gradual )
write (*,*) "Gradual underflow:", gradual
write (*,*) "Support denormals:", ieee_support_denormal()
end
$ gfortran6 -Wl,-rpath="/usr/local/lib/gcc6" z.f90
$ ./a.out
Support underflow control: F
Gradual underflow: T
Support denormals: T
Gradual underflow: F
Support denormals: T
$
So underflow control is not supported.
Why then ieee_set_underflow_mode pretends to
switch gradual underflow off?
Another compiler gives:
Support underflow control: T
Gradual underflow: F
Support denormals: F
Gradual underflow: T
Support denormals: T
which makes sense.
So the impression I get is that denormals are
enabled by default in gfortran and cannot be switched off.
I read that denormals processing could be substantially
slower that just flash to zero. I think my code might
be affected.
Anton
More information about the Fortran
mailing list