Module std_detect::detect::arch::x86

source ·
🔬This is a nightly-only experimental API. (stdsimd)
Expand description

This module implements minimal run-time feature detection for x86.

The features are detected using the detect_features function below. This function uses the CPUID instruction to read the feature flags from the CPU and encodes them in a usize where each bit position represents whether a feature is available (bit is set) or unavailable (bit is cleared).

The enum Feature is used to map bit positions to feature names, and the the __crate::detect::check_for! macro is used to map string literals (e.g., “avx”) to these bit positions (e.g., Feature::avx).

The run-time feature detection is performed by the __crate::detect::check_for(Feature) -> bool function. On its first call, this functions queries the CPU for the available features and stores them in a global AtomicUsize variable. The query is performed by just checking whether the feature bit in this global variable is set or cleared.

Modules

  • Each function performs run-time feature detection for a single feature. This allow us to use stability attributes on a per feature basis.

Enums

  • Feature 🔒 Experimental
    Each variant denotes a position in a bitset for a particular feature.