[PATCH v2 00/12] Add binary64 CORE-MATH implementations to libm
Adhemerval Zanella
adhemerval.zanella@linaro.org
Tue Sep 16 18:20:53 GMT 2025
This patchset continues the CORE-MATH integration, as done for the
binary32 implementations. For binary64, I first focused on the
implementations that show the worst accuracy. Unlike binary32, where
it is feasible to check all input accuracy with CPU time, binary64
requires both mathematical analysis and statistical tests to verify
implementation correctness.
For the former, I refer to the extensive work by Paul Zimmermann and
others [1], where they worked on analysis and the requirements for the
efficient and correctly rounded elementary functions implementation in
floating-point arithmetic as defined by the additional mathematical
operations of the IEEE 754-2019, and also added to the latest C standard.
For the latter, I check both the current implementation and the CORE-MATH
ones on different ranges with uniformly distributed random generation
numbers to gauge the current accuracy and ensure the CORE-MATH
implementation's correctness.
The current patch adds the CORE-MATH implementation for acosh, asinh,
atanh, lgamma, tgamma, erf, and erfc; as they are the symbols that showed
the worst accuracy (especially in non-default rounding modes). As for the
previous work, the CORE-MATH code was adapted to use glibc code style,
internal math definitions, and I added extra work to split data and common
definitions to avoid data definitions on ifunc builds (x86_64) and to help
with code consolidation (for maintainability).
Performance-wise, the CORE-MATH code shows mixed results, with some big
regressions (erfc), small regressions (acosh), and improvements (atanh, erf,
lgamma, and tgamma). The implementation relies on fma and other
floating-point primitives; so further tuning could provide an ifunc
variant for ABIs where such facilities are not in the base (such as x86_64).
Changes from v1:
* Fixed style issues.
* Use UINT64_C for 64-bit integer constants.
* Move some double-double common operation to its own header.
[1] https://inria.hal.science/hal-04474530
[2] https://members.loria.fr/PZimmermann/papers/accuracy.pdf
Adhemerval Zanella (12):
math: Use acosh from CORE-MATH
math: Use asinh from CORE-MATH
math: Use atanh from CORE-MATH
math: Consolidate acosh and asinh internal table
math: Move atanh internal data to separate file
math: Use lgamma from CORE-MATH
math: Use tgamma from CORE-MATH
math: Use erf from CORE-MATH
math: Use erfc from CORE-MATH
math: Consolidate internal erf/erfc tables
math: Consolidate erf/erfc definitions
math: Consolidate CORE-MATH double-double routines
SHARED-FILES | 14 +
math/Makefile | 13 +-
math/auto-libm-test-in | 6 +
math/auto-libm-test-out-erf | 138 ++
math/auto-libm-test-out-erfc | 69 +
sysdeps/i386/Makefile | 11 +-
sysdeps/i386/fpu/libm-test-ulps | 39 +
sysdeps/ieee754/dbl-64/ddcoremath.h | 213 +++
sysdeps/ieee754/dbl-64/e_acosh.c | 450 ++++-
sysdeps/ieee754/dbl-64/e_atanh.c | 276 ++-
sysdeps/ieee754/dbl-64/e_gamma_r.c | 1460 ++++++++++++--
sysdeps/ieee754/dbl-64/e_lgamma_r.c | 2236 +++++++++++++++++++---
sysdeps/ieee754/dbl-64/gamma_product.c | 46 -
sysdeps/ieee754/dbl-64/gamma_productf.c | 1 -
sysdeps/ieee754/dbl-64/lgamma_neg.c | 385 ----
sysdeps/ieee754/dbl-64/lgamma_product.c | 52 -
sysdeps/ieee754/dbl-64/libm-test-ulps | 84 +
sysdeps/ieee754/dbl-64/math_config.h | 36 +
sysdeps/ieee754/dbl-64/math_err.c | 31 +
sysdeps/ieee754/dbl-64/s_asincosh_data.c | 124 ++
sysdeps/ieee754/dbl-64/s_asincosh_data.h | 50 +
sysdeps/ieee754/dbl-64/s_asinh.c | 469 ++++-
sysdeps/ieee754/dbl-64/s_atanh_data.c | 243 +++
sysdeps/ieee754/dbl-64/s_atanh_data.h | 66 +
sysdeps/ieee754/dbl-64/s_erf.c | 420 ++--
sysdeps/ieee754/dbl-64/s_erf_common.h | 215 +++
sysdeps/ieee754/dbl-64/s_erf_data.c | 1557 +++++++++++++++
sysdeps/ieee754/dbl-64/s_erf_data.h | 56 +
sysdeps/ieee754/dbl-64/s_erfc.c | 805 ++++++--
sysdeps/ieee754/dbl-64/s_erfc_data.c | 355 ++++
sysdeps/ieee754/dbl-64/s_erfc_data.h | 49 +
sysdeps/ieee754/flt-32/lgamma_negf.c | 1 -
sysdeps/ieee754/flt-32/lgamma_productf.c | 1 -
sysdeps/ieee754/ldbl-96/gamma_product.c | 44 -
sysdeps/ieee754/ldbl-96/lgamma_product.c | 37 -
35 files changed, 8343 insertions(+), 1709 deletions(-)
create mode 100644 sysdeps/ieee754/dbl-64/ddcoremath.h
delete mode 100644 sysdeps/ieee754/dbl-64/gamma_product.c
delete mode 100644 sysdeps/ieee754/dbl-64/gamma_productf.c
delete mode 100644 sysdeps/ieee754/dbl-64/lgamma_neg.c
delete mode 100644 sysdeps/ieee754/dbl-64/lgamma_product.c
create mode 100644 sysdeps/ieee754/dbl-64/libm-test-ulps
create mode 100644 sysdeps/ieee754/dbl-64/s_asincosh_data.c
create mode 100644 sysdeps/ieee754/dbl-64/s_asincosh_data.h
create mode 100644 sysdeps/ieee754/dbl-64/s_atanh_data.c
create mode 100644 sysdeps/ieee754/dbl-64/s_atanh_data.h
create mode 100644 sysdeps/ieee754/dbl-64/s_erf_common.h
create mode 100644 sysdeps/ieee754/dbl-64/s_erf_data.c
create mode 100644 sysdeps/ieee754/dbl-64/s_erf_data.h
create mode 100644 sysdeps/ieee754/dbl-64/s_erfc_data.c
create mode 100644 sysdeps/ieee754/dbl-64/s_erfc_data.h
delete mode 100644 sysdeps/ieee754/flt-32/lgamma_negf.c
delete mode 100644 sysdeps/ieee754/flt-32/lgamma_productf.c
delete mode 100644 sysdeps/ieee754/ldbl-96/gamma_product.c
delete mode 100644 sysdeps/ieee754/ldbl-96/lgamma_product.c
--
2.43.0
More information about the Libc-alpha
mailing list