strumpack::StrumpackSparseSolverBase< scalar_t, integer_t > Class Template Referenceabstract

StrumpackSparseSolver is the main sequential or multithreaded sparse solver class. More...

#include <StrumpackSparseSolverBase.hpp>

Inheritance diagram for strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >:

Public Member Functions

 StrumpackSparseSolverBase (int argc, char *argv[], bool verbose=true, bool root=true)
 
 StrumpackSparseSolverBase (bool verbose=true, bool root=true)
 
virtual ~StrumpackSparseSolverBase ()
 
ReturnCode reorder (int nx=1, int ny=1, int nz=1, int components=1, int width=1)
 
ReturnCode reorder (const int *p, int base=0)
 
ReturnCode factor ()
 
void move_to_gpu ()
 
void remove_from_gpu ()
 
ReturnCode solve (const scalar_t *b, scalar_t *x, bool use_initial_guess=false)
 
ReturnCode solve (const DenseM_t &b, DenseM_t &x, bool use_initial_guess=false)
 
SPOptions< scalar_t > & options ()
 
const SPOptions< scalar_t > & options () const
 
void set_from_options ()
 
void set_from_options (int argc, char *argv[])
 
int maximum_rank () const
 
std::size_t factor_nonzeros () const
 
std::size_t factor_memory () const
 
int Krylov_iterations () const
 
void draw (const std::string &name) const
 

Detailed Description

template<typename scalar_t, typename integer_t = int>
class strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >

StrumpackSparseSolver is the main sequential or multithreaded sparse solver class.

This is the main interface to STRUMPACK's sparse solver. Use this for a sequential or multithreaded sparse solver. For the fully distributed solver, see StrumpackSparseSolverMPIDist.

Template Parameters
scalar_tcan be: float, double, std::complex<float> or std::complex<double>.
integer_tdefaults to a regular int. If regular int causes 32 bit integer overflows, you should switch to integer_t=int64_t instead. This should be a signed integer type.
See also
StrumpackSparseSolverMPIDist, StrumpackSparseSolverMPI

Constructor & Destructor Documentation

◆ StrumpackSparseSolverBase() [1/2]

template<typename scalar_t , typename integer_t = int>
strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::StrumpackSparseSolverBase ( int  argc,
char *  argv[],
bool  verbose = true,
bool  root = true 
)

Constructor of the StrumpackSparseSolver class, taking command line arguments.

Parameters
argcnumber of arguments, i.e, number of elements in the argv array
argvcommand line arguments. Add -h or –help to have a description printed
verboseflag to enable/disable output to cout
rootflag to denote whether this process is the root MPI process, only the root will print certain messages to cout

◆ StrumpackSparseSolverBase() [2/2]

template<typename scalar_t , typename integer_t = int>
strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::StrumpackSparseSolverBase ( bool  verbose = true,
bool  root = true 
)

Constructor of the StrumpackSparseSolver class.

Parameters
verboseflag to enable/disable output to cout
rootflag to denote whether this process is the root MPI process. Only the root will print certain messages
See also
set_from_options

◆ ~StrumpackSparseSolverBase()

template<typename scalar_t , typename integer_t = int>
virtual strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::~StrumpackSparseSolverBase ( )
virtual

(Virtual) destructor of the StrumpackSparseSolver class.

Member Function Documentation

◆ draw()

template<typename scalar_t , typename integer_t = int>
void strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::draw ( const std::string &  name) const

Create a gnuplot script to draw/plot the sparse factors. Only do this for small matrices! It is very slow!

Parameters
namefilename of the generated gnuplot script. Running
gnuplot plotname.gnuplot 
will generate a pdf file.

◆ factor()

template<typename scalar_t , typename integer_t = int>
ReturnCode strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::factor ( )

Perform numerical factorization of the sparse input matrix.

This is the computationally expensive part of the code. However, once the factorization is performed, it can be reused for multiple solves. This requires that a valid matrix has been assigned to this solver. internally this check whether the matrix has been reordered (with a call to reorder), and if not, it will call reorder.

Returns
error code
See also
set_matrix, set_csr_matrix

◆ factor_memory()

template<typename scalar_t , typename integer_t = int>
std::size_t strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::factor_memory ( ) const

Return the amount of memory taken by the sparse factorization factors. This is the fill-in. It is simply computed as factor_nonzeros() * sizeof(scalar_t), so it does not include any overhead from the metadata for the datastructures. This should be called after the factorization. For the StrumpackSparseSolverMPI and StrumpackSparseSolverMPIDist distributed memory solvers, this routine is collective on the MPI communicator.

◆ factor_nonzeros()

template<typename scalar_t , typename integer_t = int>
std::size_t strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::factor_nonzeros ( ) const

Return the number of nonzeros in the (sparse) factors. This is known as the fill-in. This should be called after computing the numerical factorization. For the StrumpackSparseSolverMPI and StrumpackSparseSolverMPIDist distributed memory solvers, this routine is collective on the MPI communicator.

◆ Krylov_iterations()

template<typename scalar_t , typename integer_t = int>
int strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::Krylov_iterations ( ) const

Return the number of iterations performed by the outer (Krylov) iterative solver. Call this after calling the solve routine.

◆ maximum_rank()

template<typename scalar_t , typename integer_t = int>
int strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::maximum_rank ( ) const

