GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HPCTrainingExamples/Libraries/ConjugateGradient at main · amd/HPCTrainingExamples

Expand file tree

/

ConjugateGradient

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

ConjugateGradient

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Makefile
Makefile
 
 
README.md
README.md
 
 
cg.m
cg.m
 
 
driver.cpp
driver.cpp
 
 
driver_mtx.cpp
driver_mtx.cpp
 
 
pcg_ic.cpp
pcg_ic.cpp
 
 
pcg_ic.h
pcg_ic.h
 
 
pcg_laplacian
pcg_laplacian
 
 
pcg_mtx
pcg_mtx
 
 

README.md

Outline

Preconditioned Conjugate Gradient (PCG) with Incomplete Cholesky

ROCm implementation of the Preconditioned Conjugate Gradient method with Incomplete Cholesky (IC0) preconditioner for solving symmetric positive definite linear systems.

Requirements

  • ROCm 6.4+ or ROCm 7.x
  • AMD GPU with ROCm support

Building

module load rocm/7.1.1   # or rocm/6.4.0
make

This builds two executables:

  • pcg_laplacian - Test driver with generated 3D Laplacian matrix
  • pcg_mtx - Driver for Matrix Market format input files

Usage

Laplacian Test Driver

# 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

Matrix Market Driver

./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

Algorithm

The implementation uses:

  • Incomplete Cholesky IC(0) factorization via rocsparse_dcsric0
  • Sparse triangular solves via rocsparse_spsv for preconditioning
  • Sparse matrix-vector product via rocsparse_spmv
  • rocBLAS for vector operations (dot products, scaling, axpy)

Files

  • pcg_ic.h - Header file with function declarations
  • pcg_ic.cpp - PCG algorithm implementation
  • driver.cpp - Laplacian test driver
  • driver_mtx.cpp - Matrix Market driver

Profiling: communication and compute performance

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_Allreduce in a distributed CG), with the timeline view that exposes the host stalls waiting on each reduction.

Version Compatibility

The code includes version detection macros to handle API differences between ROCm 6.4 and 7.x, suppressing deprecation warnings while maintaining backward compatibility.

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.