[PATCH v2] Add new log2 implementation

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


v2:
- use __FP_FAST_MATH and __builtin_fma
- drop the wordsize-64/ version
- add e_log2_data to the Makefile

Similar algorithm is used as in log: log2(2^k x) = k + log2(c) + log2(x/c)
where the last term is approximated by a polynomial of x/c - 1, the first
order coefficient is about 1/ln2 in this case.

There is separate code path when fma instruction is not available for
computing x/c - 1 precisely, for which the table size is doubled.

The worst case error is 0.547 ULP (0.55 without fma), the read only
global data size is 1168 bytes (2192 without fma) on aarch64.  The
non-nearest rounding error is less than 1 ULP.

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

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

	* math/Makefile (type-double-routines): Add e_log2_data.
	* sysdeps/ieee754/dbl-64/e_log2.c: Rewrite.
	* sysdeps/ieee754/dbl-64/e_log2_data.c: New file.
	* sysdeps/ieee754/dbl-64/math_config.h (__log2_data): Add.
	* sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c: Remove.
---
  math/Makefile                               |   2 +-
  sysdeps/ieee754/dbl-64/e_log2.c             | 245 +++++++++++++++-------------
  sysdeps/ieee754/dbl-64/e_log2_data.c        | 194 ++++++++++++++++++++++
  sysdeps/ieee754/dbl-64/math_config.h        |  14 ++
  sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c | 128 ---------------
  5 files changed, 338 insertions(+), 245 deletions(-)
  create mode 100644 sysdeps/ieee754/dbl-64/e_log2_data.c
  delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Add-new-log2-implementation.diff
Type: text/x-patch
Size: 23189 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180628/b14b80b9/attachment.bin>


More information about the Libc-alpha mailing list