This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Improves __ieee754_exp() performance by greater than 5x on sparc/x86.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]