summaryrefslogtreecommitdiff
path: root/libc/test/src/math/cosf_test.cpp
AgeCommit message (Collapse)Author
2025-10-21[libc][math] Add tolerance to math tests so that they still work when ↵lntue
accurate path is skipped. (#164522)
2025-09-10[libc] Clean up errno header usage in math tests. (#157898)Alexey Samsonov
This is one more follow-up to PR https://github.com/llvm/llvm-project/pull/157517 that cleans up the usage of libc_errno in math unit-tests (non-smoke). It follows the same rule: * if you use libc_errno in code literally, include src/__support/libc_errno.h * if you only rely on errno constants, include hdr/errno_macros.h Several tests for exp/log still retain the direct libc_errno usage, since in some cases they skip doing any validation if the error was raised. But the direct usage of libc_errno is removed from all other cases.
2025-07-23[libc][NFC] Add stdint.h proxy header to fix dependency issue with ↵lntue
<stdint.h> includes. (#150303) https://github.com/llvm/llvm-project/issues/149993
2025-06-11[libc] Move libc_errno.h to libc/src/__support and make ↵lntue
LIBC_ERRNO_MODE_SYSTEM to be header-only. (#143187) This is the first step 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-10-05[libc] remove errno.h includes (#110934)Job Henandez Lara
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.
2024-02-06[libc] Move libc_errno inside of LIBC_NAMESPACE (#80774)michaelrj-google
Having libc_errno outside of the namespace causes versioning issues when trying to link the tests against LLVM-libc. Most of this patch is just moving libc_errno inside the namespace in tests. This isn't necessary in the function implementations since those are already inside the namespace.
2024-01-23[libc][NFC] Remove `FPBits` cast operator (#79142)Guillaume Chatelet
The semantics for casting can range from "bitcast" (same representation) to "different representation", to "type promotion". Here we remove the cast operator and force usage of `get_val` as the only function to get the floating point value, making the intent clearer and more consistent.
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-06-01[libc] Reduce math tests runtimeGuillaume Chatelet
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D151798
2023-03-07[libc][math] Switch math functions to use libc_errno and fix some errno and ↵Tue Ly
floating point exceptions. Switch math functions to use libc_errno and fix some errno and floating point exceptions Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D145349
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-08-01Reland [libc][NFC] Use STL case for arrayGuillaume Chatelet
This is a reland of https://reviews.llvm.org/D130773
2022-08-01Revert "[libc][NFC] Use STL case for array"Guillaume Chatelet
This reverts commit 7add0e5fdc5c7cb6f59f60cd436bf161cf9f9eb7.
2022-08-01[libc][NFC] Use STL case for arrayGuillaume Chatelet
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion. Differential Revision: https://reviews.llvm.org/D130773
2022-07-29[libc] Implement cosf function that is correctly rounded to all rounding modes.Tue Ly
Implement cosf function that is correctly rounded to all rounding modes. 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 cosf CORE-MATH reciprocal throughput : 19.043 System LIBC reciprocal throughput : 26.328 LIBC reciprocal throughput : 30.955 $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh cosf --latency GNU libc version: 2.31 GNU libc release: stable CORE-MATH latency : 49.995 System LIBC latency : 59.286 LIBC latency : 60.174 ``` After this patch (correctly rounded): ``` $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh cosf GNU libc version: 2.31 GNU libc release: stable CORE-MATH reciprocal throughput : 19.072 System LIBC reciprocal throughput : 26.286 LIBC reciprocal throughput : 13.631 $ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh cosf --latency GNU libc version: 2.31 GNU libc release: stable CORE-MATH latency : 49.872 System LIBC latency : 59.468 LIBC latency : 56.119 ``` Reviewed By: orex, zimmermann6 Differential Revision: https://reviews.llvm.org/D130644
2022-03-08[libc] Add testing macros for errno and floating point exceptions.Tue Ly
Add testing macros for errno and floating point exceptions. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D121235
2021-12-22[libc] apply formatting to testsMichael Jones
Apply the formatting rules that were applied to the libc/src directory to the libc/test directory, as well as the files in libc/utils that are included by the tests. This does not include automated enforcement. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D116127
2021-12-07[libc] apply new lint rulesMichael Jones
This patch applies the lint rules described in the previous patch. There was also a significant amount of effort put into manually fixing things, since all of the templated functions, or structs defined in /spec, were not updated and had to be handled manually. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D114302
2021-10-29[libc][NFC] Move test related pieces from FPUtil to util/UnitTest.Siva Chandra Reddy
Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D112673
2021-10-28[libc][NFC] Move utils/CPP to src/__support/CPP.Siva Chandra Reddy
The idea is to move all pieces related to the actual libc sources to the "src" directory. This allows downstream users to ship and build just the "src" directory. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D112653
2021-08-06[libc][nfc] move ctype_utils and FPUtils to __supportMichael Jones
Some ctype functions are called from other libc functions (e.g. isspace is used in atoi). By moving ctype_utils.h to __support it becomes easier to include just the implementations of these functions. For these reasons the implementation for isspace was moved into ctype_utils as well. FPUtils was moved to simplify the build order, and to clarify which files are a part of the actual libc. Many files were modified to accomodate these changes, mostly changing the #include paths. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D107600
2021-06-30[libc][NFC] Remove few deprecated FPUtil header files and test patterns.Siva Chandra Reddy
Few tests have been converted to the new test patterns to facilitate this.
2021-03-03[libc] Remove redundant header files included from internal paths.Siva Chandra Reddy
2021-01-20[libc][NFC] add "LlvmLibc" as a prefix to all test namesMichael Jones
Summary: Having a consistent prefix makes selecting all of the llvm libc tests easier on any platform that is also using the gtest framework. This also modifies the TEST and TEST_F macros to enforce this change moving forward. Reviewers: sivachandra Subscribers:
2020-11-21[libc] Switch functions to using global headersMichael Jones
This switches all of the files in src/string, src/math, and test/src/math from using relative paths (e.g. `#include “include/string.h”`) to global paths (e.g. `#include <string.h>`) to make bringing up those functions on other platforms, such as fuchsia, easier. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D91394
2020-08-20[libc][NFC] Switch math tests to the new ULP based tolerance.Siva Chandra Reddy
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D86267
2020-06-15[lib][NFC] Split the floating point util functions into multiple files.Siva Chandra Reddy
The grouping now reflects the grouping on cppreference.com.
2020-06-09[libc][NFC] Adjust sinf and cosf around -infinity inputs.Siva Chandra Reddy
The current tests verify if the result of -infinity is a quiet NaN with sign bit set. But, that need not be the case on all platforms. So, just checking that the result is a quiet NaN and ignoring the sign bit is good enough.
2020-05-26[libc][NFC][Obvious] Convert the MPFR operations enum to an enum class.Siva Chandra Reddy
This was suggested in https://reviews.llvm.org/D79149.
2020-05-15[libc] Consolidate floating point utils into a single utils library.Siva Chandra Reddy
A new utils library named 'fputil' is added. This library is used in math tests and the MPFR wrapper. The math implementations will be modified to use this library in a later round. Reviewers: phosek Differential Revision: https://reviews.llvm.org/D79724
2020-05-05[libc] Improve information printed on failure of a math test which uses MPFR.Siva Chandra Reddy
A new test matcher class MPFRMatcher is added along with helper macros EXPECT|ASSERT_MPFR_MATCH. New type traits classes RemoveCV and IsFloatingPointType have been added and used to implement the above class and its helpers. Reviewers: abrachet, phosek Differential Revision: https://reviews.llvm.org/D79256
2020-04-16[libc] Move implementations of cosf, sinf, sincosf to src/math directory.Siva Chandra Reddy
NFC intended in the implementaton. Only mechanical changes to fit the LLVM libc implementation standard have been done. Math testing infrastructure has been added. This infrastructure compares the results produced by the libc with the high precision results from MPFR. Tests making use of this infrastructure have been added for cosf, sinf and sincosf. Reviewers: abrachet, phosek Differential Revision: https://reviews.llvm.org/D76825