diff options
author | Tue Ly <lntue.h@gmail.com> | 2022-04-05 23:17:18 +0300 |
---|---|---|
committer | Tue Ly <lntue@google.com> | 2022-07-22 17:07:31 +0300 |
commit | d883a4ad02d867e7037bd4ec342016c402484148 (patch) | |
tree | fb4e927170177ab6f6ed1af58e9ea5aa77481250 /libc/cmake/modules/LLVMLibCObjectRules.cmake | |
parent | 4f2cfbe5314b064625b2c87bde6ce5c8d04004c5 (diff) |
[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
Diffstat (limited to 'libc/cmake/modules/LLVMLibCObjectRules.cmake')
-rw-r--r-- | libc/cmake/modules/LLVMLibCObjectRules.cmake | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake index a824cad94b7c..9e825144bfda 100644 --- a/libc/cmake/modules/LLVMLibCObjectRules.cmake +++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake @@ -515,7 +515,7 @@ function(add_entrypoint_object target_name) list(SORT flags) if(SHOW_INTERMEDIATE_OBJECTS AND flags) - message(STATUS "Object library ${fq_target_name} has FLAGS: ${flags}") + message(STATUS "Entrypoint object ${fq_target_name} has FLAGS: ${flags}") endif() if(NOT ADD_TO_EXPAND_NAME) |