SimdBaseGatherable

Trait SimdBaseGatherable 

Source
pub trait SimdBaseGatherable<IV: SimdBase>: SimdBase {
    // Required methods
    unsafe fn gather(base: *const Self::Scalar, indices: IV) -> Self;
    unsafe fn gather_masked(
        base: *const Self::Scalar,
        indices: IV,
        mask: Self,
        src: Self,
    ) -> Self;
}
Expand description

A vector supporting the gather operation (indexing into an array using indices from a vector).

Required Methods§

Source

unsafe fn gather(base: *const Self::Scalar, indices: IV) -> Self

Construct a vector by accessing values at base + indices[i].

§Safety

This operation is safe if std::ptr::read(base.add(indices[i])) is safe for all i.

§Example
let arr: Vec<i32> = (0..=1024).map(|x| x + 1).collect();
let out = unsafe {
    // SAFETY: All the indices are within bounds.
    I32x4::gather(arr.as_ptr(), U64x4::from([32, 647, 827, 920]))
};
assert_eq!(out, I32x4::from([33, 648, 828, 921]));
Source

unsafe fn gather_masked( base: *const Self::Scalar, indices: IV, mask: Self, src: Self, ) -> Self

Construct a vector by accessing values at base + indices[i], if the mask’s MSB is set. Else return src[i].

§Safety

This operation is safe if std::ptr::read(base.add(indices[i])) is safe for all i.

§Example
let arr: Vec<i32> = (0..=1024).map(|x| x + 1).collect();
let out = unsafe {
    // SAFETY: All the indices are within bounds.
    I32x4::gather_masked(
        arr.as_ptr(),
        U64x4::from([32, 647, 827, 920]),
        I32x4::from([-1, -1, 0, 0]),
        I32x4::from([1, 2, 3, 4]),
    )
};
assert_eq!(out, I32x4::from([33, 648, 3, 4]));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SimdBaseGatherable<I32x4> for I32x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I32x4> for I64x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I32x4> for U32x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I32x4> for U64x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I32x8> for I32x8

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I32x8> for U32x8

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I64x2> for I64x2

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I64x2> for U64x2

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I64x4> for I32x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I64x4> for I64x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I64x4> for U32x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<I64x4> for U64x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<U64x2> for I64x2

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<U64x2> for U64x2

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<U64x4> for I32x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<U64x4> for I64x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<U64x4> for U32x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned

Source§

impl SimdBaseGatherable<U64x4> for U64x4

§Safety

base does not need to be aligned. Forall i, base + indices[i] must meet the safety requirements of std::ptr::read_unaligned