Veritable Lasagna
An Allocator & Data Structure Library for C.
Loading...
Searching...
No Matches
vl_simd.c File Reference
#include <string.h>
#include <vl/vl_libconfig.h>
#include <vl/vl_simd.h>
#include "platform/vl_simd_portable.c"
+ Include dependency graph for vl_simd.c:

Functions

const char * vlSIMDInit (void)
 Initializes the SIMD subsystem and selects the best available backend.
 

Variables

vl_simd_functions_t vlSIMDFunctions
 Global SIMD function table.
 

Function Documentation

◆ vlSIMDInit()

const char * vlSIMDInit ( void  )

Initializes the SIMD subsystem and selects the best available backend.

Must be called once at application startup, before any SIMD operations. Thread-safe; subsequent calls return immediately and are safe from any thread.

Backend Selection Algorithm

  1. x86/x86-64: Check for AVX2 → SSE2 → fallback to Portable C
  2. ARM64: Use NEON64 (guaranteed available) → fallback to Portable C
  3. ARM32: Use NEON (if available) → fallback to Portable C
  4. Other: Use Portable C

CPU capability detection uses:

  • CPUID instruction (x86/MSVC and GCC/Clang)
  • Compile-time guarantees (ARM with -mfpu=neon)

Example

int main() {
const char* backend = vlSIMDInit();
printf("SIMD backend: %s\n", backend);
// SIMD operations now use best available backend
vl_simd_vec4_f32 v = vlSIMDLoadVec4F32(data);
// ...
return 0;
}
const char * vlSIMDInit(void)
Initializes the SIMD subsystem and selects the best available backend.
Definition vl_simd.c:135
vl_simd_vec4_f32
Definition vl_simd.h:223
Returns
Pointer to a static string naming the selected backend. Examples: "SSE2", "AVX2", "NEON64", "NEON (ARMv7)", "Portable C". Pointer is valid for the lifetime of the program.
Note
Safe to call from any thread. Repeated calls are safe and return immediately on subsequent invocations.
See also
vlSIMDFunctions, vl_simd_functions_t
+ Here is the call graph for this function:

Variable Documentation

◆ vlSIMDFunctions

vl_simd_functions_t vlSIMDFunctions

Global SIMD function table.

Set by vlSIMDInit(). Thread-safe to read after initialization. Do not modify after initialization.

See also
vlSIMDInit, vl_simd_functions_t