glibc/sysdeps/ieee754/dbl-64
Patrick McGehearty 6fd0a3c6a8 Improve __ieee754_exp() performance by greater than 5x on sparc/x86.
These changes will be active for all platforms that don't provide
their own exp() routines. They will also be active for ieee754
versions of ccos, ccosh, cosh, csin, csinh, sinh, exp10, gamma, and
erf.

Typical performance gains is typically around 5x when measured on
Sparc s7 for common values between exp(1) and exp(40).

Using the glibc perf tests on sparc,
      sparc (nsec)    x86 (nsec)
      old     new     old     new
max   17629   395    5173     144
min     399    54      15      13
mean   5317   200    1349      23

The extreme max times for the old (ieee754) exp are due to the
multiprecision computation in the old algorithm when the true value is
very near 0.5 ulp away from an value representable in double
precision. The new algorithm does not take special measures for those
cases. The current glibc exp perf tests overrepresent those values.
Informal testing suggests approximately one in 200 cases might
invoke the high cost computation. The performance advantage of the new
algorithm for other values is still large but not as large as indicated
by the chart above.

Glibc correctness tests for exp() and expf() were run. Within the
test suite 3 input values were found to cause 1 bit differences (ulp)
when "FE_TONEAREST" rounding mode is set. No differences in exp() were
seen for the tested values for the other rounding modes.
Typical example:
exp(-0x1.760cd2p+0)  (-1.46113312244415283203125)
 new code:    2.31973271630014299393707e-01   0x1.db14cd799387ap-3
 old code:    2.31973271630014271638132e-01   0x1.db14cd7993879p-3
    exp    =  2.31973271630014285508337 (high precision)
Old delta: off by 0.49 ulp
New delta: off by 0.51 ulp

