public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>,
	Siddhesh Poyarekar <siddhesh@gotplt.org>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
	GCC patches <gcc-patches@gcc.gnu.org>,
	Andrew MacLeod <amacleod@redhat.com>
Subject: Re: [PATCH] Implement range-op entry for sin/cos.
Date: Tue, 25 Apr 2023 10:59:27 +0200	[thread overview]
Message-ID: <ca726bdb-68c1-49cf-77ff-622422487955@redhat.com> (raw)
In-Reply-To: <ZEIyn6wYGqCeObul@tucnak>



On 4/21/23 08:52, Jakub Jelinek wrote:
> On Thu, Apr 20, 2023 at 09:14:10PM -0400, Siddhesh Poyarekar wrote:
>> On 2023-04-20 13:57, Siddhesh Poyarekar wrote:
>>> For bounds that aren't representable, one could get error bounds from
>>> libm-test-ulps data in glibc, although I reckon those won't be
>>> exhaustive.  From a quick peek at the sin/cos data, the arc target seems
>>> to be among the worst performers at about 7ulps, although if you include
>>> the complex routines we get close to 13 ulps.  The very worst
>>> imprecision among all math routines (that's gamma) is at 16 ulps for
>>> power in glibc tests, so maybe allowing about 25-30 ulps error in bounds
>>> might work across the board.
>>
>> I was thinking about this a bit more and it seems like limiting ranges to
>> targets that can generate sane results (i.e. error bounds within, say, 5-6
>> ulps) and for the rest, avoid emitting the ranges altogether. Emitting a bad
>> range for all architectures seems like a net worse solution again.
> 
> Well, at least for basic arithmetics when libm functions aren't involved,
> there is no point in disabling ranges altogether.
> And, for libm functions, my plan was to introduce a target hook, which
> would have combined_fn argument to tell which function is queried,
> machine_mode to say which floating point format and perhaps a bool whether
> it is ulps for these basic math boundaries or results somewhere in between,
> and would return in unsigned int ulps, 0 for 0.5ulps precision.

I wonder if we could export frange_nextafter() to take a final argument 
for the number of ulps, making it possible to extend in either direction 
by a number of ulps.  And perhaps add a generic function that calls the 
target hook and extends the range accordingly:

extern int TARGET_ULP_ERROR (combined_fn, machine_mode);
extern void frange_nextafter (machine_mode,
			      REAL_VALUE_TYPE &value,
			      const REAL_VALUE_TYPE &direction,
			      int ulps);
void
adjust_frange_for_op (frange &r, combined_fn fn)
{
   ...
   int ulps = TARGET_ULP_ERROR (fn, mode);
   frange_nextafter (mode, lb, frange_val_min (type), ulps);
   frange_nextafter (mode, ub, frange_val_max (type), ulps);
   ...
}

bool
cfn_sincos::fold_range (...)
{
...
  if (cond)
     {
       r.set (type, dconstm1, const1);
       adjust_frange_for_op (r, m_cfn);
     }
...
}

Or if adjusting by ULPS is a common enough idiom, we could promote it to 
an frange method:

	void frange::adjust_ulps (int ulps);

Would that work, or did you have something else in mind?

Aldy


  parent reply	other threads:[~2023-04-25  8:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-18 13:12 Aldy Hernandez
2023-04-20 12:59 ` Jakub Jelinek
2023-04-20 13:17   ` Siddhesh Poyarekar
2023-04-20 14:02     ` Jakub Jelinek
2023-04-20 14:20       ` Jakub Jelinek
2023-04-20 15:22       ` Siddhesh Poyarekar
2023-04-20 15:52         ` Jakub Jelinek
2023-04-20 17:57           ` Siddhesh Poyarekar
2023-04-21  1:14             ` Siddhesh Poyarekar
2023-04-21  6:52               ` Jakub Jelinek
2023-04-21 11:20                 ` Siddhesh Poyarekar
2023-04-25  8:59                 ` Aldy Hernandez [this message]
2023-04-24 16:03             ` Jakub Jelinek
2023-04-24 16:05               ` Siddhesh Poyarekar
2023-04-24 16:09                 ` Jakub Jelinek
2023-04-24 16:33                 ` Jeff Law
2023-04-21 16:40   ` Jakub Jelinek
2023-04-21 20:43     ` Mikael Morin
2023-04-21 20:45       ` Jakub Jelinek
2023-04-25  9:10       ` Aldy Hernandez
2023-04-25  9:08     ` Aldy Hernandez
2023-04-27 11:13 ` [PATCH] v2: " Jakub Jelinek
2023-04-27 11:46   ` Aldy Hernandez
2023-04-27 11:53     ` Jakub Jelinek
2023-04-27 12:03       ` Aldy Hernandez

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=ca726bdb-68c1-49cf-77ff-622422487955@redhat.com \
    --to=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --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).