-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[experiment] reliable float experiments #140424
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Support for `f16` and `f128` is varied across targets, backends, and backend versions. Eventually we would like to reach a point where all backends support these approximately equally, but until then we have to work around some of these nuances of support being observable. Introduce the `cfg_target_has_reliable_f16_f128` internal feature, which provides the following new configuration gates: * `cfg(target_has_reliable_f16)` * `cfg(target_has_reliable_f16_math)` * `cfg(target_has_reliable_f128)` * `cfg(target_has_reliable_f128_math)` `reliable_f16` and `reliable_f128` indicate that basic arithmetic for the type works correctly. The `_math` versions indicate that anything relying on `libm` works correctly, since sometimes this hits a separate class of codegen bugs. These options match configuration set by the build script at [1]. The logic for LLVM support is duplicated as-is from the same script. There are a few possible updates that will come as a follow up. The config introduced here is not planned to ever become stable, it is only intended to replace the build scripts for `std` tests and `compiler-builtins` that don't have any way to configure based on the codegen backend. MCP: rust-lang/compiler-team#866 Closes: rust-lang/compiler-team#866 [1]: https://github.com/rust-lang/rust/blob/555e1d0386f024a8359645c3217f4b3eae9be042/library/std/build.rs#L84-L186
New compiler configuration has been introduced that is designed to replace the build script configuration `reliable_f16`, `reliable_f128`, `reliable_f16_math`, and `reliable_f128_math`. Do this replacement here, which allows us to clean up `std`'s build script. All tests are gated by `#[cfg(bootstrap)]` rather than doing a more complicated `cfg(bootstrap)` / `cfg(not(bootstrap))` split since the next beta split is within two weeks.
Use the existing Lemire (decimal -> float) and Dragon / Grisu algorithms (float -> decimal) to add support for `f16`. This allows updating the implementation for `Display` to the expected behavior for `Display` (currently it prints the a hex bitwise representation) and adds a `FromStr` implementation. (cherry picked from commit 4c57b48)
Extend the existing tests for `f32` and `f64` with versions that include `f16`'s new printing and parsing implementations. Co-authored-by: Speedy_Lex <[email protected]> (cherry picked from commit c4c7d6c)
This requires a fix to the subnormal test to cap the maximum allowed value within the maximum mantissa. (cherry picked from commit cb40d2d)
@bors try |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 29, 2025
[experiment] reliable float experiments Trying a few blocked things based on top of rust-lang#140323. r? `@ghost` try-job: aarch64-gnu try-job: i686-gnu-1 try-job: i686-msvc-1 try-job: test-various try-job: x86_64-gnu try-job: x86_64-msvc-ext2
@bors try |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 29, 2025
[experiment] reliable float experiments Trying a few blocked things based on top of rust-lang#140323. r? `@ghost` try-job: x86_64-gnu-llvm-19-1 try-job: x86_64-gnu-llvm-20-1
This comment has been minimized.
This comment has been minimized.
e56745d
to
67a01a2
Compare
@bors try |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 29, 2025
[experiment] reliable float experiments Trying a few blocked things based on top of rust-lang#140323. r? `@ghost` try-job: aarch64-gnu try-job: i686-gnu-1 try-job: i686-msvc-1 try-job: test-various try-job: x86_64-gnu try-job: x86_64-msvc-ext2 try-job: x86_64-gnu-llvm-19-1 try-job: x86_64-gnu-llvm-20-1
This comment has been minimized.
This comment has been minimized.
67a01a2
to
274bf8f
Compare
@bors try |
The job Click to see the possible cause of the failure (guessed by this bot)
|
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 29, 2025
[experiment] reliable float experiments Trying a few blocked things based on top of rust-lang#140323. r? `@ghost` try-job: aarch64-gnu try-job: i686-gnu-1 try-job: i686-msvc-1 try-job: test-various try-job: x86_64-gnu try-job: x86_64-msvc-ext2 try-job: x86_64-gnu-llvm-19-1 try-job: x86_64-gnu-llvm-20-1
The job Click to see the possible cause of the failure (guessed by this bot)
|
The job Click to see the possible cause of the failure (guessed by this bot)
|
The job Click to see the possible cause of the failure (guessed by this bot)
|
The job Click to see the possible cause of the failure (guessed by this bot)
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-testsuite
Area: The testsuite used to check the correctness of rustc
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-bootstrap
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trying a few blocked things based on top of #140323.
r? @ghost
try-job: aarch64-gnu
try-job: i686-gnu-1
try-job: i686-msvc-1
try-job: test-various
try-job: x86_64-gnu
try-job: x86_64-msvc-ext2
try-job: x86_64-gnu-llvm-19-1
try-job: x86_64-gnu-llvm-20-1