public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Zack Weinberg <zackw@panix.com>
To: "Ondřej Bílka" <neleai@seznam.cz>
Cc: Siddhesh Poyarekar <siddhesh@gotplt.org>,
	Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	 "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
	nd <nd@arm.com>
Subject: Re: [PATCH 2/6] Remove slow paths from sin/cos
Date: Fri, 09 Mar 2018 18:52:00 -0000	[thread overview]
Message-ID: <CAKCAbMg85h8JLK1qUNUgUUDVwU2WCnD4WCCputCM7qhr7y0i6w@mail.gmail.com> (raw)
In-Reply-To: <20180309181902.GA26430@domone>

On Fri, Mar 9, 2018 at 1:19 PM, Ondřej Bílka <neleai@seznam.cz> wrote:
> On Fri, Mar 09, 2018 at 09:47:09PM +0530, Siddhesh Poyarekar wrote:
>> On Friday 09 March 2018 09:16 PM, Wilco Dijkstra wrote:
>> > This patch removes 2nd of the 3 range reduction cases and defer to the final one.
>> > Input values above 2^27 are extremely rare, so this case doesn't need to as be
>> > optimized as smaller inputs.
>>
>> Please elaborate on two more points:
>>
>> - The basis for your claim that values above 2^27 are extremely rare,
>>   i.e. papers that you may have referred that conclude this and/or
>>   applications you may have profiled
>>
> Main reason is that for these inputs accuracy doesn't make a sense.
> There is already millions bigger error caused by limited precision when
> rounding input to float.

More concretely, for IEEE single, the gap between representable values
is bigger than 2π for values whose exponent is 2^26 or above.  Since
the sine function is periodic over 2π, that means the result of sinf()
is effectively meaningless for any input at least that big - _any
value_ within the input period could have been rounded to the
representable, so the "true" answer could be anything.  (I am tempted
to suggest that we return NaN for inputs this large, without even
bothering to do argument reduction.)

For double, this happens at 2^55, and for x86-64 long double it
happens at 2^66.  I _think_ x86-64 long double is 80-bit IEEE
extended, not quad, but I could be wrong.

zw

  reply	other threads:[~2018-03-09 18:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09 15:46 Wilco Dijkstra
2018-03-09 16:17 ` Siddhesh Poyarekar
2018-03-09 18:19   ` Ondřej Bílka
2018-03-09 18:52     ` Zack Weinberg [this message]
2018-03-09 23:05       ` Steve Ellcey
2018-03-10  0:52         ` Joseph Myers
2018-03-12 15:36           ` Wilco Dijkstra
2018-03-12 15:46             ` Zack Weinberg
2018-03-12 16:10             ` Joseph Myers
2018-03-12 21:13               ` Wilco Dijkstra
2018-03-09 19:06     ` Wilco Dijkstra
2018-03-09 19:31       ` Siddhesh Poyarekar
2018-03-12 18:09         ` Wilco Dijkstra
2018-03-13  8:53           ` Siddhesh Poyarekar

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=CAKCAbMg85h8JLK1qUNUgUUDVwU2WCnD4WCCputCM7qhr7y0i6w@mail.gmail.com \
    --to=zackw@panix.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=libc-alpha@sourceware.org \
    --cc=nd@arm.com \
    --cc=neleai@seznam.cz \
    --cc=siddhesh@gotplt.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).