Return the maximum rank encountered in any of the HSS matrices used to compress the sparse triangular factors. This should be called after the factorization phase. For the StrumpackSparseSolverMPI and StrumpackSparseSolverMPIDist distributed memory solvers, this routine is collective on the MPI communicator.

◆ options() [1/2]

template<typename scalar_t , typename integer_t = int>
SPOptions<scalar_t>& strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::options ( )

Return the object holding the options for this sparse solver.

◆ options() [2/2]

template<typename scalar_t , typename integer_t = int>
const SPOptions<scalar_t>& strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::options ( ) const

Return the object holding the options for this sparse solver.

◆ reorder() [1/2]

template<typename scalar_t , typename integer_t = int>
ReturnCode strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::reorder ( const int *  p,
int  base = 0 
)

Perform sparse matrix reordering, with a user-supplied permutation vector. Using this will ignore the reordering method selected in the options struct.

Parameters
ppermutation vector, should be of size N, the size of the sparse matrix associated with this solver
baseis the permutation 0 or 1 based?

◆ reorder() [2/2]

template<typename scalar_t , typename integer_t = int>
ReturnCode strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::reorder ( int  nx = 1,
int  ny = 1,
int  nz = 1,
int  components = 1,
int  width = 1 
)

Compute matrix reorderings for numerical stability and to reduce fill-in.

Start computation of the matrix reorderings. See the relevant options to control the matrix reordering in the manual. A first reordering is the MC64 column permutation for numerical stability. This can be disabled if the matrix has large nonzero diagonal entries. MC64 optionally also performs row and column scaling. Next, a fill-reducing reordering is computed. This is done with the nested dissection algortihms of either (PT-)Scotch, (Par)Metis or a simple geometric nested dissection code which only works on regular meshes.

Parameters
nxthis (optional) parameter is only meaningful when the matrix corresponds to a stencil on a regular mesh. The stencil is assumed to be at most 3 points wide in each dimension and only contain a single degree of freedom per grid point. The nx parameter denotes the number of grid points in the first spatial dimension.
nysee parameters nx. Parameter ny denotes the number of gridpoints in the second spatial dimension. This should only be set if the mesh is 2 or 3 dimensional.
nzSee parameters nx. Parameter nz denotes the number of gridpoints in the third spatial dimension. This should only be set if the mesh is 3 dimensional.
Returns
error code
See also
SPOptions

◆ set_from_options() [1/2]

template<typename scalar_t , typename integer_t = int>
void strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::set_from_options ( )

Parse the command line options passed in the constructor, and modify the options object accordingly. Run with option -h or –help to see a list of supported options. Or check the SPOptions documentation.

◆ set_from_options() [2/2]

template<typename scalar_t , typename integer_t = int>
void strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::set_from_options ( int  argc,
char *  argv[] 
)

Parse the command line options, and modify the options object accordingly. Run with option -h or –help to see a list of supported options. Or check the SPOptions documentation.

Parameters
argcnumber of options in argv
argvlist of options

◆ solve() [1/2]

template<typename scalar_t , typename integer_t = int>
ReturnCode strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::solve ( const DenseM_t b,
DenseM_t x,
bool  use_initial_guess = false 
)

Solve a linear system with a single or multiple right-hand sides. Before being able to solve a linear system, the matrix needs to be factored. One can call factor() explicitly, or if this was not yet done, this routine will call factor() internally.

Parameters
binput, will not be modified. DenseMatrix containgin the right-hand side vector/matrix. Should have N rows, with N the dimension of the input matrix for StrumpackSparseSolver and StrumpackSparseSolverMPI. For StrumpackSparseSolverMPIDist, the number or rows of b should be correspond to the partitioning of the block-row distributed input matrix.
xOutput, pointer to the solution vector. Array should be lenght N, the dimension of the input matrix for StrumpackSparseSolver and StrumpackSparseSolverMPI. For StrumpackSparseSolverMPIDist, the length of b should be correspond the partitioning of the block-row distributed input matrix.
use_initial_guessset to true if x contains an intial guess to the solution. This is mainly useful when using an iterative solver. If set to false, x should not be set (but should be allocated).
Returns
error code
See also
DenseMatrix, solve(), factor()

◆ solve() [2/2]

template<typename scalar_t , typename integer_t = int>
ReturnCode strumpack::StrumpackSparseSolverBase< scalar_t, integer_t >::solve ( const scalar_t *  b,
scalar_t *  x,
bool  use_initial_guess = false 
)

Solve a linear system with a single right-hand side. Before being able to solve a linear system, the matrix needs to be factored. One can call factor() explicitly, or if this was not yet done, this routine will call factor() internally.

Parameters
binput, will not be modified. Pointer to the right-hand side. Array should be lenght N, the dimension of the input matrix for StrumpackSparseSolver and StrumpackSparseSolverMPI. For StrumpackSparseSolverMPIDist, the length of b should be correspond the partitioning of the block-row distributed input matrix.
xOutput, pointer to the solution vector. Array should be lenght N, the dimension of the input matrix for StrumpackSparseSolver and StrumpackSparseSolverMPI. For StrumpackSparseSolverMPIDist, the length of b should be correspond the partitioning of the block-row distributed input matrix.
use_initial_guessset to true if x contains an intial guess to the solution. This is mainly useful when using an iterative solver. If set to false, x should not be set (but should be allocated).
Returns
error code

The documentation for this class was generated from the following file: