Skip to content

Experimentation with libm #768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 797 commits into from
Closed
Changes from all commits
Commits
Show all changes
797 commits
Select commit Hold shift + click to select a range
b5a1aaf
Allow Clippy lints in `compiler-builtins-smoke-test`
tgross35 Dec 27, 2024
8552890
Merge pull request #371 from tgross35/clippy-fixes
tgross35 Dec 27, 2024
3c7a832
Change from `-latest` to named CI images
tgross35 Dec 29, 2024
c447e5f
Introduce generic `abs` and `copysign`
tgross35 Oct 26, 2024
400e196
Add `f16` and `f128` configuration from `compiler-builtins`
tgross35 Oct 26, 2024
e80dad0
Always enable `unstable-float` in CI
tgross35 Dec 29, 2024
b1b30ca
Update and slightly refactor some of the `Float` trait
tgross35 Dec 19, 2024
f081772
Remove an `is_nan` workaround that is no longer needed
beetrees Dec 19, 2024
69cf64f
Add an 8-bit float type for testing purposes
tgross35 Dec 19, 2024
842b08b
Introduce a float extension trait and some numerical routines
tgross35 Dec 19, 2024
a114878
Add interfaces and tests based on function domains
tgross35 Dec 19, 2024
e193569
Add tests for edge cases
tgross35 Dec 19, 2024
5b26d79
Update allowed precision to account for new tests
tgross35 Dec 19, 2024
f4d97cd
Add a way to plot the output from generators
tgross35 Dec 19, 2024
83835d0
Merge pull request #348 from tgross35/function-domains
tgross35 Dec 29, 2024
971bafa
Move the macro's input function list to a new module `shared`
tgross35 Dec 22, 2024
dc15fdd
Include `shared.rs` in `libm_test::op`
tgross35 Dec 22, 2024
6e101af
Add new trait implementations for `Identifier` and `BaseName`
tgross35 Dec 29, 2024
a210d4a
Add `ALL`, `from_str` and `math_op` to `Identifier`
tgross35 Dec 22, 2024
5c5df51
Merge pull request #377 from tgross35/shared-function-list
tgross35 Dec 29, 2024
1d1d7de
Move `CheckBasis` and `CheckCtx` to a new `run_cfg` module
tgross35 Dec 26, 2024
c0d9cc3
Use `CheckCtx` in more places
tgross35 Dec 26, 2024
a6fe05b
Merge pull request #378 from tgross35/run-cfg
tgross35 Dec 29, 2024
c0e0827
Don't run `push` CI on anything other than `master`
tgross35 Dec 29, 2024
186f864
Set the allowed FMA ULP to 0
tgross35 Dec 30, 2024
766e21c
Remove lossy casting in `logspace`
tgross35 Dec 30, 2024
3785902
Forward the `CI` environment variable when running in Docker
tgross35 Dec 22, 2024
0840d59
Use `rustdoc` output to create a list of public API
tgross35 Dec 31, 2024
780519d
Add missing functions to the macro list
tgross35 Dec 31, 2024
f5d5cf8
Merge pull request #384 from tgross35/api-list
tgross35 Jan 1, 2025
0cb855b
macros: Always emit `f16_enabled` and `f128_enabled` attributes
tgross35 Jan 2, 2025
110c6f7
Rename generic `abs` to `fabs`
tgross35 Jan 2, 2025
6f6bd11
Use intrinsics for `abs` and `copysign` when available
tgross35 Jan 3, 2025
1b89400
Change to exhaustive matching for `default_ulp`
tgross35 Jan 3, 2025
2d909e1
precision: Sort `ilogb` with other precise operations
tgross35 Jan 4, 2025
aa3d242
Clean up integers stored in `MpTy`
tgross35 Jan 5, 2025
cc29de2
Add tests against MPFR for `modf` and `modff`
tgross35 Jan 4, 2025
9b15f00
Add tests against MPFR for `frexp` and `frexpf`
tgross35 Jan 4, 2025
8d6f6a1
Add tests against MPFR for `scalbn{f}` and `ldexp{f}`
tgross35 Jan 3, 2025
188e871
Add a way for tests to log to a file
tgross35 Dec 29, 2024
0d486fe
Streamline the way that test iteration count is determined
tgross35 Dec 26, 2024
ae8bf8c
Add an iterator that ensures known size
tgross35 Dec 30, 2024
addbb18
Rewrite the random test generator
tgross35 Dec 29, 2024
ac3ff8c
Update precision based on new test results
tgross35 Jan 6, 2025
b67e65b
Merge pull request #379 from rust-lang/tgross35/ntests
tgross35 Jan 6, 2025
e690971
Rename `unstable-test-support` to `unstable-public-internals`
tgross35 Jan 6, 2025
ff15e46
Increase the precision for `jn` and `jnf`
tgross35 Jan 6, 2025
ba4bc97
Add tests against MPFR for `ilogb` and `ilogbf`
tgross35 Jan 5, 2025
9080785
Add more detailed definition output for `update-api-list.py`
tgross35 Jan 2, 2025
6362d4e
Add extensive and exhaustive tests
tgross35 Dec 22, 2024
f2397e5
Update precision based on failures from extensive tests
tgross35 Dec 22, 2024
9b08ee5
Run extensive tests in CI when relevant files change
tgross35 Jan 2, 2025
067e97c
Merge pull request #388 from rust-lang/tgross35/extensive
tgross35 Jan 6, 2025
46aeb60
Enable `f16` and `f128` when creating the API change list
tgross35 Jan 2, 2025
887ec87
Add `fabsf16`, `fabsf128`, `copysignf16`, and `copysignf128`
tgross35 Jan 2, 2025
336a6b6
Add test infrastructure for `f16` and `f128`
tgross35 Jan 3, 2025
bc6b854
Merge pull request #389 from rust-lang/tgross35/f16-f128-copysign-fabs
tgross35 Jan 6, 2025
9b68478
Add domain and edge case tests to musl
tgross35 Dec 28, 2024
5e0c840
Add an override for failing ceil/floor tests on i586
tgross35 Jan 6, 2025
0164e93
Loosen precision on i586 based on new tests
tgross35 Jan 6, 2025
7419a5e
Merge pull request #406 from tgross35/musl-domain-tests
tgross35 Jan 6, 2025
45862e9
ci: Only update the github ref for pull requests
tgross35 Jan 6, 2025
ce0560c
Enable MPFR tests on i586
tgross35 Jan 6, 2025
6328b10
Increase the allowed precision for failing tests on i586
tgross35 Jan 6, 2025
9d043c5
Merge pull request #404 from tgross35/i586-mpfr
tgross35 Jan 6, 2025
d4ea030
Switch from using `unstable-intrinsics` to `intrinsics_enabled`
tgross35 Jan 6, 2025
32f96f1
Remove an unused `feature = "force-soft-floats"` gate
tgross35 Jan 6, 2025
424c3ec
Don't use intrinsics abs for `f16` and `f128` on wasm32
tgross35 Jan 6, 2025
44770b9
Replace "intrinsic" config with "arch" config
tgross35 Jan 7, 2025
5712ab1
Increase the allowed ULP for `tgammaf`
tgross35 Jan 7, 2025
43d21a5
Make extensive tests exhaustive if there are enough iterations available
beetrees Jan 7, 2025
8e82616
Account for optimization levels other than numbers
tgross35 Jan 7, 2025
0f6b1bb
Add tests against MPFR for `remquo` and `remquof`
tgross35 Jan 5, 2025
edc5958
Use `core::arch::wasm` functions rather than intrinsics
tgross35 Jan 11, 2025
5dea7fc
Split `cast` into `cast` and `cast_lossy`
tgross35 Jan 11, 2025
5fb644f
Reorder tests in `run.sh`
tgross35 Jan 11, 2025
8940fbf
Remove `ExpInt` from `Float`, always use `i32` instead
tgross35 Jan 11, 2025
d5ebe5d
Add a `release-checked` profile with debug and overflow assertions
tgross35 Jan 11, 2025
430fe28
Add `biteq` and `exp_unbiased` to `Float`
tgross35 Jan 12, 2025
233700c
Always use the same seed for benchmarking
tgross35 Jan 12, 2025
5eda282
Expose C versions of `libm` functions in the `cb` crate
tgross35 Jan 12, 2025
d56c3aa
Add a new precision adjustment for i586 `rint`
tgross35 Jan 12, 2025
6712204
Add a new precision adjustment for i586 `exp2f`
tgross35 Jan 12, 2025
def4a0e
Use wasm32 arch intrinsics for rint{,f}
hanna-kruppe Jan 12, 2025
4543883
Introduce arch::aarch64 and use it for rint{,f}
hanna-kruppe Jan 12, 2025
67537a9
Merge pull request #430 from hanna-kruppe/rint-arch
tgross35 Jan 12, 2025
f711c0e
Rename the `test-multiprecision` feature to `build-mpfr`
tgross35 Jan 13, 2025
357e9aa
Enable `build-mpfr` and `build-musl` by default
tgross35 Jan 13, 2025
35040f6
Merge pull request #432 from tgross35/test-features
tgross35 Jan 13, 2025
222d3cd
Add a utility crate for quick evaluation
tgross35 Jan 13, 2025
ef493a8
Add a generic version of `trunc`
tgross35 Jan 11, 2025
aa3f28b
Add `truncf16` and `truncf128`
tgross35 Jan 12, 2025
01384e8
Merge pull request #427 from tgross35/generic-trunc
tgross35 Jan 13, 2025
0072e74
Disable `util` and `libm-macros` for optimized tests
tgross35 Jan 13, 2025
02e78f8
Format the MPFR manual implementation list
tgross35 Jan 13, 2025
b97ef0b
Add a generic version of `fdim`
tgross35 Jan 13, 2025
31f0e1f
Add `fdimf16` and `fdimf128`
tgross35 Jan 13, 2025
b8005ac
Merge pull request #438 from tgross35/generic-fdim
tgross35 Jan 13, 2025
c95ec4c
Don't set `codegen-units=1` by default in CI
tgross35 Jan 13, 2025
c994863
Reduce indentation in `run.sh` using early return
tgross35 Jan 13, 2025
ebbd4c1
Merge pull request #440 from tgross35/not-always-1-cgu
tgross35 Jan 14, 2025
2b8045a
Simplify and optimize `fdim` (#442)
quaternic Jan 14, 2025
abf0a28
Use cargo-nextest for running tests in CI
tgross35 Jan 13, 2025
88176ee
Change `.yml` files to the canonical extension `.yaml`
tgross35 Jan 14, 2025
c63ab7b
Slightly restructure `ci/calculate-exhaustive-matrix.py`
tgross35 Jan 14, 2025
f6434c8
Pass --max-fail to nextest so it doesn't fail fast
tgross35 Jan 15, 2025
9965e93
Add an override for a recent failure
tgross35 Jan 15, 2025
d0eb897
Merge pull request #445 from tgross35/ci-flexible-script
tgross35 Jan 15, 2025
e3daee5
Replace `HasDomain` to enable multi-argument edge case and domain tests
tgross35 Jan 7, 2025
154f7a5
Adjust precision and add xfails based on new tests
tgross35 Jan 13, 2025
2fab7e0
Increase the CI timeout
tgross35 Jan 13, 2025
8ded576
Merge pull request #415 from tgross35/domain-multiple-dimensions
tgross35 Jan 16, 2025
342600b
Provide a way to override iteration count
tgross35 Jan 16, 2025
697ce77
Add benchmarks using iai-callgrind
tgross35 Jan 16, 2025
6e6ab78
Run iai-callgrind benchmarks in CI
tgross35 Jan 16, 2025
31b4115
Reduce the warm up and measurement time for `short-benchmarks`
tgross35 Jan 16, 2025
8fc8d41
Add an xfail for recent ynf failures
tgross35 Jan 16, 2025
a298d92
Merge pull request #447 from tgross35/icount-benchmarks
tgross35 Jan 16, 2025
04443d5
Remove the limit for querying a baseline
tgross35 Jan 16, 2025
a7c6178
Switch to the arm-linux runner and enable MPFR
tgross35 Jan 16, 2025
4d5fc87
Run icount benchmarks once with softfloat and once with hardfloat
tgross35 Jan 21, 2025
a7bc185
Run wall time benchmarks with `--features force-soft-floats`
tgross35 Jan 21, 2025
6d60428
Add a way to ignore benchmark regression checks
tgross35 Jan 21, 2025
32dcbd9
Ignore files relevant to benchmarking
tgross35 Jan 21, 2025
fa0a565
Merge pull request #450 from tgross35/benchmark-soft-float
tgross35 Jan 21, 2025
339511f
Remove trailing whitespace in scripts, run JuliaFormatter
tgross35 Jan 22, 2025
e4cfb0d
Add a retry to the musl download
tgross35 Jan 22, 2025
de51755
Don't set `opt_level` in the musl build script
tgross35 Jan 15, 2025
855e15a
Enable `force-soft-floats` for extensive tests
tgross35 Jan 22, 2025
3cc2c03
Port the most recent version of Musl's `sqrt` as a generic algorithm
tgross35 Jan 12, 2025
2a29b7a
Copy the u256 implementation from compiler_builtins
tgross35 Jan 15, 2025
839c72a
Add `sqrtf16` and `sqrtf128`
tgross35 Jan 21, 2025
54b6e57
Merge pull request #431 from tgross35/generic-sqrt
tgross35 Jan 22, 2025
0ce5308
Shift then mask, rather than mask then shift
tgross35 Jan 13, 2025
b5cdbd4
Make `Float::exp` return an unsigned integer
tgross35 Jan 22, 2025
11ff0e1
Add a generic version of `ceil`
tgross35 Jan 13, 2025
a836f6e
Add `ceilf16` and `ceilf128`
tgross35 Jan 13, 2025
812e15a
Merge pull request #436 from tgross35/generic-ceil
tgross35 Jan 22, 2025
42647c6
Add a generic version of `floor`
tgross35 Jan 13, 2025
23d616b
Add `floorf16` and `floorf128`
tgross35 Jan 13, 2025
31f0802
Adjust `ceil` style to be more similar to `floor`
tgross35 Jan 22, 2025
5e9ded4
Merge pull request #437 from tgross35/generic-floor
tgross35 Jan 22, 2025
a9cfff9
Add a generic version of `rint`
tgross35 Jan 22, 2025
d2da7f7
Add `rintf16` and `rintf128`
tgross35 Jan 22, 2025
753d69f
Merge pull request #454 from tgross35/generic-rint
tgross35 Jan 22, 2025
29697dc
Add the ability to parse hex, binary, and float hex with util
tgross35 Jan 22, 2025
bc6a615
Fix the parsing of three-item tuples in `util`
tgross35 Jan 22, 2025
eb29467
Add `hf16!` and `hf128!`
tgross35 Jan 22, 2025
122ba48
Introduce XFAILs that assert failure
tgross35 Jan 23, 2025
459dd80
Change `from_parts` to take a `u32` exponent rather than `i32`
tgross35 Jan 23, 2025
220c8e5
Add a generic version of `scalbn`
tgross35 Jan 23, 2025
9c68f74
Add a generic version of `round`
tgross35 Jan 24, 2025
e2ac6ef
Add `roundf16` and `roundf128`
tgross35 Jan 24, 2025
581db99
Remove an outdated note about precision
tgross35 Jan 24, 2025
933d9b0
Merge pull request #465 from tgross35/generic-round
tgross35 Jan 24, 2025
97d8bfa
Add a generic version of `fmin` and `fmax`
tgross35 Jan 24, 2025
f65487b
Add `fminf16`, `fmaxf16`, `fminf128`, and `fmaxf128`
tgross35 Jan 24, 2025
42a8dfb
Merge pull request #466 from tgross35/generic-fmin-fmax
tgross35 Jan 24, 2025
566e8e1
Add a generic version of `fmod`
tgross35 Jan 24, 2025
856e314
Add `fmodf16` using the generic implementation
tgross35 Jan 24, 2025
dae4f1a
Merge pull request #469 from tgross35/generic-mod
tgross35 Jan 24, 2025
bae270f
Increase or set CI timeouts
tgross35 Jan 24, 2025
a9d3ba4
Add way to override the number of iterations for specific tests
tgross35 Jan 24, 2025
68b9036
Add `fmodf128`
tgross35 Jan 24, 2025
614c00d
Merge pull request #470 from tgross35/f128-fmod
tgross35 Jan 24, 2025
b67b4cc
Enable missing icount benchmarks
tgross35 Jan 24, 2025
5bcd31f
Upgrade all dependencies to the latest version
tgross35 Jan 25, 2025
bd2ea1c
Use `az` exported from Rug
tgross35 Jan 25, 2025
a6ba249
Use `frexp` from Rug
tgross35 Jan 25, 2025
857ba9c
Use `remquo` from Rug
tgross35 Jan 25, 2025
46a3bce
Merge pull request #477 from tgross35/upgrade-dependencies
tgross35 Jan 25, 2025
a2074e5
Remove remnants of the `checked` feature
tgross35 Jan 25, 2025
b1e7ea0
Rework the available Cargo profiles
tgross35 Jan 25, 2025
f5f789a
Ignore specific `atan2` and `sin` tests on i586
tgross35 Jan 27, 2025
8660ace
Merge pull request #479 from tgross35/cargo-profile-updates
tgross35 Jan 28, 2025
0c7362c
Switch musl from a script download to a submodule
tgross35 Jan 27, 2025
e901b3e
Temporarily pin `indicatif` to 0.17.9
tgross35 Jan 28, 2025
a89add3
Revert "Temporarily pin `indicatif` to 0.17.9"
tgross35 Jan 28, 2025
2f770cd
Support parsing NaN and infinities from the `hf*` functions
tgross35 Jan 28, 2025
6d95937
Introduce a wrapper type for IEEE hex float formatting
tgross35 Jan 28, 2025
151cd29
Util: also print the hex float format for outputs
tgross35 Jan 28, 2025
f258331
Merge pull request #483 from tgross35/hex-print
tgross35 Jan 30, 2025
45870ef
Specify license as just MIT
Manishearth Jan 30, 2025
f66e0f1
Rename `EXP_MAX` to `EXP_SAT`
tgross35 Jan 31, 2025
ac0714b
Fix hex float trait recursion problem
tgross35 Jan 30, 2025
9c93e01
Add `scalbnf16`, `scalbnf128`, `ldexpf16`, and `ldexpf128`
tgross35 Jan 3, 2025
3109ebe
Merge pull request #391 from rust-lang/tgross35/f16-f128-scalbn
tgross35 Feb 5, 2025
c3b13e5
Add a check in the `shared.rs` that the function list is sorted
tgross35 Feb 5, 2025
a728288
Do not add `libm_helper.rs` to the sources list
tgross35 Feb 5, 2025
ad83c9a
Add checks via annotation that lists are sorted or exhaustive
tgross35 Feb 5, 2025
0492f2e
Merge pull request #489 from tgross35/sort-everything
tgross35 Feb 5, 2025
d655126
Start converting `fma` to a generic function
tgross35 Jan 23, 2025
fd7592e
Commonize the signature for all instances of `get_test_cases`
tgross35 Feb 5, 2025
9612576
Print the hex float format upon failure
tgross35 Feb 6, 2025
b2a1e35
fma: Ensure zero has the correct sign
tgross35 Feb 6, 2025
4155869
Switch `musl` to track `master`
tgross35 Feb 6, 2025
ffe7f0d
Merge pull request #493 from tgross35/fma-sign
tgross35 Feb 6, 2025
3f4d1e0
Add an integration test that verifies a list of cases
tgross35 Feb 6, 2025
3e49c09
Improve tidy output
tgross35 Feb 6, 2025
c8aec8f
Make it possible to use `hf32!` and similar macros outside of `libm`
tgross35 Feb 6, 2025
c967c7e
Add `fmaf128`
tgross35 Feb 5, 2025
724e47d
Add better edge case testing for `scalbn`
tgross35 Feb 7, 2025
34cd8f6
Run standard tests before running integration tests
tgross35 Feb 7, 2025
0fbdb7b
Check more subnormal values during edge cases tests
tgross35 Feb 7, 2025
4e86806
fmaf128: fix exponent calculation for subnormals
tgross35 Feb 7, 2025
faa3f43
Merge pull request #497 from tgross35/edge-case-max-subnorm
tgross35 Feb 7, 2025
57a21a1
Remove or reduce the scope of `allow(unused)` where possible
tgross35 Feb 7, 2025
2795848
Convert `fmaf` to a generic implementation
tgross35 Feb 7, 2025
020db46
Uncomment some hex float tests that should work now
tgross35 Feb 7, 2025
e66ec88
Work arouind iai-callgrind apt failures
tgross35 Feb 7, 2025
68bfe1d
Add an enum representation of rounding mode
tgross35 Jan 25, 2025
b19cde9
Port the CORE-MATH version of `cbrt`
tgross35 Oct 25, 2024
f069b54
Decrease the allowed error for `cbrt`
tgross35 Jan 25, 2025
670f8a8
Merge pull request #475 from tgross35/core-cbrt
tgross35 Feb 7, 2025
555a29c
Add simple icount benchmarks for `u256` operations
tgross35 Feb 8, 2025
d202e8f
Change how operators are `black_box`ed
tgross35 Feb 8, 2025
22c83fe
Replace an `assert!` with `debug_assert!` in `u256::shr`
tgross35 Feb 8, 2025
995bc5a
Increase the tolerance for `jn` and `yn`
tgross35 Feb 10, 2025
0d9ab5c
ci: Pin the nightly toolchain for i686-pc-windows-gnu
tgross35 Feb 9, 2025
6fab367
Implement `u256` with two `u128`s rather than `u64`
tgross35 Feb 8, 2025
36aaf4a
Introduce a trait constant for the minimum positive normal value
tgross35 Feb 10, 2025
a8fdead
Migrate away from nonfunctional `fenv` stubs
tgross35 Feb 10, 2025
e8fbb05
Eliminate the use of `force_eval!` in `ceil`, `floor`, and `trunc`
tgross35 Feb 10, 2025
5151be0
Merge pull request #510 from tgross35/replace-fenv
tgross35 Feb 10, 2025
90872c1
Small refactor of bigint tests
tgross35 Feb 10, 2025
2d3bd6c
Combine `fmin{,f,f16,f128}` and `fmax{,f,f16,128}` into a single file
tgross35 Feb 10, 2025
e21748d
Add `fminimum`, `fmaximum`, `fminimum_num`, and `fmaximum_num`
tgross35 Feb 10, 2025
a65eb91
Increase allowed offset from infinity for ynf
tgross35 Feb 10, 2025
913256d
Fix parsing of negative hex float literals in util
tgross35 Feb 11, 2025
c2bf953
Add `roundeven{,f,f16,f128}`
tgross35 Feb 11, 2025
8f2a9ae
Check exact values for specified cases
tgross35 Feb 11, 2025
6f0aae8
Rename `Float::exp` to `Float::ex`
tgross35 Feb 11, 2025
a1950c7
Add a way to print inputs on failure
tgross35 Feb 12, 2025
4fbd9b7
Scale test iteration count at a later point
tgross35 Feb 12, 2025
c0485a3
fma refactor 1/3: remove math/fma.rs
tgross35 Feb 12, 2025
2bafb58
fma refactor 2/3: move math/generic/fma.rs to math/fma.rs
tgross35 Feb 12, 2025
4f9dddb
fma refactor 3/3: combine `fma` public API with its implementation
tgross35 Feb 12, 2025
bfbeb10
Make `fma` a trait method on `Float`
tgross35 Feb 12, 2025
2831be0
Merge pull request #520 from tgross35/fma-restructure
tgross35 Feb 12, 2025
5275b53
Use `git ls-files` rather than manually globbing for tidy
tgross35 Feb 12, 2025
f0e10b6
ci: Pin the nightly toolchain for aarch64 jobs
tgross35 Feb 24, 2025
9a60739
Make the compiler-builtins test more accurately mirror compiler-builtins
tgross35 Feb 24, 2025
8dbc140
Resolve monomorphization errors in `compiler-builtins`
tgross35 Feb 24, 2025
aa6791f
Ignore unused variables when `compiler-builtins` is set
tgross35 Feb 24, 2025
cb14a23
Configure out remaining formatting when `compiler-builtins` is set
tgross35 Feb 24, 2025
e0240a3
Update the `libm` submodule
tgross35 Feb 23, 2025
d3ae7bf
Remove libm submodule
tgross35 Feb 24, 2025
29a8b46
Add 'libm/' from commit 'cb14a239d5f91f7cf18fedf4640794eea6bd0fda'
tgross35 Feb 24, 2025
49647cf
Try disabling another debug_assert
tgross35 Feb 24, 2025
722014d
update .gitmodules
tgross35 Feb 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "libm"]
path = libm
url = https://github.com/rust-lang/libm.git
[submodule "musl"]
path = libm/crates/musl-math-sys/musl
url = https://git.musl-libc.org/git/musl
shallow = true
1 change: 0 additions & 1 deletion libm
Submodule libm deleted from 8e8261
21 changes: 21 additions & 0 deletions libm/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.md]
# double whitespace at end of line
# denotes a line break in Markdown
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
5 changes: 5 additions & 0 deletions libm/.git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Use `git config blame.ignorerevsfile .git-blame-ignore-revs` to make
# `git blame` ignore the following commits.

