public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Patrick McGehearty <patrick.mcgehearty@oracle.com>
Cc: <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Improves __ieee754_exp() performance by greater than 5x on sparc/x86.
Date: Thu, 23 Nov 2017 21:19:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.20.1711232107300.28121@digraph.polyomino.org.uk> (raw)
In-Reply-To: <1510028685-65660-1-git-send-email-patrick.mcgehearty@oracle.com>

On Mon, 6 Nov 2017, Patrick McGehearty wrote:

> @@ -561,8 +561,10 @@ math-CPPFLAGS += -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES
>  ifneq ($(long-double-fcts),yes)
>  # The `double' and `long double' types are the same on this machine.
>  # We won't compile the `long double' code at all.  Tell the `double' code
> -# to define aliases for the `FUNCl' names.
> -math-CPPFLAGS += -DNO_LONG_DOUBLE
> +# to define aliases for the `FUNCl' names.  To avoid type conflicts in
> +# defining those aliases, tell <math.h> to declare the `FUNCl' names with
> +# `double' instead of `long double'.
> +math-CPPFLAGS += -DNO_LONG_DOUBLE -D_Mlong_double_=double
>  endif
>  
>  # These files quiet sNaNs in a way that is optimized away without

This diff hunk is bogus (reverting a recent change I made) and should not 
be included in this patch.

> +	      if (hx < 0x3e300000)
> +		{
> +		  retval = one + xx.x;
> +		  return (retval);

No parentheses around return value.

> +		}
> +	      retval = one + xx.x * (one + half * xx.x);
> +	      return (retval);

Likewise.

> +	      yy.y = xx.x + (t * (half + xx.x * t2) +
> +			     (t * t) * (t3 + xx.x * t4 + t * t5));

Split lines before an operator, not after.

> +	      yy.y = xx.x + (t * (half + xx.x * t2) +
> +			     (t * t) * (t3 + xx.x * t4 + t * t5));

Likewise.

> +	  yy.y = z + (t * (half + (z * t2)) +
> +		      (t * t) * (t3 + z * t4 + t * t5));

Likewise.

> +	  yy.y = z + (t * (half + (z * t2)) +
> +		      (t * t) * (t3 + z * t4 + t * t5));

Likewise.

> +      return (retval);

Avoid parentheses around return value.

> +	  if (ix == 0xfff00000 && xx.i_part[LOW_HALF] == 0)
> +	    return (zero);	/* exp(-inf) = 0.  */

Likewise.

> +	  return (xx.x * xx.x);	/* exp(nan/inf) is nan or inf.  */

Likewise.

> +      yy.y = z + (t * (half + z * t2) + 
> +		  (t * t) * (t3 + z * t4 + t * t5));

Split line before operator.

> +      yy.y = z + (t * (half + z * t2) +
> +		  (t * t) * (t3 + z * t4 + t * t5));

Likewise.

> +  return (yy.y);

Remove parentheses.

> /* EXP function tables - for use in ocmputing double precisoin exponential

s/ocmputing/computing/

s/precisoin/precision/

> +/* TBL[2*j] and TBL[2*j+1] are double precision numbers used to
> +   approximate exp(x) using the formula given in the comments
> +   for e_exp.c.  */

I believe the correct semantics to describe are: TBL[2*j] is 2**(j/32), 
rounded to nearest; TBL[2*j+1] is 2**(j/32) - TBL[2*j], rounded to 
nearest.  Now if that's the case, three of the low parts should be 
adjusted by 1ulp because the current values aren't actually rounded to 
nearest (unless you have some concrete reason why the present values, that 
aren't rounded to nearest, are optimal):

> +    0x1.0b5586cf9890fp+0,  0x1.8a62e4adc610ap-54,

0x1.8a62e4adc610ap-54 should be 0x1.8a62e4adc610bp-54.

> +    0x1.5342b569d4f82p+0, -0x1.07abe1db13cacp-55,

-0x1.07abe1db13cacp-55 should be -0x1.07abe1db13cadp-55.

> +    0x1.d5818dcfba487p+0,  0x1.2ed02d75b3706p-55,

0x1.2ed02d75b3706p-55 should be 0x1.2ed02d75b3707p-55.

-- 
Joseph S. Myers
joseph@codesourcery.com

  parent reply	other threads:[~2017-11-23 21:19 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07  4:25 Patrick McGehearty
2017-11-16 17:52 ` Patrick McGehearty
2017-11-16 18:27   ` Carlos O'Donell
2017-11-16 18:31   ` Joseph Myers
2017-11-23 21:19 ` Joseph Myers [this message]
2017-12-01  0:47   ` Patrick McGehearty
  -- strict thread matches above, loose matches on Subject: below --
2017-12-29 23:42 Patrick McGehearty
2018-01-01  1:36 ` Joseph Myers
2018-01-01 16:31   ` Patrick McGehearty
2018-01-01 16:41     ` Joseph Myers
2017-12-08 23:08 Patrick McGehearty
2017-12-11  8:14 ` Siddhesh Poyarekar
2017-12-11 17:04   ` Patrick McGehearty
2017-12-11 17:53     ` Siddhesh Poyarekar
2017-12-14  1:28 ` Joseph Myers
2017-12-18 20:11   ` Patrick McGehearty
2017-12-04 21:53 Patrick McGehearty
2017-12-05 23:20 ` Joseph Myers
2017-12-01  0:51 Patrick McGehearty
2017-12-01  0:56 ` Joseph Myers
2017-10-26 22:53 Patrick McGehearty
2017-11-01  0:26 ` Joseph Myers
2017-10-26 16:44 Patrick McGehearty
2017-10-26 17:20 ` Joseph Myers
2017-10-26 17:25   ` Joseph Myers
2017-10-26 18:30     ` Patrick McGehearty
2017-10-26 19:44       ` Joseph Myers
2017-10-20 13:38 Wilco Dijkstra
2017-10-20 14:58 ` Patrick McGehearty
2017-10-16 16:56 Patrick McGehearty
2017-10-18 17:22 ` Joseph Myers
2017-10-18 23:22   ` Joseph Myers
2017-10-19 22:31   ` Patrick McGehearty
2017-10-19 22:48     ` Joseph Myers
2017-10-20 15:04       ` Patrick McGehearty
2017-10-21  5:23       ` Patrick McGehearty
2017-10-23 12:47         ` Joseph Myers
2017-10-23 19:58           ` Patrick McGehearty
2017-10-23 21:31             ` Joseph Myers
2017-10-20 11:41     ` Szabolcs Nagy
2017-10-20 14:56       ` Patrick McGehearty
2017-10-20 16:10       ` Joseph Myers
2017-10-23 12:25 ` Siddhesh Poyarekar
2017-10-23 15:58   ` Joseph Myers

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=alpine.DEB.2.20.1711232107300.28121@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=patrick.mcgehearty@oracle.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).