Sample driver to run a sparse solver

The code in run_sparse_solver.cpp demonstrates how one can use LinearSolver to programm a tool similar to run_taucs and run_mumps. Yet now the code is written for any sparse solver for that the LinearSolver interface has been implemented. When you start reading the code, it is good first to skip function readArguments and just browse main.

Let us now compile and link the code. I have organized a makefile to help us in this endeavour but it is necessary first to define some variables correctly in make.inc. I assume that you have already compiled several solvers and the libraries as well as headers are available at some locations at your hard drive. This information it is necessary to put in make.inc. Let us go through it.

First it is necessary to have a BLAS libraries as all sparse solvers depend on them. This is a variable BLASLIB and it is set to MKL libraries. If you use some other BLAS, please change it.

Then METIS is used by TAUCS and MUMPS and if you employ them you need to correctly define METISLOC. It is also necessary to check METISLIB, if the METIS library name is specifed there correctly.

After that each sparse solver has three variable to define correctly. Let us consider them for TAUCS: TAUCSINC gives us the location of the headers, TAUCSLOC does the location of the libraries and TAUCSLIB does the library name. If you do not want to use TAUCS, just leave TAUCSLIB blank and the makefile will not use TAUCS.  The same concerns UMFPACK, MUMPS and PARDISO. In make.inc for PARDISO two variables PARDISOINC and PARDISOLOC are blank. The reason is that this information in the case of PARDISO is specified by means of LIB and INCLUDE environment variables (I use PARDISO from MKL and they have been defined as a part of MKL setup). LIB and INCLUDE could be employed for other solvers as well.

If you understand the meaning of variables in make.inc, it is time to look at makefile and LinearSolver/makefile. The latter is called from the former and both of them include make.inc.

When the information in make.inc is correct, make in that directory should produce run_sparse_solver.exe. Try it. I believe that this is a good exercise: to compile and link run_sparse_solver with a few solvers.

Previous

Introduction
Class Matrix
Class SparseMatrix
Sample code in C++ to run TAUCS
Sample code in C++ to run MUMPS
Class LinearSolver
  Class UMFPACK
  Class TAUCS
  Class MUMPS and PARDISO
  Gluing all together: LinearSolver::create


Comments are closed.