80 Commits

Author SHA1 Message Date
Trevor Gross
fcf8670668 Change the multiprec_ prefix to mp_
Currently there is a combination of names starting with
`multiprecision_`, `mp_` and `multiprec_`. Update so `multiprecision_`
is always used when a long form makes sense, `mp_` otherwise
(eliminating `multiprec_`).
2024-11-03 20:42:10 -06:00
Trevor Gross
5032fcf139 Change default ULP to use enum matching
Migrate from string to enum matching and tie this to `CheckCtx::new`, so
no tests need to explicitly set ULP.
2024-11-02 23:22:09 -05:00
Trevor Gross
f113f2be1e Rename Name to Identifier to avoid some ambiguity of "name" 2024-11-02 22:42:05 -05:00
Trevor Gross
2fab4f4580 Change the CheckCtx constructor to take a Name enum
This prepares to eliminate some reliance on string matching but does not
yet make those changes.
2024-11-02 22:35:30 -05:00
Trevor Gross
f7f24a4ed8 Rework tests to make use of the new MathOp trait 2024-11-02 16:36:17 -05:00
Trevor Gross
7db74d78e8 Introduce a op module with struct representations of each routine
This contains:

1. Per-function and per-operation enums created by the proc macro
2. The `MathOp` trait which is implemented once per struct representing
   a function
3. Submodules for each function, each containing a `Routine` struct that
   implements `MathOp`
2024-11-02 16:36:17 -05:00
Trevor Gross
2411357947 Fix clippy lints in crates/ and enable this on CI 2024-11-02 10:33:23 -05:00
Trevor Gross
dbf8a4ebe5 Replace libm_test::{Float, Int} with libm::{Float, Int}
This involves moving some things from full generic implementations (e.g.
`impl<F: Float> SomeTrait for F { /* ... */ }` to generic functions and
macros to implement traits that call them, due to orphan rule violations
after `Float` became a not-in-crate trait.

`Hex` was moved to `test_traits` so we can eliminate `num_traits`.
2024-11-01 00:06:04 -05:00
Trevor Gross
4c1772ed85 Change prefixes used by the Float trait
Change `EXPONENT_` to `EXP_` and `SIGNIFICAND_` to `SIG_`. These are
pretty unambiguous, and just makes for less to type once these get used.
2024-11-01 00:06:04 -05:00
Trevor Gross
abff7cd82a Add benchmarks against musl libm
Add a benchmark for each function that checks against `musl_math_sys`.
2024-10-31 22:40:30 -05:00
Trevor Gross
5523607045 Rename canonical_name to base_name
"Canonical" isn't really the right word here, update to "base".
2024-10-30 14:01:39 -05:00
Trevor Gross
ad1c652293 Update libm-test/build.rs to skip directories
Don't try to generate tests for directories, or for files that contain
`f16` or `f128` (as these types are not provided by musl's math
implementations).

(cherry picked from commit fd7ad36b70d0bbc0f0b9bc7e54d10258423fda29)
2024-10-28 22:12:13 -05:00
Trevor Gross
395419d2d2 Rename the special_case module to precision and move default ULP
Having the default ULP in lib.rs doesn't make much sense when everything
else precision-related is in special_case.rs. Rename `special_case` to
`precision` and move the `*_allowed_ulp` functions there.
2024-10-28 21:55:49 -05:00
Trevor Gross
64131ec5cd Add a test against MPFR using random inputs 2024-10-28 21:29:29 -05:00
Trevor Gross
c09e58be46 Create interfaces for testing against MPFR
Add a way to call MPFR versions of functions in a predictable way, using
the `MpOp` trait.

Everything new here is guarded by the feature `test-multiprecision`
since MPFR cannot easily build on Windows or any cross compiled targets.
2024-10-28 20:56:11 -05:00
Trevor Gross
ebb2dc11d8 Reduce the number of iterations on emulated aarch64 Linux
CI for aarch64 Linux is significantly slower than the others. Adjust how
iteration selection is done to better handle this case, which also
simplifies things.

Also set the `EMULATED` environment variable in Docker to be more
accurate, and reindents run-docker.sh.
2024-10-28 14:04:19 -05:00
Trevor Gross
1073858c72 Add a test against musl libm
Check our functions against `musl-math-sys`. This is similar to the
existing musl tests that go through binary serialization, but works on
more platforms.
2024-10-28 12:59:38 -05:00
Trevor Gross
98647ddc2f Introduce a generic way to control checks for specific cases
Sometimes we want to be able to xfail specific inputs without changing
the checked ULP for all cases or skipping the tests. There are also some
cases where we need to perform extra checks for only specific functions.

Add a trait that provides a hook for providing extra checks or skipping
existing checks on a per-function or per-input basis.
2024-10-28 12:59:38 -05:00
Trevor Gross
593fa8f3cb Add a deterministic random generator
Create a test generator that creates a known number of random inputs and
caches them, such that the same inputs are used for all functions.
2024-10-28 12:59:38 -05:00
Trevor Gross
128e572054 Add a helper for cached test inputs
Add a type that caches values used to implement `GenerateInput` on a
variety of signatures.
2024-10-28 12:59:38 -05:00
Trevor Gross
d45f6f6fad Add traits for testing
These traits give us a more generic way to interface with tuples used
for (1) test input, (2) function arguments, and (3) test input.
2024-10-28 12:59:38 -05:00
Trevor Gross
8be6ef1e0a Add numeric traits
These traits are simplified versions of what we have in
`compiler_builtins` and will be used for tests.
2024-10-28 12:59:38 -05:00
Trevor Gross
05c9691f15 Add a test that for_each_fn correctly lists all functions
Create a new test that checks `for_each_fn` against `ALL_FUNCTIONS`,
i.e. the manually entered function list against the automatically
collected list. If any are missing (e.g. new symbol added), then this
will produce an error.
2024-10-28 12:59:38 -05:00
Trevor Gross
0acb3e2b50 Collect all function names to an array
Use a build script for `libm-test` to enumerate all symbols provided by
`libm` and provide this list in a variable. This will allow us to make
sure no functions are missed anytime they must be manually listed.

Additionally, introduce some helper config options.
2024-10-28 12:59:38 -05:00
Trevor Gross
ab0c8e84fb Run cargo fmt with new settings
Apply the changes from the `.rustfmt.toml` file added in the previous
commit.
2024-10-26 20:28:28 -05:00
Trevor Gross
a68516ed6a Rename the musl-bitwise-tests feature to test-musl-serialized
We will have more test features in the near future, and it would be nice
for them all to have a common `test-` prefix. Reverse the existing
feature so this is the case.
2024-10-25 20:57:19 -04:00
Trevor Gross
d8c234b959 Do library updates necessary with dependency upgrades 2024-10-05 22:28:38 -05:00
Trevor Gross
cb305df194 Upgrade all dependencies
None of these affect the distributed library.
2024-10-05 22:24:14 -05:00
Trevor Gross
c236051681 Rename the musl-reference-tests feature to musl-bitwise-tests
The plan is to add more test related features that could be considered
"reference tests". Rename the feature here to avoid future confusion.
2024-10-05 21:42:28 -05:00
Trevor Gross
f59dd82cca Move musl-reference-tests to a new libm-test crate
There isn't any reason for this feature to be exposed or part of the
build script. Move it to a separate crate.

We will also want more tests that require some support functions; this
will create a place for them.
2024-10-05 15:54:39 -05:00