LIBXS is a portable C library with common (and not so common) functionality that has proven useful across a variety of applications. It provides building blocks for memory operations, numerics, synchronization, and more — with a focus on performance and minimal dependencies. LIBXS targets x86-64, AArch64, and RISC-V, and requires only a C89 compiler.
LIBXS was originally developed as part of LIBXSMM (its existence started even before LIBXSMM).
| Domain | Header | Description |
|---|---|---|
| Memory | libxs_mem.h |
Comparison (memcmp/diff), hashing (CRC32), matrix copy, transpose, and data shuffling. |
| GEMM | libxs_gemm.h |
Batched dense matrix multiplication (strided, pointer-array, grouped) with pluggable BLAS/JIT kernels. |
| Math | libxs_math.h |
Matrix comparison, GCD/LCM, coprime calculation, and BF16 conversion. |
| MHD | libxs_mhd.h |
Read and write MetaImage (MHD/MHA) format files for multidimensional arrays. |
| Histogram | libxs_hist.h |
Thread-safe histogram with running statistics and per-entry callbacks. |
| Malloc | libxs_malloc.h |
Pool-based allocator for steady-state performance without system calls. |
| RNG | libxs_rng.h |
Thread-safe pseudo-random number generation (SplitMix64). |
| Sync | libxs_sync.h |
Portable atomics, locks, thread-local storage, and file locking. |
| Timer | libxs_timer.h |
High-resolution timing via calibrated TSC with OS clock fallback. |
| CPUID | libxs_cpuid.h |
CPU feature detection for x86-64 (SSE–AVX-512), AArch64, and RISC-V. |
| Registry | libxs_reg.h |
Thread-safe key-value store backed by hash table with per-thread caching. |
| Utils | libxs_utils.h |
Target-attribute machinery, ISA feature gates, bit-scan, and SIMD helpers. |
See also: Fortran Interface, Scripts.
The primary build system is GNU Make:
make
Strict C89 pedantic build (recommended for development):
make GNU=1 DBG=1 PEDANTIC=2
CMake is also supported (header-only or library):
cmake -S . -B build -DLIBXS_HEADER_ONLY=ON
cmake --build build
Library — link against libxs.a (or .so) and include the desired headers:
#include <libxs_mem.h>
#include <libxs_timer.h>Header-only — include libxs_source.h in exactly one translation unit (no separate library needed):
#include <libxs_source.h>Fortran — use the provided module (documentation):
USE :: libxs, ONLY: libxs_memcmp| Sample | Description |
|---|---|
| gemm | Batched DGEMM (strided, pointer-array, grouped) with OpenMP and optional MKL JIT. |
| memory | Benchmarks for libxs_diff, libxs_memcmp, matrix copy, and transpose. |
| ozaki | Ozaki-scheme low-precision GEMM with intercepted BLAS dispatch. |
| registry | Registry dispatch microbenchmark under various access patterns. |
| scratch | Pool allocator (libxs_malloc/libxs_free) vs. system malloc. |
| shuffle | Comparison of shuffling strategies and throughput. |
| sync | Lock implementation microbenchmarks. |
LIBXS is licensed under the BSD 3-Clause License.