glibc/sysdeps
Wilco Dijkstra 6c848d7038 math: Use an improved algorithm for hypot (dbl-64)
This implementation is based on the 'An Improved Algorithm for
hypot(a,b)' by Carlos F. Borges [1] using the MyHypot3 with the
following changes:

 - Handle qNaN and sNaN.
 - Tune the 'widely varying operands' to avoid spurious underflow
   due the multiplication and fix the return value for upwards
   rounding mode.
 - Handle required underflow exception for denormal results.

The main advantage of the new algorithm is its precision: with a
random 1e9 input pairs in the range of [DBL_MIN, DBL_MAX], glibc
current implementation shows around 0.34% results with an error of
1 ulp (3424869 results) while the new implementation only shows
0.002% of total (18851).

The performance result are also only slight worse than current
implementation.  On x86_64 (Ryzen 5900X) with gcc 12:

Before:

  "hypot": {
   "workload-random": {
    "duration": 3.73319e+09,
    "iterations": 1.12e+08,
    "reciprocal-throughput": 22.8737,
    "latency": 43.7904,
    "max-throughput": 4.37184e+07,
    "min-throughput": 2.28361e+07
   }
  }

After:

  "hypot": {
   "workload-random": {
    "duration": 3.7597e+09,
    "iterations": 9.8e+07,
    "reciprocal-throughput": 23.7547,
    "latency": 52.9739,
    "max-throughput": 4.2097e+07,
    "min-throughput": 1.88772e+07
   }
  }

Co-Authored-By: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

Checked on x86_64-linux-gnu and aarch64-linux-gnu.

[1] https://arxiv.org/pdf/1904.09481.pdf
2021-12-13 09:02:34 -03:00
..
aarch64 Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
alpha Replace --enable-static-pie with --disable-default-pie 2021-12-13 08:08:59 +05:30
arc Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
arm Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
csky Replace --enable-static-pie with --disable-default-pie 2021-12-13 08:08:59 +05:30
generic Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
gnu Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
hppa Replace --enable-static-pie with --disable-default-pie 2021-12-13 08:08:59 +05:30
htl htl: Reimplement GSCOPE 2021-09-16 01:04:17 +02:00
hurd Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
i386 Cleanup encoding in comments 2021-12-13 10:01:45 +05:30
ia64 Cleanup encoding in comments 2021-12-13 10:01:45 +05:30
ieee754 math: Use an improved algorithm for hypot (dbl-64) 2021-12-13 09:02:34 -03:00
m68k Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
mach Replace --enable-static-pie with --disable-default-pie 2021-12-13 08:08:59 +05:30
microblaze Replace --enable-static-pie with --disable-default-pie 2021-12-13 08:08:59 +05:30
mips Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
nios2 Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
nptl nptl: Add public rseq symbols and <sys/rseq.h> 2021-12-09 09:49:32 +01:00
posix posix: Remove spawni.c 2021-09-27 12:44:25 -03:00
powerpc Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
pthread nptl: Add one more barrier to nptl/tst-create1 2021-12-10 11:51:25 +01:00
riscv Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
s390 Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
sh Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN 2021-12-09 23:47:49 +01:00
sparc Replace --enable-static-pie with --disable-default-pie 2021-12-13 08:08:59 +05:30
unix x86-64: Remove LD_PREFER_MAP_32BIT_EXEC support [BZ #28656] 2021-12-10 14:01:34 -08:00
wordsize-32 Disable symbol hack in libc_nonshared.a 2021-09-27 07:46:25 -07:00
wordsize-64 Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
x86 x86-64: Remove LD_PREFER_MAP_32BIT_EXEC support [BZ #28656] 2021-12-10 14:01:34 -08:00
x86_64 Cleanup encoding in comments 2021-12-13 10:01:45 +05:30