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 vm_force_isa(void) -> vm_cpu_features_t
static auto vm_cpu_probe_neon(void) -> int
Probes AArch64 Advanced SIMD (NEON).
static auto vm_cpu_probe_sve(void) -> int
Probes SVE via Linux AT_HWCAP.
static auto vm_cpu_probe_sve2(void) -> int
Probes SVE2 via Linux AT_HWCAP2.
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

Defines

#define VM_CPU_BACKEND_BEST

Function documentation

static int vm_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 vm_cpu_probe_sve(void)

Probes SVE via Linux AT_HWCAP.

Returns Non-zero if SVE is usable.

static int vm_cpu_probe_sve2(void)

Probes SVE2 via Linux AT_HWCAP2.

Returns Non-zero if SVE2 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.