monolish
0.17.3-dev.23
MONOlithic LInear equation Solvers for Highly-parallel architecture
|
The monolish namespace contains monolish::vector and monolish::view1D. monolish has the following 7 namespaces in addition to the monolish namespace:
monolish_blas.hpp
.monolish_vml.hpp
.monolish_equation.hpp
.monolish_eigen.hpp
.monolish_generalized_eigen.hpp
.This chapter describes a sample program using monolish that runs on the CPU.
Sample programs that run on the GPU can be found at examples/
. They work on CPU and GPU. The programs running on the GPU are described in the next chapter.
Sample programs for CPU can be found at examples/cpu_only
. They only work on the CPU.
First, a simple inner product program is shown below:
This program can be compiled by the following command.
The following command runs this.
A description of this program is given below:
sdot
or ddot
.This program is executed in parallel. The number of threads is specified by the OMP_NUM_THREADS
environment variable.
The following is a sample program that solves a linear equation; Ax=b using the conjugate gradient method with jacobi preconditioner.
monolish::matrix::COO has editable
attribute, so users can edit any element using insert() and monolish::matrix::COO.at() "at()" functions. COO can be created by giving array pointer or file name to the constructor, too. This sample program creates a matrix from a file. The input file format is MatrixMarket format. MatrixMarket format is a common data format for sparse matrices. scipy can also output matrices in MatrixMarket format.
monolish::matrix::CRS can easily be generated by taking COO as an argument to the constructor.
monolish proposes a new way to implement linear solvers.
Applying preconditioning means combining multiple solvers. In other words, the solver and preconditioner in the Krylov subspace method are essentially the same thing.
The solver classes included in monolish::equation all have the following functions:
The class that executes solve()
execute the registered create_precond()
and apply_precond()
. If no preconditioner is registered, it calls monolish::equation::none as "none preconditioner".
By being able to register the creation and application of preconditioners separately, users can use the preconditioner matrix in different ways.
In the current version, the create_precond() and apply_precond() functions of some classes do not work. In the future, we will make these functions work in all classes. This implementation would be very efficient for multi-grid methods.
See here for a list of solvers.
The program in the previous chapter has the matrix storage format, data type, solver name, and preconditioner name explicitly specified all over the program.
If users want to change them depending on the input matrix, this implementation requires a lot of program changes.
Since monolish is designed so that the matrix and solver classes all have the same interface, these changes can be eliminated by templating.
A templated program is shown below.
This program is templated so that the function that solves Ax=b is not oblivious to the matrix storage format or data type.