public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Paul Zimmermann <Paul.Zimmermann@inria.fr>, libc-alpha@sourceware.org
Subject: Re: correctly rounded mathematical functions
Date: Wed, 12 Jan 2022 17:12:40 -0500	[thread overview]
Message-ID: <f19641ca-b47f-3e97-3c23-ef1b2d9b6d6d@redhat.com> (raw)
In-Reply-To: <mwfsq5ouii.fsf@tomate.loria.fr>

On 1/3/22 07:48, Paul Zimmermann wrote:
> The current C working draft [1, p392] has reserved names for correctly
> rounded functions (cr_exp, cr_log, cr_sin, ...).
> 
> We propose to add such correctly rounded functions to the GNU libc,
> for the three IEEE formats (binary32, binary64, binary128) and the
> "extended double" format (long double on x86_64).
> 
> These implementations should be correctly rounded for all rounding modes,
> for example one could do the following to emulate interval arithmetic:
> 
>    fesetround (FE_DOWNWARD);
>    y_lo = cr_exp (x_lo);
>    fesetround (FE_UPWARD);
>    y_hi = cr_exp (x_hi);
> 
> These functions will not replace the current functions (exp, log, sin, ...).
> Users who want a fast implementation will call the exp/log/sin/... functions,
> users who want a correctly rounded function and thus reproducible results
> (whatever the hardware, compiler or operating system) will use the
> cr_exp/cr_log/cr_sin/... functions. Our goal is nevertheless to get the
> best performance possible, and in some cases our implementation outperforms
> the GNU libc one.
> 
> We have started to work on two functions (cbrt and acos), for which we
> provide presumably correctly rounded implementations (up to the knowledge
> of hard-to-round cases) [2]. [These implementations do replace the current
> glibc ones, since it was simpler to demonstrate our skills.]
> 
> Christoph Lauter
> Jean-Michel Muller
> Alexei Sibidanov
> Paul Zimmermann

In general I think correctly rounded functions are something we would want to support.

For a very long time we've considered that there are really 3 sets of users:

(a) Loosely correct answers provided quickly (high ULPs errors allowed, >9 ULPs)
(b) Correct answers (no errors >9 ULPs)
(c) Correctly rounded answers (0 ULPs)

Note: Rounding modes matter.

To date we have been removing the mutli-precision fallback paths and driving glibc's
implementation towards (b) where possible (with some IBM double-double exceptions).

I would like to have (c) included in glibc for selection at link-time depending on
the needs of the users, but as Joseph points out, the costs to maintenance are real
and need to be discussed.
 
> [1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2596.pdf
> [2] https://homepages.loria.fr/PZimmermann/CORE-MATH/
> 


-- 
Cheers,
Carlos.


  parent reply	other threads:[~2022-01-12 22:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-03 12:48 Paul Zimmermann
2022-01-04 19:15 ` Joseph Myers
2022-01-05 16:03   ` Paul Zimmermann
2022-01-05 18:44     ` Joseph Myers
2022-01-06  9:55       ` Paul Zimmermann
2022-01-12 22:17     ` Carlos O'Donell
2022-01-12 22:12 ` Carlos O'Donell [this message]
2022-01-13  5:00   ` Paul Zimmermann

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=f19641ca-b47f-3e97-3c23-ef1b2d9b6d6d@redhat.com \
    --to=carlos@redhat.com \
    --cc=Paul.Zimmermann@inria.fr \
    --cc=libc-alpha@sourceware.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).