This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Subnormals and mpfr, was: Re: [gfortran] Fix NEAREST constant folder


On Wed, Apr 13, 2005 at 06:32:06PM +0200, Tobias Schl?ter wrote:
> Steve Kargl wrote:
> > After spending a few hours last night with mpfr, I've come
> > to the conclusion that we don't need wrappers.  We need
> > to change how we range check for underflow and we may
> > need to change how we convert from an mpfr_t number to
> > a number that is given to the backend.  Of course, I've
> > also had a few exchanges with MPFR developers. :-)
> 
> I figured that wrappers might be an easier way to convince the rest of gcc to
> move to mpfr, but apart from this hypothetical point I agree with you.  I
> don't expect gcc to make a move in this direction before 4.2 unless we both
> provide such a beautiful implementation of compile-time arithmetic that they
> can't help loving it, and we import gmp and mpfr into the tree.  Maybe you can
> convince the mpfr people to move to gcc's cvs (or svn, once that's in place) :-)

BTW, one of the developers is implementing mpfr_subnormal(). :-)

> > For undeflow, we currently check against a Fortran model
> > number where emin is determined by the kind type.  We need to
> > permit gradual underflow by changing the check to a subnormal
> > number determined from (emin - precision).  To accomplish this,
> > I think we can add sub_exponent = min_exponent - precision
> > to the gfc_real_info structure.  Note, sub_exponent may be off
> > by 1.
> 
> The bit-width and the minimum exponent are already in the gfc_real_info
> structure, so a new field isn't needed.  If there are targets which don't have
> subnormals, we will need an additional field which tells if the target
> actually supports subnormal numbers, though.

First, we need digits not precision from the struct.  In looking
at arith.c(gfc_check_real_range()),

  else if (mpfr_cmp (q, gfc_real_kinds[i].tiny) < 0)
    retval = ARITH_UNDERFLOW;

what we need is to precompute gfc_real_kinds[i].subnormal where this
is nearest(0.,1.). :-)  I haven't looked at how we deal with the
translation of mpfr_t to numbers for the backend.  For targets that
have subnormals, we can probably use the mpfr conversion routines
and give the backends the actual subnormal.  For targets, if there are
any, that do not have subnormal numbers, we'll probably need to
explicitly underflow to 0.

-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]