Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_KokkosCrsMatrix_MatrixAdapter_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
10
20#ifndef AMESOS2_KOKKOSCRSMATRIX_MATRIXADAPTER_DECL_HPP
21#define AMESOS2_KOKKOSCRSMATRIX_MATRIXADAPTER_DECL_HPP
22
23#include "Amesos2_config.h"
24
25#include "Amesos2_MatrixAdapter_decl.hpp"
26#include "KokkosSparse_CrsMatrix.hpp"
28
29namespace Amesos2 {
30
39 template <typename Scalar,
40 typename LocalOrdinal,
41 typename ExecutionSpace>
42 class ConcreteMatrixAdapter<KokkosSparse::CrsMatrix<Scalar, LocalOrdinal, ExecutionSpace>> :
43 public MatrixAdapter<KokkosSparse::CrsMatrix<Scalar, LocalOrdinal, ExecutionSpace>>
44 {
45 public:
46 typedef KokkosSparse::CrsMatrix<Scalar, LocalOrdinal, ExecutionSpace> matrix_t;
47
48 public:
49 typedef typename MatrixTraits<matrix_t>::scalar_t scalar_t;
50 typedef typename MatrixTraits<matrix_t>::local_ordinal_t local_ordinal_t;
51 typedef typename MatrixTraits<matrix_t>::global_ordinal_t global_ordinal_t;
52 typedef typename MatrixTraits<matrix_t>::node_t node_t;
53 typedef typename MatrixTraits<matrix_t>::global_size_t global_size_t;
54 typedef Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t> map_t;
57 typedef ConcreteMatrixAdapter<matrix_t> type;
58 typedef typename MatrixTraits<matrix_t>::major_access major_access;
59
60 ConcreteMatrixAdapter(Teuchos::RCP<matrix_t> m);
61
62 Teuchos::RCP<const MatrixAdapter<matrix_t> > get_impl(const Teuchos::Ptr<const map_t> map, EDistribution distribution = ROOTED) const;
63 Teuchos::RCP<const MatrixAdapter<matrix_t> > reindex_impl(Teuchos::RCP<const map_t> &contigRowMap,
64 Teuchos::RCP<const map_t> &contigColMap,
65 const EPhase current_phase) const;
66
67 const Teuchos::RCP<const Teuchos::Comm<int> > getComm_impl() const;
68 global_size_t getGlobalNumRows_impl() const;
69 global_size_t getGlobalNumCols_impl() const;
70 global_size_t getGlobalNNZ_impl() const;
71
72 size_t getLocalNNZ_impl() const;
73
74 template<class KV>
75 void getSparseRowPtr_kokkos_view(KV & view) const {
76 deep_copy_or_assign_view(view, this->mat_->graph.row_map);
77 }
78
79 template<class KV>
80 void getSparseColInd_kokkos_view(KV & view) const {
81 deep_copy_or_assign_view(view, this->mat_->graph.entries);
82 }
83
84 template<class KV>
85 void getSparseValues_kokkos_view(KV & view) const {
86 deep_copy_or_assign_view(view, this->mat_->values);
87 }
88
89 size_t getGlobalRowNNZ_impl(global_ordinal_t row) const;
90 size_t getLocalRowNNZ_impl(local_ordinal_t row) const;
91 size_t getGlobalColNNZ_impl(global_ordinal_t col) const;
92 size_t getLocalColNNZ_impl(local_ordinal_t col) const;
93
94 global_size_t getRowIndexBase() const;
95 global_size_t getColumnIndexBase() const;
96
97 const Teuchos::RCP<const map_t>
98 getMap_impl() const;
99
100 const Teuchos::RCP<const map_t>
101 getRowMap_impl() const;
102
103 const Teuchos::RCP<const map_t>
104 getColMap_impl() const;
105
106 // implementation functions
107 void getGlobalRowCopy_impl(global_ordinal_t row,
108 const Teuchos::ArrayView<global_ordinal_t>& indices,
109 const Teuchos::ArrayView<scalar_t>& vals,
110 size_t& nnz) const;
111
112 void getGlobalColCopy_impl(global_ordinal_t col,
113 const Teuchos::ArrayView<global_ordinal_t>& indices,
114 const Teuchos::ArrayView<scalar_t>& vals,
115 size_t& nnz) const;
116
117
118 template <typename KV_GO, typename KV_S>
119 void getGlobalRowCopy_kokkos_view_impl(global_ordinal_t row,
120 KV_GO & indices,
121 KV_S & vals,
122 size_t& nnz) const;
123
124 template<typename KV_S, typename KV_GO, typename KV_GS, typename host_ordinal_type_array, typename host_scalar_type_array>
125 LocalOrdinal gather_impl(KV_S& nzvals, KV_GO& indices, KV_GS& pointers,
126 host_ordinal_type_array &perm_g2l,
127 host_ordinal_type_array &recvCountRows, host_ordinal_type_array &recvDisplRows,
128 host_ordinal_type_array &recvCounts, host_ordinal_type_array &recvDispls,
129 host_ordinal_type_array &transpose_map, host_scalar_type_array &nzvals_t,
130 bool column_major, EPhase current_phase) const;
131
133 void
134 describe (Teuchos::FancyOStream& os,
135 const Teuchos::EVerbosityLevel verbLevel =
136 Teuchos::Describable::verbLevel_default) const;
137 };
138} // end namespace Amesos2
139
140#endif // AMESOS2_KOKKOSCRSMATRIX_MATRIXADAPTER_DECL_HPP
Copy or assign views based on memory spaces.
EDistribution
Definition Amesos2_TypeDecl.hpp:89
@ ROOTED
Definition Amesos2_TypeDecl.hpp:93
A Matrix adapter interface for Amesos2.
Definition Amesos2_MatrixAdapter_decl.hpp:42
EPhase
Used to indicate a phase in the direct solution.
Definition Amesos2_TypeDecl.hpp:31
Indicates that the concrete class can use the generic getC{c|r}s methods implemented in MatrixAdapter...
Definition Amesos2_TypeDecl.hpp:57