llvm-project/libc/utils
Tue Ly a752460d73 [libc][math] Implement exp10f function correctly rounded to all rounding modes.
Implement exp10f function correctly rounded to all rounding modes.

Algorithm: perform range reduction to reduce
```
  10^x = 2^(hi + mid) * 10^lo
```
where:
```
  hi is an integer,
  0 <= mid * 2^5 < 2^5
  -log10(2) / 2^6 <= lo <= log10(2) / 2^6
```
Then `2^mid` is stored in a table of 32 entries and the product `2^hi * 2^mid` is
performed by adding `hi` into the exponent field of `2^mid`.
`10^lo` is then approximated by a degree-5 minimax polynomials generated by Sollya with:
```
  > P = fpminimax((10^x - 1)/x, 4, [|D...|], [-log10(2)/64. log10(2)/64]);
```
Performance benchmark using perf tool from the CORE-MATH project on Ryzen 1700:
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh exp10f
GNU libc version: 2.35
GNU libc release: stable
CORE-MATH reciprocal throughput   : 10.215
System LIBC reciprocal throughput : 7.944

LIBC reciprocal throughput        : 38.538
LIBC reciprocal throughput        : 12.175   (with `-msse4.2` flag)
LIBC reciprocal throughput        : 9.862    (with `-mfma` flag)

$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh exp10f --latency
GNU libc version: 2.35
GNU libc release: stable
CORE-MATH latency   : 40.744
System LIBC latency : 37.546

BEFORE
LIBC latency        : 48.989
LIBC latency        : 44.486   (with `-msse4.2` flag)
LIBC latency        : 40.221   (with `-mfma` flag)
```
This patch relies on https://reviews.llvm.org/D134002

Reviewed By: orex, zimmermann6

Differential Revision: https://reviews.llvm.org/D134104
2022-09-19 10:01:40 -04:00
..
HdrGen [libc] Fix prototype_test_gen 2022-07-29 10:18:54 +00:00
IntegrationTest [libc] Compile integration tests with -ffreestanding to avoid mixup with system libc. 2022-07-30 03:06:08 +00:00
LibcTableGenUtil [libc][NFC] Fix a few compiler warnings. 2022-08-09 22:30:40 +00:00
MPFRWrapper [libc][math] Implement exp10f function correctly rounded to all rounding modes. 2022-09-19 10:01:40 -04:00
UnitTest [libc][cmake] split fputil into individual targets 2022-08-31 10:44:52 -07:00
buildbot [libc] Add python3 to libc buildbot depedencies. 2020-12-17 08:59:13 -08:00
mathtools [libc][NFC] Add supporting class for atof implementation 2021-10-04 21:08:02 +00:00
testutils [libc] Specify rounding mode for strto[f|d] tests 2022-07-13 20:20:30 +00:00
tools [libc][cmake] Make `add_tablegen` calls match others 2022-01-24 18:36:37 +00:00
CMakeLists.txt [libc] Add a new rule add_integration_test. 2022-03-23 20:57:29 +00:00