pub type u8x64 = Simd<u8, 64>;
portable_simd
#86656)Expand description
A SIMD vector with 64 elements of type u8
.
Aliased Type§
struct u8x64(/* private fields */);
Implementations
source§impl<T, const N: usize> Simd<T, N>
impl<T, const N: usize> Simd<T, N>
sourcepub fn reverse(self) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn reverse(self) -> Simd<T, N>
portable_simd
#86656)Reverse the order of the elements in the vector.
sourcepub fn rotate_elements_left<const OFFSET: usize>(self) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn rotate_elements_left<const OFFSET: usize>(self) -> Simd<T, N>
portable_simd
#86656)Rotates the vector such that the first OFFSET
elements of the slice move to the end
while the last self.len() - OFFSET
elements move to the front. After calling rotate_elements_left
,
the element previously at index OFFSET
will become the first element in the slice.
sourcepub fn rotate_elements_right<const OFFSET: usize>(self) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn rotate_elements_right<const OFFSET: usize>(self) -> Simd<T, N>
portable_simd
#86656)Rotates the vector such that the first self.len() - OFFSET
elements of the vector move to
the end while the last OFFSET
elements move to the front. After calling rotate_elements_right
,
the element previously at index self.len() - OFFSET
will become the first element in the slice.
sourcepub fn interleave(self, other: Simd<T, N>) -> (Simd<T, N>, Simd<T, N>)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn interleave(self, other: Simd<T, N>) -> (Simd<T, N>, Simd<T, N>)
portable_simd
#86656)Interleave two vectors.
The resulting vectors contain elements taken alternatively from self
and other
, first
filling the first result, and then the second.
The reverse of this operation is Simd::deinterleave
.
let a = Simd::from_array([0, 1, 2, 3]);
let b = Simd::from_array([4, 5, 6, 7]);
let (x, y) = a.interleave(b);
assert_eq!(x.to_array(), [0, 4, 1, 5]);
assert_eq!(y.to_array(), [2, 6, 3, 7]);
sourcepub fn deinterleave(self, other: Simd<T, N>) -> (Simd<T, N>, Simd<T, N>)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn deinterleave(self, other: Simd<T, N>) -> (Simd<T, N>, Simd<T, N>)
portable_simd
#86656)Deinterleave two vectors.
The first result takes every other element of self
and then other
, starting with
the first element.
The second result takes every other element of self
and then other
, starting with
the second element.
The reverse of this operation is Simd::interleave
.
let a = Simd::from_array([0, 4, 1, 5]);
let b = Simd::from_array([2, 6, 3, 7]);
let (x, y) = a.deinterleave(b);
assert_eq!(x.to_array(), [0, 1, 2, 3]);
assert_eq!(y.to_array(), [4, 5, 6, 7]);
sourcepub fn resize<const M: usize>(self, value: T) -> Simd<T, M>where
LaneCount<M>: SupportedLaneCount,
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn resize<const M: usize>(self, value: T) -> Simd<T, M>where
LaneCount<M>: SupportedLaneCount,
portable_simd
#86656)Resize a vector.
If M
> N
, extends the length of a vector, setting the new elements to value
.
If M
< N
, truncates the vector to the first M
elements.
let x = u32x4::from_array([0, 1, 2, 3]);
assert_eq!(x.resize::<8>(9).to_array(), [0, 1, 2, 3, 9, 9, 9, 9]);
assert_eq!(x.resize::<2>(9).to_array(), [0, 1]);
source§impl<T, const N: usize> Simd<T, N>
impl<T, const N: usize> Simd<T, N>
sourcepub const LEN: usize = N
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub const LEN: usize = N
portable_simd
#86656)Number of elements in this vector.
sourcepub const fn len(&self) -> usize
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub const fn len(&self) -> usize
portable_simd
#86656)Returns the number of elements in this SIMD vector.
§Examples
let v = u32x4::splat(0);
assert_eq!(v.len(), 4);
sourcepub fn splat(value: T) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn splat(value: T) -> Simd<T, N>
portable_simd
#86656)Constructs a new SIMD vector with all elements set to the given value.
§Examples
let v = u32x4::splat(8);
assert_eq!(v.as_array(), &[8, 8, 8, 8]);
sourcepub const fn as_array(&self) -> &[T; N]
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub const fn as_array(&self) -> &[T; N]
portable_simd
#86656)Returns an array reference containing the entire SIMD vector.
§Examples
let v: u64x4 = Simd::from_array([0, 1, 2, 3]);
assert_eq!(v.as_array(), &[0, 1, 2, 3]);
sourcepub fn as_mut_array(&mut self) -> &mut [T; N]
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn as_mut_array(&mut self) -> &mut [T; N]
portable_simd
#86656)Returns a mutable array reference containing the entire SIMD vector.
sourcepub const fn from_array(array: [T; N]) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub const fn from_array(array: [T; N]) -> Simd<T, N>
portable_simd
#86656)Converts an array to a SIMD vector.
sourcepub const fn to_array(self) -> [T; N]
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub const fn to_array(self) -> [T; N]
portable_simd
#86656)Converts a SIMD vector to an array.
sourcepub const fn from_slice(slice: &[T]) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub const fn from_slice(slice: &[T]) -> Simd<T, N>
portable_simd
#86656)Converts a slice to a SIMD vector containing slice[..N]
.
§Panics
Panics if the slice’s length is less than the vector’s Simd::N
.
Use load_or_default
for an alternative that does not panic.
§Example
let source = vec![1, 2, 3, 4, 5, 6];
let v = u32x4::from_slice(&source);
assert_eq!(v.as_array(), &[1, 2, 3, 4]);
sourcepub fn copy_to_slice(self, slice: &mut [T])
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn copy_to_slice(self, slice: &mut [T])
portable_simd
#86656)sourcepub fn load_or_default(slice: &[T]) -> Simd<T, N>where
T: Default,
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn load_or_default(slice: &[T]) -> Simd<T, N>where
T: Default,
portable_simd
#86656)Reads contiguous elements from slice
. Elements are read so long as they’re in-bounds for
the slice
. Otherwise, the default value for the element type is returned.
§Examples
let vec: Vec<i32> = vec![10, 11];
let result = Simd::<i32, 4>::load_or_default(&vec);
assert_eq!(result, Simd::from_array([10, 11, 0, 0]));
sourcepub fn load_or(slice: &[T], or: Simd<T, N>) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn load_or(slice: &[T], or: Simd<T, N>) -> Simd<T, N>
portable_simd
#86656)Reads contiguous elements from slice
. Elements are read so long as they’re in-bounds for
the slice
. Otherwise, the corresponding value from or
is passed through.
§Examples
let vec: Vec<i32> = vec![10, 11];
let or = Simd::from_array([-5, -4, -3, -2]);
let result = Simd::load_or(&vec, or);
assert_eq!(result, Simd::from_array([10, 11, -3, -2]));
sourcepub fn load_select_or_default(
slice: &[T],
enable: Mask<<T as SimdElement>::Mask, N>,
) -> Simd<T, N>where
T: Default,
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn load_select_or_default(
slice: &[T],
enable: Mask<<T as SimdElement>::Mask, N>,
) -> Simd<T, N>where
T: Default,
portable_simd
#86656)Reads contiguous elements from slice
. Each element is read from memory if its
corresponding element in enable
is true
.
When the element is disabled or out of bounds for the slice, that memory location
is not accessed and the corresponding value from or
is passed through.
§Examples
let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let enable = Mask::from_array([true, true, false, true]);
let or = Simd::from_array([-5, -4, -3, -2]);
let result = Simd::load_select(&vec, enable, or);
assert_eq!(result, Simd::from_array([10, 11, -3, 13]));
sourcepub fn load_select(
slice: &[T],
enable: Mask<<T as SimdElement>::Mask, N>,
or: Simd<T, N>,
) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn load_select( slice: &[T], enable: Mask<<T as SimdElement>::Mask, N>, or: Simd<T, N>, ) -> Simd<T, N>
portable_simd
#86656)Reads contiguous elements from slice
. Each element is read from memory if its
corresponding element in enable
is true
.
When the element is disabled or out of bounds for the slice, that memory location
is not accessed and the corresponding value from or
is passed through.
§Examples
let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let enable = Mask::from_array([true, true, false, true]);
let or = Simd::from_array([-5, -4, -3, -2]);
let result = Simd::load_select(&vec, enable, or);
assert_eq!(result, Simd::from_array([10, 11, -3, 13]));
sourcepub unsafe fn load_select_unchecked(
slice: &[T],
enable: Mask<<T as SimdElement>::Mask, N>,
or: Simd<T, N>,
) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn load_select_unchecked( slice: &[T], enable: Mask<<T as SimdElement>::Mask, N>, or: Simd<T, N>, ) -> Simd<T, N>
portable_simd
#86656)Reads contiguous elements from slice
. Each element is read from memory if its
corresponding element in enable
is true
.
When the element is disabled, that memory location is not accessed and the corresponding
value from or
is passed through.
sourcepub unsafe fn load_select_ptr(
ptr: *const T,
enable: Mask<<T as SimdElement>::Mask, N>,
or: Simd<T, N>,
) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn load_select_ptr( ptr: *const T, enable: Mask<<T as SimdElement>::Mask, N>, or: Simd<T, N>, ) -> Simd<T, N>
portable_simd
#86656)Reads contiguous elements starting at ptr
. Each element is read from memory if its
corresponding element in enable
is true
.
When the element is disabled, that memory location is not accessed and the corresponding
value from or
is passed through.
sourcepub fn gather_or(
slice: &[T],
idxs: Simd<usize, N>,
or: Simd<T, N>,
) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn gather_or( slice: &[T], idxs: Simd<usize, N>, or: Simd<T, N>, ) -> Simd<T, N>
portable_simd
#86656)Reads from potentially discontiguous indices in slice
to construct a SIMD vector.
If an index is out-of-bounds, the element is instead selected from the or
vector.
§Examples
let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let idxs = Simd::from_array([9, 3, 0, 5]); // Note the index that is out-of-bounds
let alt = Simd::from_array([-5, -4, -3, -2]);
let result = Simd::gather_or(&vec, idxs, alt);
assert_eq!(result, Simd::from_array([-5, 13, 10, 15]));
sourcepub fn gather_or_default(slice: &[T], idxs: Simd<usize, N>) -> Simd<T, N>where
T: Default,
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn gather_or_default(slice: &[T], idxs: Simd<usize, N>) -> Simd<T, N>where
T: Default,
portable_simd
#86656)Reads from indices in slice
to construct a SIMD vector.
If an index is out-of-bounds, the element is set to the default given by T: Default
.
§Examples
let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let idxs = Simd::from_array([9, 3, 0, 5]); // Note the index that is out-of-bounds
let result = Simd::gather_or_default(&vec, idxs);
assert_eq!(result, Simd::from_array([0, 13, 10, 15]));
sourcepub fn gather_select(
slice: &[T],
enable: Mask<isize, N>,
idxs: Simd<usize, N>,
or: Simd<T, N>,
) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn gather_select( slice: &[T], enable: Mask<isize, N>, idxs: Simd<usize, N>, or: Simd<T, N>, ) -> Simd<T, N>
portable_simd
#86656)Reads from indices in slice
to construct a SIMD vector.
The mask enable
s all true
indices and disables all false
indices.
If an index is disabled or is out-of-bounds, the element is selected from the or
vector.
§Examples
let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let idxs = Simd::from_array([9, 3, 0, 5]); // Includes an out-of-bounds index
let alt = Simd::from_array([-5, -4, -3, -2]);
let enable = Mask::from_array([true, true, true, false]); // Includes a masked element
let result = Simd::gather_select(&vec, enable, idxs, alt);
assert_eq!(result, Simd::from_array([-5, 13, 10, -2]));
sourcepub unsafe fn gather_select_unchecked(
slice: &[T],
enable: Mask<isize, N>,
idxs: Simd<usize, N>,
or: Simd<T, N>,
) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn gather_select_unchecked( slice: &[T], enable: Mask<isize, N>, idxs: Simd<usize, N>, or: Simd<T, N>, ) -> Simd<T, N>
portable_simd
#86656)Reads from indices in slice
to construct a SIMD vector.
The mask enable
s all true
indices and disables all false
indices.
If an index is disabled, the element is selected from the or
vector.
§Safety
Calling this function with an enable
d out-of-bounds index is undefined behavior
even if the resulting value is not used.
§Examples
let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let idxs = Simd::from_array([9, 3, 0, 5]); // Includes an out-of-bounds index
let alt = Simd::from_array([-5, -4, -3, -2]);
let enable = Mask::from_array([true, true, true, false]); // Includes a masked element
// If this mask was used to gather, it would be unsound. Let's fix that.
let enable = enable & idxs.simd_lt(Simd::splat(vec.len()));
// The out-of-bounds index has been masked, so it's safe to gather now.
let result = unsafe { Simd::gather_select_unchecked(&vec, enable, idxs, alt) };
assert_eq!(result, Simd::from_array([-5, 13, 10, -2]));
sourcepub unsafe fn gather_ptr(source: Simd<*const T, N>) -> Simd<T, N>where
T: Default,
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn gather_ptr(source: Simd<*const T, N>) -> Simd<T, N>where
T: Default,
portable_simd
#86656)Reads elementwise from pointers into a SIMD vector.
§Safety
Each read must satisfy the same conditions as core::ptr::read
.
§Example
let values = [6, 2, 4, 9];
let offsets = Simd::from_array([1, 0, 0, 3]);
let source = Simd::splat(values.as_ptr()).wrapping_add(offsets);
let gathered = unsafe { Simd::gather_ptr(source) };
assert_eq!(gathered, Simd::from_array([2, 6, 6, 9]));
sourcepub unsafe fn gather_select_ptr(
source: Simd<*const T, N>,
enable: Mask<isize, N>,
or: Simd<T, N>,
) -> Simd<T, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn gather_select_ptr( source: Simd<*const T, N>, enable: Mask<isize, N>, or: Simd<T, N>, ) -> Simd<T, N>
portable_simd
#86656)Conditionally read elementwise from pointers into a SIMD vector.
The mask enable
s all true
pointers and disables all false
pointers.
If a pointer is disabled, the element is selected from the or
vector,
and no read is performed.
§Safety
Enabled elements must satisfy the same conditions as core::ptr::read
.
§Example
let values = [6, 2, 4, 9];
let enable = Mask::from_array([true, true, false, true]);
let offsets = Simd::from_array([1, 0, 0, 3]);
let source = Simd::splat(values.as_ptr()).wrapping_add(offsets);
let gathered = unsafe { Simd::gather_select_ptr(source, enable, Simd::splat(0)) };
assert_eq!(gathered, Simd::from_array([2, 6, 0, 9]));
sourcepub fn store_select(
self,
slice: &mut [T],
enable: Mask<<T as SimdElement>::Mask, N>,
)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn store_select( self, slice: &mut [T], enable: Mask<<T as SimdElement>::Mask, N>, )
portable_simd
#86656)Conditionally write contiguous elements to slice
. The enable
mask controls
which elements are written, as long as they’re in-bounds of the slice
.
If the element is disabled or out of bounds, no memory access to that location
is made.
§Examples
let mut arr = [0i32; 4];
let write = Simd::from_array([-5, -4, -3, -2]);
let enable = Mask::from_array([false, true, true, true]);
write.store_select(&mut arr[..3], enable);
assert_eq!(arr, [0, -4, -3, 0]);
sourcepub unsafe fn store_select_unchecked(
self,
slice: &mut [T],
enable: Mask<<T as SimdElement>::Mask, N>,
)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn store_select_unchecked( self, slice: &mut [T], enable: Mask<<T as SimdElement>::Mask, N>, )
portable_simd
#86656)Conditionally write contiguous elements to slice
. The enable
mask controls
which elements are written.
§Safety
Every enabled element must be in bounds for the slice
.
§Examples
let mut arr = [0i32; 4];
let write = Simd::from_array([-5, -4, -3, -2]);
let enable = Mask::from_array([false, true, true, true]);
unsafe { write.store_select_unchecked(&mut arr, enable) };
assert_eq!(arr, [0, -4, -3, -2]);
sourcepub unsafe fn store_select_ptr(
self,
ptr: *mut T,
enable: Mask<<T as SimdElement>::Mask, N>,
)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn store_select_ptr( self, ptr: *mut T, enable: Mask<<T as SimdElement>::Mask, N>, )
portable_simd
#86656)Conditionally write contiguous elements starting from ptr
.
The enable
mask controls which elements are written.
When disabled, the memory location corresponding to that element is not accessed.
§Safety
Memory addresses for element are calculated pointer::wrapping_offset
and
each enabled element must satisfy the same conditions as core::ptr::write
.
sourcepub fn scatter(self, slice: &mut [T], idxs: Simd<usize, N>)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn scatter(self, slice: &mut [T], idxs: Simd<usize, N>)
portable_simd
#86656)Writes the values in a SIMD vector to potentially discontiguous indices in slice
.
If an index is out-of-bounds, the write is suppressed without panicking.
If two elements in the scattered vector would write to the same index
only the last element is guaranteed to actually be written.
§Examples
let mut vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let idxs = Simd::from_array([9, 3, 0, 0]); // Note the duplicate index.
let vals = Simd::from_array([-27, 82, -41, 124]);
vals.scatter(&mut vec, idxs); // two logical writes means the last wins.
assert_eq!(vec, vec![124, 11, 12, 82, 14, 15, 16, 17, 18]);
sourcepub fn scatter_select(
self,
slice: &mut [T],
enable: Mask<isize, N>,
idxs: Simd<usize, N>,
)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn scatter_select( self, slice: &mut [T], enable: Mask<isize, N>, idxs: Simd<usize, N>, )
portable_simd
#86656)Writes values from a SIMD vector to multiple potentially discontiguous indices in slice
.
The mask enable
s all true
indices and disables all false
indices.
If an enabled index is out-of-bounds, the write is suppressed without panicking.
If two enabled elements in the scattered vector would write to the same index,
only the last element is guaranteed to actually be written.
§Examples
let mut vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let idxs = Simd::from_array([9, 3, 0, 0]); // Includes an out-of-bounds index
let vals = Simd::from_array([-27, 82, -41, 124]);
let enable = Mask::from_array([true, true, true, false]); // Includes a masked element
vals.scatter_select(&mut vec, enable, idxs); // The last write is masked, thus omitted.
assert_eq!(vec, vec![-41, 11, 12, 82, 14, 15, 16, 17, 18]);
sourcepub unsafe fn scatter_select_unchecked(
self,
slice: &mut [T],
enable: Mask<isize, N>,
idxs: Simd<usize, N>,
)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn scatter_select_unchecked( self, slice: &mut [T], enable: Mask<isize, N>, idxs: Simd<usize, N>, )
portable_simd
#86656)Writes values from a SIMD vector to multiple potentially discontiguous indices in slice
.
The mask enable
s all true
indices and disables all false
indices.
If two enabled elements in the scattered vector would write to the same index,
only the last element is guaranteed to actually be written.
§Safety
Calling this function with an enabled out-of-bounds index is undefined behavior, and may lead to memory corruption.
§Examples
let mut vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let idxs = Simd::from_array([9, 3, 0, 0]);
let vals = Simd::from_array([-27, 82, -41, 124]);
let enable = Mask::from_array([true, true, true, false]); // Masks the final index
// If this mask was used to scatter, it would be unsound. Let's fix that.
let enable = enable & idxs.simd_lt(Simd::splat(vec.len()));
// We have masked the OOB index, so it's safe to scatter now.
unsafe { vals.scatter_select_unchecked(&mut vec, enable, idxs); }
// The second write to index 0 was masked, thus omitted.
assert_eq!(vec, vec![-41, 11, 12, 82, 14, 15, 16, 17, 18]);
sourcepub unsafe fn scatter_ptr(self, dest: Simd<*mut T, N>)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn scatter_ptr(self, dest: Simd<*mut T, N>)
portable_simd
#86656)Writes pointers elementwise into a SIMD vector.
§Safety
Each write must satisfy the same conditions as core::ptr::write
.
§Example
let mut values = [0; 4];
let offset = Simd::from_array([3, 2, 1, 0]);
let ptrs = Simd::splat(values.as_mut_ptr()).wrapping_add(offset);
unsafe { Simd::from_array([6, 3, 5, 7]).scatter_ptr(ptrs); }
assert_eq!(values, [7, 5, 3, 6]);
sourcepub unsafe fn scatter_select_ptr(
self,
dest: Simd<*mut T, N>,
enable: Mask<isize, N>,
)
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub unsafe fn scatter_select_ptr( self, dest: Simd<*mut T, N>, enable: Mask<isize, N>, )
portable_simd
#86656)Conditionally write pointers elementwise into a SIMD vector.
The mask enable
s all true
pointers and disables all false
pointers.
If a pointer is disabled, the write to its pointee is skipped.
§Safety
Enabled pointers must satisfy the same conditions as core::ptr::write
.
§Example
let mut values = [0; 4];
let offset = Simd::from_array([3, 2, 1, 0]);
let ptrs = Simd::splat(values.as_mut_ptr()).wrapping_add(offset);
let enable = Mask::from_array([true, true, false, false]);
unsafe { Simd::from_array([6, 3, 5, 7]).scatter_select_ptr(ptrs, enable); }
assert_eq!(values, [0, 0, 3, 6]);
source§impl<const N: usize> Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
impl<const N: usize> Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
sourcepub fn swizzle_dyn(self, idxs: Simd<u8, N>) -> Simd<u8, N>
🔬This is a nightly-only experimental API. (portable_simd
#86656)
pub fn swizzle_dyn(self, idxs: Simd<u8, N>) -> Simd<u8, N>
portable_simd
#86656)Swizzle a vector of bytes according to the index vector. Indices within range select the appropriate byte. Indices “out of bounds” instead select 0.
Note that the current implementation is selected during build-time
of the standard library, so cargo build -Zbuild-std
may be necessary
to unlock better performance, especially for larger vectors.
A planned compiler improvement will enable using #[target_feature]
instead.
Trait Implementations
source§impl<T, U, const N: usize> AddAssign<U> for Simd<T, N>
impl<T, U, const N: usize> AddAssign<U> for Simd<T, N>
source§fn add_assign(&mut self, rhs: U)
fn add_assign(&mut self, rhs: U)
+=
operation. Read moresource§impl<T, U, const N: usize> BitAndAssign<U> for Simd<T, N>
impl<T, U, const N: usize> BitAndAssign<U> for Simd<T, N>
source§fn bitand_assign(&mut self, rhs: U)
fn bitand_assign(&mut self, rhs: U)
&=
operation. Read moresource§impl<T, U, const N: usize> BitOrAssign<U> for Simd<T, N>
impl<T, U, const N: usize> BitOrAssign<U> for Simd<T, N>
source§fn bitor_assign(&mut self, rhs: U)
fn bitor_assign(&mut self, rhs: U)
|=
operation. Read moresource§impl<T, U, const N: usize> BitXorAssign<U> for Simd<T, N>
impl<T, U, const N: usize> BitXorAssign<U> for Simd<T, N>
source§fn bitxor_assign(&mut self, rhs: U)
fn bitxor_assign(&mut self, rhs: U)
^=
operation. Read moresource§impl<T, U, const N: usize> DivAssign<U> for Simd<T, N>
impl<T, U, const N: usize> DivAssign<U> for Simd<T, N>
source§fn div_assign(&mut self, rhs: U)
fn div_assign(&mut self, rhs: U)
/=
operation. Read moresource§impl<T, U, const N: usize> MulAssign<U> for Simd<T, N>
impl<T, U, const N: usize> MulAssign<U> for Simd<T, N>
source§fn mul_assign(&mut self, rhs: U)
fn mul_assign(&mut self, rhs: U)
*=
operation. Read moresource§impl<T, const N: usize> Ord for Simd<T, N>
impl<T, const N: usize> Ord for Simd<T, N>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T, const N: usize> PartialOrd for Simd<T, N>
impl<T, const N: usize> PartialOrd for Simd<T, N>
source§impl<'a, const N: usize> Product<&'a Simd<u8, N>> for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
impl<'a, const N: usize> Product<&'a Simd<u8, N>> for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
source§impl<T, U, const N: usize> RemAssign<U> for Simd<T, N>
impl<T, U, const N: usize> RemAssign<U> for Simd<T, N>
source§fn rem_assign(&mut self, rhs: U)
fn rem_assign(&mut self, rhs: U)
%=
operation. Read moresource§impl<T, U, const N: usize> ShlAssign<U> for Simd<T, N>
impl<T, U, const N: usize> ShlAssign<U> for Simd<T, N>
source§fn shl_assign(&mut self, rhs: U)
fn shl_assign(&mut self, rhs: U)
<<=
operation. Read moresource§impl<T, U, const N: usize> ShrAssign<U> for Simd<T, N>
impl<T, U, const N: usize> ShrAssign<U> for Simd<T, N>
source§fn shr_assign(&mut self, rhs: U)
fn shr_assign(&mut self, rhs: U)
>>=
operation. Read moresource§impl<const N: usize> SimdOrd for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
impl<const N: usize> SimdOrd for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
source§fn simd_max(self, other: Simd<u8, N>) -> Simd<u8, N>
fn simd_max(self, other: Simd<u8, N>) -> Simd<u8, N>
portable_simd
#86656)other
.source§impl<const N: usize> SimdPartialEq for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
impl<const N: usize> SimdPartialEq for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
source§type Mask = Mask<<u8 as SimdElement>::Mask, N>
type Mask = Mask<<u8 as SimdElement>::Mask, N>
portable_simd
#86656)source§impl<const N: usize> SimdPartialOrd for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
impl<const N: usize> SimdPartialOrd for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
source§fn simd_lt(self, other: Simd<u8, N>) -> <Simd<u8, N> as SimdPartialEq>::Mask
fn simd_lt(self, other: Simd<u8, N>) -> <Simd<u8, N> as SimdPartialEq>::Mask
portable_simd
#86656)other
.source§fn simd_le(self, other: Simd<u8, N>) -> <Simd<u8, N> as SimdPartialEq>::Mask
fn simd_le(self, other: Simd<u8, N>) -> <Simd<u8, N> as SimdPartialEq>::Mask
portable_simd
#86656)other
.source§impl<const N: usize> SimdUint for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
impl<const N: usize> SimdUint for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
source§type Scalar = u8
type Scalar = u8
portable_simd
#86656)source§type Cast<T: SimdElement> = Simd<T, N>
type Cast<T: SimdElement> = Simd<T, N>
portable_simd
#86656)source§fn cast<T>(self) -> <Simd<u8, N> as SimdUint>::Cast<T>where
T: SimdCast,
fn cast<T>(self) -> <Simd<u8, N> as SimdUint>::Cast<T>where
T: SimdCast,
portable_simd
#86656)source§fn wrapping_neg(self) -> Simd<u8, N>
fn wrapping_neg(self) -> Simd<u8, N>
portable_simd
#86656)source§fn saturating_add(self, second: Simd<u8, N>) -> Simd<u8, N>
fn saturating_add(self, second: Simd<u8, N>) -> Simd<u8, N>
portable_simd
#86656)source§fn saturating_sub(self, second: Simd<u8, N>) -> Simd<u8, N>
fn saturating_sub(self, second: Simd<u8, N>) -> Simd<u8, N>
portable_simd
#86656)source§fn reduce_sum(self) -> <Simd<u8, N> as SimdUint>::Scalar
fn reduce_sum(self) -> <Simd<u8, N> as SimdUint>::Scalar
portable_simd
#86656)source§fn reduce_product(self) -> <Simd<u8, N> as SimdUint>::Scalar
fn reduce_product(self) -> <Simd<u8, N> as SimdUint>::Scalar
portable_simd
#86656)source§fn reduce_max(self) -> <Simd<u8, N> as SimdUint>::Scalar
fn reduce_max(self) -> <Simd<u8, N> as SimdUint>::Scalar
portable_simd
#86656)source§fn reduce_min(self) -> <Simd<u8, N> as SimdUint>::Scalar
fn reduce_min(self) -> <Simd<u8, N> as SimdUint>::Scalar
portable_simd
#86656)source§fn reduce_and(self) -> <Simd<u8, N> as SimdUint>::Scalar
fn reduce_and(self) -> <Simd<u8, N> as SimdUint>::Scalar
portable_simd
#86656)source§fn reduce_or(self) -> <Simd<u8, N> as SimdUint>::Scalar
fn reduce_or(self) -> <Simd<u8, N> as SimdUint>::Scalar
portable_simd
#86656)source§fn reduce_xor(self) -> <Simd<u8, N> as SimdUint>::Scalar
fn reduce_xor(self) -> <Simd<u8, N> as SimdUint>::Scalar
portable_simd
#86656)source§fn swap_bytes(self) -> Simd<u8, N>
fn swap_bytes(self) -> Simd<u8, N>
portable_simd
#86656)source§fn reverse_bits(self) -> Simd<u8, N>
fn reverse_bits(self) -> Simd<u8, N>
portable_simd
#86656)source§fn leading_zeros(self) -> Simd<u8, N>
fn leading_zeros(self) -> Simd<u8, N>
portable_simd
#86656)source§fn trailing_zeros(self) -> Simd<u8, N>
fn trailing_zeros(self) -> Simd<u8, N>
portable_simd
#86656)source§impl<T, U, const N: usize> SubAssign<U> for Simd<T, N>
impl<T, U, const N: usize> SubAssign<U> for Simd<T, N>
source§fn sub_assign(&mut self, rhs: U)
fn sub_assign(&mut self, rhs: U)
-=
operation. Read moresource§impl<'a, const N: usize> Sum<&'a Simd<u8, N>> for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
impl<'a, const N: usize> Sum<&'a Simd<u8, N>> for Simd<u8, N>where
LaneCount<N>: SupportedLaneCount,
source§impl ToBytes for Simd<u8, 64>
impl ToBytes for Simd<u8, 64>
source§type Bytes = Simd<u8, core::::core_simd::to_bytes::{impl#6}::Bytes::{constant#0}>
type Bytes = Simd<u8, core::::core_simd::to_bytes::{impl#6}::Bytes::{constant#0}>
portable_simd
#86656)source§fn to_ne_bytes(self) -> <Simd<u8, 64> as ToBytes>::Bytes
fn to_ne_bytes(self) -> <Simd<u8, 64> as ToBytes>::Bytes
portable_simd
#86656)source§fn to_be_bytes(self) -> <Simd<u8, 64> as ToBytes>::Bytes
fn to_be_bytes(self) -> <Simd<u8, 64> as ToBytes>::Bytes
portable_simd
#86656)source§fn to_le_bytes(self) -> <Simd<u8, 64> as ToBytes>::Bytes
fn to_le_bytes(self) -> <Simd<u8, 64> as ToBytes>::Bytes
portable_simd
#86656)source§fn from_ne_bytes(bytes: <Simd<u8, 64> as ToBytes>::Bytes) -> Simd<u8, 64>
fn from_ne_bytes(bytes: <Simd<u8, 64> as ToBytes>::Bytes) -> Simd<u8, 64>
portable_simd
#86656)