ROCm implementation of the Preconditioned Conjugate Gradient method with Incomplete Cholesky (IC0) preconditioner for solving symmetric positive definite linear systems.
- ROCm 6.4+ or ROCm 7.x
- AMD GPU with ROCm support
module load rocm/7.1.1 # or rocm/6.4.0
makeThis builds two executables:
pcg_laplacian- Test driver with generated 3D Laplacian matrixpcg_mtx- Driver for Matrix Market format input files
# Default 20x20x20 grid ./pcg_laplacian # Custom grid size and solver parameters ./pcg_laplacian <nx> <ny> <nz> [tol] [maxiter] # Example: 50x50x50 grid with tolerance 1e-10 ./pcg_laplacian 50 50 50 1e-10 1000
./pcg_mtx <matrix.mtx> [options] Options: -tol <value> Convergence tolerance (default: 1e-10) -maxiter <value> Maximum iterations (default: 10000) -rhs <file.mtx> Right-hand side vector in Matrix Market format (default: vector of all ones)
Example:
./pcg_mtx thermal2.mtx -tol 1e-8 -maxiter 2000 ./pcg_mtx matrix.mtx -rhs rhs.mtx -tol 1e-10
The implementation uses:
- Incomplete Cholesky IC(0) factorization via
rocsparse_dcsric0 - Sparse triangular solves via
rocsparse_spsvfor preconditioning - Sparse matrix-vector product via
rocsparse_spmv - rocBLAS for vector operations (dot products, scaling, axpy)
pcg_ic.h- Header file with function declarationspcg_ic.cpp- PCG algorithm implementationdriver.cpp- Laplacian test driverdriver_mtx.cpp- Matrix Market driver
See PROFILING.md for a step-by-step supplement on using the
ROCm profilers on this system (rocprofv3, rocprof-compute, and
rocprofiler-systems) to measure and visualize:
- Compute — per-kernel time for SpMV, the triangular solves (SpSV), and the rocBLAS vector kernels, plus a roofline showing the memory-bandwidth ceiling.
- Communication — host↔device transfers and, in particular, the
per-iteration dot-product synchronizations (the single-GPU analog of the
MPI_Allreducein a distributed CG), with the timeline view that exposes the host stalls waiting on each reduction.
The code includes version detection macros to handle API differences between ROCm 6.4 and 7.x, suppressing deprecation warnings while maintaining backward compatibility.