Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
Amesos2_ShyLUBasker_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 
20 #ifndef AMESOS2_SHYLUBASKER_DECL_HPP
21 #define AMESOS2_SHYLUBASKER_DECL_HPP
22 
23 #include "Amesos2_SolverTraits.hpp"
24 #include "Amesos2_SolverCore.hpp"
25 #include "Amesos2_ShyLUBasker_FunctionMap.hpp"
26 
27 #include "shylubasker_decl.hpp"
28 #include "shylubasker_def.hpp"
29 #include "shylubasker_trilinos_decl.hpp"
30 
31 
32 namespace Amesos2 {
33 
41 template <class Matrix,class Vector>
42 class ShyLUBasker : public SolverCore<Amesos2::ShyLUBasker, Matrix, Vector>
43 {
44  friend class SolverCore<Amesos2::ShyLUBasker,Matrix,Vector>; // Give our base access
45  // to our private
46  // implementation funcs
47 public:
48 
50  static const char* name; // declaration. Initialization outside.
51 
52 
53  typedef ShyLUBasker<Matrix,Vector> type;
54 
55  typedef SolverCore<Amesos2::ShyLUBasker,Matrix,Vector> super_type;
56 
57  // Since typedef's are not inheritted, go grab them
58  typedef typename VectorTraits<Vector>::scalar_t vector_scalar_type;
59  typedef typename super_type::scalar_type scalar_type;
60  typedef typename super_type::local_ordinal_type local_ordinal_type;
61  typedef typename super_type::global_ordinal_type global_ordinal_type;
62  typedef typename super_type::global_size_type global_size_type;
63  typedef typename super_type::node_type node_type;
64 
65  typedef TypeMap<Amesos2::ShyLUBasker,scalar_type> type_map;
66  typedef typename type_map::type shylubasker_type;
67  typedef typename type_map::dtype shylubasker_dtype;
68 
69  typedef typename type_map::type slu_type;
70 
71  typedef FunctionMap<Amesos2::ShyLUBasker,shylubasker_type> function_map;
72 
73  typedef Matrix matrix_type;
74  typedef MatrixAdapter<matrix_type> matrix_adapter_type;
75 
76  typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
77 // typedef Kokkos::View<local_ordinal_type*, HostExecSpaceType> host_size_type_array;
78  typedef Kokkos::View<local_ordinal_type*, HostExecSpaceType> host_ordinal_type_array;
79  typedef Kokkos::View<shylubasker_type*, HostExecSpaceType> host_value_type_array;
80 
81 
82  ShyLUBasker( Teuchos::RCP<const Matrix> A,
83  Teuchos::RCP<Vector> X,
84  Teuchos::RCP<const Vector> B);
85  ~ShyLUBasker( );
86 
87 
88 private:
89 
94  bool single_proc_optimization() const;
95 
96 
102  int preOrdering_impl();
103 
104 
105  int symbolicFactorization_impl();
106 
107 
114 
115 
127  int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
128  const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
129 
130 
134  bool matrixShapeOK_impl() const;
135 
136 
137  void setParameters_impl(
138  const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
139 
140 
147  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
148 
149 
158  bool loadA_impl(EPhase current_phase);
159 
160 
161  // Members
162  int num_threads;
163 
164  // The following Kokkos::View's are persisting storage for A's CCS arrays
166  host_value_type_array nzvals_view_;
168  host_ordinal_type_array rowind_view_;
170  host_ordinal_type_array colptr_view_;
171 
172 
173  bool is_contiguous_;
174  bool use_gather_;
175 
176  typedef typename Kokkos::View<shylubasker_type**, Kokkos::LayoutLeft,
177  typename HostExecSpaceType::memory_space> host_solve_array_t;
178 
180  mutable host_solve_array_t xValues_;
181  int ldx_;
182 
184  mutable host_solve_array_t bValues_;
185  int ldb_;
186 
187  /*Handle for ShyLUBasker object*/
188 #if defined( HAVE_AMESOS2_KOKKOS )
189  /*
190  typedef typename node_type::device_type kokkos_device;
191  typedef typename kokkos_device::execution_space kokkos_exe;
192  static_assert(std::is_same<kokkos_exe,Kokkos::OpenMP>::value,
193  "Kokkos node type not support by experimental ShyLUBasker Amesos2");
194  */
195  typedef Kokkos::DefaultHostExecutionSpace Exe_Space;
196  ::BaskerNS::BaskerTrilinosInterface<local_ordinal_type, shylubasker_dtype, Exe_Space> *ShyLUbasker;
197 #else
198  #pragma message("Amesos_ShyLUBasker_decl Error: ENABLED SHYLU_NODEBASKER BUT NOT KOKKOS!")
199 #endif
200 
201 }; // End class ShyLUBasker
202 
203 
204 // Specialize solver_traits struct for ShyLUBasker
205 // TODO
206 template <>
207 struct solver_traits<ShyLUBasker> {
208 #ifdef HAVE_TEUCHOS_COMPLEX
209 /*
210  typedef Meta::make_list4<float,
211  double,
212  std::complex<float>,
213  std::complex<double> > supported_scalars;
214 */
215  typedef Meta::make_list6<float,
216  double,
217  Kokkos::complex<float>,
218  Kokkos::complex<double>,
219  std::complex<float>,
220  std::complex<double> > supported_scalars;
221 #else
222  typedef Meta::make_list2<float, double> supported_scalars;
223 #endif
224 };
225 
226 template <typename Scalar, typename LocalOrdinal, typename ExecutionSpace>
227 struct solver_supports_matrix<ShyLUBasker,
228  KokkosSparse::CrsMatrix<Scalar, LocalOrdinal, ExecutionSpace>> {
229  static const bool value = true;
230 };
231 
232 } // end namespace Amesos2
233 
234 #endif // AMESOS2_SHYLUBASKER_DECL_HPP
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:71
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
ShyLUBasker specific solve.
Definition: Amesos2_ShyLUBasker_def.hpp:285
host_ordinal_type_array rowind_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_ShyLUBasker_decl.hpp:168
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for Umfpack.
Definition: Amesos2_ShyLUBasker_decl.hpp:166
Map types to solver-specific data-types and enums.
Definition: Amesos2_TypeMap.hpp:48
host_solve_array_t bValues_
Persisting 1D store for B.
Definition: Amesos2_ShyLUBasker_decl.hpp:184
Amesos2 interface to the Baker package.
Definition: Amesos2_ShyLUBasker_decl.hpp:42
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_ShyLUBasker_def.hpp:531
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_ShyLUBasker_def.hpp:109
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:37
host_ordinal_type_array colptr_view_
Stores the row indices of the nonzero entries.
Definition: Amesos2_ShyLUBasker_decl.hpp:170
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_ShyLUBasker_def.hpp:388
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_ShyLUBasker_def.hpp:604
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:738
int numericFactorization_impl()
ShyLUBasker specific numeric factorization.
Definition: Amesos2_ShyLUBasker_def.hpp:203
Passes functions to TPL functions based on type.
Definition: Amesos2_FunctionMap.hpp:42
host_solve_array_t xValues_
Persisting 1D store for X.
Definition: Amesos2_ShyLUBasker_decl.hpp:180
Provides access to interesting solver traits.
bool single_proc_optimization() const
can we optimize size_type and ordinal_type for straight pass through, also check that is_contiguous_ ...
Definition: Amesos2_ShyLUBasker_def.hpp:103