Skip to content

Commit

Permalink
Explain why to use Simd early
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed Apr 23, 2023
1 parent 92259a4 commit 4064678
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/core_simd/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ use crate::simd::{
/// `Simd<T, N>` supports the operators (+, *, etc.) that `T` does in "elementwise" fashion.
/// These take the element at each index from the left-hand side and right-hand side,
/// perform the operation, then return the result in the same index in a vector of equal size.
/// In other words, an elementwise operation is equivalent to a zip, then map.
/// However, `Simd` differs from normal iteration and normal arrays:
/// - `Simd<T, N>` executes `N` operations in a single step with no `break`s
/// - `Simd<T, N>` can have an alignment greater than `T`, for better mechanical sympathy
///
/// By always imposing these constraints on `Simd`, it is easier to compile elementwise operations
/// into machine instructions that can themselves be executed in parallel.
///
/// ```rust
/// # #![feature(portable_simd)]
Expand Down

0 comments on commit 4064678

Please sign in to comment.