# Reformat with a new `.rustfmt.toml`
5882cabb83c30bf7c36023f9a55a80583636b0e8
311 changes: 311 additions & 0 deletions libm/.github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
name: CI
on:
push:
branches:
- master
pull_request:

env:
CARGO_TERM_COLOR: always
RUSTDOCFLAGS: -Dwarnings
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: full
BENCHMARK_RUSTC: nightly-2025-01-16 # Pin the toolchain for reproducable results

jobs:
test:
name: Build and test
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-15
# FIXME: pinned due to https://github.com/llvm/llvm-project/issues/127804
channel: nightly-2025-02-07
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
# FIXME: pinned due to https://github.com/llvm/llvm-project/issues/127804
channel: nightly-2025-02-07
- target: aarch64-pc-windows-msvc
os: windows-2025
build_only: 1 # Can't run on x86 hosts
- target: arm-unknown-linux-gnueabi
os: ubuntu-24.04
- target: arm-unknown-linux-gnueabihf
os: ubuntu-24.04
- target: armv7-unknown-linux-gnueabihf
os: ubuntu-24.04
- target: i586-unknown-linux-gnu
os: ubuntu-24.04
- target: i686-unknown-linux-gnu
os: ubuntu-24.04
- target: loongarch64-unknown-linux-gnu
os: ubuntu-24.04
- target: powerpc-unknown-linux-gnu
os: ubuntu-24.04
- target: powerpc64-unknown-linux-gnu
os: ubuntu-24.04
- target: powerpc64le-unknown-linux-gnu
os: ubuntu-24.04
- target: riscv64gc-unknown-linux-gnu
os: ubuntu-24.04
- target: thumbv6m-none-eabi
os: ubuntu-24.04
- target: thumbv7em-none-eabi
os: ubuntu-24.04
- target: thumbv7em-none-eabihf
os: ubuntu-24.04
- target: thumbv7m-none-eabi
os: ubuntu-24.04
- target: x86_64-unknown-linux-gnu
os: ubuntu-24.04
- target: x86_64-apple-darwin
os: macos-13
- target: wasm32-unknown-unknown
os: ubuntu-24.04
build_only: 1
- target: i686-pc-windows-msvc
os: windows-2025
- target: x86_64-pc-windows-msvc
os: windows-2025
- target: i686-pc-windows-gnu
os: windows-2025
# FIXME: pinned due to https://github.com/rust-lang/rust/issues/136795
channel: nightly-2025-02-07-i686-gnu
- target: x86_64-pc-windows-gnu
os: windows-2025
channel: nightly-x86_64-gnu
runs-on: ${{ matrix.os }}
env:
BUILD_ONLY: ${{ matrix.build_only }}
steps:
- name: Print runner information
run: uname -a
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust (rustup)
shell: bash
run: |
channel="nightly"
# Account for channels that have required components (MinGW)
[ -n "${{ matrix.channel }}" ] && channel="${{ matrix.channel }}"
rustup update "$channel" --no-self-update
rustup default "$channel"
rustup target add "${{ matrix.target }}"
rustup component add clippy llvm-tools-preview
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Verify API list
if: matrix.os == 'ubuntu-24.04'
run: python3 etc/update-api-list.py --check

