summaryrefslogtreecommitdiff
path: root/libc/test/src/math/explogxf_test.cpp
AgeCommit message (Collapse)Author
2025-08-14[libc][math] Refactor coshf implementation to header-only in ↵Muhammad Bassiouni
src/__support/math folder. (#153427) Part of #147386 in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-07-21[libc][math] fix explogxf test (#149891)Muhammad Bassiouni
2025-07-17[libc][math] Refactor exp10f implementation to header-only in ↵Muhammad Bassiouni
src/__support/math folder. (#148405) Part of #147386 in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2024-07-28[libc] Create a separate proxy header for math-function-macros.h (#98430)Nhat Nguyen
Fix #98393
2024-04-05[libc] Add proxy header math_macros.h. (#87598)lntue
Context: https://github.com/llvm/llvm-project/pull/87017 - Add proxy header `libc/hdr/math_macros.h` that will: - include `<math.h>` in overlay mode, - include `"include/llvm-libc-macros/math-macros.h"` in full build mode. - Its corresponding CMake target `libc.hdr.math_macros` will only depend on `libc.include.math` and `libc.include.llvm-libc-macros.math_macros` in full build mode. - Replace all `#include "include/llvm-libc-macros/math-macros.h"` with `#include "hdr/math_macros.h"`. - Add dependency to `libc.hdr.math_macros` CMake target when using `add_fp_unittest`. - Update the remaining dependency. - Update bazel overlay: add `libc:hdr_math_macros` target, and replacing all dependency on `libc:llvm_libc_macros_math_macros` with `libc:hdr_math_macros`.
2024-03-18[libc] Remove direct math.h includes (#85324)Michael Jones
Reland of #84991 A downstream overlay mode user ran into issues with the isnan macro not working in our sources with a specific libc configuration. This patch replaces the last direct includes of math.h with our internal math_macros.h, along with the necessary build system changes.
2023-10-19[libc][math][NFC] Remove global scope constants declaration in math tests ↵lntue
(#69558) Clean up usage of `DECLARE_SPECIAL_CONSTANTS` in global scope.
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-02-07[libc][NFC] Move UnitTest and IntegrationTest to the 'test' directory.Siva Chandra Reddy
This part of the effort to make all test related pieces into the `test` directory. This helps is excluding test related pieces in a straight forward manner if LLVM_INCLUDE_TESTS is OFF. Future patches will also move the MPFR wrapper and testutils into the 'test' directory.
2022-09-19[libc][math] Improve tanhf performance.Tue Ly
Optimize the core part of `tanhf` implementation that is to compute `e^x` similar to https://reviews.llvm.org/D133870. Factor the constants and polynomial approximation out so that it can be used for `exp10f` Performance benchmark using perf tool from the CORE-MATH project on Ryzen 1700: ``` $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanhf GNU libc version: 2.35 GNU libc release: stable CORE-MATH reciprocal throughput : 13.377 System LIBC reciprocal throughput : 55.046 BEFORE: LIBC reciprocal throughput : 75.674 LIBC reciprocal throughput : 33.242 (with `-msse4.2` flag) LIBC reciprocal throughput : 25.927 (with `-mfma` flag) AFTER: LIBC reciprocal throughput : 26.359 LIBC reciprocal throughput : 18.888 (with `-msse4.2` flag) LIBC reciprocal throughput : 14.243 (with `-mfma` flag) $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh tanhf --latency GNU libc version: 2.35 GNU libc release: stable CORE-MATH latency : 43.365 System LIBC latency : 123.499 BEFORE LIBC latency : 112.968 LIBC latency : 104.908 (with `-msse4.2` flag) LIBC latency : 92.310 (with `-mfma` flag) AFTER LIBC latency : 69.828 LIBC latency : 63.874 (with `-msse4.2` flag) LIBC latency : 57.427 (with `-mfma` flag) ``` Reviewed By: orex, zimmermann6 Differential Revision: https://reviews.llvm.org/D134002
2022-09-14[libc][math] Improve exp2f performance.Tue Ly
Reduce the number of subintervals that need lookup table and optimize the evaluation steps. Currently, `exp2f` is computed by reducing to `2^hi * 2^mid * 2^lo` where `-16/32 <= mid <= 15/32` and `-1/64 <= lo <= 1/64`, and `2^lo` is then approximated by a degree 6 polynomial. Experiment with Sollya showed that by using a degree 6 polynomial, we can approximate `2^lo` for a bigger range with reasonable errors: ``` > P = fpminimax((2^x - 1)/x, 5, [|D...|], [-1/64, 1/64]); > dirtyinfnorm(2^x - 1 - x*P, [-1/64, 1/64]); 0x1.e18a1bc09114def49eb851655e2e5c4dd08075ac2p-63 > P = fpminimax((2^x - 1)/x, 5, [|D...|], [-1/32, 1/32]); > dirtyinfnorm(2^x - 1 - x*P, [-1/32, 1/32]); 0x1.05627b6ed48ca417fe53e3495f7df4baf84a05e2ap-56 ``` So we can optimize the implementation a bit with: # Reduce the range to `mid = i/16` for `i = 0..15` and `-1/32 <= lo <= 1/32` # Store the table `2^mid` in bits, and add `hi` directly to its exponent field to compute `2^hi * 2^mid` # Rearrange the order of evaluating the polynomial approximating `2^lo`. Performance benchmark using perf tool from the CORE-MATH project on Ryzen 1700: ``` $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh exp2f GNU libc version: 2.35 GNU libc release: stable CORE-MATH reciprocal throughput : 9.534 System LIBC reciprocal throughput : 6.229 BEFORE: LIBC reciprocal throughput : 21.405 LIBC reciprocal throughput : 15.241 (with `-msse4.2` flag) LIBC reciprocal throughput : 11.111 (with `-mfma` flag) AFTER: LIBC reciprocal throughput : 18.617 LIBC reciprocal throughput : 12.852 (with `-msse4.2` flag) LIBC reciprocal throughput : 9.253 (with `-mfma` flag) $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh exp2f --latency GNU libc version: 2.35 GNU libc release: stable CORE-MATH latency : 40.869 System LIBC latency : 30.580 BEFORE LIBC latency : 64.888 LIBC latency : 61.027 (with `-msse4.2` flag) LIBC latency : 48.778 (with `-mfma` flag) AFTER LIBC latency : 48.803 LIBC latency : 45.047 (with `-msse4.2` flag) LIBC latency : 37.487 (with `-mfma` flag) ``` Reviewed By: sivachandra, orex Differential Revision: https://reviews.llvm.org/D133870
2022-08-30[libc][math] Fix broken tests.Kirill Okhotnikov
2022-08-30[libc][math] Added atanf function.Kirill Okhotnikov
Performance by core-math (core-math/glibc 2.31/current llvm-14): 28.879/20.843/20.15 Differential Revision: https://reviews.llvm.org/D132842
2022-08-30[libc][math] Added auxiliary function log2_eval for asinhf/acoshf/atanhf.Kirill Okhotnikov
1) `double log2_eval(double)` function added with better than float precision is added. 2) Some refactoring done to put all auxiliary functions and corresponding data to one place to reuse the code. 3) Added tests for new functions. 4) Performance and precision tests of the function shows, that it more precise than exiting log2, (no exceptional cases), but timing is ~5% higer that on current one. Differential Revision: https://reviews.llvm.org/D132809