Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_BlockCrsMatrix_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10// clang-format off
11#ifndef TPETRA_BLOCKCRSMATRIX_DECL_HPP
12#define TPETRA_BLOCKCRSMATRIX_DECL_HPP
13
16
17#include "Tpetra_CrsGraph.hpp"
18#include "Tpetra_RowMatrix.hpp"
19#include "Tpetra_BlockMultiVector_decl.hpp"
21
22#include "KokkosSparse_BsrMatrix.hpp"
23
24#if KOKKOSKERNELS_VERSION >= 40299
25#include "Tpetra_Details_MatrixApplyHelper.hpp"
26#endif
27
28namespace Tpetra {
29
30template<class BlockCrsMatrixType>
31Teuchos::RCP<BlockCrsMatrixType>
32importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
33 const Import<typename BlockCrsMatrixType::local_ordinal_type,
34 typename BlockCrsMatrixType::global_ordinal_type,
35 typename BlockCrsMatrixType::node_type>& importer);
36template<class BlockCrsMatrixType>
37Teuchos::RCP<BlockCrsMatrixType>
38exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
39 const Export<typename BlockCrsMatrixType::local_ordinal_type,
40 typename BlockCrsMatrixType::global_ordinal_type,
41 typename BlockCrsMatrixType::node_type>& exporter);
42
120
121namespace Impl {
123#if defined(TPETRA_ENABLE_BLOCKCRS_LITTLEBLOCK_LAYOUTLEFT)
124 using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutLeft;
125#else
126 using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutRight;
127#endif
128}
129
130template<class Scalar,
131 class LO,
132 class GO,
133 class Node>
135 virtual public ::Tpetra::RowMatrix<Scalar, LO, GO, Node>,
136 virtual public ::Tpetra::DistObject<char, LO, GO, Node>
137{
138private:
139 using dist_object_type = ::Tpetra::DistObject<char, LO, GO, Node>;
141 using STS = Teuchos::ScalarTraits<Scalar>;
142
143protected:
145 typedef char packet_type;
146
147public:
149
150
152 using scalar_type = Scalar;
153
161
170 typedef Node node_type;
171
173 typedef typename Node::device_type device_type;
175 typedef typename device_type::execution_space execution_space;
177 typedef typename device_type::memory_space memory_space;
178
180 typedef ::Tpetra::Map<LO, GO, node_type> map_type;
182 typedef ::Tpetra::MultiVector<Scalar, LO, GO, node_type> mv_type;
184 typedef ::Tpetra::CrsGraph<LO, GO, node_type> crs_graph_type;
185
187 typedef Kokkos::View<impl_scalar_type**,
190 Kokkos::MemoryTraits<Kokkos::Unmanaged> >
192 typedef typename little_block_type::HostMirror little_block_host_type;
193
195 typedef Kokkos::View<const impl_scalar_type**,
198 Kokkos::MemoryTraits<Kokkos::Unmanaged> >
202 typedef typename BMV::little_host_vec_type little_host_vec_type;
203
206 typedef typename BMV::const_little_host_vec_type const_host_little_vec_type;
207
208 using row_matrix_type = RowMatrix<Scalar, LO, GO, node_type>;
209 using local_inds_device_view_type =
210 typename row_matrix_type::local_inds_device_view_type;
211 using local_inds_host_view_type =
212 typename row_matrix_type::local_inds_host_view_type;
213 using nonconst_local_inds_host_view_type =
214 typename row_matrix_type::nonconst_local_inds_host_view_type;
215
216 using global_inds_device_view_type =
217 typename row_matrix_type::global_inds_device_view_type;
218 using global_inds_host_view_type =
219 typename row_matrix_type::global_inds_host_view_type;
220 using nonconst_global_inds_host_view_type =
221 typename row_matrix_type::nonconst_global_inds_host_view_type;
222
223 using values_device_view_type =
224 typename row_matrix_type::values_device_view_type;
225 using values_host_view_type =
226 typename row_matrix_type::values_host_view_type;
227 using nonconst_values_host_view_type =
228 typename row_matrix_type::nonconst_values_host_view_type;
229
230 using local_graph_device_type = typename crs_graph_type::local_graph_device_type;
231
232 using local_matrix_device_type =
233 KokkosSparse::Experimental::BsrMatrix<impl_scalar_type,
236 void,
237 typename local_graph_device_type::size_type>;
238
239#if KOKKOSKERNELS_VERSION >= 40299
240private:
241 // TODO: When KokkosKernels 4.4 is released, local_matrix_device_type can be permanently modified to use the default_size_type
242 // of KK. This is always a type that is enabled by KK's ETI (preferring int if both or neither int and size_t are enabled).
243 using local_matrix_int_rowptrs_device_type =
244 KokkosSparse::Experimental::BsrMatrix<impl_scalar_type,
247 void,
248 int>;
249
251 using ApplyHelper = Details::MatrixApplyHelper<
252 local_matrix_device_type,
253 local_matrix_int_rowptrs_device_type,
254 typename mv_type::device_view_type>;
255
263 mutable std::shared_ptr<ApplyHelper> applyHelper;
264
265public:
266 std::shared_ptr<ApplyHelper> getApplyHelper() const {
267 if (!applyHelper) {
268 auto A_lcl = getLocalMatrixDevice();
269 applyHelper = std::make_shared<ApplyHelper>(A_lcl.nnz(), A_lcl.graph.row_map);
270 }
271 return applyHelper;
272 }
273
274#endif
275
277 typename local_matrix_device_type::HostMirror;
278
280
282
285
295 BlockCrsMatrix (const crs_graph_type& graph, const LO blockSize);
296
298 const typename local_matrix_device_type::values_type& values,
299 const LO blockSize);
300
309 const map_type& domainPointMap,
310 const map_type& rangePointMap,
311 const LO blockSize);
312
314 virtual ~BlockCrsMatrix () {}
315
317
319
321 Teuchos::RCP<const map_type> getDomainMap () const override;
322
324 Teuchos::RCP<const map_type> getRangeMap () const override;
325
327 Teuchos::RCP<const map_type> getRowMap () const override;
328
330 Teuchos::RCP<const map_type> getColMap () const override;
331
334
336 size_t getLocalNumRows() const override;
337
338 size_t getLocalMaxNumRowEntries() const override;
339
349 void
350 apply (const mv_type& X,
351 mv_type& Y,
352 Teuchos::ETransp mode = Teuchos::NO_TRANS,
353 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
354 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ()) const override;
355
358 bool hasTransposeApply () const override {
359 // FIXME (mfh 04 May 2014) Transpose and conjugate transpose modes
360 // are not implemented yet. Fill in applyBlockTrans() to fix this.
361 return false;
362 }
363
365 void setAllToScalar (const Scalar& alpha);
366
368
370
372 std::string description () const override;
373
397 void
398 describe (Teuchos::FancyOStream& out,
399 const Teuchos::EVerbosityLevel verbLevel) const override;
400
402
404
406 virtual LO getBlockSize () const override { return blockSize_; }
407
409 virtual Teuchos::RCP<const ::Tpetra::RowGraph<LO,GO,Node> > getGraph () const override;
410
411 const crs_graph_type & getCrsGraph () const { return graph_; }
412
417 void
420 Teuchos::ETransp mode = Teuchos::NO_TRANS,
421 const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
422 const Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ());
423
426 void
428 const Import<LO, GO, Node>& importer) const;
429
432 void
434 const Export<LO, GO, Node>& exporter) const;
435
436
463 LO
464 replaceLocalValues (const LO localRowInd,
465 const LO colInds[],
466 const Scalar vals[],
467 const LO numColInds) const;
468
495 LO
496 sumIntoLocalValues (const LO localRowInd,
497 const LO colInds[],
498 const Scalar vals[],
499 const LO numColInds) const;
500
501
534 void
535 getLocalRowView (LO LocalRow,
536 local_inds_host_view_type &indices,
537 values_host_view_type &values) const override;
538
541 void
543 local_inds_host_view_type &indices,
544 nonconst_values_host_view_type &values) const;
545
547 virtual void
548 getLocalRowCopy (LO LocalRow,
549 nonconst_local_inds_host_view_type &Indices,
550 nonconst_values_host_view_type &Values,
551 size_t& NumEntries) const override;
553 getLocalBlockDeviceNonConst (const LO localRowInd, const LO localColInd) const;
554
555 little_block_host_type
556 getLocalBlockHostNonConst (const LO localRowInd, const LO localColInd) const;
557
558
582 LO
583 getLocalRowOffsets (const LO localRowInd,
584 ptrdiff_t offsets[],
585 const LO colInds[],
586 const LO numColInds) const;
587
593 LO
594 replaceLocalValuesByOffsets (const LO localRowInd,
595 const ptrdiff_t offsets[],
596 const Scalar vals[],
597 const LO numOffsets) const;
598
599 LO
600 absMaxLocalValuesByOffsets (const LO localRowInd,
601 const ptrdiff_t offsets[],
602 const Scalar vals[],
603 const LO numOffsets) const;
604
610 LO
611 sumIntoLocalValuesByOffsets (const LO localRowInd,
612 const ptrdiff_t offsets[],
613 const Scalar vals[],
614 const LO numOffsets) const;
615
622 size_t getNumEntriesInLocalRow (const LO localRowInd) const override;
623
624
627 local_matrix_device_type getLocalMatrixDevice () const;
628
645 bool localError () const {
646 return *localError_;
647 }
648
663 std::string errorMessages () const {
664 return (*errs_).is_null () ? std::string ("") : (*errs_)->str ();
665 }
666
698 void
699 getLocalDiagOffsets (const Kokkos::View<size_t*, device_type,
700 Kokkos::MemoryUnmanaged>& offsets) const;
701
702
716 void
718 Kokkos::MemoryUnmanaged>& diag,
719 const Kokkos::View<const size_t*, device_type,
720 Kokkos::MemoryUnmanaged>& offsets) const;
721
735protected:
737 LO
738 absMaxLocalValues (const LO localRowInd,
739 const LO colInds[],
740 const Scalar vals[],
741 const LO numColInds) const;
742
748
749
754 using buffer_device_type = typename DistObject<Scalar, LO, GO,
756
757 virtual bool checkSizes (const ::Tpetra::SrcDistObject& source) override;
758
759 // clang-format on
760 using dist_object_type::
761 copyAndPermute;
763 // clang-format off
764
765 virtual void
767 (const SrcDistObject& sourceObj,
768 const size_t numSameIDs,
769 const Kokkos::DualView<const local_ordinal_type*,
770 buffer_device_type>& permuteToLIDs,
771 const Kokkos::DualView<const local_ordinal_type*,
772 buffer_device_type>& permuteFromLIDs,
773 const CombineMode CM) override;
774
775 // clang-format on
780 // clang-format off
781
782 virtual void
784 (const SrcDistObject& sourceObj,
785 const Kokkos::DualView<const local_ordinal_type*,
786 buffer_device_type>& exportLIDs,
787 Kokkos::DualView<packet_type*,
788 buffer_device_type>& exports,
789 Kokkos::DualView<size_t*,
790 buffer_device_type> numPacketsPerLID,
791 size_t& constantNumPackets) override;
792
793 // clang-format on
798 // clang-format off
799
800 virtual void
802 (const Kokkos::DualView<const local_ordinal_type*,
803 buffer_device_type>& importLIDs,
804 Kokkos::DualView<packet_type*,
805 buffer_device_type> imports,
806 Kokkos::DualView<size_t*,
807 buffer_device_type> numPacketsPerLID,
808 const size_t constantNumPackets,
809 const CombineMode combineMode) override;
811
812private:
814 crs_graph_type graph_;
815 Teuchos::RCP<crs_graph_type> graphRCP_;
824 map_type rowMeshMap_;
831 map_type domainPointMap_;
838 map_type rangePointMap_;
840 LO blockSize_;
841
855 using graph_row_offset_host_type = typename crs_graph_type::local_graph_device_type::row_map_type::HostMirror;
856 graph_row_offset_host_type ptrHost_;
857
863 using graph_column_indices_host_type = typename crs_graph_type::local_graph_device_type::entries_type::HostMirror;
864 graph_column_indices_host_type indHost_;
865
871 using impl_scalar_type_dualview = Kokkos::DualView<impl_scalar_type*, device_type>;
872 using impl_scalar_type_wrapped_dualview = Details::WrappedDualView<impl_scalar_type_dualview>;
873 mutable impl_scalar_type_wrapped_dualview val_;
874
896 Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
900 Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
901
909 Teuchos::RCP<Teuchos::RCP<typename crs_graph_type::import_type> > pointImporter_;
910
912 LO offsetPerBlock_;
913
925 Teuchos::RCP<bool> localError_;
926
934 Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
935
937 std::ostream& markLocalErrorAndGetStream ();
938
939 // //! Clear the local error state and stream.
940 // void clearLocalErrorStateAndStream ();
941
942 template<class Device>
943 struct is_cuda {
944#if defined(KOKKOS_ENABLE_CUDA)
945 // CudaHostPinnedSpace::execution_space ==
946 // HostSpace::execution_space. That's OK; it's host memory, that
947 // just happens to be Cuda accessible. But what if somebody gives
948 // us Device<Cuda, CudaHostPinnedSpace>? It looks like they mean
949 // to run on device then, so we should sync to device.
950 static constexpr bool value =
951 std::is_same<typename Device::execution_space, Kokkos::Cuda>::value;
952 // Gonna badly fake this here for other execspaces
953#elif defined(KOKKOS_ENABLE_HIP)
954 static constexpr bool value =
955 std::is_same<typename Device::execution_space, Kokkos::HIP>::value;
956#elif defined(KOKKOS_ENABLE_SYCL)
957 static constexpr bool value =
958 std::is_same<typename Device::execution_space, Kokkos::Experimental::SYCL>::value;
959#else
960 static constexpr bool value = false;
961#endif
962 };
963
964public:
965 typename impl_scalar_type_dualview::t_host::const_type
966 getValuesHost() const;
967
968 typename impl_scalar_type_dualview::t_dev::const_type
969 getValuesDevice() const;
970
989 typename impl_scalar_type_dualview::t_host
991
992 typename impl_scalar_type_dualview::t_dev
993 getValuesDeviceNonConst() const;
994
996 typename impl_scalar_type_dualview::t_host::const_type
997 getValuesHost (const LO& lclRow) const;
998
1000 typename impl_scalar_type_dualview::t_dev::const_type
1001 getValuesDevice (const LO& lclRow) const;
1002
1004 typename impl_scalar_type_dualview::t_host
1005 getValuesHostNonConst (const LO& lclRow);
1006
1008 typename impl_scalar_type_dualview::t_dev
1009 getValuesDeviceNonConst (const LO& lclRow);
1011
1012private:
1013
1023 void
1024 applyBlockTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1026 const Teuchos::ETransp mode,
1027 const Scalar alpha,
1028 const Scalar beta);
1029
1037 void
1038 applyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1040 const Scalar alpha,
1041 const Scalar beta);
1042
1050 void
1051 localApplyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1053 const Scalar alpha,
1054 const Scalar beta);
1055
1095 LO
1096 findRelOffsetOfColumnIndex (const LO localRowIndex,
1097 const LO colIndexToFind,
1098 const LO hint = 0) const;
1099
1102 LO offsetPerBlock () const;
1103
1105 getConstLocalBlockFromInput (const impl_scalar_type* val, const size_t pointOffset) const;
1106
1108 getNonConstLocalBlockFromInput (impl_scalar_type* val, const size_t pointOffset) const;
1109
1110 little_block_host_type
1111 getNonConstLocalBlockFromInputHost (impl_scalar_type* val, const size_t pointOffset) const;
1112
1113
1114
1115public:
1116
1118 virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
1119
1120
1122 virtual global_size_t getGlobalNumCols() const override;
1123
1124 virtual size_t getLocalNumCols() const override;
1125
1126 virtual GO getIndexBase() const override;
1127
1129 virtual global_size_t getGlobalNumEntries() const override;
1130
1132 virtual size_t getLocalNumEntries() const override;
1142 virtual size_t getNumEntriesInGlobalRow (GO globalRow) const override;
1143
1146 virtual size_t getGlobalMaxNumRowEntries () const override;
1147
1149 virtual bool hasColMap () const override;
1150
1160 virtual bool isLocallyIndexed () const override;
1161
1171 virtual bool isGloballyIndexed () const override;
1172
1174 virtual bool isFillComplete () const override;
1175
1177 virtual bool supportsRowViews () const override;
1178
1179
1181
1183
1204 virtual void
1205 getGlobalRowCopy (GO GlobalRow,
1206 nonconst_global_inds_host_view_type &Indices,
1207 nonconst_values_host_view_type &Values,
1208 size_t& NumEntries) const override;
1233 virtual void
1234 getGlobalRowView (GO GlobalRow,
1235 global_inds_host_view_type & indices,
1236 values_host_view_type & values) const override;
1237
1249 virtual void getLocalDiagCopy (::Tpetra::Vector<Scalar,LO,GO,Node>& diag) const override;
1250
1252
1254
1260 virtual void leftScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1261
1267 virtual void rightScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1268
1277 virtual typename ::Tpetra::RowMatrix<Scalar, LO, GO, Node>::mag_type
1278 getFrobeniusNorm () const override;
1280
1281 // Friend declaration for nonmember function.
1282 template<class BlockCrsMatrixType>
1283 friend Teuchos::RCP<BlockCrsMatrixType>
1284 Tpetra::importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1285 const Import<typename BlockCrsMatrixType::local_ordinal_type,
1286 typename BlockCrsMatrixType::global_ordinal_type,
1287 typename BlockCrsMatrixType::node_type>& importer);
1288 // Friend declaration for nonmember function.
1289 template<class BlockCrsMatrixType>
1290 friend Teuchos::RCP<BlockCrsMatrixType>
1291 Tpetra::exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1292 const Export<typename BlockCrsMatrixType::local_ordinal_type,
1293 typename BlockCrsMatrixType::global_ordinal_type,
1294 typename BlockCrsMatrixType::node_type>& exporter);
1295
1296};
1297
1298template<class BlockCrsMatrixType>
1299Teuchos::RCP<BlockCrsMatrixType>
1300importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1301 const Import<typename BlockCrsMatrixType::local_ordinal_type,
1302 typename BlockCrsMatrixType::global_ordinal_type,
1303 typename BlockCrsMatrixType::node_type>& importer)
1304{
1305 Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1306 sourceMatrix->importAndFillComplete (destMatrix, importer);
1307 return destMatrix;
1308}
1309
1310
1311template<class BlockCrsMatrixType>
1312Teuchos::RCP<BlockCrsMatrixType>
1313exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1314 const Export<typename BlockCrsMatrixType::local_ordinal_type,
1315 typename BlockCrsMatrixType::global_ordinal_type,
1316 typename BlockCrsMatrixType::node_type>& exporter)
1317{
1318 Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1319 sourceMatrix->exportAndFillComplete (destMatrix, exporter);
1320 return destMatrix;
1321}
1322
1323} // namespace Tpetra
1324
1325#endif // TPETRA_BLOCKCRSMATRIX_DECL_HPP
Declaration of the Tpetra::CrsMatrix class.
LO sumIntoLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const
Sum into values at the given (mesh, i.e., block) column indices, in the given (mesh,...
virtual ~BlockCrsMatrix()
Destructor (declared virtual for memory safety).
virtual LO getBlockSize() const override
The number of degrees of freedom per mesh point.
void exportAndFillComplete(Teuchos::RCP< BlockCrsMatrix< Scalar, LO, GO, Node > > &destMatrix, const Export< LO, GO, Node > &exporter) const
Import from this to the given destination matrix, and make the result fill complete.
virtual bool isLocallyIndexed() const override
Whether matrix indices are locally indexed.
virtual bool isFillComplete() const override
Whether fillComplete() has been called.
virtual size_t getGlobalMaxNumRowEntries() const override
The maximum number of entries in any row over all processes in the matrix's communicator.
void applyBlock(const BlockMultiVector< Scalar, LO, GO, Node > &X, BlockMultiVector< Scalar, LO, GO, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, const Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), const Scalar beta=Teuchos::ScalarTraits< Scalar >::zero())
Version of apply() that takes BlockMultiVector input and output.
LO replaceLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like replaceLocalValues, but avoids computing row offsets.
BlockCrsMatrix(const crs_graph_type &graph, const map_type &domainPointMap, const map_type &rangePointMap, const LO blockSize)
Constructor that takes a graph, domain and range point Maps, and a block size.
virtual void getLocalRowCopy(LO LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const override
Not implemented.
BlockCrsMatrix(const crs_graph_type &graph, const typename local_matrix_device_type::values_type &values, const LO blockSize)
std::string errorMessages() const
The current stream of error messages.
LO absMaxLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const
Variant of getLocalDiagCopy() that uses precomputed offsets and puts diagonal blocks in a 3-D Kokkos:...
impl_scalar_type_dualview::t_host getValuesHostNonConst(const LO &lclRow)
Get a non-const Host view of the locally owned values.
BlockCrsMatrix(const crs_graph_type &graph, const LO blockSize)
Constructor that takes a graph and a block size.
Scalar scalar_type
The type of entries in the matrix (that is, of each entry in each block).
virtual void getGlobalRowView(GO GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const override
Get a constant, nonpersisting, globally indexed view of the given row of the matrix.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
Print a description of this object to the given output stream.
size_t getLocalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, on this process.
LO local_ordinal_type
The type of local indices.
virtual void getGlobalRowCopy(GO GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const override
Get a copy of the given global row's entries.
LO getLocalRowOffsets(const LO localRowInd, ptrdiff_t offsets[], const LO colInds[], const LO numColInds) const
Get relative offsets corresponding to the given rows, given by local row index.
virtual size_t getLocalNumCols() const override
The number of columns needed to apply the forward operator on this node.
virtual void copyAndPermute(const SrcDistObject &sourceObj, const size_t numSameIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteToLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteFromLIDs, const CombineMode CM) override
::Tpetra::MultiVector< Scalar, LO, GO, node_type > mv_type
The implementation of MultiVector that this class uses.
virtual void getLocalDiagCopy(::Tpetra::Vector< Scalar, LO, GO, Node > &diag) const override
Get a copy of the diagonal entries, distributed by the row Map.
Teuchos::RCP< const map_type > getRangeMap() const override
Get the (point) range Map of this matrix.
LO sumIntoLocalValuesByOffsets(const LO localRowInd, const ptrdiff_t offsets[], const Scalar vals[], const LO numOffsets) const
Like sumIntoLocalValues, but avoids computing row offsets.
virtual bool hasColMap() const override
Whether this matrix has a well-defined column Map.
device_type::execution_space execution_space
The Kokkos execution space that this class uses.
size_t getLocalNumRows() const override
get the local number of block rows
virtual size_t getLocalNumEntries() const override
The local number of stored (structurally nonzero) entries.
bool hasTransposeApply() const override
Whether it is valid to apply the transpose or conjugate transpose of this matrix.
impl_scalar_type_dualview::t_host getValuesHostNonConst() const
Get the host or device View of the matrix's values (val_).
Kokkos::View< impl_scalar_type **, Impl::BlockCrsMatrixLittleBlockArrayLayout, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > little_block_type
The type used to access nonconst matrix blocks.
Teuchos::RCP< const map_type > getColMap() const override
get the (mesh) map for the columns of this block matrix.
virtual typename::Tpetra::RowMatrix< Scalar, LO, GO, Node >::mag_type getFrobeniusNorm() const override
The Frobenius norm of the matrix.
virtual void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< packet_type *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, const CombineMode combineMode) override
local_matrix_device_type getLocalMatrixDevice() const
void apply(const mv_type &X, mv_type &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const override
For this matrix A, compute Y := beta * Y + alpha * Op(A) * X.
virtual global_size_t getGlobalNumCols() const override
The global number of columns of this matrix.
void getLocalDiagOffsets(const Kokkos::View< size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Get offsets of the diagonal entries in the matrix.
Teuchos::RCP< const map_type > getRowMap() const override
get the (mesh) map for the rows of this block matrix.
std::string description() const override
One-line description of this object.
void importAndFillComplete(Teuchos::RCP< BlockCrsMatrix< Scalar, LO, GO, Node > > &destMatrix, const Import< LO, GO, Node > &importer) const
Import from this to the given destination matrix, and make the result fill complete.
void getLocalRowView(LO LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const override
Get a view of the (mesh, i.e., block) row, using local (mesh, i.e., block) indices.
void getLocalDiagCopy(const Kokkos::View< impl_scalar_type ***, device_type, Kokkos::MemoryUnmanaged > &diag, const Kokkos::View< const size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Variant of getLocalDiagCopy() that uses precomputed offsets and puts diagonal blocks in a 3-D Kokkos:...
GO global_ordinal_type
The type of global indices.
size_t getNumEntriesInLocalRow(const LO localRowInd) const override
Return the number of entries in the given row on the calling process.
virtual bool supportsRowViews() const override
Whether this object implements getLocalRowView() and getGlobalRowView().
virtual Teuchos::RCP< const ::Tpetra::RowGraph< LO, GO, Node > > getGraph() const override
Get the (mesh) graph.
LO replaceLocalValues(const LO localRowInd, const LO colInds[], const Scalar vals[], const LO numColInds) const
Replace values at the given (mesh, i.e., block) column indices, in the given (mesh,...
virtual size_t getNumEntriesInGlobalRow(GO globalRow) const override
The current number of entries on the calling process in the specified global row.
typename DistObject< Scalar, LO, GO, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
Node::device_type device_type
The Kokkos::Device specialization that this class uses.
BMV::little_vec_type little_vec_type
The type used to access nonconst vector blocks.
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
BMV::const_little_vec_type const_little_vec_type
The type used to access const vector blocks.
impl_scalar_type_dualview::t_host::const_type getValuesHost(const LO &lclRow) const
Get a const Host view of the locally owned values.
Kokkos::View< const impl_scalar_type **, Impl::BlockCrsMatrixLittleBlockArrayLayout, device_type, Kokkos::MemoryTraits< Kokkos::Unmanaged > > const_little_block_type
The type used to access const matrix blocks.
void getLocalRowViewNonConst(LO LocalRow, local_inds_host_view_type &indices, nonconst_values_host_view_type &values) const
impl_scalar_type_dualview::t_dev getValuesDeviceNonConst(const LO &lclRow)
Get a non-const Device view of the locally owned values.
char packet_type
Implementation detail; tells.
virtual void packAndPrepare(const SrcDistObject &sourceObj, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< packet_type *, buffer_device_type > &exports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, size_t &constantNumPackets) override
::Tpetra::Map< LO, GO, node_type > map_type
The implementation of Map that this class uses.
virtual void rightScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x) override
Scale the RowMatrix on the right with the given Vector x.
virtual GO getIndexBase() const override
The index base for global indices in this matrix.
impl_scalar_type_dualview::t_dev::const_type getValuesDevice(const LO &lclRow) const
Get a const Device view of the locally owned values.
bool localError() const
Whether this object had an error on the calling process.
virtual global_size_t getGlobalNumEntries() const override
The global number of stored (structurally nonzero) entries.
typename BMV::impl_scalar_type impl_scalar_type
The implementation type of entries in the matrix.
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
The communicator over which this matrix is distributed.
::Tpetra::CrsGraph< LO, GO, node_type > crs_graph_type
The implementation of CrsGraph that this class uses.
device_type::memory_space memory_space
The Kokkos memory space that this class uses.
global_size_t getGlobalNumRows() const override
get the global number of block rows
virtual void leftScale(const ::Tpetra::Vector< Scalar, LO, GO, Node > &x) override
Scale the RowMatrix on the left with the given Vector x.
Teuchos::RCP< const map_type > getDomainMap() const override
Get the (point) domain Map of this matrix.
virtual bool isGloballyIndexed() const override
Whether matrix indices are globally indexed.
BlockCrsMatrix()
Default constructor: Makes an empty block matrix.
MultiVector for multiple degrees of freedom per mesh point.
typename mv_type::impl_scalar_type impl_scalar_type
The implementation type of entries in the object.
Kokkos::View< impl_scalar_type *, device_type > little_vec_type
"Block view" of all degrees of freedom at a mesh point, for a single column of the MultiVector.
Kokkos::View< const impl_scalar_type *, device_type > const_little_vec_type
"Const block view" of all degrees of freedom at a mesh point, for a single column of the MultiVector.
Kokkos::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, device_type, void, size_t > local_graph_device_type
A wrapper around Kokkos::DualView to safely manage data that might be replicated between host and dev...
Base class for distributed Tpetra objects that support data redistribution.
DistObject(const Teuchos::RCP< const map_type > &map)
virtual void packAndPrepare(const SrcDistObject &source, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< packet_type *, buffer_device_type > &exports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, size_t &constantNumPackets)
virtual void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< packet_type *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, const CombineMode combineMode)
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
A read-only, row-oriented interface to a sparse matrix.
Abstract base class for objects that can be the source of an Import or Export operation.
A distributed dense vector.
Namespace for new Tpetra features that are not ready for public release, but are ready for evaluation...
Kokkos::LayoutRight BlockCrsMatrixLittleBlockArrayLayout
give an option to use layoutleft
Namespace Tpetra contains the class and methods constituting the Tpetra library.
size_t global_size_t
Global size_t object.
CombineMode
Rule for combining data in an Import or Export.