# Non-linux tests just use our raw script
- name: Run locally
if: matrix.os != 'ubuntu-24.04' || contains(matrix.target, 'wasm')
shell: bash
run: ./ci/run.sh ${{ matrix.target }}

# Otherwise we use our docker containers to run builds
- name: Run in Docker
if: matrix.os == 'ubuntu-24.04' && !contains(matrix.target, 'wasm')
run: |
rustup target add x86_64-unknown-linux-musl
cargo generate-lockfile && ./ci/run-docker.sh ${{ matrix.target }}

- name: Print test logs if available
if: always()
run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi
shell: bash

clippy:
name: Clippy
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Install Rust
run: |
rustup update nightly --no-self-update
rustup default nightly
rustup component add clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all --all-features --all-targets

builtins:
name: Check use with compiler-builtins
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update nightly --no-self-update && rustup default nightly
- uses: Swatinem/rust-cache@v2
- run: cargo check --manifest-path crates/compiler-builtins-smoke-test/Cargo.toml
- run: cargo test --manifest-path crates/compiler-builtins-smoke-test/Cargo.toml

benchmarks:
name: Benchmarks
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@master
with:
submodules: true
- uses: taiki-e/install-action@cargo-binstall

- name: Set up dependencies
run: |
sudo apt update
sudo apt install -y valgrind gdb libc6-dbg # Needed for iai-callgrind
rustup update "$BENCHMARK_RUSTC" --no-self-update
rustup default "$BENCHMARK_RUSTC"
# Install the version of iai-callgrind-runner that is specified in Cargo.toml
iai_version="$(cargo metadata --format-version=1 --features icount |
jq -r '.packages[] | select(.name == "iai-callgrind").version')"
cargo binstall -y iai-callgrind-runner --version "$iai_version"
sudo apt-get install valgrind

