public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <joseph@codesourcery.com>
To: Vincent Lefevre <vincent+gcc@vinc17.org>
Cc: Geert Bosch <bosch@adacore.com>, Michael Matz <matz@suse.de>,
	     Uros Bizjak <ubizjak@gmail.com>, GCC <gcc@gcc.gnu.org>,
	     Florent de Dinechin <Florent.de.Dinechin@ens-lyon.fr>,
	     christoph.lauter@ens-lyon.fr
Subject: Re: Using crlibm as the default math library in GCC sources
Date: Wed, 14 Nov 2007 16:45:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.0711141344070.20433@digraph.polyomino.org.uk> (raw)
In-Reply-To: <20071114102747.GH12913@prunille.vinc17.org>

On Wed, 14 Nov 2007, Vincent Lefevre wrote:

> On 2007-11-12 21:29:44 -0500, Geert Bosch wrote:
> > On Nov 12, 2007, at 12:37, Michael Matz wrote:
> >> * only double is implemented, hence long double and float are missing at
> >>  least, at least the long double would need some implementation work,
> >>  as you can't simply enlarge the mantissa and hope all your results are
> >>  still correct
> > Initially, float could simply use double and cast the result.
> > For double->float the results will remain correctly rounded.
> 
> Yes, very probably, but this needs to be proven for each supported
> function, due to the double rounding problem (this may take some time
> for functions like pow).

As I understand the mention of moving towards automatically generating 
functions, crlibm might eventually be able to provide functions for float 
that do most computations in double but use double double for the hard 
cases (like functions for double presently use double double for most 
cases and triple double for hard cases), through automatic generation 
given the type used for function inputs/outputs (float in this case) and 
the types available for intermediate computations (double in this case) as 
well as information on worst cases for rounding?

> > For x86, the use of -mfpmath=sse addresses most, if not all, issues
> > related to excess precision for float and double.
> 
> But not all x86 processors support SSE2. However, I suppose you can
> have crlibm support for some architectures only.

It also seems to me that automatic generation might help address the x86 
issues as well, by providing both SSE2 versions (IEEE double as 
intermediate type) and x87 versions (using long double in all intermediate 
computations to avoid excess precision issues).

> and consistent. For instance, sin(x)*sin(x) + cos(x)*cos(x) will
> always be very close to 1, as mathematically expected.

FWIW, Nick Maclaren once told me that many applications don't care about 
accurate argument reduction for large arguments to sin and cos (for many 
purposes the answer just need be within a few ulp of the correct answer 
for an argument within a few ulp of the given argument - which would allow 
any answer between -1 and 1 for sin and cos of large values), but may 
still expect that sin^2 + cos^2 is very close to 1.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2007-11-14 13:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-06 19:54 Uros Bizjak
2007-11-11 15:06 ` Richard Sandiford
2007-11-12  2:34   ` Uros Bizjak
2007-11-12 10:28     ` Joe Buck
2007-11-12 18:16 ` Michael Matz
2007-11-13  8:59   ` Geert Bosch
2007-11-13 14:49     ` Michael Matz
2007-11-13 18:55       ` Geert Bosch
2007-11-15 21:31         ` Christoph Quirin Lauter
2007-11-14 14:59     ` Vincent Lefevre
2007-11-14 16:45       ` Joseph S. Myers [this message]
2007-11-17 13:41       ` Geert Bosch
2007-11-17 14:39         ` Tim Prince
2007-11-18 17:09         ` Vincent Lefevre
2007-11-12 16:24 François-Xavier Coudert

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=Pine.LNX.4.64.0711141344070.20433@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=Florent.de.Dinechin@ens-lyon.fr \
    --cc=bosch@adacore.com \
    --cc=christoph.lauter@ens-lyon.fr \
    --cc=gcc@gcc.gnu.org \
    --cc=matz@suse.de \
    --cc=ubizjak@gmail.com \
    --cc=vincent+gcc@vinc17.org \
    /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).