LIBXS is a portable C library providing building blocks for memory operations, numerics, synchronization, and more -- with a focus on performance and minimal dependencies. Targets x86-64, AArch64, and RISC-V; requires only a C89 compiler. Originally developed as part of LIBXSMM.
| Domain | Header | Description |
|---|---|---|
| Memory | libxs_mem.h |
Comparison, hashing (CRC32), matrix copy/transpose, shuffle |
| GEMM | libxs_gemm.h |
Batched dense GEMM (strided, pointer-array, grouped) |
| Math | libxs_math.h |
Matrix comparison, GCD/LCM, coprime, BF16 conversion |
| MHD | libxs_mhd.h |
Read/write MetaImage (MHD/MHA) files |
| Histogram | libxs_hist.h |
Thread-safe histogram with running statistics |
| Malloc | libxs_malloc.h |
Pool-based allocator (steady-state, no system calls) |
| RNG | libxs_rng.h |
Thread-safe pseudo-random number generation (SplitMix64) |
| Sync | libxs_sync.h |
Portable atomics, locks, TLS, and file locking |
| Timer | libxs_timer.h |
High-resolution timing via calibrated TSC |
| CPUID | libxs_cpuid.h |
CPU feature detection (SSE to AVX-512, AArch64, RISC-V) |
| Registry | libxs_reg.h |
Thread-safe key-value store with per-thread caching |
| Utils | libxs_utils.h |
ISA feature gates, bit-scan, SIMD helpers |
See also: Fortran Interface, Scripts.
make GNU=1The library is compiled for SSE4.2 by default but dynamically
dispatches to the best ISA available at runtime (up to AVX-512).
Use SSE=0 to compile natively for the build host.
| Variable | Default | Description |
|---|---|---|
| GNU | 0 | Use GNU GCC-compatible compiler |
| DBG | 0 | Debug build |
| SYM | 0 | Include debug symbols (-g) |
| SSE | 1 | x86 baseline: 0=native, 1=SSE4.2 (portable) |
CMake is also supported (header-only or library):
cmake -S . -B build -DLIBXS_HEADER_ONLY=ON
cmake --build buildInstall into a chosen prefix:
make GNU=1 -j $(nproc) install PREFIX=$HOME/libxsThis installs headers, the Fortran module, the static and shared
libraries, and the header-only source tree under PREFIX.
Out-of-tree builds are also supported:
mkdir /tmp/libxs-build && cd /tmp/libxs-build
make -j $(nproc) -f /path/to/libxs/MakefileLibrary -- link against libxs.a (or .so) and include the
desired headers:
#include <libxs_mem.h>
#include <libxs_timer.h>Header-only (explicit) -- include libxs_source.h (no
separate library needed). Safe to include from multiple
translation units:
#include <libxs_source.h>Header-only (implicit) -- compile with -DLIBXS_SOURCE and
any LIBXS public header automatically includes the implementation.
No special include order is required. When used through
LIBXSTREAM without a
pre-built library (-DLIBXSTREAM_SOURCE), LIBXS_SOURCE is
implied automatically.
Fortran -- use the provided module (documentation):
USE :: libxs, ONLY: libxs_memcmp| Sample | Description |
|---|---|
| gemm | Batched DGEMM (strided, pointer-array, grouped) with OMP |
| memory | Benchmarks for comparison, matrix copy, and transpose |
| ozaki | Ozaki-scheme low-precision GEMM with intercepted BLAS |
| registry | Registry dispatch microbenchmark |
| scratch | Pool allocator vs system malloc |
| shuffle | Shuffling strategies comparison |
| sync | Lock implementation microbenchmarks |