]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrum
authorbors <bors@rust-lang.org>
Sat, 13 Nov 2021 02:17:20 +0000 (02:17 +0000)
committerbors <bors@rust-lang.org>
Sat, 13 Nov 2021 02:17:20 +0000 (02:17 +0000)
commit032dfe43605f4324966933078ffe6f717b77c7c8
treeccd1d0a8cb3f7c183a4e22cb4e3c5d68709ac427
parente90c5fbbc5df5c81267747daeb937d4e955ce6ad
parent7c3d72d069600c7826e44d26bf005eb28e91b169
Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrum

pub use core::simd;

A portable abstraction over SIMD has been a major pursuit in recent years for several programming languages. In Rust, `std::arch` offers explicit SIMD acceleration via compiler intrinsics, but it does so at the cost of having to individually maintain each and every single such API, and is almost completely `unsafe` to use.  `core::simd` offers safe abstractions that are resolved to the appropriate SIMD instructions by LLVM during compilation, including scalar instructions if that is all that is available.

`core::simd` is enabled by the `#![portable_simd]` nightly feature tracked in https://github.com/rust-lang/rust/issues/86656 and is introduced here by pulling in the https://github.com/rust-lang/portable-simd repository as a subtree. We built the repository out-of-tree to allow faster compilation and a stochastic test suite backed by the proptest crate to verify that different targets, features, and optimizations produce the same result, so that using this library does not introduce any surprises. As these tests are technically non-deterministic, and thus can introduce overly interesting Heisenbugs if included in the rustc CI, they are visible in the commit history of the subtree but do nothing here. Some tests **are** introduced via the documentation, but these use deterministic asserts.

There are multiple unsolved problems with the library at the current moment, including a want for better documentation, technical issues with LLVM scalarizing and lowering to libm, room for improvement for the APIs, and so far I have not added the necessary plumbing for allowing the more experimental or libm-dependent APIs to be used. However, I thought it would be prudent to open this for review in its current condition, as it is both usable and it is likely I am going to learn something else needs to be fixed when bors tries this out.

The major types are
- `core::simd::Simd<T, N>`
- `core::simd::Mask<T, N>`

There is also the `LaneCount` struct, which, together with the SimdElement and SupportedLaneCount traits, limit the implementation's maximum support to vectors we know will actually compile and provide supporting logic for bitmasks. I'm hoping to simplify at least some of these out of the way as the compiler and library evolve.
library/core/src/lib.rs
library/core/tests/lib.rs
library/std/src/lib.rs