Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_Lapack_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
54#ifndef AMESOS2_LAPACK_DECL_HPP
55#define AMESOS2_LAPACK_DECL_HPP
56
57#include <Teuchos_ScalarTraits.hpp>
58#include <Teuchos_SerialDenseSolver.hpp>
59#include <Teuchos_SerialDenseMatrix.hpp>
60
62#include "Amesos2_SolverCore.hpp"
63
64
65namespace Amesos2 {
66
67
78 template <class Matrix,
79 class Vector>
80 class Lapack : public SolverCore<Amesos2::Lapack, Matrix, Vector>
81 {
82 friend class SolverCore<Amesos2::Lapack,Matrix,Vector>; // Give our base access
83 // to our private
84 // implementation funcs
85 public:
86
88 static const char* name; // declaration. Initialization outside.
89
90 typedef Lapack<Matrix,Vector> type;
91 typedef SolverCore<Amesos2::Lapack,Matrix,Vector> super_type;
92
93 // Since typedef's are not inheritted, go grab them
94 typedef typename super_type::scalar_type scalar_type;
95 typedef typename super_type::local_ordinal_type local_ordinal_type;
96 typedef typename super_type::global_ordinal_type global_ordinal_type;
97 typedef typename super_type::global_size_type global_size_type;
98
99 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
100
101 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
102 typedef Kokkos::View<int*, HostExecSpaceType> host_size_type_array;
103 typedef Kokkos::View<int*, HostExecSpaceType> host_ordinal_type_array;
104 typedef Kokkos::View<scalar_type*, HostExecSpaceType> host_value_type_array;
105
107
108
115 Lapack(Teuchos::RCP<const Matrix> A,
116 Teuchos::RCP<Vector> X,
117 Teuchos::RCP<const Vector> B);
118
119
121 ~Lapack( );
122
124
125 private:
126
130 int preOrdering_impl();
131
132
137
138
145
146
157 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
158 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
159
160
164 bool matrixShapeOK_impl() const;
165
166
175 void setParameters_impl(const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
176
177
182 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
183
184
193 bool loadA_impl(EPhase current_phase);
194
195
196 // We keep some `temporary' storage for when we retrive values
197 // from the input matrix
198 //
199 // NOTE:: It seems that the Teuchos::LAPACK wrappers only really
200 // work for the OrdinalType=int case, so that's what we'll work
201 // with, but ideally we should just be able to give
202 // global_ordinal_type.
203
205 Teuchos::Array<scalar_type> nzvals_;
207 // Teuchos::Array<global_ordinal_type> rowind_;
208 Teuchos::Array<int> rowind_;
210 // Teuchos::Array<global_size_type> colptr_;
211 Teuchos::Array<int> colptr_;
213 mutable Teuchos::Array<scalar_type> rhsvals_;
214
215 // The following Kokkos::View's are persisting storage for A's CCS arrays
217 host_value_type_array nzvals_view_;
219 host_ordinal_type_array rowind_view_;
221 host_size_type_array colptr_view_;
222
224 // Teuchos::SerialDenseMatrix<global_ordinal_type,scalar_type> lu_;
225 Teuchos::SerialDenseMatrix<int,scalar_type> lu_;
226
228 // Teuchos::SerialDenseSolver<global_ordinal_type,scalar_type> solver_;
229 mutable Teuchos::SerialDenseSolver<int,scalar_type> solver_;
230
231 bool is_contiguous_;
232
233 }; // End class Lapack
234
235
236 // Specialize the solver_traits struct for Lapack.
237 //
238 // Specializations of Teuchos::LAPACK only exist for real and
239 // complex float and double types.
240 //
241 // TODO: Reinstate the complex support once the bug in
242 // Teuchos::SerialDenseSolver has been fixed
243 template <>
244 struct solver_traits<Lapack> {
245// #ifdef HAVE_TEUCHOS_COMPLEX
246// typedef Meta::make_list4<float,
247// double,
248// std::complex<float>,
249// std::complex<double> >supported_scalars;
250// #else
251 typedef Meta::make_list2<float, double> supported_scalars;
252// #endif
253};
254
255} // end namespace Amesos2
256
257#endif // AMESOS2_NEWSOLVER_DECL_HPP
Provides access to interesting solver traits.
Amesos2 interface to the LAPACK.
Definition: Amesos2_Lapack_decl.hpp:81
Teuchos::SerialDenseMatrix< int, scalar_type > lu_
L and U storage.
Definition: Amesos2_Lapack_decl.hpp:225
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > &parameterList)
Definition: Amesos2_Lapack_def.hpp:227
Teuchos::Array< int > colptr_
Stores the location in Ai_ and Aval_ that starts col j.
Definition: Amesos2_Lapack_decl.hpp:211
host_size_type_array colptr_view_
Stores the row indices of the nonzero entries.
Definition: Amesos2_Lapack_decl.hpp:221
Teuchos::Array< int > rowind_
Stores the column indices of the nonzero entries.
Definition: Amesos2_Lapack_decl.hpp:208
Teuchos::SerialDenseSolver< int, scalar_type > solver_
The serial solver.
Definition: Amesos2_Lapack_decl.hpp:229
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Lapack_def.hpp:216
int numericFactorization_impl()
Perform numeric factorization using LAPACK.
Definition: Amesos2_Lapack_def.hpp:105
Teuchos::Array< scalar_type > nzvals_
Stores the values of the nonzero entries.
Definition: Amesos2_Lapack_decl.hpp:205
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Lapack_def.hpp:243
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Lapack_def.hpp:267
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for Umfpack.
Definition: Amesos2_Lapack_decl.hpp:217
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Lapack solve.
Definition: Amesos2_Lapack_def.hpp:132
int preOrdering_impl()
No-op.
Definition: Amesos2_Lapack_def.hpp:89
host_ordinal_type_array rowind_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_Lapack_decl.hpp:219
int symbolicFactorization_impl()
No-op.
Definition: Amesos2_Lapack_def.hpp:97
Teuchos::Array< scalar_type > rhsvals_
Store for RHS and Solution values.
Definition: Amesos2_Lapack_decl.hpp:213
static const char * name
The name of this solver interface.
Definition: Amesos2_Lapack_decl.hpp:88
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers.
Definition: Amesos2_SolverCore_decl.hpp:106
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:71