std1.0.0-beta-7 SafeC docs

Module simd::cpu

#include <std/simd/cpu.h> source

which SIMD instruction sets the CPU runs.

std's hot kernels (sgemm, vmath, the FFT butterflies, dsp_dot_f64) are built in several versions and use the best one this returns, in order:

x86-64      AVX-512 (F+BW+DQ+VL) > AVX2 + FMA > AVX > SSE4.1 > SSE2
AArch64     SVE > Neon
Cortex-M    Helium (MVE) > DSP extension   -- compile time only: pick
            the target (arm-81m for Helium, arm-7em / arm-8m for DSP)
WebAssembly SIMD128 when built with it

On x86-64 and AArch64 Linux the level is detected once at run time (cpuid + xgetbv / getauxval), so one binary uses AVX-512 where it exists and still runs on an SSE2-only CPU. Whatever the build already guarantees (e.g. --target-cpu=native defines AVX2) is the floor. SAFEC_SIMD=sse2|sse4.1|avx|avx2|avx512|neon|sve caps the level, to test or compare the slower paths.

Functions

simd_levelThe best level available (detected once, then cached).
simd_level_name"AVX-512", "AVX2", ..., "scalar".

Macros

SIMD_SCALAR
SIMD_SSE2
SIMD_SSE41
SIMD_AVX
SIMD_AVX2AVX2 + FMA
SIMD_AVX512AVX-512 F, BW, DQ and VL
SIMD_NEON
SIMD_SVE
SIMD_DSPCortex-M DSP extension
SIMD_HELIUMCortex-M MVE
SIMD_WASM128