In addition, because ieee754_exp() is used by other routines, cexp()
showed test results with very small imaginary input values where the
imaginary portion of the result was off by 3 ulp when in upward
rounding mode, but not in the other rounding modes.  For x86, tgamma
showed a few values where the ulp increased to 6 (max ulp for tgamma
is 5). Sparc tgamma did not show these failures.  I presume the tgamma
differences are due to compiler optimization differences within the
gamma function.The gamma function is known to be difficult to compute
accurately.

	* sysdeps/ieee754/dbl-64/e_exp.c: Include <math-svid-compat.h> and
	<errno.h>.  Include "eexp.tbl".
	(half): New constant.
	(one): Likewise.
	(__ieee754_exp): Rewrite.
	(__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/eexp.tbl: New file.
	* sysdeps/ieee754/dbl-64/slowexp.c: Remove file.
	* sysdeps/i386/fpu/slowexp.c: Likewise.
	* sysdeps/ia64/fpu/slowexp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/slowexp.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Likewise.
	* sysdeps/generic/math_private.h (__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/e_pow.c: Remove mention of slowexp.c in
	comment.
	* sysdeps/powerpc/power4/fpu/Makefile [$(subdir) = math]
	(CPPFLAGS-slowexp.c): Remove variable.
	* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
	Remove slowexp-fma, slowexp-fma4 and slowexp-avx.
	(CFLAGS-slowexp-fma.c): Remove variable.
	(CFLAGS-slowexp-fma4.c): Likewise.
	(CFLAGS-slowexp-avx.c): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Do not
	define as macro.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Likewise.
	* math/Makefile (type-double-routines): Remove slowexp.
	* manual/probes.texi (slowexp_p6): Remove.
	(slowexp_p32): Likewise.
2017-12-19 17:27:31 +00:00
..
wordsize-64 [BZ #22243] fix log2(0) and log(10) in downward rounding 2017-10-04 10:13:56 +01:00
asincos.tbl Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
atnat2.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
atnat.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
branred.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
branred.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
dbl2mpn.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
dla.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
doasin.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
doasin.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
dosincos.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
dosincos.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_acos.c
e_acosh.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_asin.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_atan2.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_atanh.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_cosh.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_exp2.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_exp10.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_exp.c Improve __ieee754_exp() performance by greater than 5x on sparc/x86. 2017-12-19 17:27:31 +00:00
e_fmod.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_gamma_r.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_hypot.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_ilogb.c Format floating routines. 2013-10-17 16:03:24 +02:00
e_j0.c Fix y0 and y1 exception handling for zero input [BZ #21134] 2017-02-15 10:30:59 -02:00
e_j1.c Fix y0 and y1 exception handling for zero input [BZ #21134] 2017-02-15 10:30:59 -02:00
e_jn.c [BZ #22244] Fix yn(n,0) without SVID wrapper 2017-10-04 10:15:12 +01:00
e_lgamma_r.c Use fabs(f/l) rather than __fabs 2017-09-29 18:54:24 +01:00
e_log2.c Use fabs(f/l) rather than __fabs 2017-09-29 18:54:24 +01:00
e_log10.c Use fabs(f/l) rather than __fabs 2017-09-29 18:54:24 +01:00
e_log.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_pow.c Improve __ieee754_exp() performance by greater than 5x on sparc/x86. 2017-12-19 17:27:31 +00:00
e_rem_pio2.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_remainder.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
e_sinh.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
e_sqrt.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
eexp.tbl Improve __ieee754_exp() performance by greater than 5x on sparc/x86. 2017-12-19 17:27:31 +00:00
gamma_product.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
gamma_productf.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
halfulp.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
k_cos.c
k_rem_pio2.c Narrowing the visibility of libc-internal.h even further. 2017-03-01 20:33:46 -05:00
k_sin.c
k_tan.c Replace sysdeps/ieee754/dbl-64/k_tan.c with empty file 2012-02-26 16:10:46 +01:00
lgamma_neg.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
lgamma_product.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Makefile Fix CFLAGS override in sysdeps/ieee754/dbl-64 2017-08-24 15:56:11 +01:00
MathLib.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpa-arch.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpa.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpa.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpatan2.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpatan.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpatan.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpexp.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mplog.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpn2dbl.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpsqrt.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mpsqrt.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mptan.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
mydefs.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
powtwo.tbl Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
root.tbl Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_asinh.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_atan.c Use libm_alias_double for dbl-64 atan, tan. 2017-10-02 23:16:56 +00:00
s_cbrt.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_ceil.c Use libm_alias_double for more dbl-64 functions. 2017-10-03 17:47:35 +00:00
s_copysign.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_cos.c
s_erf.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_expm1.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_fabs.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_finite.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
s_floor.c Use libm_alias_double for more dbl-64 functions. 2017-10-03 17:47:35 +00:00
s_fma.c Use libm_alias_double for dbl-64 fma. 2017-10-04 20:32:48 +00:00
s_fmaf.c Use libm_alias_float for dbl-64 fmaf. 2017-10-03 21:01:33 +00:00
s_fpclassify.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
s_frexp.c Use libm_alias_double for dbl-64 frexp. 2017-10-03 20:56:46 +00:00
s_fromfp_main.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_fromfp.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_fromfpx.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_getpayload.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_isinf.c math: add LDBL_CLASSIFY_COMPAT support 2015-12-03 13:00:46 -05:00
s_isnan.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
s_issignaling.c Consistently use uintN_t not u_intN_t in libm. 2017-08-03 19:55:04 +00:00
s_llrint.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_llround.c Use libm_alias_double for more dbl-64 functions. 2017-10-03 17:47:35 +00:00
s_log1p.c Refactor code forcing underflow exceptions. 2015-09-23 22:42:30 +00:00
s_logb.c Use libm_alias_double for dbl-64 logb. 2017-10-03 23:44:41 +00:00
s_lrint.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_lround.c Use libm_alias_double for more dbl-64 functions. 2017-10-03 17:47:35 +00:00
s_modf.c Use libm_alias_double for dbl-64 modf. 2017-10-03 23:46:23 +00:00
s_nearbyint.c Use libm_alias_double for more dbl-64 functions. 2017-10-03 17:47:35 +00:00
s_nexttoward.c
s_nextup.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_remquo.c Use libm_alias_double for more dbl-64 functions. 2017-10-03 17:47:35 +00:00
s_rint.c Use libm_alias_double for more dbl-64 functions. 2017-10-03 17:47:35 +00:00
s_round.c Use libm_alias_double for more dbl-64 functions. 2017-10-03 17:47:35 +00:00
s_roundeven.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_scalbln.c [BZ #6803] Set errno for scalbln, scalbn 2014-06-20 07:48:20 +05:30
s_scalbn.c Make scalbn set errno (bug 6803). 2015-09-16 21:11:00 +00:00
s_setpayload_main.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_setpayload.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_setpayloadsig.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_signbit.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
s_sin.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_sincos.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_tan.c Use libm_alias_double for dbl-64 atan, tan. 2017-10-02 23:16:56 +00:00
s_tanh.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_totalorder.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_totalordermag.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_trunc.c Use libm_alias_double for more dbl-64 functions. 2017-10-03 17:47:35 +00:00
s_ufromfp.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
s_ufromfpx.c Use libm_alias_double for some dbl-64 functions. 2017-09-29 23:54:33 +00:00
sincos32.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
sincos32.h Fix typo in sincos32.h inclusion guard. 2017-09-25 15:56:22 +02:00
sincostab.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
slowpow.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
t_exp2.h
t_exp.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
uasncs.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
uatan.tbl Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
uexp.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
uexp.tbl Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
ulog.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
ulog.tbl Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
upow.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
upow.tbl Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
urem.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
usncs.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
utan.h Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
utan.tbl Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
x2y2m1.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
x2y2m1f.c Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00