Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_PardisoMKL_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
10
22#ifndef AMESOS2_PARDISOMKL_DECL_HPP
23#define AMESOS2_PARDISOMKL_DECL_HPP
24
25#include <Teuchos_StandardParameterEntryValidators.hpp>
26
28#include "Amesos2_SolverCore.hpp"
29#include "Amesos2_PardisoMKL_FunctionMap.hpp"
30
31
32namespace Amesos2 {
33
34
45 template <class Matrix,
46 class Vector>
47 class PardisoMKL : public SolverCore<Amesos2::PardisoMKL, Matrix, Vector>
48 {
49 friend class SolverCore<Amesos2::PardisoMKL,Matrix,Vector>; // Give our base access
50 // to our private
51 // implementation funcs
52 public:
53
55 static const char* name; // declaration. Initialization outside.
56
57 typedef PardisoMKL<Matrix,Vector> type;
58 typedef SolverCore<Amesos2::PardisoMKL,Matrix,Vector> super_type;
59
60 // Since typedef's are not inheritted, go grab them
61 typedef typename super_type::scalar_type scalar_type;
62 typedef typename super_type::local_ordinal_type local_ordinal_type;
63 typedef typename super_type::global_ordinal_type global_ordinal_type;
64 typedef typename super_type::global_size_type global_size_type;
65
66 typedef TypeMap<Amesos2::PardisoMKL,scalar_type> type_map;
67
68 typedef typename type_map::type solver_scalar_type;
69 typedef typename type_map::magnitude_type solver_magnitude_type;
70
71 // This may be PMKL::_INTEGER_t or long long int depending on the
72 // mapping and input ordinal
73 typedef typename TypeMap<Amesos2::PardisoMKL,local_ordinal_type>::type int_t;
74
75 /* For PardisoMKL we dispatch based on the integer type instead of
76 * the scalar type:
77 * - _INTEGER_t => use the pardiso(...) method
78 * - long long int => use the pardiso_64(...) method
79 */
80 typedef FunctionMap<Amesos2::PardisoMKL,int_t> function_map;
81
82 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
83 typedef Kokkos::View<int_t*, HostExecSpaceType> host_size_type_array;
84 typedef Kokkos::View<int_t*, HostExecSpaceType> host_ordinal_type_array;
85 typedef Kokkos::View<solver_scalar_type*, HostExecSpaceType> host_value_type_array;
86 typedef typename Kokkos::View<solver_scalar_type**, Kokkos::LayoutLeft,
87 typename HostExecSpaceType::memory_space> host_solver_scalar_view;
88
90
91
98 PardisoMKL(Teuchos::RCP<const Matrix> A,
99 Teuchos::RCP<Vector> X,
100 Teuchos::RCP<const Vector> B);
101
102
104 ~PardisoMKL( );
105
107
108 private:
109
117 int preOrdering_impl();
118
119
128
129
136
137
148 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
149 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
150
151
157 bool matrixShapeOK_impl() const;
158
159
178 void setParameters_impl(const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
179
180
185 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
186
187
196 bool loadA_impl(EPhase current_phase);
197
198
203 void describe_impl(Teuchos::FancyOStream &out,
204 const Teuchos::EVerbosityLevel verbLevel) const;
205
206
208
229 void check_pardiso_mkl_error(EPhase phase, int_t error) const;
230
240 void set_pardiso_mkl_matrix_type(int_t mtype = 0);
241
242
243 /* Declare private variables necessary for interaction with the
244 * PardisoMKL TPL.
245 *
246 * For example, the following Arrays are persisting storage arrays
247 * for A, X, and B that can be used with solvers expecting a
248 * compressed-row representation of the matrix A.
249 */
250
252 host_value_type_array nzvals_view_;
254 host_ordinal_type_array colind_view_;
256 host_size_type_array rowptr_view_;
258 mutable host_solver_scalar_view xvals_;
260 mutable host_solver_scalar_view bvals_;
261
263 mutable void* pt_[64];
265 int_t mtype_;
267 int_t n_;
269 Teuchos::Array<int_t> perm_;
271 mutable int_t nrhs_;
272
273 // Partial factorization
274 size_t schur_size_;
275 int_t partial_facto_;
276 host_size_type_array schur_part_;
277 host_value_type_array schur_out_;
278 scalar_type* schur_out_ptr_;
279 mutable host_solver_scalar_view wvals_;
280 bool only_forward_solve_;
281 bool only_backward_solve_;
282
285 int_t iparm_[64];
286
287 // We will deal with 1 factor at a time
288 static const int_t maxfct_;
289 static const int_t mnum_;
290
291
292 static const bool complex_
293 = Meta::or_<std::is_same_v<solver_scalar_type, PMKL::_MKL_Complex8>,
294 std::is_same_v<solver_scalar_type, PMKL::_DOUBLE_COMPLEX_t>>::value;
295
296 bool pardiso_initialized_;
297 bool is_contiguous_;
298
300 int_t msglvl_;
301 int debug_level_;
302}; // End class PardisoMKL
303
304
305// Specialize the solver_traits struct for PardisoMKL.
306template <>
307struct solver_traits<PardisoMKL> {
308#ifdef HAVE_TEUCHOS_COMPLEX
309 typedef Meta::make_list6<float,
310 double,
311 std::complex<float>,
312 std::complex<double>,
313 PMKL::_MKL_Complex8,
314 PMKL::_DOUBLE_COMPLEX_t> supported_scalars;
315#else
316typedef Meta::make_list2<float,
317 double> supported_scalars;
318#endif
319};
320
321template <typename Scalar, typename LocalOrdinal, typename ExecutionSpace>
322struct solver_supports_matrix<PardisoMKL,
323 KokkosSparse::CrsMatrix<Scalar, LocalOrdinal, ExecutionSpace>> {
324 static const bool value = true;
325};
326} // end namespace Amesos
327
328#endif // AMESOS2_PARDISOMKL_DECL_HPP
Provides access to interesting solver traits.
Amesos2 interface to the PardisoMKL package.
Definition Amesos2_PardisoMKL_decl.hpp:48
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_PardisoMKL_def.hpp:573
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition Amesos2_PardisoMKL_def.hpp:389
void describe_impl(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the status information about the current solver with some level of verbosity.
Definition Amesos2_PardisoMKL_def.hpp:750
int_t nrhs_
number of righthand-side vectors
Definition Amesos2_PardisoMKL_decl.hpp:271
int_t mtype_
The matrix type. We deal only with unsymmetrix matrices.
Definition Amesos2_PardisoMKL_decl.hpp:265
int_t iparm_[64]
Definition Amesos2_PardisoMKL_decl.hpp:285
int numericFactorization_impl()
PardisoMKL specific numeric factorization.
Definition Amesos2_PardisoMKL_def.hpp:174
int_t n_
Number of equations in the sparse linear system.
Definition Amesos2_PardisoMKL_decl.hpp:267
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_PardisoMKL_def.hpp:380
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_PardisoMKL_def.hpp:703
Teuchos::Array< int_t > perm_
Permutation vector.
Definition Amesos2_PardisoMKL_decl.hpp:269
void set_pardiso_mkl_matrix_type(int_t mtype=0)
Definition Amesos2_PardisoMKL_def.hpp:835
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
PardisoMKL specific solve.
Definition Amesos2_PardisoMKL_def.hpp:223
int_t msglvl_
The messaging level. Set to 1 if you wish for Pardiso MKL to print statistical info.
Definition Amesos2_PardisoMKL_decl.hpp:300
host_ordinal_type_array colind_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_PardisoMKL_decl.hpp:254
host_solver_scalar_view xvals_
Persisting, contiguous, 2D view for X.
Definition Amesos2_PardisoMKL_decl.hpp:258
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition Amesos2_PardisoMKL_def.hpp:106
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for PardisoMKL.
Definition Amesos2_PardisoMKL_decl.hpp:252
void check_pardiso_mkl_error(EPhase phase, int_t error) const
Throws an appropriate runtime error in the event that error < 0 .
Definition Amesos2_PardisoMKL_def.hpp:782
void * pt_[64]
PardisoMKL internal data address pointer.
Definition Amesos2_PardisoMKL_decl.hpp:263
static const char * name
The name of this solver interface.
Definition Amesos2_PardisoMKL_decl.hpp:55
host_solver_scalar_view bvals_
Persisting, contiguous, 2D view for B.
Definition Amesos2_PardisoMKL_decl.hpp:260
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using PardisoMKL.
Definition Amesos2_PardisoMKL_def.hpp:117
host_size_type_array rowptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_PardisoMKL_decl.hpp:256
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition Amesos2_SolverCore_decl.hpp:72
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