Skip to content

Commit

Permalink
Auto merge of #99491 - workingjubilee:sync-psimd, r=workingjubilee
Browse files Browse the repository at this point in the history
Sync in portable-simd subtree

r? `@ghost`
  • Loading branch information
bors committed Jul 22, 2022
2 parents e7a9c11 + f8aa494 commit 41419e7
Show file tree
Hide file tree
Showing 37 changed files with 1,617 additions and 889 deletions.
1 change: 1 addition & 0 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3569,6 +3569,7 @@ impl<T> [T] {
///
/// ```
/// #![feature(portable_simd)]
/// use core::simd::SimdFloat;
///
/// let short = &[1, 2, 3];
/// let (prefix, middle, suffix) = short.as_simd::<4>();
Expand Down
1 change: 1 addition & 0 deletions library/core/tests/simd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::simd::f32x4;
use core::simd::SimdFloat;

#[test]
fn testing() {
Expand Down
5 changes: 5 additions & 0 deletions library/portable-simd/beginners-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,10 @@ Fortunately, most SIMD types have a fairly predictable size. `i32x4` is bit-equi

However, this is not the same as alignment. Computer architectures generally prefer aligned accesses, especially when moving data between memory and vector registers, and while some support specialized operations that can bend the rules to help with this, unaligned access is still typically slow, or even undefined behavior. In addition, different architectures can require different alignments when interacting with their native SIMD types. For this reason, any `#[repr(simd)]` type has a non-portable alignment. If it is necessary to directly interact with the alignment of these types, it should be via [`mem::align_of`].

When working with slices, data correctly aligned for SIMD can be acquired using the [`as_simd`] and [`as_simd_mut`] methods of the slice primitive.

[`mem::transmute`]: https://doc.rust-lang.org/core/mem/fn.transmute.html
[`mem::align_of`]: https://doc.rust-lang.org/core/mem/fn.align_of.html
[`as_simd`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.as_simd
[`as_simd_mut`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.as_simd_mut

3 changes: 2 additions & 1 deletion library/portable-simd/crates/core_simd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ categories = ["hardware-support", "no-std"]
license = "MIT OR Apache-2.0"

[features]
default = []
default = ["as_crate"]
as_crate = []
std = []
generic_const_exprs = []

Expand Down
120 changes: 0 additions & 120 deletions library/portable-simd/crates/core_simd/src/comparisons.rs

This file was deleted.

11 changes: 11 additions & 0 deletions library/portable-simd/crates/core_simd/src/elements.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mod float;
mod int;
mod uint;

mod sealed {
pub trait Sealed {}
}

pub use float::*;
pub use int::*;
pub use uint::*;
Loading

0 comments on commit 41419e7

Please sign in to comment.