StrumpackSparseSolverMPIDist.hpp
Go to the documentation of this file.
1 /*
2  * STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
3  * Regents of the University of California, through Lawrence Berkeley
4  * National Laboratory (subject to receipt of any required approvals
5  * from the U.S. Dept. of Energy). All rights reserved.
6  *
7  * If you have questions about your rights to use or distribute this
8  * software, please contact Berkeley Lab's Technology Transfer
9  * Department at TTD@lbl.gov.
10  *
11  * NOTICE. This software is owned by the U.S. Department of Energy. As
12  * such, the U.S. Government has been granted for itself and others
13  * acting on its behalf a paid-up, nonexclusive, irrevocable,
14  * worldwide license in the Software to reproduce, prepare derivative
15  * works, and perform publicly and display publicly. Beginning five
16  * (5) years after the date permission to assert copyright is obtained
17  * from the U.S. Department of Energy, and subject to any subsequent
18  * five (5) year renewals, the U.S. Government is granted for itself
19  * and others acting on its behalf a paid-up, nonexclusive,
20  * irrevocable, worldwide license in the Software to reproduce,
21  * prepare derivative works, distribute copies to the public, perform
22  * publicly and display publicly, and to permit others to do so.
23  *
24  * Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
25  * (Lawrence Berkeley National Lab, Computational Research
26  * Division).
27  */
32 #ifndef STRUMPACK_SPARSE_SOLVER_MPI_DIST_HPP
33 #define STRUMPACK_SPARSE_SOLVER_MPI_DIST_HPP
34 
36 #include "dense/ScaLAPACKWrapper.hpp"
37 #include "dense/DistributedVector.hpp"
38 #include "sparse/CSRMatrixMPI.hpp"
39 
40 namespace strumpack {
41 
42  // forward declarations
43  template<typename scalar_t,typename integer_t> class EliminationTreeMPIDist;
44  template<typename scalar_t,typename integer_t> class MatrixReorderingMPI;
45 
70  template<typename scalar_t,typename integer_t>
72  public StrumpackSparseSolverBase<scalar_t,integer_t> {
73 
79 
80  public:
96  (MPI_Comm comm, int argc, char* argv[], bool verbose=true);
97 
107  StrumpackSparseSolverMPIDist(MPI_Comm comm, bool verbose=true);
108 
113 
127 
148  (integer_t N, const integer_t* row_ptr, const integer_t* col_ind,
149  const scalar_t* values, bool symmetric_pattern=false);
150 
164 
186  (integer_t local_rows, const integer_t* row_ptr,
187  const integer_t* col_ind, const scalar_t* values,
188  const integer_t* dist, bool symmetric_pattern=false);
189 
195  void set_MPIAIJ_matrix
196  (integer_t local_rows,
197  const integer_t* d_ptr, const integer_t* d_ind, const scalar_t* d_val,
198  const integer_t* o_ptr, const integer_t* o_ind, const scalar_t* o_val,
199  const integer_t* garray);
200 
201 
236  (integer_t local_rows, const integer_t* row_ptr,
237  const integer_t* col_ind, const scalar_t* values,
238  const integer_t* dist, bool symmetric_pattern=false);
239 
260 
278  (integer_t local_rows, const integer_t* d_ptr, const integer_t* d_ind,
279  const scalar_t* d_val, const integer_t* o_ptr, const integer_t* o_ind,
280  const scalar_t* o_val, const integer_t* garray);
281 
286  MPI_Comm comm() const;
287 
288  private:
291  MPIComm comm_;
292 
293  SpMat_t* matrix() override { return mat_mpi_.get(); }
294  Reord_t* reordering() override;
295  Tree_t* tree() override { return tree_mpi_dist_.get(); }
296  const SpMat_t* matrix() const override { return mat_mpi_.get(); }
297  const Reord_t* reordering() const override;
298  const Tree_t* tree() const override { return tree_mpi_dist_.get(); }
299 
300  void setup_tree() override;
301  void setup_reordering() override;
302  int compute_reordering(const int* p, int base, int nx, int ny, int nz,
303  int components, int width) override;
304  void separator_reordering() override;
305 
306  void perf_counters_stop(const std::string& s) override;
307  void synchronize() override { comm_.barrier(); }
308  void reduce_flop_counters() const override;
309 
310  void redistribute_values();
311 
312  ReturnCode solve_internal
313  (const scalar_t* b, scalar_t* x, bool use_initial_guess=false) override;
314  ReturnCode solve_internal
315  (const DenseM_t& b, DenseM_t& x, bool use_initial_guess=false) override;
316 
317  std::unique_ptr<CSRMatrixMPI<scalar_t,integer_t>> mat_mpi_;
318  std::unique_ptr<MatrixReorderingMPI<scalar_t,integer_t>> nd_mpi_;
319  std::unique_ptr<EliminationTreeMPIDist<scalar_t,integer_t>> tree_mpi_dist_;
320  };
321 
322 } // end namespace strumpack
323 
324 #endif // STRUMPACK_SPARSE_SOLVER_MPI_DIST_HPP
strumpack::StrumpackSparseSolverMPIDist::broadcast_matrix
void broadcast_matrix(const CSRMatrix< scalar_t, integer_t > &A)
strumpack::MatrixReorderingMPI
Definition: StrumpackSparseSolverMPIDist.hpp:44
strumpack::StrumpackSparseSolverMPIDist::set_distributed_csr_matrix
void set_distributed_csr_matrix(integer_t local_rows, const integer_t *row_ptr, const integer_t *col_ind, const scalar_t *values, const integer_t *dist, bool symmetric_pattern=false)
strumpack::MPIComm
Wrapper class around an MPI_Comm object.
Definition: MPIWrapper.hpp:190
strumpack::Trans::N
@ N
strumpack::CSRMatrix
Class for storing a compressed sparse row matrix (single node).
Definition: CSRMatrix.hpp:53
CSRMatrixMPI.hpp
Contains the CSRMatrixMPI class definition, a class representing a block-row distributed compressed s...
strumpack
Definition: StrumpackOptions.hpp:42
strumpack::DenseMatrixWrapper
Like DenseMatrix, this class represents a matrix, stored in column major format, to allow direct use ...
Definition: DenseMatrix.hpp:990
StrumpackSparseSolverBase.hpp
Contains the definition of the base (abstract/pure virtual) sparse solver class.
strumpack::DenseMatrix< scalar_t >
strumpack::StrumpackSparseSolverMPIDist::update_matrix_values
void update_matrix_values(integer_t local_rows, const integer_t *row_ptr, const integer_t *col_ind, const scalar_t *values, const integer_t *dist, bool symmetric_pattern=false)
strumpack::StrumpackSparseSolverMPIDist
This is the fully distributed solver.
Definition: StrumpackSparseSolverMPIDist.hpp:71
strumpack::EliminationTreeMPIDist
Definition: StrumpackSparseSolverMPIDist.hpp:43
strumpack::StrumpackSparseSolverMPIDist::comm
MPI_Comm comm() const
strumpack::MPIComm::barrier
void barrier() const
Definition: MPIWrapper.hpp:295
strumpack::ReturnCode
ReturnCode
Enumeration for the possible return codes.
Definition: StrumpackParameters.hpp:60
strumpack::StrumpackSparseSolverMPIDist::StrumpackSparseSolverMPIDist
StrumpackSparseSolverMPIDist(MPI_Comm comm, int argc, char *argv[], bool verbose=true)
strumpack::CSRMatrixMPI
Block-row distributed compressed sparse row storage.
Definition: CSRMatrixMPI.hpp:72
strumpack::StrumpackSparseSolverMPIDist::set_matrix
void set_matrix(const CSRMatrixMPI< scalar_t, integer_t > &A)
strumpack::StrumpackSparseSolverMPIDist::set_MPIAIJ_matrix
void set_MPIAIJ_matrix(integer_t local_rows, const integer_t *d_ptr, const integer_t *d_ind, const scalar_t *d_val, const integer_t *o_ptr, const integer_t *o_ind, const scalar_t *o_val, const integer_t *garray)
strumpack::CompressedSparseMatrix
Abstract base class for compressed sparse matrix storage.
Definition: CompressedSparseMatrix.hpp:163
strumpack::StrumpackSparseSolverMPIDist::broadcast_csr_matrix
void broadcast_csr_matrix(integer_t N, const integer_t *row_ptr, const integer_t *col_ind, const scalar_t *values, bool symmetric_pattern=false)
strumpack::EliminationTree
Definition: StrumpackSparseSolverBase.hpp:53
strumpack::StrumpackSparseSolverMPIDist::update_MPIAIJ_matrix_values
void update_MPIAIJ_matrix_values(integer_t local_rows, const integer_t *d_ptr, const integer_t *d_ind, const scalar_t *d_val, const integer_t *o_ptr, const integer_t *o_ind, const scalar_t *o_val, const integer_t *garray)
strumpack::StrumpackSparseSolverMPIDist::~StrumpackSparseSolverMPIDist
~StrumpackSparseSolverMPIDist()
strumpack::MatrixReordering
Definition: StrumpackSparseSolverBase.hpp:52
strumpack::StrumpackSparseSolverBase
StrumpackSparseSolver is the main sequential or multithreaded sparse solver class.
Definition: StrumpackSparseSolverBase.hpp:77