Mixed-precision SPICE modernization. mp-spice composes two header-only libraries — MTL5 for linear algebra and Universal for parameterized number systems — to explore SPICE circuit-simulation solvers under custom arithmetic (half precision, posits, ...).
MTL5 deliberately has no dependency on Universal: it is the general linear-algebra layer. mp-spice is the integration layer where MTL5's algorithms meet Universal's number types.
KLU is the sparse direct
solver of choice for circuit-simulation (Modified Nodal Analysis) matrices.
MTL5 provides a native, value-type-generic KLU
(sparse::factorization::native_klu). mp-spice drives it on real circuit
matrices from the SuiteSparse Matrix Collection and
compares accuracy across:
| Type | Notes |
|---|---|
double |
reference |
float |
single precision |
cfloat<16,5> |
IEEE-like half (Universal) |
posit<16,2> |
16-bit posit (Universal) |
Target matrices:
Rajat/rajat30— small/medium demo.Freescale/circuit5M— very large stress/scaling target.
Status: all four precisions work (enabled by default;
-DMPSPICE_MIXED_PRECISION_KLU=OFFto builddouble/floatonly). Example output onRajat/rajat11(135×135 circuit matrix, exact solution all-ones):type ||Ax-b||inf ||x-1||inf ------------------------------------------ double 3.553e-15 2.803e-13 float 9.505e-07 7.176e-05 cfloat<16,5> solve failed: zero pivot (block singular in half precision) posit<16,2> 3.229e-04 1.819e-01Note how
posit<16,2>completes the solve wherecfloat<16,5>fails — a concrete mixed-precision result. Robustness on stiff circuit matrices is expected to improve with scaling and iterative refinement (see docs/roadmap.md, Milestone 2).
# Dependencies (MTL5 + Universal) are pulled automatically via FetchContent.
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
# Run the smoke test
ctest --test-dir build --output-on-failure
# Run the demo on the built-in synthetic circuit matrix
./build/applications/klu_mixed_precision/klu_mixed_precision
# ...or on a real SuiteSparse matrix
scripts/fetch_matrices.sh # downloads rajat30 into ./data
./build/applications/klu_mixed_precision/klu_mixed_precision data/rajat30/rajat30.mtxUsing local checkouts instead of fetching from GitHub:
cmake -B build \
-DFETCHCONTENT_SOURCE_DIR_MTL5=../mtl5 \
-DFETCHCONTENT_SOURCE_DIR_UNIVERSAL=../universalapplications/klu_mixed_precision/ # the KLU mixed-precision demo
include/sw/mp_spice/ # shared composition-layer headers
scripts/fetch_matrices.sh # SuiteSparse matrix downloader
tests/ # smoke tests
docs/roadmap.md # milestones and known integration work
MIT — see LICENSE.