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
18
19
20#ifndef AMESOS2_SHYLUBASKER_DECL_HPP
21#define AMESOS2_SHYLUBASKER_DECL_HPP
22
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
32namespace Amesos2 {
33
41template <class Matrix,class Vector>
42class 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
47public:
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 super_type::scalar_type scalar_type;
59 typedef typename super_type::local_ordinal_type local_ordinal_type;
60 typedef typename super_type::global_ordinal_type global_ordinal_type;
61 typedef typename super_type::global_size_type global_size_type;
62 typedef typename super_type::node_type node_type;
63
64 typedef TypeMap<Amesos2::ShyLUBasker,scalar_type> type_map;
65 typedef typename type_map::type shylubasker_type;
66 typedef typename type_map::dtype shylubasker_dtype;
67
68 typedef typename type_map::type slu_type;
69
70 typedef FunctionMap<Amesos2::ShyLUBasker,shylubasker_type> function_map;
71
72 typedef Matrix matrix_type;
73 typedef MatrixAdapter<matrix_type> matrix_adapter_type;
74
75 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
76// typedef Kokkos::View<local_ordinal_type*, HostExecSpaceType> host_size_type_array;
77 typedef Kokkos::View<local_ordinal_type*, HostExecSpaceType> host_ordinal_type_array;
78 typedef Kokkos::View<shylubasker_type*, HostExecSpaceType> host_value_type_array;
79
80
81 ShyLUBasker( Teuchos::RCP<const Matrix> A,
82 Teuchos::RCP<Vector> X,
83 Teuchos::RCP<const Vector> B);
84 ~ShyLUBasker( );
85
86
87private:
88
93 bool single_proc_optimization() const;
94
95
101 int preOrdering_impl();
102
103
104 int symbolicFactorization_impl();
105
106
113
114
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
136 void setParameters_impl(
137 const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
138
139
146 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
147
148
157 bool loadA_impl(EPhase current_phase);
158
159
160 // Members
161 int num_threads;
162
163 // The following Kokkos::View's are persisting storage for A's CCS arrays
165 host_value_type_array nzvals_view_;
167 host_ordinal_type_array rowind_view_;
169 host_ordinal_type_array colptr_view_;
170
171
172 bool is_contiguous_;
173 bool use_gather_;
174
175 typedef typename Kokkos::View<shylubasker_type**, Kokkos::LayoutLeft,
176 typename HostExecSpaceType::memory_space> host_solve_array_t;
177
179 mutable host_solve_array_t xValues_;
180 int ldx_;
181
183 mutable host_solve_array_t bValues_;
184 int ldb_;
185
186 /*Handle for ShyLUBasker object*/
187#if defined( HAVE_AMESOS2_KOKKOS ) && defined( KOKKOS_ENABLE_OPENMP )
188 /*
189 typedef typename node_type::device_type kokkos_device;
190 typedef typename kokkos_device::execution_space kokkos_exe;
191 static_assert(std::is_same<kokkos_exe,Kokkos::OpenMP>::value,
192 "Kokkos node type not support by experimental ShyLUBasker Amesos2");
193 */
194 typedef Kokkos::OpenMP Exe_Space;
195 ::BaskerNS::BaskerTrilinosInterface<local_ordinal_type, shylubasker_dtype, Exe_Space> *ShyLUbasker;
196#else
197 #pragma message("Amesos_ShyLUBasker_decl Error: ENABLED SHYLU_NODEBASKER BUT NOT KOKKOS or NOT OPENMP!")
198#endif
199
200
201}; // End class ShyLUBasker
202
203
204// Specialize solver_traits struct for ShyLUBasker
205// TODO
206template <>
207struct 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
226template <typename Scalar, typename LocalOrdinal, typename ExecutionSpace>
227struct 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
Provides access to interesting solver traits.
A Matrix adapter interface for Amesos2.
Definition Amesos2_MatrixAdapter_decl.hpp:42
Amesos2 interface to the Baker package.
Definition Amesos2_ShyLUBasker_decl.hpp:43
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_ShyLUBasker_def.hpp:589
host_ordinal_type_array colptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_ShyLUBasker_decl.hpp:169
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:289
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_ShyLUBasker_def.hpp:522
int numericFactorization_impl()
ShyLUBasker specific numeric factorization.
Definition Amesos2_ShyLUBasker_def.hpp:190
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for Umfpack.
Definition Amesos2_ShyLUBasker_decl.hpp:165
static const char * name
Name of this solver interface.
Definition Amesos2_ShyLUBasker_decl.hpp:50
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition Amesos2_ShyLUBasker_def.hpp:106
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:100
host_solve_array_t xValues_
Persisting 1D store for X.
Definition Amesos2_ShyLUBasker_decl.hpp:179
host_ordinal_type_array rowind_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_ShyLUBasker_decl.hpp:167
host_solve_array_t bValues_
Persisting 1D store for B.
Definition Amesos2_ShyLUBasker_decl.hpp:183
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_ShyLUBasker_def.hpp:391
SolverCore(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
Passes functions to TPL functions based on type.
Definition Amesos2_FunctionMap.hpp:43
Map types to solver-specific data-types and enums.
Definition Amesos2_TypeMap.hpp:48
Provides traits about solvers.
Definition Amesos2_SolverTraits.hpp:37