[all-commits] [llvm/llvm-project] d883a4: [libc] Implement sinf function that is correctly r...
lntue via All-commits
all-commits at lists.llvm.org
Fri Jul 22 07:07:54 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d883a4ad02d867e7037bd4ec342016c402484148
https://github.com/llvm/llvm-project/commit/d883a4ad02d867e7037bd4ec342016c402484148
Author: Tue Ly <lntue.h at gmail.com>
Date: 2022-07-22 (Fri, 22 Jul 2022)
Changed paths:
M libc/cmake/modules/LLVMLibCObjectRules.cmake
M libc/docs/math.rst
M libc/src/__support/FPUtil/CMakeLists.txt
A libc/src/__support/FPUtil/except_value_utils.h
M libc/src/math/generic/CMakeLists.txt
A libc/src/math/generic/range_reduction.h
A libc/src/math/generic/range_reduction_fma.h
M libc/src/math/generic/sinf.cpp
M libc/test/src/math/exhaustive/CMakeLists.txt
M libc/test/src/math/exhaustive/sinf_test.cpp
M libc/test/src/math/sinf_test.cpp
M utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Log Message:
-----------
[libc] Implement sinf function that is correctly rounded to all rounding modes.
Implement sinf function that is correctly rounded to all rounding modes.
- We use a simple range reduction for `pi/16 < |x|` :
Let `k = round(x / pi)` and `y = (x/pi) - k`.
So `k` is an integer and `-0.5 <= y <= 0.5`.
Then
```
sin(x) = sin(y*pi + k*pi)
= (-1)^(k & 1) * sin(y*pi)
~ (-1)^(k & 1) * y * P(y^2)
```
where `y*P(y^2)` is a degree-15 minimax polynomial generated by Sollya with:
```
> P = fpminimax(sin(x*pi)/x, [|0, 2, 4, 6, 8, 10, 12, 14|], [|D...|], [0, 0.5]);
```
- Performance benchmark using perf tool from CORE-MATH project
(https://gitlab.inria.fr/core-math/core-math/-/tree/master) on Ryzen 1700:
Before this patch (not correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinf
CORE-MATH reciprocal throughput : 17.892
System LIBC reciprocal throughput : 25.559
LIBC reciprocal throughput : 29.381
```
After this patch (correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinf
CORE-MATH reciprocal throughput : 17.896
System LIBC reciprocal throughput : 25.740
LIBC reciprocal throughput : 27.872
LIBC reciprocal throughput : 20.012 (with `-msse4.2` flag)
LIBC reciprocal throughput : 14.244 (with `-mfma` flag)
```
Reviewed By: zimmermann6
Differential Revision: https://reviews.llvm.org/D123154
More information about the All-commits
mailing list