Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_Lapack_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
20#ifndef AMESOS2_LAPACK_DECL_HPP
21#define AMESOS2_LAPACK_DECL_HPP
22
23#include <Teuchos_ScalarTraits.hpp>
24#include <Teuchos_SerialDenseSolver.hpp>
25#include <Teuchos_SerialDenseMatrix.hpp>
26
28#include "Amesos2_SolverCore.hpp"
29
30
31namespace Amesos2 {
32
33
44 template <class Matrix,
45 class Vector>
46 class Lapack : public SolverCore<Amesos2::Lapack, Matrix, Vector>
47 {
48 friend class SolverCore<Amesos2::Lapack,Matrix,Vector>; // Give our base access
49 // to our private
50 // implementation funcs
51 public:
52
54 static const char* name; // declaration. Initialization outside.
55
56 typedef Lapack<Matrix,Vector> type;
57 typedef SolverCore<Amesos2::Lapack,Matrix,Vector> super_type;
58
59 // Since typedef's are not inheritted, go grab them
60 typedef typename super_type::scalar_type scalar_type;
61 typedef typename super_type::local_ordinal_type local_ordinal_type;
62 typedef typename super_type::global_ordinal_type global_ordinal_type;
63 typedef typename super_type::global_size_type global_size_type;
64
65 // Version of scalar type that can be used in Kokkos device code
66 typedef typename MatrixTraits<Matrix>::impl_scalar_type impl_scalar_type;
67
68 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
69
70 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
71 typedef Kokkos::View<int*, HostExecSpaceType> host_size_type_array;
72 typedef Kokkos::View<int*, HostExecSpaceType> host_ordinal_type_array;
73 typedef Kokkos::View<impl_scalar_type*, HostExecSpaceType> host_value_type_array;
74
76
77
84 Lapack(Teuchos::RCP<const Matrix> A,
85 Teuchos::RCP<Vector> X,
86 Teuchos::RCP<const Vector> B);
87
88
90 ~Lapack( );
91
93
94 private:
95
99 int preOrdering_impl();
100
101
106
107
114
115
126 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
127 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
128
129
133 bool matrixShapeOK_impl() const;
134
135
144 void setParameters_impl(const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
145
146
151 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
152
153
162 bool loadA_impl(EPhase current_phase);
163
164
169 void describe_impl(Teuchos::FancyOStream &out,
170 const Teuchos::EVerbosityLevel verbLevel) const;
171
172
173 // We keep some `temporary' storage for when we retrive values
174 // from the input matrix
175 //
176 // NOTE:: It seems that the Teuchos::LAPACK wrappers only really
177 // work for the OrdinalType=int case, so that's what we'll work
178 // with, but ideally we should just be able to give
179 // global_ordinal_type.
180
182 Teuchos::Array<scalar_type> nzvals_;
184 // Teuchos::Array<global_ordinal_type> rowind_;
185 Teuchos::Array<int> rowind_;
187 // Teuchos::Array<global_size_type> colptr_;
188 Teuchos::Array<int> colptr_;
190 mutable Teuchos::Array<scalar_type> rhsvals_;
191
192 // The following Kokkos::View's are persisting storage for A's CCS arrays
194 host_value_type_array nzvals_view_;
196 host_ordinal_type_array rowind_view_;
198 host_size_type_array colptr_view_;
199
201 // Teuchos::SerialDenseMatrix<global_ordinal_type,scalar_type> lu_;
202 Teuchos::SerialDenseMatrix<int,scalar_type> lu_;
203
205 // Teuchos::SerialDenseSolver<global_ordinal_type,scalar_type> solver_;
206 mutable Teuchos::SerialDenseSolver<int,scalar_type> solver_;
207
208 bool is_contiguous_;
209
210 }; // End class Lapack
211
212
213 // Specialize the solver_traits struct for Lapack.
214 //
215 // Specializations of Teuchos::LAPACK only exist for real and
216 // complex float and double types.
217 //
218 // TODO: Reinstate the complex support once the bug in
219 // Teuchos::SerialDenseSolver has been fixed
220 template <>
221 struct solver_traits<Lapack> {
222// #ifdef HAVE_TEUCHOS_COMPLEX
223// typedef Meta::make_list4<float,
224// double,
225// std::complex<float>,
226// std::complex<double> >supported_scalars;
227// #else
228 typedef Meta::make_list2<float, double> supported_scalars;
229// #endif
230};
231
232} // end namespace Amesos2
233
234#endif // AMESOS2_NEWSOLVER_DECL_HPP
Provides access to interesting solver traits.
Amesos2 interface to the LAPACK.
Definition Amesos2_Lapack_decl.hpp:47
Teuchos::SerialDenseMatrix< int, scalar_type > lu_
L and U storage.
Definition Amesos2_Lapack_decl.hpp:202
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition Amesos2_Lapack_def.hpp:183
Teuchos::Array< int > colptr_
Stores the location in Ai_ and Aval_ that starts col j.
Definition Amesos2_Lapack_decl.hpp:188
host_size_type_array colptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_Lapack_decl.hpp:198
Teuchos::Array< int > rowind_
Stores the column indices of the nonzero entries.
Definition Amesos2_Lapack_decl.hpp:185
Teuchos::SerialDenseSolver< int, scalar_type > solver_
The serial solver.
Definition Amesos2_Lapack_decl.hpp:206
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_Lapack_def.hpp:172
int numericFactorization_impl()
Perform numeric factorization using LAPACK.
Definition Amesos2_Lapack_def.hpp:71
Teuchos::Array< scalar_type > nzvals_
Stores the values of the nonzero entries.
Definition Amesos2_Lapack_decl.hpp:182
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_Lapack_def.hpp:199
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_Lapack_def.hpp:223
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for Umfpack.
Definition Amesos2_Lapack_decl.hpp:194
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Lapack solve.
Definition Amesos2_Lapack_def.hpp:98
int preOrdering_impl()
No-op.
Definition Amesos2_Lapack_def.hpp:55
host_ordinal_type_array rowind_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_Lapack_decl.hpp:196
int symbolicFactorization_impl()
No-op.
Definition Amesos2_Lapack_def.hpp:63
Teuchos::Array< scalar_type > rhsvals_
Store for RHS and Solution values.
Definition Amesos2_Lapack_decl.hpp:190
static const char * name
The name of this solver interface.
Definition Amesos2_Lapack_decl.hpp:54
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_Lapack_def.hpp:278
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition Amesos2_SolverCore_decl.hpp:72
Provides traits about solvers.
Definition Amesos2_SolverTraits.hpp:37