From: Anton Shterenlikht <mexas@bris.ac.uk>
To: nmm1@cam.ac.uk, sgk@troutmask.apl.washington.edu
Cc: fortran@gcc.gnu.org, mexas@bris.ac.uk
Subject: Re: how *not* to use denormalised numbers?
Date: Tue, 10 Nov 2015 16:27:00 -0000 [thread overview]
Message-ID: <201511101627.tAAGREW7050759@mech-as222.men.bris.ac.uk> (raw)
In-Reply-To: <Prayer.1.3.5.1511101549230.22219@hermes-2.csi.cam.ac.uk>
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
next prev parent reply other threads:[~2015-11-10 16:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 14:41 Anton Shterenlikht
2015-11-10 15:16 ` Steve Kargl
2015-11-10 15:49 ` N.M. Maclaren
2015-11-10 16:27 ` Anton Shterenlikht [this message]
2015-11-10 16:50 ` FX
2015-11-10 17:11 ` N.M. Maclaren
2015-11-10 19:55 ` FX
2015-11-10 16:59 Dominique d'Humières
2015-11-10 18:14 ` Steve Kargl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201511101627.tAAGREW7050759@mech-as222.men.bris.ac.uk \
--to=mexas@bris.ac.uk \
--cc=fortran@gcc.gnu.org \
--cc=nmm1@cam.ac.uk \
--cc=sgk@troutmask.apl.washington.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).