Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_Basker_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 
53 #ifndef AMESOS2_BASKER_DECL_HPP
54 #define AMESOS2_BASKER_DECL_HPP
55 
56 #include "Amesos2_SolverTraits.hpp"
57 #include "Amesos2_SolverCore.hpp"
58 #include "Amesos2_Basker_FunctionMap.hpp"
59 
60 
61 //Note: We got an error while being a class variable and mutable. Need to comeback and fix!!
62 
63 
64 namespace Amesos2 {
65 
66 
74 template <class Matrix,class Vector>
75 class Basker : public SolverCore<Amesos2::Basker, Matrix, Vector>
76 {
77  friend class SolverCore<Amesos2::Basker,Matrix,Vector>; // Give our base access
78  // to our private
79  // implementation funcs
80 public:
81 
83  static const char* name; // declaration. Initialization outside.
84 
85 
86  typedef Basker<Matrix,Vector> type;
87 
88 
89  typedef SolverCore<Amesos2::Basker,Matrix,Vector> super_type;
90 
91  // Since typedef's are not inheritted, go grab them
92  typedef typename super_type::scalar_type scalar_type;
93  typedef typename super_type::local_ordinal_type local_ordinal_type;
94  typedef typename super_type::global_ordinal_type global_ordinal_type;
95  typedef typename super_type::global_size_type global_size_type;
96 
97  typedef TypeMap<Amesos2::Basker,scalar_type> type_map;
98 
99 
100  typedef typename type_map::type slu_type;
101  typedef typename type_map::magnitude_type magnitude_type;
102 
103  typedef FunctionMap<Amesos2::Basker,slu_type> function_map;
104 
105 
106  Basker(Teuchos::RCP<const Matrix> A,
107  Teuchos::RCP<Vector> X,
108  Teuchos::RCP<const Vector> B);
109  ~Basker( );
110 
111 
112 private:
113 
119  int preOrdering_impl();
120 
121 
122  int symbolicFactorization_impl();
123 
124 
131 
132 
144  int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
145  const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
146 
147 
151  bool matrixShapeOK_impl() const;
152 
153 
154  void setParameters_impl(
155  const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
156 
157 
164  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
165 
166 
175  bool loadA_impl(EPhase current_phase);
176 
177 
178 
179  int num_threads;
180 
181  // The following Arrays are persisting storage arrays for A, X, and B
183  Teuchos::Array<slu_type> nzvals_;
185  Teuchos::Array<local_ordinal_type> rowind_;
187  Teuchos::Array<local_ordinal_type> colptr_;
188 
190  mutable Teuchos::Array<slu_type> xvals_; local_ordinal_type ldx_;
192  mutable Teuchos::Array<slu_type> bvals_; local_ordinal_type ldb_;
193 
194 
195 
196 
197  /*Handle for Basker object*/
198 #ifdef SHYLUBASKER
199 
200 #ifdef HAVE_AMESOS2_KOKKOS
201  //#pragma message("HAVE SHYLUBASKER AND KOKKOS")
202  typedef Kokkos::OpenMP Exe_Space;
203  ::BaskerNS::Basker<local_ordinal_type,slu_type,Exe_Space> *basker;
204 #else
205  #pragma message("HAVE SHYLUBASKER AND NOT KOKKOS! ERROR")
206 #endif
207 
208 #else
209  mutable ::Basker::Basker<local_ordinal_type,slu_type> basker;
210 #endif
211 
212 
213 
214 }; // End class Basker
215 
216 
217 // Specialize solver_traits struct for Basker
218 // TODO
219 template <>
220 struct solver_traits<Basker> {
221 #ifdef HAVE_TEUCHOS_COMPLEX
222  typedef Meta::make_list4<float,
223  double,
224  std::complex<float>,
225  std::complex<double> > supported_scalars;
226 #else
227  typedef Meta::make_list2<float, double> supported_scalars;
228 #endif
229 };
230 
231 } // end namespace Amesos2
232 
233 #endif // AMESOS2_BASKER_DECL_HPP
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
Definition: basker.cpp:35
Map types to solver-specific data-types and enums.
Definition: Amesos2_TypeMap.hpp:82
Teuchos::Array< slu_type > bvals_
Persisting 1D store for B.
Definition: Amesos2_Basker_decl.hpp:192
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Basker_def.hpp:372
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Basker_def.hpp:342
std::string name() const
Return the name of this solver.
Definition: Amesos2_SolverCore_def.hpp:502
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:70
Teuchos::Array< local_ordinal_type > colptr_
Stores the row indices of the nonzero entries.
Definition: Amesos2_Basker_decl.hpp:187
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
Amesos2 interface to the Baker package.
Definition: Amesos2_Basker_decl.hpp:75
Teuchos::Array< local_ordinal_type > rowind_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_Basker_decl.hpp:185
Teuchos::Array< slu_type > xvals_
Persisting 1D store for X.
Definition: Amesos2_Basker_decl.hpp:190
Teuchos::Array< slu_type > nzvals_
Stores the values of the nonzero entries for Basker.
Definition: Amesos2_Basker_decl.hpp:183
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Basker_def.hpp:317
Passes functions to TPL functions based on type.
Definition: Amesos2_FunctionMap.hpp:76
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Basker_def.hpp:127
Provides access to interesting solver traits.
int numericFactorization_impl()
Basker specific numeric factorization.
Definition: Amesos2_Basker_def.hpp:184
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Basker specific solve.
Definition: Amesos2_Basker_def.hpp:246