A small SIMD numerical library in C. A dispatch table picks AVX2, SSE2, ARM NEON or scalar implementations at runtime from CPUID, and on top of that sit N-dimensional float arrays and an FFT.
- SIMD layer: 8-float vector type with add, mul and fused multiply-add (AVX2 with FMA, SSE2, scalar), chosen at runtime with CPUID
- Arrays: N-dimensional float arrays with a stride-based layout, views, and broadcasting
- Expressions: a lazy expression tree (add, mul, scalar mul) evaluated in one pass over the output, with no temporary arrays
- FFT: radix-2 FFT with precomputed twiddle factors and an AVX2 path, plus inverse and real-input variants
include/ headers (simd_abstraction.h, array.h, fft.h)
src/ simd_abstraction.c, array.c, fft.c
tests/ test_simd.c, test_array.c, test_fft.c
Makefile
Requires gcc on x86-64 (the Makefile uses -mavx2 -msse2 -mfma -fopenmp).
make test-simd
make test-array
make test-fft # test_fft.c includes windows.h, so Windows only for now
make clean
simd_dispatch_t* d = simd_init_dispatch();
simd_vec_t a = simd_load(x), b = simd_load(y);
simd_store(out, d->add(a, b));
simd_free_dispatch(d);