This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
RFC: signaling NaNs, intrinsic modules, ieee_arithmetic
- From: "Asher Langton" <langton2 at llnl dot gov>
- To: fortran at gcc dot gnu dot org
- Date: Fri, 27 Jul 2007 11:41:41 -0700
- Subject: RFC: signaling NaNs, intrinsic modules, ieee_arithmetic
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=Oz8+dcGuuzMTjs8xRsIIQYTKeKSX+wvLzuCwg7FWhXCd5E4+v7xUGo8NWDeOwMxSGKiWgpbCmPUkC4BPbMUYtEHC+ZbCVy/V0ccHlq4SvqIkZOJTjF0TuaFoU9RATFqivAsG1XH/jEwU7B03+ylKSsORgrPV88isZTGnYeofmsA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=EMBnltmfLzx1nGnSgh/02+j65ejX0iDbTDZ15c/YKkd6aOrsov2G6jtasc3TwG98lEQYjnv7/fD/naKQPqQzAMBA2EIufVlz42eZilxDi7Pmsk8P7DZxGMg0LYxCPwgCMDXv4BK4xTTIcqSou0/aOShQqTzNmnufeKz2TBfGY2w=
Hi all,
I've been working on a patch for -finit-local-zero (as well as other
options, including runtime control of initialization:
http://gcc.gnu.org/ml/fortran/2007-06/msg00028.html) and thinking
about how to implement the IEEE math intrinsic modules, and I have a
few questions/issues:
1) As far as I can tell, it's not currently possible to build an
initialization gfc_expr representing a signaling NaN. MPFR has a
set_nan option, but it doesn't distinguish between signaling and quiet
NaNs. When we call real_from_mpfr (in trans-const.c), all NaNs end
up quiet. For debugging purposes, I'm intercepting all MPFR NaNs in
trans-const.c:gfc_conv_mpfr_to_tree and forcing them to be signaling.
The proper solution would probably be to ask the MPFR folks to add
set_snan and set_qnan options, and then patch gcc/real.c to take
advantage of those. In the meantime, is it worthwhile to hack in a
temporary fix to create/detect MPFR signaling NaNs? Ideally, I'd like
to be able to use -finit-real=snan -ffpe-trap=invalid to force an
exception whenever an uninitialized local real variable is used.
2) What is the preferred way to implement intrinsic modules?
Following Brooks's suggestion, I've encapsulated the
runtime-controlled initialization routines in a intrinsic module.
I've essentially hard-coded the module (in module.c) as a routine that
creates all of the necessary gfc_symbols. It should also be possible
to implement some intrinsic modules as actual Fortran modules in
libgfortran. Which is preferable?
3) I'll probably start working on the IEEE math modules
(ieee_features, ieee_exceptions, ieee_arithmetic) soon. Is anybody
else working on these? Is it worth setting a up a subversion branch
to work on this extension?
Thanks,
Asher