Ginkgo: Example programs (original) (raw)

Here you can find example programs that demonstrate the usage of Ginkgo. Some examples are built on one another and some are stand-alone and demonstrate a concept of Ginkgo, which can be used in your own code.

You can browse the available example programs

  1. as a graph that shows how example programs build upon each other.
  2. as a list that provides a short synopsis of each program.
  3. or grouped by topic.

By default, all Ginkgo examples are built using CMake.

An example for building the examples and using Ginkgo as an external library without CMake can be found in the script provided for each example, which should be called with the form: ./build.sh PATH_TO_GINKGO_BUILD_DIR

By default, Ginkgo is compiled with at least -DGINKGO_BUILD_REFERENCE=ON. Ginkgo also tries to detect your environment setup (presence of CUDA, ...) to enable the relevant accelerator modules. If you want to target a specific GPU, make sure that Ginkgo is compiled with the accelerator specific module enabled, such as:

  1. -DGINKGO_BUILD_CUDA=ON option for NVIDIA GPUs.
  2. -DGINKGO_BUILD_HIP=ON option for AMD or NVIDIA GPUs.
  3. -DGINKGO_BUILD_SYCL=ON option for Intel GPUs (and possibly any other platform).

Connections between example programs

The following graph shows the connections between example programs and how they build on each other. Click on any of the boxes to go to one of the programs. If you hover your mouse pointer over a box, a brief description of the program should appear.

Legend:

Example programs

The simple-solver program A minimal CG solver in Ginkgo, which reads a matrix from a file.
The minimal-cuda-solver program A minimal solver on the CUDA executor than can be run on NVIDIA GPU's.
The poisson-solver program Solve an actual physically relevant problem, the poisson problem. The matrix is generated within Ginkgo.
The preconditioned-solver program Using a Jacobi preconditioner to solve a linear system.
The ilu-preconditioned-solver program Using an ILU preconditioner to solve a linear system.
The performance-debugging program Using Loggers to debug the performance within Ginkgo.
The three-pt-stencil-solver program Using a three point stencil to solve the poisson equation with array views.
The nine-pt-stencil-solver program Using a nine point 2D stencil to solve the poisson equation with array views.
The external-lib-interfacing program Using Ginkgo's solver with the external library deal.II.
The custom-logger program Creating a custom logger specifically for comparing the recurrent and the real residual norms.
The custom-matrix-format program Creating a matrix-free stencil solver by using Ginkgo's advanced methods to build your own custom matrix format.
The inverse-iteration program Using Ginkgo to compute eigenvalues of a matrix with the inverse iteration method.
The simple-solver-logging program Using the logging functionality in Ginkgo to get solver and other information to diagnose and debug your code.
The papi-logging program Using the PAPI logging library in Ginkgo to get advanced information about your code and its behaviour.
The ginkgo-overhead program Measuring the overhead of the Ginkgo library.
The custom-stopping-criterion program Creating a custom stopping criterion for the iterative solution process.
The ginkgo-ranges program Using the ranges concept to factorize a matrix with the LU factorization.
The mixed-spmv program Shows the Ginkgo mixed precision spmv functionality.
The mixed-precision-ir program Manual implementation of a Mixed Precision Iterative Refinement (MPIR) solver.
The adaptiveprecision-blockjacobi program Shows how to use the adaptive precision block-Jacobi preconditioner.
The cb-gmres program Using the Ginkgo CB-GMRES solver (Compressed Basis GMRES).
The heat-equation program Solving a 2D heat equation and showing matrix assembly, vector initialization and solver setup in a more complex setting with output visualization.
The iterative-refinement program Using a low accuracy CG solver as an inner solver to an iterative refinement (IR) method which solves a linear system.
The ir-ilu-preconditioned-solver program Combining iterative refinement with the adaptive precision block-Jacobi preconditioner to approximate triangular systems occurring in ILU preconditioning.
The par-ilu-convergence program Convergence analysis at the examples of parallel incomplete factorization solver.
The preconditioner-export program Explicit generation and storage of preconditioners for given matrices.
The multigrid-preconditioned-solver program Use multigrid as preconditioner to a solver.
The mixed-multigrid-solver program Use multigrid with different precision multigrid_level as a solver.
The distributed-solver program Use a distributed solver to solve a 1D Laplace equation.

Example programs grouped by topics

Basic techniques

Solving a simple linear system with choice of executors The simple-solver program
Debug the performance of a solver or preconditioner The performance-debugging program The preconditioner-export program
Using the CUDA executor The minimal-cuda-solver program
Using preconditioners The preconditioned-solver program, The ilu-preconditioned-solver program, The ir-ilu-preconditioned-solver program, The adaptiveprecision-blockjacobi program, The par-ilu-convergence program, The preconditioner-export program The multigrid-preconditioned-solver program
Iterative refinement The iterative-refinement program, The mixed-precision-ir program, The ir-ilu-preconditioned-solver program
Solving a physically relevant problem The poisson-solver program, The three-pt-stencil-solver program, The nine-pt-stencil-solver program, The custom-matrix-format program
Reading in a matrix and right hand side from a file The simple-solver program, The minimal-cuda-solver program, The preconditioned-solver program, The ilu-preconditioned-solver program, The inverse-iteration program, The simple-solver-logging program, The papi-logging program, The custom-stopping-criterion program, The custom-logger program

Advanced techniques

Using Ginkgo with external libraries The external-lib-interfacing program
Customizing Ginkgo The custom-logger program, The custom-stopping-criterion program, The custom-matrix-format program
Writing your own matrix format The custom-matrix-format program
Using Ginkgo to construct more complex linear algebra routines The inverse-iteration program
Logging within Ginkgo The simple-solver-logging program, The papi-logging program, The performance-debugging program The custom-logger program
Constructing your own stopping criterion The custom-stopping-criterion program
Using ranges in Ginkgo The ginkgo-ranges program
Mixed precision The mixed-spmv program, The mixed-precision-ir program, The adaptiveprecision-blockjacobi program The mixed-multigrid-solver program
Multigrid The multigrid-preconditioned-solver program The mixed-multigrid-solver program
Configure a solver from a config file The file-config-solver program
Distributed The distributed-solver program