- uses: Swatinem/rust-cache@v2

- name: Run icount benchmarks
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: ./ci/bench-icount.sh

- name: Upload the benchmark baseline
uses: actions/upload-artifact@v4
with:
name: ${{ env.BASELINE_NAME }}
path: ${{ env.BASELINE_NAME }}.tar.xz

- name: Run wall time benchmarks
run: |
# Always use the same seed for benchmarks. Ideally we should switch to a
# non-random generator.
export LIBM_SEED=benchesbenchesbenchesbencheswoo!
cargo bench --all --features short-benchmarks,build-musl,force-soft-floats

- name: Print test logs if available
if: always()
run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi
shell: bash

msrv:
name: Check MSRV
runs-on: ubuntu-24.04
timeout-minutes: 10
env:
RUSTFLAGS: # No need to check warnings on old MSRV, unset `-Dwarnings`
steps:
- uses: actions/checkout@master
- run: |
msrv="$(perl -ne 'print if s/rust-version\s*=\s*"(.*)"/\1/g' Cargo.toml)"
echo "MSRV: $msrv"
echo "MSRV=$msrv" >> "$GITHUB_ENV"
- name: Install Rust
run: rustup update "$MSRV" --no-self-update && rustup default "$MSRV"
- uses: Swatinem/rust-cache@v2
- run: cargo build -p libm

