|
| MatrixBatchCsr (const int batch_size, const int mat_size, const int nnz_per_system, std::optional< int > max_iter=std::nullopt, std::optional< double > res_tol=std::nullopt, std::optional< bool > logger=std::nullopt, std::optional< int > preconditionner_max_block_size=1u) |
| The constructor for MatrixBatchCsr class.
|
|
| MatrixBatchCsr (Kokkos::View< double **, Kokkos::LayoutRight, ExecSpace > batch_values, Kokkos::View< int *, Kokkos::LayoutRight, ExecSpace > cols_idx, Kokkos::View< int *, Kokkos::LayoutRight, ExecSpace > nnz_per_row, std::optional< int > max_iter=std::nullopt, std::optional< double > res_tol=std::nullopt, std::optional< bool > logger=std::nullopt, std::optional< int > preconditionner_max_block_size=1u) |
| Constructor for MatrixBatchCsr class.
|
|
std::tuple< Kokkos::View< double **, Kokkos::LayoutRight, ExecSpace >, Kokkos::View< int *, Kokkos::LayoutRight, ExecSpace >, Kokkos::View< int *, Kokkos::LayoutRight, ExecSpace > > | get_batch_csr () |
| A function to update information about values,indices and the number of non-zero per row for the whole batch.
|
|
void | setup_solver () final |
| Perform a pre-process operation on the solver.
|
|
void | solve (BatchedRHS const b) const final |
| Solve the batched linear problem Ax=b.
|
|
void | solve (BatchedRHS const x, BatchedRHS const b) const |
| Solve the batched linear problem Ax=b.
|
|
double | norm (int batch_idx) const |
| A function returning the norm of a matrix located at batch_idx.
|
|
virtual | ~MatrixBatch ()=default |
| Destruct.
|
|
std::size_t | size () const |
| Get the size of the square matrix corresponding to a single batch in one of its dimensions.
|
|
std::size_t | batch_size () const |
| Get the batch size of the linear problem.
|
|
template<class ExecSpace, MatrixBatchCsrSolver Solver = MatrixBatchCsrSolver::BICGSTAB>
class MatrixBatchCsr< ExecSpace, Solver >
Matrix class which is able to manage and solve a batch of sparse linear systems.
Executes on either CPU or GPU. It takes advantage of the sparse structure, and the only batched solver available in Ginkgo : Stabilized Bicg. This class uses the CSR storage format which needs three arrays, one stores values, the other column indices. The third array contains the count of non-zero inside the matrix lines.(eg:for a given line index i nn_per_row[i]= sum of non-zeros until line i) The class returns these arrays (as Kokkos views) with the get_csr_views function, it is then possible to fill them outside the class. The sparsity pattern is the same for all matrices, hence column indices are stored only for one system. Tolerance and maximal number of iterations, which are parameters for the iterative solver, are set in the constructor. It is possibile to get convergence information by activating the logger at constructor call.
- Template Parameters
-
ExecSpace | Execution space,needed by Kokkos for allocations and parallelism. The simplest choice is to follow Kokkos, for that: specify Kokkos::DefaultExecutionSpace |
Solver | Refers to the solver type, default value is the Bicgstab which is more general. The use of a CG solver is also possible, in this case, please make sure that matrices structure fulfils CG requirements. |
template<class ExecSpace , MatrixBatchCsrSolver Solver = MatrixBatchCsrSolver::BICGSTAB>
std::tuple< Kokkos::View< double **, Kokkos::LayoutRight, ExecSpace >, Kokkos::View< int *, Kokkos::LayoutRight, ExecSpace >, Kokkos::View< int *, Kokkos::LayoutRight, ExecSpace > > MatrixBatchCsr< ExecSpace, Solver >::get_batch_csr |
( |
| ) |
|
|
inline |
A function to update information about values,indices and the number of non-zero per row for the whole batch.
Data is managed by Kokkos Views stored on the host.
- Returns
- vals_view A 2D Kokkos view which stores the values of non-zero elements for the whole batch.
-
col_idx_view A 1D Kokkos view which stores the column indices for each non-zero component.(only for one matrix)
-
nnz_per_row_view A 1D Kokkos view which stores the count of non-zero per line, in an additive way. see nnz_per_row parameter in constructor.
template<class ExecSpace , MatrixBatchCsrSolver Solver = MatrixBatchCsrSolver::BICGSTAB>
Perform a pre-process operation on the solver.
Must be called after filling the matrix.
It uses the batch of matrices to generate a batched Jacobi preconditioner. Other parameters like maximum number of iterations and tolerance are also used to instantiate a Ginkgo solver.
The stopping criterion is a reduction factor ||Ax-b||/||b||<tol with max_iter maximum iterations.
Implements MatrixBatch< ExecSpace >.