Skip to main content

SimdIntElement

Trait SimdIntElement 

Source
pub trait SimdIntElement:
    SimdElement
    + Eq
    + Ord
    + Binary
    + Not<Output = Self>
    + Shl<usize, Output = Self>
    + ShlAssign<usize>
    + Shr<usize, Output = Self>
    + ShrAssign<usize>
    + BitAnd<Self, Output = Self>
    + BitAndAssign<Self>
    + BitOr<Self, Output = Self>
    + BitOrAssign<Self>
    + BitXor<Self, Output = Self>
    + BitXorAssign<Self>
    + TryFrom<u8, Error: Copy + Error + Eq>
    + TryFrom<u16, Error: Copy + Error + Eq>
    + TryFrom<u32, Error: Copy + Error + Eq>
    + TryFrom<u64, Error: Copy + Error + Eq>
    + TryFrom<u128, Error: Copy + Error + Eq>
    + TryFrom<usize, Error: Copy + Error + Eq>
    + TryFrom<i8, Error: Copy + Error + Eq>
    + TryFrom<i16, Error: Copy + Error + Eq>
    + TryFrom<i32, Error: Copy + Error + Eq>
    + TryFrom<i64, Error: Copy + Error + Eq>
    + TryFrom<i128, Error: Copy + Error + Eq>
    + TryFrom<isize, Error: Copy + Error + Eq>
    + for<'a> Shl<&'a usize, Output = Self>
    + for<'a> ShlAssign<&'a usize>
    + for<'a> Shr<&'a usize, Output = Self>
    + for<'a> ShrAssign<&'a usize>
    + for<'a> BitAnd<&'a Self, Output = Self>
    + for<'a> BitAndAssign<&'a Self>
    + for<'a> BitOr<&'a Self, Output = Self>
    + for<'a> BitOrAssign<&'a Self>
    + for<'a> BitXor<&'a Self, Output = Self>
    + for<'a> BitXorAssign<&'a Self> {
    type Native<S: Simd>: SimdInt<S, Element = Self, Unsigned = <Self::Unsigned as SimdIntElement>::Native<S>, Signed = <Self::Signed as SimdIntElement>::Native<S>>;
    type Unsigned: SimdIntElement<Mask = Self::Mask, Unsigned = Self::Unsigned, Signed = Self::Signed>;
    type Signed: SimdIntElement<Mask = Self::Mask, Unsigned = Self::Unsigned, Signed = Self::Signed>;
}
Expand description

Types that can be used as elements in integer SIMD vectors.

Self::Native selects the native-width vector for this scalar type and a SIMD backend, so an integer-generic caller can use crate::dispatch!:

use fearless_simd::{dispatch, prelude::*, Level};

#[inline(always)]
fn count_ones_simd<S: Simd, T: SimdIntElement>(simd: S, value: T) -> T {
    T::Native::<S>::splat(simd, value).count_ones()[0]
}

fn count_ones<T: SimdIntElement>(level: Level, value: T) -> T {
    dispatch!(level, simd => count_ones_simd(simd, value))
}

let level = Level::new();
assert_eq!(count_ones(level, 7_u8), 3);
assert_eq!(count_ones(level, 7_i64), 3);

Required Associated Types§

Source

type Native<S: Simd>: SimdInt<S, Element = Self, Unsigned = <Self::Unsigned as SimdIntElement>::Native<S>, Signed = <Self::Signed as SimdIntElement>::Native<S>>

The native-width integer vector for this scalar type and backend S.

Its lane count depends on both the scalar type and the backend, and is available as T::Native::<S>::LEN with SimdBase in scope.

Source

type Unsigned: SimdIntElement<Mask = Self::Mask, Unsigned = Self::Unsigned, Signed = Self::Signed>

The corresponding unsigned integer type for this signed integer type. E.g. u8 for i8.

If Self is already unsigned, this type will also be Self.

Source

type Signed: SimdIntElement<Mask = Self::Mask, Unsigned = Self::Unsigned, Signed = Self::Signed>

The corresponding signed integer type for this unsigned integer type. E.g. i8 for u8.

If Self is already signed, this type will also be Self.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl SimdIntElement for i8

Source§

impl SimdIntElement for i16

Source§

impl SimdIntElement for i32

Source§

impl SimdIntElement for i64

Source§

impl SimdIntElement for u8

Source§

impl SimdIntElement for u16

Source§

impl SimdIntElement for u32

Source§

impl SimdIntElement for u64

Implementors§