src/features/cpu.c file

Functions

void vm_dispatch_init32(void)
auto vm_backend_best32(void) -> const vm_backend*
void vm_dispatch_init64(void)
auto vm_backend_best64(void) -> const vm_backend*
static auto force_isa(void) -> vm_cpu_features_t
static auto cpu_probe_neon(void) -> int
Probes AArch64 Advanced SIMD (NEON).
static auto cpu_probe_sve(void) -> int
Probes SVE via Linux AT_HWCAP.
static auto cpu_probe_sve2(void) -> int
Probes SVE2 via Linux AT_HWCAP2.
static auto cpu_probe_arm_fp16(void) -> int
Probes AArch64 vector FP16 (HWCAP_ASIMDHP).
static auto cpu_probe_arm_bf16(void) -> int
Probes AArch64 BF16 (HWCAP2_BF16).
static auto cpu_probe_i8mm(void) -> int
Probes AArch64 I8MM (HWCAP2_I8MM).
auto vm_cpu_compiled_features(void) -> vm_cpu_features_t
ISA bits compiled into this binary.
auto vm_cpu_runtime_features(void) -> vm_cpu_features_t
ISA bits detected on this CPU (cached).
auto vm_cpu_selected_features(void) -> vm_cpu_features_t
Highest-priority ISA that is both compiled and present.
auto vm_cpu_name(const vm_cpu_features_t features) -> const char*
Short name of the highest bit set in features.
auto vm_cpu_note(void) -> const char*
Optional one-line note set by a registered module.
void vm_cpu_set_note(const char* note)
Attach a module note for banners.
auto vm_compiled_float_bits(void) -> unsigned
Float widths compiled into this library (32, 64, or 32|64).
void vm_cpu_init(void)
Probe once and bind dispatched _ptr names.

Variables

static vm_cpu_features_t runtime_cache
static const char* module_note
static atomic_int runtime_cached
static atomic_flag runtime_lock
vm_cpu_features_t level
vm_cpu_features_t tier
static const struct @367051055320315055127163050306056335011212072013 cpu_ladder
Tiers in priority order: the first level fully present wins.

Defines

#define VM_CPU_BACKEND_BEST

Function documentation

static int cpu_probe_neon(void)

Probes AArch64 Advanced SIMD (NEON).

Returns Non-zero if NEON / ASIMD is usable.

ASIMD is mandatory on AArch64, so non-Linux targets (Apple, BSD, Windows) report it as present. Linux still consults AT_HWCAP.

static int cpu_probe_sve(void)

Probes SVE via Linux AT_HWCAP.

Returns Non-zero if SVE is usable.

static int cpu_probe_sve2(void)

Probes SVE2 via Linux AT_HWCAP2.

Returns Non-zero if SVE2 is usable.

static int cpu_probe_arm_fp16(void)

Probes AArch64 vector FP16 (HWCAP_ASIMDHP).

Returns Non-zero if Advanced SIMD half-precision is usable.

static int cpu_probe_arm_bf16(void)

Probes AArch64 BF16 (HWCAP2_BF16).

Returns Non-zero if BF16 is usable.

static int cpu_probe_i8mm(void)

Probes AArch64 I8MM (HWCAP2_I8MM).

Returns Non-zero if integer 8-bit matrix multiply is usable.

vm_cpu_features_t vm_cpu_compiled_features(void)

ISA bits compiled into this binary.

Returns Feature mask of enabled backends.

ISA bits compiled into this library (VECMAT_ENABLE_*).

vm_cpu_features_t vm_cpu_runtime_features(void)

ISA bits detected on this CPU (cached).

Returns Feature mask of usable backends.

ISA bits detected on this CPU (runtime probe).

vm_cpu_features_t vm_cpu_selected_features(void)

Highest-priority ISA that is both compiled and present.

Returns Single selected feature bit (or scalar).

ISA the picker bound: registered backend, else best compiled-and-runtime.

const char* vm_cpu_name(const vm_cpu_features_t features)

Short name of the highest bit set in features.

Parameters
features Feature mask.
Returns Stable string such as avx2 or scalar.

Short name for a feature mask (avx2, neon, scalar, etc.).

const char* vm_cpu_note(void)

Optional one-line note set by a registered module.

NULL until a module calls vm_cpu_set_note(). The pointer is not copied.

void vm_cpu_set_note(const char* note)

Attach a module note for banners.

Pass NULL to clear.

void vm_cpu_init(void)

Probe once and bind dispatched _ptr names.

Thread-safe and idempotent (C11 atomics, double-checked locking). Call before reading vm_cpu_selected_features() if you care about the first-use race; kernels themselves call this on first use.

Variable documentation

static const struct @367051055320315055127163050306056335011212072013 cpu_ladder

Tiers in priority order: the first level fully present wins.

AVX2 needs FMA (its files are built with -mfma); without it it falls to the next row. AVX-512F is also built with -mfma but implies FMA. RISC-V V will add a VM_LEVEL_RVV row.