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>;
}
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>

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.

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§

type Native<S: Simd> = <S as Simd>::i8s

Source§

impl SimdIntElement for i16

Source§

type Native<S: Simd> = <S as Simd>::i16s

Source§

impl SimdIntElement for i32

Source§

type Native<S: Simd> = <S as Simd>::i32s

Source§

impl SimdIntElement for i64

Source§

type Native<S: Simd> = <S as Simd>::i64s

Source§

impl SimdIntElement for u8

Source§

type Native<S: Simd> = <S as Simd>::u8s

Source§

impl SimdIntElement for u16

Source§

type Native<S: Simd> = <S as Simd>::u16s

Source§

impl SimdIntElement for u32

Source§

type Native<S: Simd> = <S as Simd>::u32s

Source§

impl SimdIntElement for u64

Source§

type Native<S: Simd> = <S as Simd>::u64s

Implementors§