Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_CssMKL_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_CSSMKL_DECL_HPP
23#define AMESOS2_CSSMKL_DECL_HPP
24
25#include <map>
26
27#include <Teuchos_StandardParameterEntryValidators.hpp>
28
30#include "Amesos2_SolverCore.hpp"
31#include "Amesos2_CssMKL_FunctionMap.hpp"
32
33
34namespace Amesos2 {
35
36
47 template <class Matrix,
48 class Vector>
49 class CssMKL : public SolverCore<Amesos2::CssMKL, Matrix, Vector>
50 {
51 friend class SolverCore<Amesos2::CssMKL,Matrix,Vector>; // Give our base access
52 // to our private
53 // implementation funcs
54 public:
55
57 static const char* name; // declaration. Initialization outside.
58
59 typedef CssMKL<Matrix,Vector> type;
60 typedef SolverCore<Amesos2::CssMKL,Matrix,Vector> super_type;
61
62 // Since typedef's are not inheritted, go grab them
63 typedef typename super_type::scalar_type scalar_type;
64 typedef typename super_type::local_ordinal_type local_ordinal_type;
65 typedef typename super_type::global_ordinal_type global_ordinal_type;
66 typedef typename super_type::global_size_type global_size_type;
67 typedef typename super_type::node_type node_type;
68 typedef Tpetra::Map<local_ordinal_type,
69 global_ordinal_type,
70 node_type> map_type;
71
72 typedef TypeMap<Amesos2::PardisoMKL,scalar_type> type_map;
73
74 typedef typename type_map::type solver_scalar_type;
75 typedef typename type_map::magnitude_type solver_magnitude_type;
76
77 // This may be PMKL::_INTEGER_t or long long int depending on the
78 // mapping and input ordinal
79 typedef typename TypeMap<Amesos2::PardisoMKL,global_ordinal_type>::type int_t;
80
81 /* For CssMKL we dispatch based on the integer type instead of
82 * the scalar type:
83 * - _INTEGER_t => use the cluster_sparse_solver(...) method
84 * - long long int => use the cluster_sparse_solver_64(...) method
85 */
86 typedef FunctionMap<Amesos2::CssMKL,int_t> function_map;
87
88 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
89 typedef Kokkos::View<int_t*, HostExecSpaceType> host_size_type_array;
90 typedef Kokkos::View<int_t*, HostExecSpaceType> host_ordinal_type_array;
91 typedef Kokkos::View<solver_scalar_type*, HostExecSpaceType> host_value_type_array;
92
94
95
102 CssMKL(Teuchos::RCP<const Matrix> A,
103 Teuchos::RCP<Vector> X,
104 Teuchos::RCP<const Vector> B);
105
106
108 ~CssMKL( );
109
111
112 private:
113
121 int preOrdering_impl();
122
123
132
133
140
141
152 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
153 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
154
155
161 bool matrixShapeOK_impl() const;
162
163
195 void setParameters_impl(const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
196
197
202 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
203
204
213 bool loadA_impl(EPhase current_phase);
214
215
217
238 void check_css_mkl_error(EPhase phase, int_t error) const;
239
249 void set_css_mkl_matrix_type(int_t mtype = 0);
250 void set_css_mkl_default_parameters(void* pt[], int_t iparm[]) const;
251
252
253 /* Declare private variables necessary for interaction with the
254 * CssMKL TPL.
255 *
256 * For example, the following Arrays are persisting storage arrays
257 * for A, X, and B that can be used with solvers expecting a
258 * compressed-row representation of the matrix A.
259 */
260
262 host_value_type_array nzvals_view_;
263 host_value_type_array nzvals_temp_;
265 host_ordinal_type_array colind_view_;
267 host_size_type_array rowptr_view_;
269 mutable Teuchos::Array<solver_scalar_type> xvals_;
271 mutable Teuchos::Array<solver_scalar_type> bvals_;
272
274 mutable void* pt_[64];
276 int_t mtype_;
278 int_t n_;
280 Teuchos::Array<int_t> perm_;
282 mutable int_t nrhs_;
283
284 bool css_initialized_;
285 bool is_contiguous_;
286
288 int_t msglvl_;
289
292 int_t iparm_[64];
293
294 // We will deal with 1 factor at a time
295 static const int_t maxfct_;
296 static const int_t mnum_;
297
298
299 static const bool complex_
300 = Meta::or_<std::is_same_v<solver_scalar_type, PMKL::_MKL_Complex8>,
301 std::is_same_v<solver_scalar_type, PMKL::_DOUBLE_COMPLEX_t>>::value;
302
303 MPI_Fint CssComm_;
304 Teuchos::RCP<const map_type> css_rowmap_;
305 Teuchos::RCP<const map_type> css_contig_rowmap_;
306 Teuchos::RCP<const map_type> css_contig_colmap_;
307
308}; // End class CssMKL
309
310
311// Specialize the solver_traits struct for CssMKL.
312template <>
313struct solver_traits<CssMKL> {
314#ifdef HAVE_TEUCHOS_COMPLEX
315 typedef Meta::make_list6<float,
316 double,
317 std::complex<float>,
318 std::complex<double>,
319 PMKL::_MKL_Complex8,
320 PMKL::_DOUBLE_COMPLEX_t> supported_scalars;
321#else
322typedef Meta::make_list2<float,
323 double> supported_scalars;
324#endif
325};
326
327} // end namespace Amesos
328
329#endif // AMESOS2_CSSMKL_DECL_HPP
Provides access to interesting solver traits.
Amesos2 interface to the CssMKL package.
Definition Amesos2_CssMKL_decl.hpp:50
Teuchos::Array< solver_scalar_type > xvals_
Persisting, contiguous, 1D store for X.
Definition Amesos2_CssMKL_decl.hpp:269
void * pt_[64]
CssMKL internal data address pointer.
Definition Amesos2_CssMKL_decl.hpp:274
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_CssMKL_def.hpp:456
int_t mtype_
The matrix type. We deal only with unsymmetrix matrices.
Definition Amesos2_CssMKL_decl.hpp:276
host_size_type_array rowptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_CssMKL_decl.hpp:267
void check_css_mkl_error(EPhase phase, int_t error) const
Throws an appropriate runtime error in the event that error < 0 .
Definition Amesos2_CssMKL_def.hpp:548
Teuchos::Array< solver_scalar_type > bvals_
Persisting, contiguous, 1D store for B.
Definition Amesos2_CssMKL_decl.hpp:271
int_t msglvl_
The messaging level. Set to 1 if you wish for CSS to print statistical info.
Definition Amesos2_CssMKL_decl.hpp:288
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for CssMKL.
Definition Amesos2_CssMKL_decl.hpp:262
static const char * name
The name of this solver interface.
Definition Amesos2_CssMKL_decl.hpp:57
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition Amesos2_CssMKL_def.hpp:121
host_ordinal_type_array colind_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_CssMKL_decl.hpp:265
Teuchos::Array< int_t > perm_
Permutation vector.
Definition Amesos2_CssMKL_decl.hpp:280
int numericFactorization_impl()
CssMKL specific numeric factorization.
Definition Amesos2_CssMKL_def.hpp:169
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using CssMKL.
Definition Amesos2_CssMKL_def.hpp:131
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_CssMKL_def.hpp:272
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
CssMKL specific solve.
Definition Amesos2_CssMKL_def.hpp:202
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_CssMKL_def.hpp:380
int_t iparm_[64]
Definition Amesos2_CssMKL_decl.hpp:292
int_t n_
Number of equations in the sparse linear system.
Definition Amesos2_CssMKL_decl.hpp:278
void set_css_mkl_matrix_type(int_t mtype=0)
Definition Amesos2_CssMKL_def.hpp:602
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition Amesos2_CssMKL_def.hpp:281
int_t nrhs_
number of righthand-side vectors
Definition Amesos2_CssMKL_decl.hpp:282
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