# Iterative Sparse Solvers based on Reverse Communication Interface (RCI ISS)

Intel MKL supports the iterative sparse solvers (ISS) based on the reverse communication interface (RCI), referred to here as . The RCI ISS interface implements a group of user-callable routines that are used in the step-by-step solving process of a symmetric positive definite system (RCI Conjugate Gradient Solver, or RCI CG), and of a non-symmetric indefinite (non-degenerate) system (RCI Flexible Generalized Minimal RESidual Solver, or RCI FGMRES) of linear algebraic equations and exploits the general RCI scheme described in [Dong95].

See the Linear Solvers Basics for discussion of terms and concepts related to the ISS routines.

RCI means that when the solver needs the results of certain operations (for example, matrix-vector multiplications), the user himself must perform them and pass the result to the solver. This gives the great universality to the solver as it is independent of the specific implementation of the operations like the matrix-vector multiplication. To perform such operations, the user can use the built-in sparse matrix-vector multiplications and triangular solvers routines (see Sparse BLAS Level 2 and Level 3).

### Note

The RCI CG solver is implemented in two versions: for system of equations with single right hand side, and for system of equations with multiple right hand sides.

The CG method may fail to compute the solution or compute the wrong solution if the matrix of the system is not symmetric and positive definite.

The FGMRES method may fail if the matrix is degenerate.

Table “RCI CG Interface Routines” lists the names of the routines, and describes their general use.

RCI ISS Interface Routines
Routine | Description
--- | ---
dcg_init, dcgmrhs_init, dfgmres_init | Initializes the solver.
dcg_check, dcgmrhs_check, dfgmres_check | Checks the consistency and correctness of the user defined data.
dcg, dcgmrhs, dfgmres | Computes the approximate solution vector.
dcg_get, dcgmrhs_get, dfgmres_get | Retrieves the number of the current iteration.

The Intel MKL RCI ISS interface routines are normally invoked in the order listed in Table“RCI ISS Interface Routines”, with the exception of dcg_get, dcgmrhs_get, and dfgmres_get routines that can be invoked at any place in the code. However, in this case some precautions should be taken to avoid the wrong results. Advanced users can change that order if they need it. Others should follow the above order of calls.

The following diagram in Figure “Typical Order for Invoking RCI ISS Interface Routines” indicates the typical order in which the RCI ISS interface routines can be invoked.

Typical Order for Invoking RCI ISS interface Routines

The following pseudocode shows the general schemes of using the RCI CG routines.

...

generate matrix A

generate preconditioner C (optional)

call `dcg_init(n, x, b, RCI_request, ipar, dpar, tmp)`

change parameters in ipar, dpar if necessary

call `dcg_check(n, x, b, RCI_request, ipar, dpar, tmp)`

1 call `dcg(n, x, b, RCI_request, ipar, dpar, tmp)`

if `(RCI_request.eq.1)` then

multiply the matrix A by `tmp(1:n,1)` and put the result in `tmp(1:n,2)`

It is possible to use MKL Sparse BLAS Level 2 subroutines for this operation

`c proceed with CG iterations`

`goto 1`

`endif`

`if (RCI_request.eq.2)then`

`do the stopping test`

`if (test not passed) then`

`c proceed with CG iterations`

`go to 1`

`else`

`c stop CG iterations`

`goto 2`

`endif`

`endif`

`if (RCI_request.eq.3)` then (optional)

apply the preconditioner C inverse to `tmp(1:n,3)` and put the result in `tmp(1:n,4)`

`c proceed with CG iterations`

`goto 1`

`end`

2 call`dcg_get(n, x, b, RCI_request, ipar, dpar, tmp, itercount)`

current iteration number is in itercount

the computed approximation is in the array x

And the following pseudocode shows the general schemes of using the RCI FGMRES routines.

...

generate matrix A

generate preconditioner C (optional)

call `dfgmres_init(n, x, b, RCI_request, ipar, dpar, tmp)`

change parameters in ipar, dpar if necessary

call `dfgmres_check(n, x, b, RCI_request, ipar, dpar, tmp)`

1 call `dfgmres(n, x, b, RCI_request, ipar, dpar, tmp)`

if `(RCI_request.eq.1)` then

multiply the matrix A by `tmp(ipar(22))` and put the result in `tmp(ipar(23))`

It is possible to use MKL Sparse BLAS Level 2 subroutines for this operation

`c proceed with FGMRES iterations`

`goto 1`

`endif`

`if (RCI_request.eq.2) then`

`do the stopping test`

`if` (test not passed) `then`

`c proceed with FGMRES iterations`

`go to 1`

`else`

`c stop FGMRES iterations`

`goto 2`

`endif`

`endif`

`if (RCI_request.eq.3)` then (optional)

apply the preconditioner C inverse to `tmp(ipar(22))` and put the result in `tmp(ipar(23))`

`c proceed with FGMRES iterations`

`goto 1`

`endif`

`if (RCI_request.eq.4) then`

check the norm of the next orthogonal vector, it is contained in `dpar(7)`

`if` (the norm is not zero up to rounding/computational errors) `then`

`c proceed with FGMRES iterations`

`goto 1`

`else`

`c stop FGMRES iterations`

`goto 2`

`endif`

`endif`

2 call `dfgmres_get(n, x, b, RCI_request, ipar, dpar, tmp, itercount)`

current iteration number is in itercount

the computed approximation is in the array x

Note that for the FGMRES method the array x initially contains the current initial approximation to the solution that can be updated only by calling the routine dfgmres_get. It updates the solution in accordance with the computations performed by the routine dfgmres.

The above pseudocodes demonstrate two main differences in the use of RCI CG and RCI FGMRES interfaces. The first difference relates to RCI_request=3 (different locations in the tmp array, which is 2-dimensional for CG and 1-dimensional for FGMRES). The second difference relates to RCI_request=4 (the RCI CG interface never produces RCI_request=4).

Code examples that use the RCI ISS interface routines to solve systems of linear equations can be found in the Iterative Sparse Solver Code Example section in the Appendix C.

- CG Interface Description
- FGMRES Interface Description
- Implementation Details

Parent topic: Sparse Solver Routines