Skip to content

Commit 4064678

Browse files
Explain why to use Simd early
1 parent 92259a4 commit 4064678

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/core_simd/src/vector.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ use crate::simd::{
88
/// `Simd<T, N>` supports the operators (+, *, etc.) that `T` does in "elementwise" fashion.
99
/// These take the element at each index from the left-hand side and right-hand side,
1010
/// perform the operation, then return the result in the same index in a vector of equal size.
11-
/// In other words, an elementwise operation is equivalent to a zip, then map.
11+
/// However, `Simd` differs from normal iteration and normal arrays:
12+
/// - `Simd<T, N>` executes `N` operations in a single step with no `break`s
13+
/// - `Simd<T, N>` can have an alignment greater than `T`, for better mechanical sympathy
14+
///
15+
/// By always imposing these constraints on `Simd`, it is easier to compile elementwise operations
16+
/// into machine instructions that can themselves be executed in parallel.
1217
///
1318
/// ```rust
1419
/// # #![feature(portable_simd)]

0 commit comments

Comments
 (0)