Skip to main content

SimdCapabilityInfo

Struct SimdCapabilityInfo 

Source
pub struct SimdCapabilityInfo {
    pub has_sse42: bool,
    pub has_avx: bool,
    pub has_avx2: bool,
    pub has_fma: bool,
    pub has_avx512f: bool,
    pub has_avx512bw: bool,
    pub has_avx512vl: bool,
    pub has_neon: bool,
    pub has_sve: bool,
    pub cache_line_bytes: usize,
    pub vector_width_bytes: usize,
}
Expand description

Extended CPU SIMD capability description with the field naming convention required by the multi-versioning layer.

On std-enabled builds, SimdCapabilityInfo::detect returns a &'static Self reference that is initialised exactly once per process (via OnceLock). On no_std builds it returns a fresh Self value computed from compile-time cfg! constants.

Fields§

§has_sse42: bool

SSE4.2 support (x86-64 only).

§has_avx: bool

AVX support (x86-64 only).

§has_avx2: bool

AVX2 support (x86-64 only).

§has_fma: bool

FMA (Fused Multiply-Add) support (x86-64 only).

§has_avx512f: bool

AVX-512 Foundation support (x86-64 only).

§has_avx512bw: bool

AVX-512 Byte & Word instructions (x86-64 only).

§has_avx512vl: bool

AVX-512 Vector Length extensions (x86-64 only).

§has_neon: bool

NEON support. Always true on AArch64.

§has_sve: bool

SVE (Scalable Vector Extension) support.

§cache_line_bytes: usize

Bytes in a single cache line (typically 64 on modern CPUs).

§vector_width_bytes: usize

Width of the widest supported SIMD vector register in bytes.

Implementations§

Source§

impl SimdCapabilityInfo

Source

pub fn detect() -> &'static Self

Detect (or derive) capabilities for the current CPU and return a reference to the process-wide cached value.

The first call performs runtime detection and stores the result. Subsequent calls return the same &'static reference.

Source

pub fn has_avx512_full(&self) -> bool

Returns true when AVX-512F, BW, and VL are all present.

Source

pub fn has_avx2_fma(&self) -> bool

Returns true when both AVX2 and FMA are present.

Source

pub fn f64_simd_width(&self) -> usize

Number of f64 elements that fit in the widest supported SIMD register.

For AVX-512 this is 8; for AVX2 / NEON-128 this is 4 / 2; for scalar 1.

Source

pub fn f32_simd_width(&self) -> usize

Number of f32 elements that fit in the widest supported SIMD register.

Always twice f64_simd_width().

Source

pub fn optimal_level(&self) -> LegacyLevel

Returns the LegacyLevel that best summarises these capabilities.

Trait Implementations§

Source§

impl Clone for SimdCapabilityInfo

Source§

fn clone(&self) -> SimdCapabilityInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SimdCapabilityInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SimdCapabilityInfo

Source§

fn eq(&self, other: &SimdCapabilityInfo) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SimdCapabilityInfo

Source§

impl Eq for SimdCapabilityInfo

Source§

impl StructuralPartialEq for SimdCapabilityInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.