Skip to main content

Simd

Trait Simd 

Source
pub trait Simd: Copy + Debug {
    type Array: AsRef<[Self::Elem]> + Copy + Debug + IntoIterator<Item = Self::Elem> + PartialEq<Self::Array> + Index<usize, Output = Self::Elem> + IndexMut<usize, Output = Self::Elem>;
    type Elem: Elem;
    type Mask: Mask;
    type Isa: Isa;

    // Required methods
    fn to_bits(self) -> <Self::Isa as Isa>::Bits;
    fn from_bits(bits: <Self::Isa as Isa>::Bits) -> Self;
    fn to_array(self) -> Self::Array;

    // Provided methods
    fn reinterpret_cast<T>(self) -> T
       where T: Simd<Isa = Self::Isa> { ... }
    fn same_cast<T>(self) -> T
       where T: Simd<Elem = Self::Elem, Isa = Self::Isa> { ... }
}
Expand description

SIMD vector type.

Required Associated Types§

Source

type Array: AsRef<[Self::Elem]> + Copy + Debug + IntoIterator<Item = Self::Elem> + PartialEq<Self::Array> + Index<usize, Output = Self::Elem> + IndexMut<usize, Output = Self::Elem>

Representation of this vector as a [Self::Elem; N] array.

Source

type Elem: Elem

Type of data held in each SIMD lane.

Source

type Mask: Mask

Mask with the same number of elements as this vector.

Source

type Isa: Isa

The ISA associated with this SIMD vector.

Required Methods§

Source

fn to_bits(self) -> <Self::Isa as Isa>::Bits

Convert this SIMD vector to the common “bits” type used by all vectors in this family.

Source

fn from_bits(bits: <Self::Isa as Isa>::Bits) -> Self

Convert this SIMD vector from the common “bits” type used by all vectors in this family.

Source

fn to_array(self) -> Self::Array

Convert self to a SIMD array.

This is a cheap transmute in most cases, since SIMD vectors usually have the same layout as [S::Elem; N] but a greater alignment.

Provided Methods§

Source

fn reinterpret_cast<T>(self) -> T
where T: Simd<Isa = Self::Isa>,

Reinterpret the bits of this vector as another vector from the same family.

Source

fn same_cast<T>(self) -> T
where T: Simd<Elem = Self::Elem, Isa = Self::Isa>,

Cast this vector to another with the same ISA and element type.

This cast is a no-op which doesn’t generate any code. It is needed in some cases to downcast a Simd type to one of an Isas associated types, or vice-versa.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§