lance_linalg::simd

Trait SIMD

Source
pub trait SIMD<T: Num + Copy, const N: usize>:
    Debug
    + AddAssign<Self>
    + Add<Self, Output = Self>
    + Mul<Self, Output = Self>
    + Sub<Self, Output = Self>
    + SubAssign<Self>
    + Copy
    + Clone
    + Sized
    + for<'a> From<&'a [T]> {
    const LANES: usize = N;

    // Required methods
    fn splat(val: T) -> Self;
    fn zeros() -> Self;
    unsafe fn load(ptr: *const T) -> Self;
    unsafe fn load_unaligned(ptr: *const T) -> Self;
    unsafe fn store(&self, ptr: *mut T);
    unsafe fn store_unaligned(&self, ptr: *mut T);
    fn reduce_sum(&self) -> T;
    fn reduce_min(&self) -> T;
    fn min(&self, rhs: &Self) -> Self;
    fn find(&self, val: T) -> Option<i32>;

    // Provided method
    fn as_array(&self) -> [T; N] { ... }
}
Expand description

Lance SIMD lib

Provided Associated Constants§

Source

const LANES: usize = N

Required Methods§

Source

fn splat(val: T) -> Self

Create a new instance with all lanes set to val.

Source

fn zeros() -> Self

Create a new instance with all lanes set to zero.

Source

unsafe fn load(ptr: *const T) -> Self

Gather elements from the slice, using i32 indices. Load aligned data from aligned memory.

§Safety

It crashes if the ptr is not aligned.

Source

unsafe fn load_unaligned(ptr: *const T) -> Self

Load unaligned data from memory.

§Safety
Source

unsafe fn store(&self, ptr: *mut T)

Store the values to aligned memory.

§Safety

It crashes if the ptr is not aligned

Source

unsafe fn store_unaligned(&self, ptr: *mut T)

Store the values to unaligned memory.

§Safety
Source

fn reduce_sum(&self) -> T

Calculate the sum across this vector.

Source

fn reduce_min(&self) -> T

Find the minimal value in the vector.

Source

fn min(&self, rhs: &Self) -> Self

Return the minimal value of these two vectors.

Source

fn find(&self, val: T) -> Option<i32>

Find the index of value in the vector. If not found, return None.

Provided Methods§

Source

fn as_array(&self) -> [T; N]

Return the values as an array.

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 SIMD<f32, 8> for f32x8

Source§

impl SIMD<f32, 16> for f32x16

Source§

impl SIMD<i32, 8> for i32x8