[libc][math] fmod/fmodf implementation.This is a implementation of find remainder fmod function from standard libm.The underline algorithm is developed by myself, but probably it was firstinvente
[libc][math] fmod/fmodf implementation.This is a implementation of find remainder fmod function from standard libm.The underline algorithm is developed by myself, but probably it was firstinvented before.Some features of the implementation:1. The code is written on more-or-less modern C++.2. One general implementation for both float and double precision numbers.3. Spitted platform/architecture dependent and independent code and tests.4. Tests covers 100% of the code for both float and double numbers. Tests cases with NaN/Inf etc is copied from glibc.5. The new implementation in general 2-4 times faster for “regular” x,y values. It can be 20 times faster for x/y huge value, but can also be 2 times slower for double denormalized range (according to perf tests provided).6. Two different implementation of division loop are provided. In some platforms division can be very time consuming operation. Depend on platform it can be 3-10 times slower than multiplication.Performance tests:The test is based on core-math project (https://gitlab.inria.fr/core-math/core-math). By Tue Ly suggestion I took hypot function and use it as template for fmod. Preserving all test cases.`./check.sh <--special|--worst> fmodf` passed.`CORE_MATH_PERF_MODE=rdtsc ./perf.sh fmodf` results are```GNU libc version: 2.35GNU libc release: stable21.166 <-- FPU51.031 <-- current glibc37.659 <-- this fmod version.```
show more ...
[libc][math] Differential "diff" test for hypot/hypotf functions.Added test handler in preparation to fmod/fmodf commit.Differential Revision: https://reviews.llvm.org/D127091
[libc] Improve hypotf performance with different algorithm correctly rounded to all rounding modes.Algorithm for hypotf: compute (a*a + b*b) in double precision, then use Dekker's algorithm to find
[libc] Improve hypotf performance with different algorithm correctly rounded to all rounding modes.Algorithm for hypotf: compute (a*a + b*b) in double precision, then use Dekker's algorithm to find the rounding error, and then correcting it after taking its square-root.Reviewed By: sivachandraDifferential Revision: https://reviews.llvm.org/D118157
[libc] Implement log1pf correctly rounded to all rounding modes.Implement log1pf correctly rounded to all rounding modes relying on logf implementation for exponent > 2^(-8).Reviewed By: sivachan
[libc] Implement log1pf correctly rounded to all rounding modes.Implement log1pf correctly rounded to all rounding modes relying on logf implementation for exponent > 2^(-8).Reviewed By: sivachandra, zimmermann6Differential Revision: https://reviews.llvm.org/D118962
[libc] Set default CXX_STANDARD to C++17 and let targets set their own standard if needed.CMAKE_CXX_STANDARD 14 is set in the llvm-project/llvm folder overriding all COMPILE_OPTIONS -std=c++17. We
[libc] Set default CXX_STANDARD to C++17 and let targets set their own standard if needed.CMAKE_CXX_STANDARD 14 is set in the llvm-project/llvm folder overriding all COMPILE_OPTIONS -std=c++17. We need to override the CXX_STANDARD property of the target in order to set the correct C++ standard flags.Reviewed By: gchateletDifferential Revision: https://reviews.llvm.org/D118871
[libc] Implement log10f correctly rounded for all rounding modes.Based on RLIBM implementation similar to logf and log2f. Most of the exceptional inputs are the exact powers of 10.Reviewed By: s
[libc] Implement log10f correctly rounded for all rounding modes.Based on RLIBM implementation similar to logf and log2f. Most of the exceptional inputs are the exact powers of 10.Reviewed By: sivachandra, zimmermann6, santoshn, jpl169Differential Revision: https://reviews.llvm.org/D118093
[libc] Implement correct rounding with all rounding modes for hypot functions.Update the rounding logic for generic hypot function so that it will round correctly with all rounding modes.Reviewed
[libc] Implement correct rounding with all rounding modes for hypot functions.Update the rounding logic for generic hypot function so that it will round correctly with all rounding modes.Reviewed By: sivachandra, zimmermann6Differential Revision: https://reviews.llvm.org/D117590
[libc] Implement correctly rounded log2f based on RLIBM library.Implement log2f based on RLIBM library correctly rounded for all rounding modes.Reviewed By: sivachandra, michaelrj, santoshn, jpl1
[libc] Implement correctly rounded log2f based on RLIBM library.Implement log2f based on RLIBM library correctly rounded for all rounding modes.Reviewed By: sivachandra, michaelrj, santoshn, jpl169, zimmermann6Differential Revision: https://reviews.llvm.org/D115828
[libc] Add performance tests for hypotf and hypot.Add performance tests for hypotf and hypot.Reviewed By: sivachandra, michaelrjDifferential Revision: https://reviews.llvm.org/D116122
[libc] Show average runtime for math single-input-single-output performance tests.Run performance tests in denormal and normal ranges separately and show more detailed results.Reviewed By: sivach
[libc] Show average runtime for math single-input-single-output performance tests.Run performance tests in denormal and normal ranges separately and show more detailed results.Reviewed By: sivachandraDifferential Revision: https://reviews.llvm.org/D116112
[libc] Implement correctly rounded logf based on RLIBM library.Implement correctly rounded logf based on RLIBM library: https://people.cs.rutgers.edu/~sn349/rlibm/.Reviewed By: sivachandra, santo
[libc] Implement correctly rounded logf based on RLIBM library.Implement correctly rounded logf based on RLIBM library: https://people.cs.rutgers.edu/~sn349/rlibm/.Reviewed By: sivachandra, santoshn, jpl169, zimmermann6Differential Revision: https://reviews.llvm.org/D115408
[libc][nfc] move ctype_utils and FPUtils to __supportSome ctype functions are called from other libc functions (e.g. isspaceis used in atoi). By moving ctype_utils.h to __support it becomes easier
[libc][nfc] move ctype_utils and FPUtils to __supportSome ctype functions are called from other libc functions (e.g. isspaceis used in atoi). By moving ctype_utils.h to __support it becomes easierto include just the implementations of these functions. For thesereasons the implementation for isspace was moved intoctype_utils as well.FPUtils was moved to simplify the build order, and to clarify whichfiles are a part of the actual libc.Many files were modified to accomodate these changes, mostly changingthe #include paths.Reviewed By: sivachandraDifferential Revision: https://reviews.llvm.org/D107600
[libc] Add diff and perf targets for more math functionsComparing the run time of math functions from LLVM libcwith the MSVCRT libc:|function |perf-LLVM libc |perf-MSVCRT|ceilf |2.36 mins
[libc] Add diff and perf targets for more math functionsComparing the run time of math functions from LLVM libcwith the MSVCRT libc:|function |perf-LLVM libc |perf-MSVCRT|ceilf |2.36 mins (141491389600 ns)|47.10 sec (47100940100 ns)|exp2f |6.37 mins (358441794700 ns)|12.39 mins (719404388300 ns)|expf |6.35 mins (381204661800 ns)|6.17 mins (346150163200 ns)|fabsf |1.18 mins (78425546600 ns) |53.75 sec (53745301900 ns)|floorf |3.15 mins (164770963800 ns)|45.94 sec (45935988400 ns)|logbf |4.38 mins (262508058800 ns)|55.47 sec (55466377700 ns)|nearbyintf |3.20 mins (167972868000 ns)|9.13 mins (523822963600 ns)|rintf |3.20 mins (168001498700 ns)|22.35 mins (1341266448800 ns)|roundf |2.35 mins (141151500600 ns)|1.42 mins (85326429800 ns)|truncf |2.31 mins (114846424000 ns)|59.41 sec (59414309100 ns)Evaluating the number of differing results in Windows:|function |diff|ceilf |8388606 differing results|exp2f |213303887 differing results|expf |193922 differing results|fabsf |8388606 differing results|floorf |8388606 differing results|logbf |0 differing results|nearbyintf |0 differing results|rintf |0 differing results|roundf |0 differing results|truncf |0 differing resultsReviewed By: sivachandraDifferential Revision: https://reviews.llvm.org/D107462
[libc] Add differential and performance targets for sqrtfComparing the runtime of the sqrt functions from LLVM libc with the system libc:|function |perf - LLVM libc |perf - MSVCRT|
[libc] Add differential and performance targets for sqrtfComparing the runtime of the sqrt functions from LLVM libc with the system libc:|function |perf - LLVM libc |perf - MSVCRT|sqrtf - Windows|44.05 sec (44051715500 ns)| 417.84 sec (417843359900 ns) = 6.96 mins|function |perf - LLVM libc |perf - glibc|sqrtf - Linux |30.48 sec (30479458632 ns)|43.72 sec (43716901527 ns)By running the differential test:|function |diff|sqrtf - Windows|0 differing results|sqrtf - Linux |0 differing resultsReviewed By: sivachandraDifferential Revision: https://reviews.llvm.org/D107229
[libc] Add implementation of expm1f.Use expm1f(x) = exp(x) - 1 for |x| > ln(2).For |x| <= ln(2), divide it into 3 subintervals: [-ln2, -1/8], [-1/8, 1/8], [1/8, ln2]and use a degree-6 polynomial
[libc] Add implementation of expm1f.Use expm1f(x) = exp(x) - 1 for |x| > ln(2).For |x| <= ln(2), divide it into 3 subintervals: [-ln2, -1/8], [-1/8, 1/8], [1/8, ln2]and use a degree-6 polynomial approximation generated by Sollya's fpminmax for each interval.Errors < 1.5 ULPs when we use fma to evaluate the polynomials.Differential Revision: https://reviews.llvm.org/D101134
[libc] Add differential quality and perf analysis targets for sinf and cosf. Infrastructure needed for setting up the diff binaries has been added. Along the way, an exhaustive test for sinf and c
[libc] Add differential quality and perf analysis targets for sinf and cosf. Infrastructure needed for setting up the diff binaries has been added. Along the way, an exhaustive test for sinf and cosf have also been added.Reviewed By: lntueDifferential Revision: https://reviews.llvm.org/D101276