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
165 // We keep some `temporary' storage for when we retrive values
166 // from the input matrix
167 //
168 // NOTE:: It seems that the Teuchos::LAPACK wrappers only really
169 // work for the OrdinalType=int case, so that's what we'll work
170 // with, but ideally we should just be able to give
171 // global_ordinal_type.
172
174 Teuchos::Array<scalar_type> nzvals_;
176 // Teuchos::Array<global_ordinal_type> rowind_;
177 Teuchos::Array<int> rowind_;
179 // Teuchos::Array<global_size_type> colptr_;
180 Teuchos::Array<int> colptr_;
182 mutable Teuchos::Array<scalar_type> rhsvals_;
183
184 // The following Kokkos::View's are persisting storage for A's CCS arrays
186 host_value_type_array nzvals_view_;
188 host_ordinal_type_array rowind_view_;
190 host_size_type_array colptr_view_;
191
193 // Teuchos::SerialDenseMatrix<global_ordinal_type,scalar_type> lu_;
194 Teuchos::SerialDenseMatrix<int,scalar_type> lu_;
195
197 // Teuchos::SerialDenseSolver<global_ordinal_type,scalar_type> solver_;
198 mutable Teuchos::SerialDenseSolver<int,scalar_type> solver_;
199
200 bool is_contiguous_;
201
202 }; // End class Lapack
203
204
205 // Specialize the solver_traits struct for Lapack.
206 //
207 // Specializations of Teuchos::LAPACK only exist for real and
208 // complex float and double types.
209 //
210 // TODO: Reinstate the complex support once the bug in
211 // Teuchos::SerialDenseSolver has been fixed
212 template <>
213 struct solver_traits<Lapack> {
214// #ifdef HAVE_TEUCHOS_COMPLEX
215// typedef Meta::make_list4<float,
216// double,
217// std::complex<float>,
218// std::complex<double> >supported_scalars;
219// #else
220 typedef Meta::make_list2<float, double> supported_scalars;
221// #endif
222};
223
224} // end namespace Amesos2
225
226#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:194
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:180
host_size_type_array colptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_Lapack_decl.hpp:190
Teuchos::Array< int > rowind_
Stores the column indices of the nonzero entries.
Definition Amesos2_Lapack_decl.hpp:177
Teuchos::SerialDenseSolver< int, scalar_type > solver_
The serial solver.
Definition Amesos2_Lapack_decl.hpp:198
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:174
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:186
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:188
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:182
static const char * name
The name of this solver interface.
Definition Amesos2_Lapack_decl.hpp:54
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