Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_PardisoMKL_decl.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// Amesos2: Templated Direct Sparse Solver Package
6// Copyright 2011 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39//
40// ***********************************************************************
41//
42// @HEADER
43
44
56#ifndef AMESOS2_PARDISOMKL_DECL_HPP
57#define AMESOS2_PARDISOMKL_DECL_HPP
58
59#include <map>
60
61#include <Teuchos_StandardParameterEntryValidators.hpp>
62
64#include "Amesos2_SolverCore.hpp"
65#include "Amesos2_PardisoMKL_FunctionMap.hpp"
66
67
68namespace Amesos2 {
69
70
81 template <class Matrix,
82 class Vector>
83 class PardisoMKL : public SolverCore<Amesos2::PardisoMKL, Matrix, Vector>
84 {
85 friend class SolverCore<Amesos2::PardisoMKL,Matrix,Vector>; // Give our base access
86 // to our private
87 // implementation funcs
88 public:
89
91 static const char* name; // declaration. Initialization outside.
92
93 typedef PardisoMKL<Matrix,Vector> type;
94 typedef SolverCore<Amesos2::PardisoMKL,Matrix,Vector> super_type;
95
96 // Since typedef's are not inheritted, go grab them
97 typedef typename super_type::scalar_type scalar_type;
98 typedef typename super_type::local_ordinal_type local_ordinal_type;
99 typedef typename super_type::global_ordinal_type global_ordinal_type;
100 typedef typename super_type::global_size_type global_size_type;
101
102 typedef TypeMap<Amesos2::PardisoMKL,scalar_type> type_map;
103
104 typedef typename type_map::type solver_scalar_type;
105 typedef typename type_map::magnitude_type solver_magnitude_type;
106
107 // This may be PMKL::_INTEGER_t or long long int depending on the
108 // mapping and input ordinal
109 typedef typename TypeMap<Amesos2::PardisoMKL,local_ordinal_type>::type int_t;
110
111 /* For PardisoMKL we dispatch based on the integer type instead of
112 * the scalar type:
113 * - _INTEGER_t => use the pardiso(...) method
114 * - long long int => use the pardiso_64(...) method
115 */
116 typedef FunctionMap<Amesos2::PardisoMKL,int_t> function_map;
117
118 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
119 typedef Kokkos::View<int_t*, HostExecSpaceType> host_size_type_array;
120 typedef Kokkos::View<int_t*, HostExecSpaceType> host_ordinal_type_array;
121 typedef Kokkos::View<solver_scalar_type*, HostExecSpaceType> host_value_type_array;
122
124
125
132 PardisoMKL(Teuchos::RCP<const Matrix> A,
133 Teuchos::RCP<Vector> X,
134 Teuchos::RCP<const Vector> B);
135
136
138 ~PardisoMKL( );
139
141
142 private:
143
151 int preOrdering_impl();
152
153
162
163
170
171
182 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
183 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
184
185
191 bool matrixShapeOK_impl() const;
192
193
212 void setParameters_impl(const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
213
214
219 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
220
221
230 bool loadA_impl(EPhase current_phase);
231
232
234
255 void check_pardiso_mkl_error(EPhase phase, int_t error) const;
256
266 void set_pardiso_mkl_matrix_type(int_t mtype = 0);
267
268
269 /* Declare private variables necessary for interaction with the
270 * PardisoMKL TPL.
271 *
272 * For example, the following Arrays are persisting storage arrays
273 * for A, X, and B that can be used with solvers expecting a
274 * compressed-row representation of the matrix A.
275 */
276
278 host_value_type_array nzvals_view_;
280 host_ordinal_type_array colind_view_;
282 host_size_type_array rowptr_view_;
284 mutable Teuchos::Array<solver_scalar_type> xvals_;
286 mutable Teuchos::Array<solver_scalar_type> bvals_;
287
289 mutable void* pt_[64];
291 int_t mtype_;
293 int_t n_;
295 Teuchos::Array<int_t> perm_;
297 mutable int_t nrhs_;
298
301 int_t iparm_[64];
302
304 static const int_t msglvl_;
305
306 // We will deal with 1 factor at a time
307 static const int_t maxfct_;
308 static const int_t mnum_;
309
310
311 static const bool complex_
312 = Meta::or_<Meta::is_same<solver_scalar_type, PMKL::_MKL_Complex8>::value,
313 Meta::is_same<solver_scalar_type, PMKL::_DOUBLE_COMPLEX_t>::value>::value;
314
315 bool is_contiguous_;
316
317}; // End class PardisoMKL
318
319
320// Specialize the solver_traits struct for PardisoMKL.
321template <>
322struct solver_traits<PardisoMKL> {
323#ifdef HAVE_TEUCHOS_COMPLEX
324 typedef Meta::make_list6<float,
325 double,
326 std::complex<float>,
327 std::complex<double>,
328 PMKL::_MKL_Complex8,
329 PMKL::_DOUBLE_COMPLEX_t> supported_scalars;
330#else
331typedef Meta::make_list2<float,
332 double> supported_scalars;
333#endif
334};
335
336} // end namespace Amesos
337
338#endif // AMESOS2_PARDISOMKL_DECL_HPP
Provides access to interesting solver traits.
Amesos2 interface to the PardisoMKL package.
Definition Amesos2_PardisoMKL_decl.hpp:84
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_PardisoMKL_def.hpp:406
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition Amesos2_PardisoMKL_def.hpp:303
int_t nrhs_
number of righthand-side vectors
Definition Amesos2_PardisoMKL_decl.hpp:297
int_t mtype_
The matrix type. We deal only with unsymmetrix matrices.
Definition Amesos2_PardisoMKL_decl.hpp:291
int_t iparm_[64]
Definition Amesos2_PardisoMKL_decl.hpp:301
int numericFactorization_impl()
PardisoMKL specific numeric factorization.
Definition Amesos2_PardisoMKL_def.hpp:176
static const int_t msglvl_
The messaging level. Set to 1 if you wish for Pardiso MKL to print statistical info.
Definition Amesos2_PardisoMKL_decl.hpp:304
int_t n_
Number of equations in the sparse linear system.
Definition Amesos2_PardisoMKL_decl.hpp:293
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_PardisoMKL_def.hpp:294
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_PardisoMKL_def.hpp:508
Teuchos::Array< int_t > perm_
Permutation vector.
Definition Amesos2_PardisoMKL_decl.hpp:295
void set_pardiso_mkl_matrix_type(int_t mtype=0)
Definition Amesos2_PardisoMKL_def.hpp:606
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:203
host_ordinal_type_array colind_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_PardisoMKL_decl.hpp:280
Teuchos::Array< solver_scalar_type > bvals_
Persisting, contiguous, 1D store for B.
Definition Amesos2_PardisoMKL_decl.hpp:286
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition Amesos2_PardisoMKL_def.hpp:133
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for PardisoMKL.
Definition Amesos2_PardisoMKL_decl.hpp:278
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:553
void * pt_[64]
PardisoMKL internal data address pointer.
Definition Amesos2_PardisoMKL_decl.hpp:289
static const char * name
The name of this solver interface.
Definition Amesos2_PardisoMKL_decl.hpp:91
Teuchos::Array< solver_scalar_type > xvals_
Persisting, contiguous, 1D store for X.
Definition Amesos2_PardisoMKL_decl.hpp:284
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using PardisoMKL.
Definition Amesos2_PardisoMKL_def.hpp:144
host_size_type_array rowptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_PardisoMKL_decl.hpp:282
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition Amesos2_SolverCore_decl.hpp:106
Passes functions to TPL functions based on type.
Definition Amesos2_FunctionMap.hpp:77
Map types to solver-specific data-types and enums.
Definition Amesos2_TypeMap.hpp:82
Provides traits about solvers.
Definition Amesos2_SolverTraits.hpp:71