rustfmt:
name: Rustfmt
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@master
- name: Install Rust
run: |
rustup update nightly --no-self-update
rustup default nightly
rustup component add rustfmt
- run: cargo fmt -- --check

# Determine which extensive tests should be run based on changed files.
calculate_extensive_matrix:
name: Calculate job matrix
runs-on: ubuntu-24.04
timeout-minutes: 10
outputs:
matrix: ${{ steps.script.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Fetch pull request ref
run: git fetch origin "$GITHUB_REF:$GITHUB_REF"
if: github.event_name == 'pull_request'
- run: python3 ci/ci-util.py generate-matrix >> "$GITHUB_OUTPUT"
id: script

extensive:
name: Extensive tests for ${{ matrix.ty }}
needs:
# Wait on `clippy` so we have some confidence that the crate will build
- clippy
- calculate_extensive_matrix
runs-on: ubuntu-24.04
timeout-minutes: 180
strategy:
matrix:
# Use the output from `calculate_extensive_matrix` to calculate the matrix
# FIXME: it would be better to run all jobs (i.e. all types) but mark those that
# didn't change as skipped, rather than completely excluding the job. However,
# this is not currently possible https://github.com/actions/runner/issues/1985.
include: ${{ fromJSON(needs.calculate_extensive_matrix.outputs.matrix).matrix }}
env:
CHANGED: ${{ matrix.changed }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust
run: |
rustup update nightly --no-self-update
rustup default nightly
- uses: Swatinem/rust-cache@v2
- name: Run extensive tests
run: |
echo "Changed: '$CHANGED'"
if [ -z "$CHANGED" ]; then
echo "No tests to run, exiting."
exit
fi

# Run the non-extensive tests first to catch any easy failures
cargo t --profile release-checked -- "$CHANGED"

LIBM_EXTENSIVE_TESTS="$CHANGED" cargo t \
--features build-mpfr,unstable,force-soft-floats \
--profile release-checked \
-- extensive
- name: Print test logs if available
run: if [ -f "target/test-log.txt" ]; then cat target/test-log.txt; fi
shell: bash

success:
needs:
- test
- builtins
- benchmarks
- msrv
- rustfmt
- extensive
runs-on: ubuntu-24.04
timeout-minutes: 10
# GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
# dependencies fails.
if: always() # make sure this is never "skipped"
steps:
# Manually check the status of all dependencies. `if: failure()` does not work.
- name: check if any dependency failed
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
27 changes: 27 additions & 0 deletions libm/.github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release-plz

permissions:
pull-requests: write
contents: write

on:
push:
branches:
- master

jobs:
release-plz:
name: Release-plz
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust (rustup)
run: rustup update nightly --no-self-update && rustup default nightly
- name: Run release-plz
uses: MarcoIeni/release-plz-action@v0.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
11 changes: 11 additions & 0 deletions libm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**.bk
.#*
/bin
/math/src
target
Cargo.lock
**.tar.gz

# Benchmark cache
iai-home
baseline-*
5 changes: 5 additions & 0 deletions libm/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This matches rustc
style_edition = "2024"
use_small_heuristics = "Max"
group_imports = "StdExternalCrate"
imports_granularity = "Module"
Loading