[PATCH v2] Add new exp and exp2 implementations

Szabolcs Nagy szabolcs.nagy@arm.com
Thu Jun 28 12:59:00 GMT 2018


v2:
- define TOINT_INTRINSICS for all targets.

Optimized exp and exp2 implementations using a lookup table for
fractional powers of 2.  There are several variants, see e_exp_data.c,
they can be selected by modifying math_config.h allowing different
tradeoffs.

The default selection should be acceptable as generic libm code.
Worst case error is 0.509 ULP for exp and 0.507 ULP for exp2, on
aarch64 the rodata size is 2160 bytes, shared between exp and exp2.
On aarch64 .text + .rodata size decreased by 24912 bytes.

The non-nearest rounding error is less than 1 ULP even on targets
without efficient round implementation (although the error rate is
higher in that case).  Targets with single instruction, rounding mode
independent, to nearest integer rounding and conversion can use them
by setting TOINT_INTRINSICS and adding the necessary code to their
math_private.h.

The __exp1 code uses the same algorithm, so the error bound of pow
increased a bit.

New double precision error handling code was added following the
style of the single precision error handling code.

Improvements on Cortex-A72 compared to current glibc master:
exp latency: 1.5x
exp thruput: 2.3x
exp latency: 1.3x on small inputs
exp thruput: 1.8x on small inputs
exp2 latency: 1.6x
exp2 thruput: 3.2x

For small inputs the current exp code uses a separate algorithm
so the speed up there is less.

2018-06-28  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* math/Makefile (libm-support): Remove t_exp.
	(type-double-routines): Add math_err and e_exp_data.
	* sysdeps/ieee754/dbl-64/e_exp.c: Rewrite.
	* sysdeps/ieee754/dbl-64/e_exp2.c: Rewrite.
	* sysdeps/ieee754/dbl-64/e_exp_data.c: New file.
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Update error bound.
	* sysdeps/ieee754/dbl-64/eexp.tbl: Remove.
	* sysdeps/ieee754/dbl-64/math_config.h: New file.
	* sysdeps/ieee754/dbl-64/math_err.c: New file.
	* sysdeps/ieee754/dbl-64/t_exp.c: Remove.
	* sysdeps/ieee754/dbl-64/t_exp2.h: Remove.
	* sysdeps/ieee754/dbl-64/uexp.h: Remove.
	* sysdeps/ieee754/dbl-64/uexp.tbl: Remove.
---
  math/Makefile                        |    4 +-
  sysdeps/ieee754/dbl-64/e_exp.c       |  487 +++------
  sysdeps/ieee754/dbl-64/e_exp2.c      |  219 +++--
  sysdeps/ieee754/dbl-64/e_exp_data.c  |  500 ++++++++++
  sysdeps/ieee754/dbl-64/e_pow.c       |    6 +-
  sysdeps/ieee754/dbl-64/eexp.tbl      |  172 ----
  sysdeps/ieee754/dbl-64/math_config.h |  111 +++
  sysdeps/ieee754/dbl-64/math_err.c    |   92 ++
  sysdeps/ieee754/dbl-64/t_exp.c       |  435 ---------
  sysdeps/ieee754/dbl-64/t_exp2.h      |  585 -----------
  sysdeps/ieee754/dbl-64/uexp.h        |   68 --
  sysdeps/ieee754/dbl-64/uexp.tbl      | 1786 ----------------------------------
  12 files changed, 978 insertions(+), 3487 deletions(-)
  create mode 100644 sysdeps/ieee754/dbl-64/e_exp_data.c
  delete mode 100644 sysdeps/ieee754/dbl-64/eexp.tbl
  create mode 100644 sysdeps/ieee754/dbl-64/math_config.h
  create mode 100644 sysdeps/ieee754/dbl-64/math_err.c
  delete mode 100644 sysdeps/ieee754/dbl-64/t_exp.c
  delete mode 100644 sysdeps/ieee754/dbl-64/t_exp2.h
  delete mode 100644 sysdeps/ieee754/dbl-64/uexp.h
  delete mode 100644 sysdeps/ieee754/dbl-64/uexp.tbl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-new-exp-and-exp2-implementations.diff
Type: text/x-patch
Size: 215391 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180628/c4a2240f/attachment.bin>


More information about the Libc-alpha mailing list