53 #ifndef AMESOS2_CHOLMOD_DECL_HPP
54 #define AMESOS2_CHOLMOD_DECL_HPP
57 #include "Amesos2_SolverCore.hpp"
60 #if defined(KOKKOSKERNELS_ENABLE_SUPERNODAL_SPTRSV) && defined(KOKKOSKERNELS_ENABLE_TPL_CHOLMOD)
61 #include "KokkosKernels_Handle.hpp"
74 template <
class Matrix,
90 using scalar_type = typename super_type::scalar_type;
91 using local_ordinal_type = typename super_type::local_ordinal_type;
92 using global_ordinal_type = typename super_type::global_ordinal_type;
93 using global_size_type = typename super_type::global_size_type;
94 using node_type = typename super_type::node_type;
103 using chol_type = typename type_map::type;
104 using magnitude_type = typename type_map::magnitude_type;
117 Cholmod(Teuchos::RCP<const Matrix> A,
118 Teuchos::RCP<Vector> X,
119 Teuchos::RCP<const Vector> B);
164 int
solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
165 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
190 const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
214 mutable struct CholData {
217 cholmod_dense *Y, *E;
222 typedef Kokkos::DefaultHostExecutionSpace HostExecSpaceType;
223 typedef typename HostExecSpaceType::memory_space HostMemSpaceType;
229 typedef int size_int_type;
230 typedef int ordinal_int_type;
232 typedef long size_long_type;
233 typedef long ordinal_long_type;
235 typedef Kokkos::View<size_long_type*, HostExecSpaceType> host_size_long_type_array;
236 typedef Kokkos::View<ordinal_long_type*, HostExecSpaceType> host_ordinal_long_type_array;
238 typedef Kokkos::View<size_int_type*, HostExecSpaceType> host_size_int_type_array;
239 typedef Kokkos::View<ordinal_int_type*, HostExecSpaceType> host_ordinal_int_type_array;
241 typedef Kokkos::View<chol_type*, HostExecSpaceType> host_value_type_array;
248 host_size_long_type_array host_rows_long_view_;
251 host_ordinal_long_type_array host_col_ptr_long_view_;
253 typedef typename Kokkos::View<chol_type**, Kokkos::LayoutLeft, HostExecSpaceType>
262 #if defined(KOKKOSKERNELS_ENABLE_SUPERNODAL_SPTRSV) && defined(KOKKOSKERNELS_ENABLE_TPL_CHOLMOD)
264 using DeviceExecSpaceType= Kokkos::DefaultExecutionSpace;
266 #ifdef KOKKOS_ENABLE_CUDA
268 using DeviceMemSpaceType =
typename Kokkos::CudaSpace;
269 #elif KOKKOS_ENABLE_HIP
271 using DeviceMemSpaceType =
typename Kokkos::HIPSpace;
273 using DeviceMemSpaceType =
typename DeviceExecSpaceType::memory_space;
276 typedef Kokkos::View<chol_type**, Kokkos::LayoutLeft, DeviceMemSpaceType>
277 device_solve_array_t;
280 mutable device_solve_array_t device_xValues_;
281 mutable device_solve_array_t device_bValues_;
282 typedef Kokkos::View<int*, HostMemSpaceType> host_int_array;
283 typedef Kokkos::View<int*, DeviceMemSpaceType> device_int_array;
284 host_int_array host_trsv_etree_;
285 host_int_array host_trsv_perm_;
286 device_int_array device_trsv_perm_;
287 mutable device_solve_array_t device_trsv_rhs_;
288 mutable device_solve_array_t device_trsv_sol_;
289 typedef KokkosKernels::Experimental::KokkosKernelsHandle <size_int_type, ordinal_int_type, chol_type,
290 DeviceExecSpaceType, DeviceMemSpaceType, DeviceMemSpaceType> kernel_handle_int_type;
291 typedef KokkosKernels::Experimental::KokkosKernelsHandle <size_long_type, ordinal_long_type, chol_type,
292 DeviceExecSpaceType, DeviceMemSpaceType, DeviceMemSpaceType> kernel_handle_long_type;
293 mutable kernel_handle_int_type device_int_khL_;
294 mutable kernel_handle_int_type device_int_khU_;
295 mutable kernel_handle_long_type device_long_khL_;
296 mutable kernel_handle_long_type device_long_khU_;
304 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > map;
307 bool use_triangular_solves_;
308 bool use_cholmod_int_type_;
310 void triangular_solve_symbolic();
311 void triangular_solve_numeric();
314 void triangular_solve()
const;
321 #ifdef HAVE_TEUCHOS_COMPLEX
322 typedef Meta::make_list3<double, std::complex<double>,
323 Kokkos::complex<double>> supported_scalars;
325 typedef Meta::make_list1<double> supported_scalars;
329 template <
typename Scalar,
typename LocalOrdinal,
typename ExecutionSpace>
330 struct solver_supports_matrix<Cholmod,
331 KokkosSparse::CrsMatrix<Scalar, LocalOrdinal, ExecutionSpace>> {
332 static const bool value =
true;
337 #endif // AMESOS2_CHOLMOD_DECL_HPP
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Cholmod_def.hpp:113
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
host_solve_array_t host_xValues_
Persisting 1D store for X.
Definition: Amesos2_Cholmod_decl.hpp:257
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Cholmod_def.hpp:424
Template for providing a mechanism to map function calls to the correct Solver function based on the ...
Map types to solver-specific data-types and enums.
Definition: Amesos2_TypeMap.hpp:82
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Cholmod_def.hpp:353
host_value_type_array host_nzvals_view_
Stores the values of the nonzero entries for CHOLMOD.
Definition: Amesos2_Cholmod_decl.hpp:245
Provides traits about solvers.
Definition: Amesos2_SolverTraits.hpp:71
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
CHOLMOD specific solve.
Definition: Amesos2_Cholmod_def.hpp:242
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Definition: Amesos2_Cholmod_def.hpp:361
host_size_int_type_array host_rows_int_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_Cholmod_decl.hpp:247
std::string name() const override
Return the name of this solver.
Definition: Amesos2_SolverCore_def.hpp:759
Passes functions to TPL functions based on type.
Definition: Amesos2_FunctionMap.hpp:76
Provides access to interesting solver traits.
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Cholmod_def.hpp:475
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using CHOLMOD.
Definition: Amesos2_Cholmod_def.hpp:144
host_ordinal_int_type_array host_col_ptr_int_view_
Stores the row indices of the nonzero entries.
Definition: Amesos2_Cholmod_decl.hpp:250
Amesos2 interface to the CHOLMOD package.
Definition: Amesos2_Cholmod_decl.hpp:76
int numericFactorization_impl()
CHOLMOD specific numeric factorization.
Definition: Amesos2_Cholmod_def.hpp:187
host_solve_array_t host_bValues_
Persisting 1D store for B.
Definition: Amesos2_Cholmod_decl.hpp:260