[PATCH 4/6] Add new log2 implementation

Szabolcs Nagy szabolcs.nagy@arm.com
Wed Jun 27 14:54:00 GMT 2018


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-27  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* 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/e_log2.c      | 245 ++++++++++++++++++-----------------
  sysdeps/ieee754/dbl-64/e_log2_data.c | 194 +++++++++++++++++++++++++++
  sysdeps/ieee754/dbl-64/math_config.h |  14 ++
  3 files changed, 337 insertions(+), 116 deletions(-)
  create mode 100644 sysdeps/ieee754/dbl-64/e_log2_data.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Add-new-log2-implementation.patch.diff
Type: text/x-patch
Size: 18096 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180627/88ff14c3/attachment.bin>


More information about the Libc-alpha mailing list