[PATCH v2] Add new log implementation

Szabolcs Nagy szabolcs.nagy@arm.com
Thu Jun 28 11:06:00 GMT 2018


v2:
- Use __FP_FAST_FMA and __builtin_fma.

Optimized log using carefully generated lookup table with 1/c and log(c)
values for small intervalls around 1.  The log(c) is very near a double
precision value, it has about 62 bits precision.  The algorithm is
log(2^k x) = k log(2) + log(c) + log(x/c), where the last term is
approximated by a polynomial of x/c - 1.  Near 1 a single polynomial of
x - 1 is used.

There is separate code path when fma instruction is not available for
computing x/c - 1 precisely, in which case the table size is doubled.
The code uses __builtin_fma under __FP_FAST_FMA to ensure it is inlined
as an instruction.

With the default configuration settings the worst case error is 0.519 ULP
(and 0.520 without fma), the rodata size is 2192 bytes (4240 without fma).
The non-nearest rounding error is less than 1 ULP.

Improvements on Cortex-A72 compared to current glibc master:
latency: 2.0x
thruput: 2.9x

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

	* math/Makefile (type-double-routines): Add e_log_data.
	* sysdeps/ieee754/dbl-64/e_log.c: Rewrite.
	* sysdeps/ieee754/dbl-64/e_log_data.c: New file.
	* sysdeps/ieee754/dbl-64/math_config.h (__log_data): Add.
	* sysdeps/ieee754/dbl-64/ulog.h: Remove.
	* sysdeps/ieee754/dbl-64/ulog.tbl: Remove.
---
  math/Makefile                        |    3 +-
  sysdeps/ieee754/dbl-64/e_log.c       |  272 ++-
  sysdeps/ieee754/dbl-64/e_log_data.c  |  471 +++++
  sysdeps/ieee754/dbl-64/math_config.h |   14 +
  sysdeps/ieee754/dbl-64/ulog.h        |   93 -
  sysdeps/ieee754/dbl-64/ulog.tbl      | 3326 ----------------------------------
  6 files changed, 614 insertions(+), 3565 deletions(-)
  create mode 100644 sysdeps/ieee754/dbl-64/e_log_data.c
  delete mode 100644 sysdeps/ieee754/dbl-64/ulog.h
  delete mode 100644 sysdeps/ieee754/dbl-64/ulog.tbl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Add-new-log-implementation.diff
Type: text/x-patch
Size: 210937 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180628/acbf5811/attachment.bin>


More information about the Libc-alpha mailing list