summaryrefslogtreecommitdiff
path: root/libc/src/math/generic/sinhf.cpp
AgeCommit message (Collapse)Author
2025-03-11[libc][math] Skip checking for exceptional values when ↵lntue
LIBC_MATH_SKIP_ACCURATE_PASS is set. (#130811)
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek
This is a part of #97655.
2024-01-23[reland][libc] Remove unnecessary `FPBits` functions and properties (#79128)Guillaume Chatelet
- reland #79113 - Fix aarch64 RISC-V build
2024-01-23Revert "[libc] Remove unnecessary `FPBits` functions and properties" (#79118)Guillaume Chatelet
Reverts llvm/llvm-project#79113 It broke aarch64 build bot machines.
2024-01-23[libc] Remove unnecessary `FPBits` functions and properties (#79113)Guillaume Chatelet
This patch reduces the surface of `FPBits`.
2024-01-18[libc][NFC] Introduce a Sign type for FPBits (#78500)Guillaume Chatelet
Another patch is needed to cover `DyadicFloat` and `NormalFloat` constructors.
2023-12-19[libc][NFC] Make `EXP_MANT_MASK` an implementation detail (#75810)Guillaume Chatelet
This mask is an implementation detail of `FPBits` and shouldn't really leak outside of it.
2023-12-19[libc][NFC] Use FPBits builders instead of custom constructs (#75942)Guillaume Chatelet
2023-12-13[reland][libc][NFC] Implement `FPBits` in terms of `FloatProperties` to ↵Guillaume Chatelet
reduce clutter (#75196) (#75318) Also make type naming consistent by using `UIntType` instead of `intU_t`. This patch is a reland of #75196 but does not include the "use `FPBits` instead of `FPBits_t`, `FPB`" part. This needs more work.
2023-12-13Revert "[libc][NFC] Implement `FPBits` in terms of `FloatProperties` to ↵Guillaume Chatelet
reduce clutter" (#75304) Reverts llvm/llvm-project#75196 GCC complains about change of meaning for `FPBits` ``` /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/FPUtil/generic/FMod.h:188:9: error: declaration of ‘using FPBits = struct __llvm_libc_18_0_0_git::fputil::FPBits<T>’ changes meaning of ‘FPBits’ [-fpermissive] 188 | using FPBits = FPBits<T>; | ^~~~~~ ``` I'll reland with a different name.
2023-12-13[libc][NFC] Implement `FPBits` in terms of `FloatProperties` to reduce ↵Guillaume Chatelet
clutter (#75196) Also make type naming consistent: - `UIntType` instead of `intU_t` - `FPBits` instead of `FPBits_t`, `FPB`
2023-11-06[libc][math] Add min/max/min_denorm/max_denorm constants to FPBits and clean ↵lntue
up its constants return types. (#71298)
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-06-20[libc][math] Slightly improve sinhf and coshf performance.Tue Ly
Re-order exceptional branches and slightly adjust the evaluation. Depends on https://reviews.llvm.org/D153026 . Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D153062
2023-06-12[libc] Add platform independent floating point rounding mode checks.Tue Ly
Many math functions need to check for floating point rounding modes to return correct values. Currently most of them use the internal implementation of `fegetround`, which is platform-dependent and blocking math functions to be enabled on platforms with unimplemented `fegetround`. In this change, we add platform independent rounding mode checks and switching math functions to use them instead. https://github.com/llvm/llvm-project/issues/63016 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D152280
2023-03-23[libc] Fix some math conversion warningsAlex Brachet
Differential Revision: https://reviews.llvm.org/D146738
2023-02-24[libc][math] Set floating point exceptions for exp*f, sinhf, and coshf.Tue Ly
Set FE_OVERFLOW and FE_UNDERFLOW for expf, exp2f, exp10f, expm1f, sinhf and coshf. Reviewed By: sivachandra, renyichen Differential Revision: https://reviews.llvm.org/D144340
2023-02-10[libc] Move likely/unlikely to the optimization headerGuillaume Chatelet
2023-02-07[libc][NFC] Move attributes from common to macros folderGuillaume Chatelet
2022-09-15[libc][math] Improve sinhf and coshf performance.Tue Ly
Optimize `sinhf` and `coshf` by computing exp(x) and exp(-x) simultaneously. Currently `sinhf` and `coshf` are implemented using the following formulas: ``` sinh(x) = 0.5 *(exp(x) - 1) - 0.5*(exp(-x) - 1) cosh(x) = 0.5*exp(x) + 0.5*exp(-x) ``` where `exp(x)` and `exp(-x)` are calculated separately using the formula: ``` exp(x) ~ 2^hi * 2^mid * exp(dx) ~ 2^hi * 2^mid * P(dx) ``` By expanding the polynomial `P(dx)` into even and odd parts ``` P(dx) = P_even(dx) + dx * P_odd(dx) ``` we can see that the computations of `exp(x)` and `exp(-x)` have many things in common, namely: ``` exp(x) ~ 2^(hi + mid) * (P_even(dx) + dx * P_odd(dx)) exp(-x) ~ 2^(-(hi + mid)) * (P_even(dx) - dx * P_odd(dx)) ``` Expanding `sinh(x)` and `cosh(x)` with respect to the above formulas, we can compute these two functions as follow in order to maximize the sharing parts: ``` sinh(x) = (e^x - e^(-x)) / 2 ~ 0.5 * (P_even * (2^(hi + mid) - 2^(-(hi + mid))) + dx * P_odd * (2^(hi + mid) + 2^(-(hi + mid)))) cosh(x) = (e^x + e^(-x)) / 2 ~ 0.5 * (P_even * (2^(hi + mid) + 2^(-(hi + mid))) + dx * P_odd * (2^(hi + mid) - 2^(-(hi + mid)))) ``` So in this patch, we perform the following optimizations for `sinhf` and `coshf`: # Use the above formulas to maximize sharing intermediate results, # Apply similar optimizations from https://reviews.llvm.org/D133870 Performance benchmark using `perf` tool from the CORE-MATH project on Ryzen 1700: For `sinhf`: ``` $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinhf GNU libc version: 2.35 GNU libc release: stable CORE-MATH reciprocal throughput : 16.718 System LIBC reciprocal throughput : 63.151 BEFORE: LIBC reciprocal throughput : 90.116 LIBC reciprocal throughput : 28.554 (with `-msse4.2` flag) LIBC reciprocal throughput : 22.577 (with `-mfma` flag) AFTER: LIBC reciprocal throughput : 36.482 LIBC reciprocal throughput : 16.955 (with `-msse4.2` flag) LIBC reciprocal throughput : 13.943 (with `-mfma` flag) $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinhf --latency GNU libc version: 2.35 GNU libc release: stable CORE-MATH latency : 48.821 System LIBC latency : 137.019 BEFORE LIBC latency : 97.122 LIBC latency : 84.214 (with `-msse4.2` flag) LIBC latency : 71.611 (with `-mfma` flag) AFTER LIBC latency : 54.555 LIBC latency : 50.865 (with `-msse4.2` flag) LIBC latency : 48.700 (with `-mfma` flag) ``` For `coshf`: ``` $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh coshf GNU libc version: 2.35 GNU libc release: stable CORE-MATH reciprocal throughput : 16.939 System LIBC reciprocal throughput : 19.695 BEFORE: LIBC reciprocal throughput : 52.845 LIBC reciprocal throughput : 29.174 (with `-msse4.2` flag) LIBC reciprocal throughput : 22.553 (with `-mfma` flag) AFTER: LIBC reciprocal throughput : 37.169 LIBC reciprocal throughput : 17.805 (with `-msse4.2` flag) LIBC reciprocal throughput : 14.691 (with `-mfma` flag) $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh coshf --latency GNU libc version: 2.35 GNU libc release: stable CORE-MATH latency : 48.478 System LIBC latency : 48.044 BEFORE LIBC latency : 99.123 LIBC latency : 85.595 (with `-msse4.2` flag) LIBC latency : 72.776 (with `-mfma` flag) AFTER LIBC latency : 57.760 LIBC latency : 53.967 (with `-msse4.2` flag) LIBC latency : 50.987 (with `-mfma` flag) ``` Reviewed By: orex, zimmermann6 Differential Revision: https://reviews.llvm.org/D133913
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
2022-07-29[libc][math] Added sinhf function.Kirill Okhotnikov
Differential Revision: https://reviews.llvm.org/D129278