about summary refs log tree commit diff
path: root/src/tools/miri
AgeCommit message (Collapse)AuthorLines
2025-04-05Rollup merge of #136457 - calder:master, r=tgross35Stuart Cook-4/+4
Expose algebraic floating point intrinsics # Problem A stable Rust implementation of a simple dot product is 8x slower than C++ on modern x86-64 CPUs. The root cause is an inability to let the compiler reorder floating point operations for better vectorization. See https://github.com/calder/dot-bench for benchmarks. Measurements below were performed on a i7-10875H. ### C++: 10us ✅ With Clang 18.1.3 and `-O2 -march=haswell`: <table> <tr> <th>C++</th> <th>Assembly</th> </tr> <tr> <td> <pre lang="cc"> float dot(float *a, float *b, size_t len) { #pragma clang fp reassociate(on) float sum = 0.0; for (size_t i = 0; i < len; ++i) { sum += a[i] * b[i]; } return sum; } </pre> </td> <td> <img src="https://github.com/user-attachments/assets/739573c0-380a-4d84-9fd9-141343ce7e68" /> </td> </tr> </table> ### Nightly Rust: 10us ✅ With rustc 1.86.0-nightly (8239a37f9) and `-C opt-level=3 -C target-feature=+avx2,+fma`: <table> <tr> <th>Rust</th> <th>Assembly</th> </tr> <tr> <td> <pre lang="rust"> fn dot(a: &[f32], b: &[f32]) -> f32 { let mut sum = 0.0; for i in 0..a.len() { sum = fadd_algebraic(sum, fmul_algebraic(a[i], b[i])); } sum } </pre> </td> <td> <img src="https://github.com/user-attachments/assets/9dcf953a-2cd7-42f3-bc34-7117de4c5fb9" /> </td> </tr> </table> ### Stable Rust: 84us ❌ With rustc 1.84.1 (e71f9a9a9) and `-C opt-level=3 -C target-feature=+avx2,+fma`: <table> <tr> <th>Rust</th> <th>Assembly</th> </tr> <tr> <td> <pre lang="rust"> fn dot(a: &[f32], b: &[f32]) -> f32 { let mut sum = 0.0; for i in 0..a.len() { sum += a[i] * b[i]; } sum } </pre> </td> <td> <img src="https://github.com/user-attachments/assets/936a1f7e-33e4-4ff8-a732-c3cdfe068dca" /> </td> </tr> </table> # Proposed Change Add `core::intrinsics::f*_algebraic` wrappers to `f16`, `f32`, `f64`, and `f128` gated on a new `float_algebraic` feature. # Alternatives Considered https://github.com/rust-lang/rust/issues/21690 has a lot of good discussion of various options for supporting fast math in Rust, but is still open a decade later because any choice that opts in more than individual operations is ultimately contrary to Rust's design principles. In the mean time, processors have evolved and we're leaving major performance on the table by not supporting vectorization. We shouldn't make users choose between an unstable compiler and an 8x performance hit. # References * https://github.com/rust-lang/rust/issues/21690 * https://github.com/rust-lang/libs-team/issues/532 * https://github.com/rust-lang/rust/issues/136469 * https://github.com/calder/dot-bench * https://www.felixcloutier.com/x86/vfmadd132ps:vfmadd213ps:vfmadd231ps try-job: x86_64-gnu-nopt try-job: x86_64-gnu-aux
2025-04-04Expose algebraic floating point intrinsicsCalder Coalson-4/+4
2025-04-01interpret: add a version of run_for_validation for &selfRalf Jung-1/+1
2025-03-28cache mangle_internal_symbol resultsRalf Jung-33/+40
2025-03-27run a few more concurrency tests on aarch64-linux-androidRalf Jung-4/+4
2025-03-21Merge pull request #4236 from RalfJung/rustupRalf Jung-1/+4
Rustup
2025-03-21Merge from rustcRalf Jung-0/+3
2025-03-21Preparing for merge from rustcRalf Jung-1/+1
2025-03-21catch_unwind: do not permit catch function to unwindRalf Jung-1/+2
2025-03-20interpret memory access hooks: also pass through the Pointer used for the accessRalf Jung-0/+3
2025-03-20Merge from rustcThe Miri Cronjob Bot-23/+66
2025-03-20Preparing for merge from rustcThe Miri Cronjob Bot-1/+1
2025-03-17Auto merge of #127173 - bjorn3:mangle_rustc_std_internal_symbol, ↵bors-19/+64
r=wesleywiser,jieyouxu Mangle rustc_std_internal_symbols functions This reduces the risk of issues when using a staticlib or rust dylib compiled with a different rustc version in a rust program. Currently this will either (in the case of staticlib) cause a linker error due to duplicate symbol definitions, or (in the case of rust dylibs) cause rustc_std_internal_symbols functions to be silently overridden. As rust gets more commonly used inside the implementation of libraries consumed with a C interface (like Spidermonkey, Ruby YJIT (curently has to do partial linking of all rust code to hide all symbols not part of the C api), the Rusticl OpenCL implementation in mesa) this is becoming much more of an issue. With this PR the only symbols remaining with an unmangled name are rust_eh_personality (LLVM doesn't allow renaming it) and `__rust_no_alloc_shim_is_unstable`. Helps mitigate https://github.com/rust-lang/rust/issues/104707 try-job: aarch64-gnu-debug try-job: aarch64-apple try-job: x86_64-apple-1 try-job: x86_64-mingw-1 try-job: i686-mingw-1 try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: test-various try-job: armhf-gnu
2025-03-17Auto merge of #137081 - ↵bors-2/+2
Shourya742:2025-02-15-change-config.toml-to-bootstrap.toml, r=onur-ozkan,jieyouxu,kobzol change config.toml to bootstrap.toml Currently, both Bootstrap and Cargo uses same name as their configuration file, which can be confusing. This PR is based on a discussion to rename `config.toml` to `bootstrap.toml` for Bootstrap. Closes: https://github.com/rust-lang/rust/issues/126875. I have split the PR into atomic commits to make it easier to review. Once the changes are finalized, I will squash them. I am particularly concerned about the changes made to modules that are not part of Bootstrap. How should we handle those changes? Should we ping the respective maintainers?
2025-03-17Fix miribjorn3-19/+64
2025-03-17Rollup merge of #137793 - NobodyXu:stablise-annoymous-pipe, r=joshtriplettJacob Pratt-2/+0
Stablize anonymous pipe Since #135822 is staled, I create this PR to stablise anonymous pipe Closes #127154 try-job: test-various
2025-03-17replace config.toml to bootstrap.toml in src:toolsbit-aloo-2/+2
2025-03-16Merge from rustcThe Miri Cronjob Bot-8/+0
2025-03-16Preparing for merge from rustcThe Miri Cronjob Bot-1/+1
2025-03-15Merge from rustcThe Miri Cronjob Bot-2/+2
2025-03-15Preparing for merge from rustcThe Miri Cronjob Bot-1/+1
2025-03-14Do not suggest using `-Zmacro-backtrace` for builtin macrosEsteban Küber-8/+0
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
2025-03-14Merge from rustcThe Miri Cronjob Bot-81/+91
2025-03-14Preparing for merge from rustcThe Miri Cronjob Bot-1/+1
2025-03-14Auto merge of #138157 - scottmcm:inline-more-tiny-things, r=oli-obkbors-2/+2
Allow more top-down inlining for single-BB callees This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them. Fixes #138136 ~~Draft as it's built atop #138135, which adds a mir-opt test that's a nice demonstration of this. To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
2025-03-13Rollup merge of #138417 - RalfJung:interpret-cleanup, r=oli-obkMatthias Krüger-50/+60
minor interpreter cleanups - remove the `eval_inline_asm` hook that `@saethlin` added; the usage never materialized and he agreed with removing it - I tried merging `init_alloc_extra` and `adjust_global_allocation` and it didn't work; leave a comment as to why. Also, make the allocation code path a bit more clear by renaming `init_alloc_extra` to `init_local_allocation`. r? `@oli-obk`
2025-03-14Stablize feature `anonymous_pipe`Jiahao XU-2/+0
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-03-12Allow more top-down inlining for single-BB calleesScott McMurray-2/+2
This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them.
2025-03-12Merge pull request #4185 from geetanshjuneja/abi_checkRalf Jung-7/+161
FnAbi Compatability check
2025-03-12added check_shim_abigeetanshjuneja-7/+161
added input arg mismatch test added detailed ub messages added return type mismatch test
2025-03-12alloc_addresses: use MemoryKind instead of tcx query to determine global ↵Ralf Jung-2/+5
allocations
2025-03-12minor interpret cleanupsRalf Jung-50/+60
2025-03-12intrinsics: remove unnecessary leading underscore from argument namesRalf Jung-28/+28
2025-03-11miri native_calls: ensure we actually expose *mutable* provenance to the ↵Ralf Jung-3/+3
memory FFI can access
2025-03-11Merge from rustcThe Miri Cronjob Bot-11/+11
2025-03-11Preparing for merge from rustcThe Miri Cronjob Bot-1/+1
2025-03-08Move fs into sysThalia Archibald-9/+9
2025-03-08Erase non-pal sys platform pathsThalia Archibald-2/+2
2025-03-07Merge pull request #4223 from Stypox/ctrl-c-backtraceRalf Jung-1/+5
Show interpreter backtrace error on Ctrl+C
2025-03-07Show interpreter backtrace error on Ctrl+CStypox-1/+5
See https://github.com/rust-lang/rust/pull/111769
2025-03-07Merge pull request #4222 from rust-lang/rustup-2025-03-07Ben Kimock-55/+121
Automatic Rustup
2025-03-07Merge from rustcThe Miri Cronjob Bot-54/+120
2025-03-07Preparing for merge from rustcThe Miri Cronjob Bot-1/+1
2025-03-07Merge pull request #4221 from saethlin/nextest-parallelismBen Kimock-2/+1
Update documentation about nextest
2025-03-07Merge pull request #4218 from saethlin/tier-2-sysrootsBen Kimock-0/+1
Fix tier 2 sysroots job
2025-03-06Update documentation about nextestBen Kimock-2/+1
2025-03-06Fix tier 2 sysroots jobBen Kimock-0/+1
2025-03-06Rollup merge of #137802 - RalfJung:miri-native-call-exposed, r=oli-obkMichael Goulet-54/+120
miri native-call support: all previously exposed provenance is accessible to the callee When Miri invokes a native C function, the memory C can access needs to be "prepared": to avoid false positives, we need to consider all that memory initialized, and we need to consider it to have arbitrary provenance. So far we did this for all pointers passed to C, but not for pointers that were exposed already before the native call. This PR adjusts the logic so that we now "prepare" all memory that has ever been exposed. This fixes cases such as: - cast a pointer to integer, send that integer to C, and access the memory there (`test_pass_ptr_as_int`) - send a pointer to some memory to C, which stores it somewhere; then in Rust store another pointer in that memory, and access that via C (`test_pass_ptr_via_previously_shared_mem`) r? `````@oli-obk`````
2025-03-06Merge from rustcThe Miri Cronjob Bot-15/+0
2025-03-06Preparing for merge from rustcThe Miri Cronjob Bot-1/+1