Skip to content

hfp/libxs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7,213 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LIBXS

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.

Functionality

Domain Header Description
Registry libxs_reg.h Thread-safe key-value store
Predict libxs_predict.h Fingerprint-guided parameter prediction
Malloc libxs_malloc.h Pool allocator (no system calls at steady)
Memory libxs_mem.h Byte compare, matrix copy/transpose
String libxs_str.h Edit distance, substring, similarity
Token libxs_token.h Fixed-width 8-byte tokenizer
Timer libxs_timer.h High-resolution timing via calibrated TSC
CPUID libxs_cpuid.h CPU feature detection (SSE..AVX-512, etc.)
Utils libxs_utils.h ISA gates, bit-scan, SIMD helpers
Sync libxs_sync.h Portable atomics, locks, TLS, file locks
GEMM libxs_gemm.h Batched dense GEMM (strided, grouped)
Math libxs_math.h Matrix compare, GCD/LCM, BF16 conversion
Hash libxs_hash.h CRC32, Adler-32, string hashing
Perm libxs_perm.h Shuffle, kd-tree, Hilbert/Morton curves
Hist libxs_hist.h Thread-safe histogram, running statistics
MHD libxs_mhd.h Read/write MetaImage (MHD/MHA) files
RNG libxs_rng.h Pseudo-random generation (SplitMix64)

See also: Fortran Interface, Scripts.

Build

make GNU=1

The 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 build

Installation

Install into a chosen prefix:

make GNU=1 -j $(nproc) install PREFIX=$HOME/libxs

This 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/Makefile

Usage

Library — link against libxs.a (or .so) and include the desired headers:

#include <libxs/libxs_mem.h>
#include <libxs/libxs_timer.h>

Header-only (explicit) — include libxs_source.h (no separate library needed). Safe to include from multiple translation units:

#include <libxs/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

Samples

Sample Description
tokenizer Reversible byte-level tokenizer
converse Extractive summarization via tokenized fprints
registry Registry dispatch microbenchmark
predict Fingerprint-guided parameter prediction
rosetta Hierarchical type discovery on opaque data
setdiff Deterministic set-difference tolerance
shuffle Shuffling strategies comparison
scratch Pool allocator vs system malloc
spatial Stratification, pair counting, kd-tree
fprint Foeppl fingerprint structure/geometry tests
memory Byte comparison, matrix copy, transpose
ozaki Ozaki-scheme low-precision GEMM
gemm Batched DGEMM (strided, pointer, grouped)
syrk Symmetric rank-k/2k update with validation
sync Lock implementation microbenchmarks

License

BSD 3-Clause