Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_Superludist_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Amesos2: Templated Direct Sparse Solver Package
4//
5// Copyright 2011 NTESS and the Amesos2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
19#ifndef AMESOS2_SUPERLUDIST_DECL_HPP
20#define AMESOS2_SUPERLUDIST_DECL_HPP
21
23#include "Amesos2_SolverCore.hpp"
25
26namespace Amesos2 {
27
28
54template <class Matrix,
55 class Vector>
56class Superludist : public SolverCore<Amesos2::Superludist, Matrix, Vector>
57{
58 friend class SolverCore<Amesos2::Superludist,Matrix,Vector>; // Give our base access
59 // to our private
60 // implementation funcs
61public:
62
64 static const char* name; // declaration. Initialization outside.
65
66 typedef Superludist<Matrix,Vector> type;
67 typedef SolverCore<Amesos2::Superludist,Matrix,Vector> super_type;
68
69 typedef Matrix matrix_type;
70 typedef Vector vector_type;
71
72 // Since typedef's are not inheritted, go grab them
73 typedef typename super_type::scalar_type scalar_type;
74 typedef typename super_type::local_ordinal_type local_ordinal_type;
75 typedef typename super_type::global_ordinal_type global_ordinal_type;
76 typedef typename super_type::global_size_type global_size_type;
77 typedef typename super_type::node_type node_type;
78
79 typedef TypeMap<Amesos2::Superludist,scalar_type> type_map;
80
81 typedef typename type_map::type slu_type;
82 typedef typename type_map::magnitude_type magnitude_type;
83
84 typedef FunctionMap<Amesos2::Superludist,slu_type> function_map;
85
86 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
87 typedef Kokkos::View<SLUD::int_t*, HostExecSpaceType> host_size_type_array;
88 typedef Kokkos::View<SLUD::int_t*, HostExecSpaceType> host_ordinal_type_array;
89 typedef Kokkos::View<slu_type*, HostExecSpaceType> host_value_type_array;
90
91 typedef Tpetra::Map<local_ordinal_type,
92 global_ordinal_type,
93 node_type> map_type;
94
96
97
104 Superludist(Teuchos::RCP<const Matrix> A,
105 Teuchos::RCP<Vector> X,
106 Teuchos::RCP<const Vector> B);
107
108
110 ~Superludist( );
111
113
114private:
115
122 void computeRowPermutationLargeDiagMC64(SLUD::SuperMatrix& GA);
123
130 int preOrdering_impl();
131
132
141
142
153
154
166 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
167 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
168
169
175 bool matrixShapeOK_impl() const;
176
177
199 /*
200 * The following options could be supported in the future:
201 *
202 * <li> \c "Equil" : { \c "YES" | \c "NO" } or, equivalently, { \c true | \c false }.
203 * Specifies whether the solver to equilibrate the matrix before solving.</li>
204 * <li> \c "IterRefine" : { \c "NO" | \c "SINGLE" | \c "DOUBLE" | \c "EXTRA"
205 * }. Specifies whether to perform iterative refinement, and in
206 * what precision to compute the residual. (Not currently supported)</li>
207 */
209 const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
210
211
218 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
219
220
233 void get_default_grid_size(int nprocs, SLUD::int_t& nprow, SLUD::int_t& npcol) const;
234
235
250 bool loadA_impl(EPhase current_phase);
251
252
253 // struct holds all data necessary to make a superlu factorization or solve call
254 mutable struct SLUData {
255 SLUD::SuperMatrix A;
256 SLUD::SuperMatrix AC;
257 typename type_map::LUstruct_t LU;
258 SLUD::Glu_freeable_t glu_freeable;
259
263 int domains;
264 MPI_Comm symb_comm;
265 SLUD::int_t *sizes, *fstVtxSep; // memory allocated by get_perm_c_parmetis
266 SLUD::Pslu_freeable_t pslu_freeable;
267
268 SLUD::amesos2_superlu_dist_options_t options;
269 SLUD::amesos2_superlu_dist_mem_usage_t mem_usage;
270 SLUD::gridinfo_t grid;
271 MPI_Comm mat_comm;
272 typename type_map::LUstruct_t lu;
273 SLUD::SuperLUStat_t stat;
274 typename type_map::SOLVEstruct_t solve_struct;
275
276 Teuchos::Array<magnitude_type> berr;
277 Teuchos::Array<magnitude_type> ferr;
278
279 // Pick up data type specific ScalePermstruct_t
280 typename type_map::ScalePermstruct_t scale_perm; // R, C, perm_r, and perm_c found in here
281
282 Teuchos::Array<magnitude_type> R, C; // equilibration scalings
283 Teuchos::Array<magnitude_type> R1, C1; // row-permutation scalings
284 Teuchos::Array<SLUD::int_t> perm_r, perm_c;
285
286 SLUD::DiagScale_t equed;
287 bool rowequ, colequ;
288 magnitude_type rowcnd, colcnd, amax;
289 int largediag_mc64_job; // job id for LargeDiag_MC64 row permutation
290 } data_;
291
292 // The following Arrays are persisting storage arrays for A, X, and B
294 host_value_type_array nzvals_view_;
295 host_value_type_array nzvals_temp_;
297 host_ordinal_type_array colind_view_;
299 host_size_type_array rowptr_view_;
301 mutable Teuchos::Array<slu_type> bvals_;
303 mutable Teuchos::Array<slu_type> xvals_;
304
307 bool same_symbolic_;
308 bool force_symbfact_;
309 mutable bool same_solve_struct_; // may be modified in solve_impl, but still `logically const'
310
312 Teuchos::RCP<const map_type> superlu_rowmap_;
313 Teuchos::RCP<const map_type> superlu_contig_rowmap_;
314 Teuchos::RCP<const map_type> superlu_contig_colmap_;
315
316 bool is_contiguous_;
317
318}; // End class Superludist
319
320
321// Specialize the solver_traits template for SuperLU_DIST
322template <>
324#if defined(HAVE_TEUCHOS_COMPLEX) && !defined(__clang__)
325 typedef Meta::make_list3<double, std::complex<double>, SLUD::Z::doublecomplex> supported_scalars;
326#else
327 typedef Meta::make_list1<double> supported_scalars;
328#endif
329};
330
331} // end namespace Amesos2
332
333#endif // AMESOS2_SUPERLUDIST_DECL_HPP
Provides access to interesting solver traits.
Provides a mechanism to map function calls to the correct Solver function based on the scalar type of...
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition Amesos2_SolverCore_decl.hpp:72
Amesos2 interface to the distributed memory version of SuperLU.
Definition Amesos2_Superludist_decl.hpp:57
bool in_grid_
true if this processor is in SuperLU_DISTS's 2D process grid
Definition Amesos2_Superludist_decl.hpp:306
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_Superludist_def.hpp:780
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition Amesos2_Superludist_def.hpp:789
static const char * name
Name of this solver interface.
Definition Amesos2_Superludist_decl.hpp:64
int numericFactorization_impl()
SuperLU_DIST specific numeric factorization.
Definition Amesos2_Superludist_def.hpp:463
host_ordinal_type_array colind_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_Superludist_decl.hpp:297
Teuchos::RCP< const map_type > superlu_rowmap_
Maps rows of the matrix to processors in the SuperLU_DIST processor grid.
Definition Amesos2_Superludist_decl.hpp:312
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal solver structures.
Definition Amesos2_Superludist_def.hpp:977
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for SuperLU_DIST.
Definition Amesos2_Superludist_decl.hpp:294
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition Amesos2_Superludist_def.hpp:358
Teuchos::Array< slu_type > bvals_
1D store for B values
Definition Amesos2_Superludist_decl.hpp:301
host_size_type_array rowptr_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_Superludist_decl.hpp:299
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
SuperLU_DIST specific solve.
Definition Amesos2_Superludist_def.hpp:614
void get_default_grid_size(int nprocs, SLUD::int_t &nprow, SLUD::int_t &npcol) const
Definition Amesos2_Superludist_def.hpp:952
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using SuperLU_DIST.
Definition Amesos2_Superludist_def.hpp:414
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_Superludist_def.hpp:866
Teuchos::Array< slu_type > xvals_
1D store for X values
Definition Amesos2_Superludist_decl.hpp:303
void computeRowPermutationLargeDiagMC64(SLUD::SuperMatrix &GA)
Compute the row permutation for option LargeDiag-MC64.
Definition Amesos2_Superludist_def.hpp:303
Passes functions to TPL functions based on type.
Definition Amesos2_FunctionMap.hpp:43
Map types to solver-specific data-types and enums.
Definition Amesos2_TypeMap.hpp:48
Provides traits about solvers.
Definition Amesos2_SolverTraits.hpp:37