[PATCH 3/3] Add new pow implementation

Szabolcs Nagy szabolcs.nagy@arm.com
Tue Sep 11 12:41:00 GMT 2018


v6:
- Document table generation method.
- Rebase NEWS and math/Makefile changes.
v5:
- Fix a typo in log_inline comment and make the wording clearer.
- Update improvements in commit message.
- Update tested targets in commit message.
v4:
- Fixed a !__FP_FAST_FMA bug: pow(0x1.ffffffffXXXp-1, big) had large ulp error.
- Update specialcase documentation.
- Fix a GNU style issue.
- Remove unused configurations and related code/data.
- Update NEWS entry.
- Document tested targets in the commit message.
v3:
- Add empty e_pow_log_data.c to targets that have their own pow.
- Fix GNU style issues.
- Document internal function semantics.
- Add NEWS entry.
v2:
- use __FP_FAST_FMA and __builtin_fma
- update x86_64 makefiles too to allow fma contraction.

The algorithm is exp(y * log(x)), where log(x) is computed with about
1.3*2^-68 relative error (1.5*2^-68 without fma), returning the result
in two doubles, and the exp part uses the same algorithm (and lookup
tables) as exp, but takes the input as two doubles and a sign (to handle
negative bases with odd integer exponent).  The __exp1 internal symbol
is no longer necessary.

There is separate code path when fma is not available but the worst case
error is about 0.54 ULP in both cases.  The lookup table and consts for
log are 4168 bytes.  The .rodata+.text is decreased by 37908 bytes on
aarch64.  The non-nearest rounding error is less than 1 ULP.

Improvements on Cortex-A72 compared to current glibc master:
pow thruput: 2.40x in [0.01 11.1]x[0.01 11.1]
pow latency: 1.84x in [0.01 11.1]x[0.01 11.1]

Tested on
aarch64-linux-gnu (defined __FP_FAST_FMA, TOINT_INTRINSICS) and
arm-linux-gnueabihf (!defined __FP_FAST_FMA, !TOINT_INTRINSICS) and
x86_64-linux-gnu (!defined __FP_FAST_FMA, !TOINT_INTRINSICS) and
powerpc64le-linux-gnu (defined __FP_FAST_FMA, !TOINT_INTRINSICS) targets.

2018-09-11  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* NEWS: Mention pow improvements.
	* math/Makefile (type-double-routines): Add e_pow_log_data.
	* sysdeps/generic/math_private.h (__exp1): Remove.
	* sysdeps/i386/fpu/e_pow_log_data.c: New file.
	* sysdeps/ia64/fpu/e_pow_log_data.c: New file.
	* sysdeps/ieee754/dbl-64/Makefile (CFLAGS-e_pow.c): Allow fma
	contraction.
	* sysdeps/ieee754/dbl-64/e_exp.c (__exp1): Remove.
	(exp_inline): Remove.
	(__ieee754_exp): Only single double input is handled.
	* sysdeps/ieee754/dbl-64/e_pow.c: Rewrite.
	* sysdeps/ieee754/dbl-64/e_pow_log_data.c: New file.
	* sysdeps/ieee754/dbl-64/math_config.h (issignaling_inline): Define.
	(__pow_log_data): Define.
	* sysdeps/ieee754/dbl-64/upow.h: Remove.
	* sysdeps/ieee754/dbl-64/upow.tbl: Remove.
	* sysdeps/m68k/m680x0/fpu/e_pow_log_data.c: New file.
	* sysdeps/x86_64/fpu/multiarch/Makefile (CFLAGS-e_pow-fma.c): Allow fma
	contraction.
	(CFLAGS-e_pow-fma4.c): Likewise
---
  NEWS                                     |     2 +-
  math/Makefile                            |     2 +-
  sysdeps/generic/math_private.h           |     1 -
  sysdeps/i386/fpu/e_pow_log_data.c        |     1 +
  sysdeps/ia64/fpu/e_pow_log_data.c        |     1 +
  sysdeps/ieee754/dbl-64/Makefile          |     1 -
  sysdeps/ieee754/dbl-64/e_exp.c           |    35 +-
  sysdeps/ieee754/dbl-64/e_pow.c           |   657 +-
  sysdeps/ieee754/dbl-64/e_pow_log_data.c  |   195 +
  sysdeps/ieee754/dbl-64/math_config.h     |    22 +
  sysdeps/ieee754/dbl-64/upow.h            |    76 -
  sysdeps/ieee754/dbl-64/upow.tbl          | 10188 -----------------------------
  sysdeps/m68k/m680x0/fpu/e_pow_log_data.c |     1 +
  sysdeps/x86_64/fpu/multiarch/Makefile    |     4 +-
  14 files changed, 570 insertions(+), 10616 deletions(-)
  create mode 100644 sysdeps/i386/fpu/e_pow_log_data.c
  create mode 100644 sysdeps/ia64/fpu/e_pow_log_data.c
  create mode 100644 sysdeps/ieee754/dbl-64/e_pow_log_data.c
  delete mode 100644 sysdeps/ieee754/dbl-64/upow.h
  delete mode 100644 sysdeps/ieee754/dbl-64/upow.tbl
  create mode 100644 sysdeps/m68k/m680x0/fpu/e_pow_log_data.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Add-new-pow-implementation.diff
Type: text/x-patch
Size: 533360 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180911/2be4cebc/attachment.bin>


More information about the Libc-alpha mailing list