pub struct CpuFeatures {
pub avx2: bool,
pub avx512f: bool,
pub avx512bw: bool,
pub avx512vl: bool,
pub sse4_2: bool,
pub neon: bool,
}Expand description
CPU features detected at runtime.
Use CpuFeatures::detect to query the current CPU capabilities, or
detect_cpu_features for a cached version backed by a OnceLock.
Fields§
§avx2: boolAVX2 (256-bit integer / float SIMD).
avx512f: boolAVX-512 Foundation (512-bit float SIMD).
avx512bw: boolAVX-512 Byte-and-Word (512-bit byte/word integer SIMD).
avx512vl: boolAVX-512 Vector Length extensions (128/256-bit masked operations).
sse4_2: boolSSE 4.2 (128-bit SIMD with string/text processing extras).
neon: boolARM NEON (128-bit SIMD on aarch64).
Implementations§
Source§impl CpuFeatures
impl CpuFeatures
Sourcepub fn detect() -> Self
pub fn detect() -> Self
Detect CPU features on the current machine.
This is a thin wrapper around detect_cpu_features which caches the
result in a OnceLock so subsequent calls are free.
Sourcepub fn best_simd_width(&self) -> usize
pub fn best_simd_width(&self) -> usize
Return the widest available SIMD register width in bits.
| CPU capability | Width |
|---|---|
| AVX-512F | 512 |
| AVX2 | 256 |
| SSE 4.2 | 128 |
| scalar | 64 |
Trait Implementations§
Source§impl Clone for CpuFeatures
impl Clone for CpuFeatures
Source§fn clone(&self) -> CpuFeatures
fn clone(&self) -> CpuFeatures
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CpuFeatures
impl Debug for CpuFeatures
Source§impl PartialEq for CpuFeatures
impl PartialEq for CpuFeatures
impl Copy for CpuFeatures
impl Eq for CpuFeatures
impl StructuralPartialEq for CpuFeatures
Auto Trait Implementations§
impl Freeze for CpuFeatures
impl RefUnwindSafe for CpuFeatures
impl Send for CpuFeatures
impl Sync for CpuFeatures
impl Unpin for CpuFeatures
impl UnsafeUnpin for CpuFeatures
impl UnwindSafe for CpuFeatures
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more