Skip to content
UebermutPublic

About

Parallel approximate-Cholesky preconditioner and PCG solver for graph-Laplacian and SDDM linear systems (C++23, OpenMP/CUDA, Python bindings)

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

apxchol

Parallel approximate-Cholesky preconditioning and PCG for sparse Laplacian and SDDM systems. CPU setup and solve use OpenMP; CUDA provides an optional GPU-resident solve. C++, Python and Octave/MATLAB interfaces are included.

Build and run

Requires CMake, a C++23 compiler, and Eigen (fetched if absent).

git clone https://github.com/AlgOptGroup/apxchol
cd apxchol
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j6
ctest --test-dir build --output-on-failure
./build/apxchol matrix.mtx --random-rhs --tol 1e-8
./build/apxchol matrix.mtx --rhs rhs.mtx -o solution.mtx

The CLI requires an explicit RHS or --random-rhs. It reports whether input is an assembled operator or adjacency matrix, forming L = D - A for the latter. --input-kind overrides detection; --help lists options.

Interfaces

#include "apxchol.h"
auto result = apxchol::solve(L, b, {.tol = 1e-8});

apxchol::cpu_solver solver(L);       // factor once, solve many
auto r1 = solver.solve(b1);
auto r2 = solver.solve(b2, 1e-10, 1000);
Eigen::VectorXd z = solver.apply(r);

apxchol::apx_cholesky provides Eigen's preconditioner interface. Singular Laplacians use their compatible subspace; SDDM operators retain a full factor.

pip install apxchol                 # or: pip install -e python
solver = apxchol.factorize(A)
result = solver.solve(b, rtol=1e-8)

Bindings expect assembled operators. Use apxchol.laplacian(Adj) in Python or apxchol_laplacian(Adj) in Octave for adjacency input. See the Python and Octave/MATLAB guides.

Configuration

CMake option Purpose
APXCHOL_USE_CUDA=ON Dataflow triangular solve and GPU PCG; core links only cudart
APXCHOL_POOL_FP32=OFF fp64 residual-pool weights instead of default fp32
APXCHOL_64BIT_EDGE_INDICES=ON Wide factor/pool offsets
APXCHOL_64BIT_NODE_INDICES=ON Wide vertices and offsets

cmake -LH build lists build options. Algorithm defaults live in factor_options.h. APXCHOL_SPTRSV_FP16=0|1 controls factor storage (GPU default on, CPU off). --sampler gks|trace_cycle selects the clique sampler; GKS remains its default. Trace-cycle supports CPU setup and full GPU-owned setup. Factor construction defaults to CPU. APXCHOL_GPU_BLOCK_FRONTEND=on enables GPU selection; experimental GPU-owned numerical setup additionally requires APXCHOL_GPU_ROUND_SHADOW=force and APXCHOL_GPU_FACTOR_FINALIZE=force. This applies to one-shot block-greedy/tree solves with directed AoS storage; public/exported factors and unsupported stored formats retain validated fallback paths. See the setup contracts.

Threads and placement

The CPU solver is limited by memory traffic rather than core count, so where the threads sit matters more than how many there are. One 64-core EPYC 7742 socket (four NUMA domains, two memory channels each), 8 matrices, both samplers, geometric mean of the one-RHS total (Euler, 2026-09-18):

Threads × NUMA domains 16 × 1 16 × 4 32 × 4 64 × 4
Relative time 1.00 0.86 0.77 0.83

Spread the threads over the memory domains of one socket and stop near eight per domain: all 64 cores were slower than 32, and slower than the compact 16 on social graphs; spreading 16 threads over both sockets was slower than one domain on three of four matrices. The library never changes affinity. Pin explicitly, one place per chosen core (lscpu -p=CPU,CORE,NODE lists them): OMP_PROC_BIND=close OMP_PLACES="{0},{1},{16},{17},...".

Further reading

Developed at ETH Zürich. Contact: apxchol@inf.ethz.ch. License · Citation.

About

Parallel approximate-Cholesky preconditioner and PCG solver for graph-Laplacian and SDDM linear systems (C++23, OpenMP/CUDA, Python bindings)

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages