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 
29 namespace 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;
56  typedef ConcreteMatrixAdapter<matrix_t> type;
57  typedef typename MatrixTraits<matrix_t>::major_access major_access;
58 
59  ConcreteMatrixAdapter(Teuchos::RCP<matrix_t> m);
60 
61  Teuchos::RCP<const MatrixAdapter<matrix_t> > get_impl(const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map, EDistribution distribution = ROOTED) const;
62 
63  const Teuchos::RCP<const Teuchos::Comm<int> > getComm_impl() const;
64  global_size_t getGlobalNumRows_impl() const;
65  global_size_t getGlobalNumCols_impl() const;
66  global_size_t getGlobalNNZ_impl() const;
67 
68  template<class KV>
69  void getSparseRowPtr_kokkos_view(KV & view) const {
70  deep_copy_or_assign_view(view, this->mat_->graph.row_map);
71  }
72 
73  template<class KV>
74  void getSparseColInd_kokkos_view(KV & view) const {
75  deep_copy_or_assign_view(view, this->mat_->graph.entries);
76  }
77 
78  template<class KV>
79  void getSparseValues_kokkos_view(KV & view) const {
80  deep_copy_or_assign_view(view, this->mat_->values);
81  }
82 
83  size_t getGlobalRowNNZ_impl(global_ordinal_t row) const;
84  size_t getLocalRowNNZ_impl(local_ordinal_t row) const;
85  size_t getGlobalColNNZ_impl(global_ordinal_t col) const;
86  size_t getLocalColNNZ_impl(local_ordinal_t col) const;
87 
88  global_size_t getRowIndexBase() const;
89  global_size_t getColumnIndexBase() const;
90 
91  const Teuchos::RCP<const Tpetra::Map<local_ordinal_t,
92  global_ordinal_t,
93  node_t> >
94  getMap_impl() const;
95 
96  const Teuchos::RCP<const Tpetra::Map<local_ordinal_t,
97  global_ordinal_t,
98  node_t> >
99  getRowMap_impl() const;
100 
101  const Teuchos::RCP<const Tpetra::Map<local_ordinal_t,
102  global_ordinal_t,
103  node_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  };
125 
126 } // end namespace Amesos2
127 
128 #endif // AMESOS2_KOKKOSCRSMATRIX_MATRIXADAPTER_DECL_HPP
Copy or assign views based on memory spaces.
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:42
Indicates that the concrete class can use the generic getC{c|r}s methods implemented in MatrixAdapter...
Definition: Amesos2_TypeDecl.hpp:57
EDistribution
Definition: Amesos2_TypeDecl.hpp:89