public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Michael Hudson-Doyle <michael.hudson@canonical.com>,
	Joseph Myers <joseph@codesourcery.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Ensure calculations happen with desired rounding mode in y1lf128
Date: Wed, 17 Aug 2022 11:53:43 +0000	[thread overview]
Message-ID: <AM5PR0801MB1668EC9F8A41F189B0C0B191836A9@AM5PR0801MB1668.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <CAJ8wqtdtuvTO6Er7O+L_-E0PqPzVpCv+1rtQJWJsd+KTHzN8Xw@mail.gmail.com>

Hi Michael,

> It does seem likely that an algorithm that does not require setting a rounding mode
> would in general be better than one that does but also that this is not very realistic.

Rewriting this function would not be trivial, but the math functions that are already
rewritten (like exp, pow, log) prove you can get fast and accurate results without
ever needing rounding mode changes.

When you design a polynomial to be very accurate, it actually works in all rounding
modes without extra effort. For this function it seems like whoever wrote it didn't
understand how to accurately evaluate polynomials - the input range of neval/deval
is (0.0, 4.0] so the repeated multiplies actually multiply the rounding errors...

> But I guess my point is that SET_RESTORE_ROUND without barriers is a footgun. 
> I guess I should commit my patch and perhaps see about writing some more for other
> uses of the macro?

The patch LGTM. Yes more patches would be welcome. It's a good idea to check
what happens if you remove the SET_RESTORE_ROUND - there will be cases where
the ULP is good enough.

Cheers,
Wilco

  reply	other threads:[~2022-08-17 11:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 12:28 Wilco Dijkstra
2022-08-15 20:59 ` Joseph Myers
2022-08-17  4:23   ` Michael Hudson-Doyle
2022-08-17 11:53     ` Wilco Dijkstra [this message]
2022-08-17 16:52       ` Joseph Myers
2022-08-22 12:28       ` Paul Zimmermann
  -- strict thread matches above, loose matches on Subject: below --
2022-08-12  0:05 Michael Hudson-Doyle

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=AM5PR0801MB1668EC9F8A41F189B0C0B191836A9@AM5PR0801MB1668.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=michael.hudson@canonical.com \
    /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).