Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_Basker_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 
19 #ifndef AMESOS2_BASKER_DECL_HPP
20 #define AMESOS2_BASKER_DECL_HPP
21 
22 #include "Amesos2_SolverTraits.hpp"
23 #include "Amesos2_SolverCore.hpp"
24 #include "Amesos2_Basker_FunctionMap.hpp"
25 
26 //Note: We got an error while being a class variable and mutable. Need to comeback and fix!!
27 
28 
29 namespace Amesos2 {
30 
38 template <class Matrix,class Vector>
39 class Basker : public SolverCore<Amesos2::Basker, Matrix, Vector>
40 {
41  friend class SolverCore<Amesos2::Basker,Matrix,Vector>; // Give our base access
42  // to our private
43  // implementation funcs
44 public:
45 
47  static const char* name; // declaration. Initialization outside.
48 
49 
50  typedef Amesos2::Basker<Matrix,Vector> type;
51 
52  typedef SolverCore<Amesos2::Basker,Matrix,Vector> super_type;
53 
54  // Since typedef's are not inheritted, go grab them
55  typedef typename super_type::scalar_type scalar_type;
56  typedef typename super_type::local_ordinal_type local_ordinal_type;
57  typedef typename super_type::global_ordinal_type global_ordinal_type;
58  typedef typename super_type::global_size_type global_size_type;
59  typedef typename super_type::node_type node_type;
60 
61  typedef TypeMap<Amesos2::Basker,scalar_type> type_map;
62 
63  typedef typename type_map::type basker_type;
64 
65  typedef typename type_map::dtype basker_dtype;
66 
67  typedef FunctionMap<Amesos2::Basker,basker_type> function_map;
68 
69  typedef Matrix matrix_type;
70  typedef MatrixAdapter<matrix_type> matrix_adapter_type;
71 
72 
73  Basker( Teuchos::RCP<const Matrix> A,
74  Teuchos::RCP<Vector> X,
75  Teuchos::RCP<const Vector> B);
76  ~Basker( );
77 
78 
79 private:
80 
85  bool single_proc_optimization() const;
86 
92  int preOrdering_impl();
93 
94 
95  int symbolicFactorization_impl();
96 
97 
104 
105 
117  int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
118  const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
119 
120 
124  bool matrixShapeOK_impl() const;
125 
126 
127  void setParameters_impl(
128  const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
129 
130 
137  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
138 
139 
148  bool loadA_impl(EPhase current_phase);
149 
150 
151  // Members
152  int num_threads;
153 
154  typedef Kokkos::DefaultHostExecutionSpace HostSpaceType;
155  typedef Kokkos::View<local_ordinal_type*, HostSpaceType> host_ordinal_type_array;
156 
157  typedef Kokkos::View<basker_type*, HostSpaceType> host_value_type_array;
158 
159  // The following Views are persisting storage arrays for A, X, and B
161  host_value_type_array host_nzvals_view_;
163  host_ordinal_type_array host_rows_view_;
165  host_ordinal_type_array host_col_ptr_view_;
166 
167  bool is_contiguous_;
168 
169  typedef typename Kokkos::View<basker_type**, Kokkos::LayoutLeft, HostSpaceType>
170  host_solve_array_t;
171 
173  mutable host_solve_array_t xValues_;
174 
176  mutable host_solve_array_t bValues_;
177 
178  /*Handle for Basker object*/
179  mutable ::BaskerClassicNS::BaskerClassic<local_ordinal_type,basker_dtype> basker;
180 
181 }; // End class Basker
182 
183 
184 // Specialize solver_traits struct for Basker
185 // TODO
186 template <>
187 struct solver_traits<Basker> {
188 #ifdef HAVE_TEUCHOS_COMPLEX
189  typedef Meta::make_list6<float,
190  double,
191  Kokkos::complex<float>,
192  Kokkos::complex<double>,
193  std::complex<float>,
194  std::complex<double> > supported_scalars;
195 #else
196  typedef Meta::make_list2<float, double> supported_scalars;
197 #endif
198 };
199 
200 template <typename Scalar, typename LocalOrdinal, typename ExecutionSpace>
201 struct solver_supports_matrix<Basker,
202  KokkosSparse::CrsMatrix<Scalar, LocalOrdinal, ExecutionSpace>> {
203  static const bool value = true;
204 };
205 
206 } // end namespace Amesos2
207 
208 #endif // AMESOS2_BASKER_DECL_HPP
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:71
host_ordinal_type_array host_col_ptr_view_
Stores the row indices of the nonzero entries.
Definition: Amesos2_Basker_decl.hpp:165
Map types to solver-specific data-types and enums.
Definition: Amesos2_TypeMap.hpp:48
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Basker_def.hpp:261
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Basker_def.hpp:241
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:37
host_solve_array_t bValues_
Persisting 1D store for B.
Definition: Amesos2_Basker_decl.hpp:176
Amesos2 interface to the Baker package.
Definition: Amesos2_Basker_decl.hpp:39
bool single_proc_optimization() const
can we optimize size_type and ordinal_type for straight pass through,
Definition: Amesos2_Basker_def.hpp:51
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:42
std::string name() const override
Return the name of this solver.
Definition: Amesos2_SolverCore_def.hpp:725
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Basker_def.hpp:215
host_solve_array_t xValues_
Persisting 1D store for X.
Definition: Amesos2_Basker_decl.hpp:173
Passes functions to TPL functions based on type.
Definition: Amesos2_FunctionMap.hpp:42
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Basker_def.hpp:57
Provides access to interesting solver traits.
host_ordinal_type_array host_rows_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_Basker_decl.hpp:163
int numericFactorization_impl()
Basker specific numeric factorization.
Definition: Amesos2_Basker_def.hpp:80
host_value_type_array host_nzvals_view_
Stores the values of the nonzero entries for CHOLMOD.
Definition: Amesos2_Basker_decl.hpp:161
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:132