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//
4// Tpetra: Templated Linear Algebra Services Package
5// Copyright (2008) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// ************************************************************************
38// @HEADER
39
40#ifndef TPETRA_BLOCKCRSMATRIX_DECL_HPP
41#define TPETRA_BLOCKCRSMATRIX_DECL_HPP
42
45
46#include "Tpetra_CrsGraph.hpp"
47#include "Tpetra_RowMatrix.hpp"
48#include "Tpetra_BlockMultiVector_decl.hpp"
50
51#include "KokkosSparse_BsrMatrix.hpp"
52
53namespace Tpetra {
54
55template<class BlockCrsMatrixType>
56Teuchos::RCP<BlockCrsMatrixType>
57importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
58 const Import<typename BlockCrsMatrixType::local_ordinal_type,
59 typename BlockCrsMatrixType::global_ordinal_type,
60 typename BlockCrsMatrixType::node_type>& importer);
61template<class BlockCrsMatrixType>
62Teuchos::RCP<BlockCrsMatrixType>
63exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
64 const Export<typename BlockCrsMatrixType::local_ordinal_type,
65 typename BlockCrsMatrixType::global_ordinal_type,
66 typename BlockCrsMatrixType::node_type>& exporter);
67
145
146namespace Impl {
148#if defined(TPETRA_ENABLE_BLOCKCRS_LITTLEBLOCK_LAYOUTLEFT)
149 using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutLeft;
150#else
151 using BlockCrsMatrixLittleBlockArrayLayout = Kokkos::LayoutRight;
152#endif
153}
154
155template<class Scalar,
156 class LO,
157 class GO,
158 class Node>
160 virtual public ::Tpetra::RowMatrix<Scalar, LO, GO, Node>,
161 virtual public ::Tpetra::DistObject<char, LO, GO, Node>
162{
163private:
166 using STS = Teuchos::ScalarTraits<Scalar>;
167
168protected:
170 typedef char packet_type;
171
172public:
174
175
178
186
195 typedef Node node_type;
196
198 typedef typename Node::device_type device_type;
200 typedef typename device_type::execution_space execution_space;
202 typedef typename device_type::memory_space memory_space;
203
205 typedef ::Tpetra::Map<LO, GO, node_type> map_type;
207 typedef ::Tpetra::MultiVector<Scalar, LO, GO, node_type> mv_type;
209 typedef ::Tpetra::CrsGraph<LO, GO, node_type> crs_graph_type;
210
212 typedef Kokkos::View<impl_scalar_type**,
215 Kokkos::MemoryTraits<Kokkos::Unmanaged> >
217 typedef typename little_block_type::HostMirror little_block_host_type;
218
220 typedef Kokkos::View<const impl_scalar_type**,
223 Kokkos::MemoryTraits<Kokkos::Unmanaged> >
227 typedef typename BMV::little_host_vec_type little_host_vec_type;
228
231 typedef typename BMV::const_little_host_vec_type const_host_little_vec_type;
232
234 using local_inds_device_view_type =
235 typename row_matrix_type::local_inds_device_view_type;
236 using local_inds_host_view_type =
237 typename row_matrix_type::local_inds_host_view_type;
238 using nonconst_local_inds_host_view_type =
239 typename row_matrix_type::nonconst_local_inds_host_view_type;
240
241 using global_inds_device_view_type =
242 typename row_matrix_type::global_inds_device_view_type;
243 using global_inds_host_view_type =
244 typename row_matrix_type::global_inds_host_view_type;
245 using nonconst_global_inds_host_view_type =
246 typename row_matrix_type::nonconst_global_inds_host_view_type;
247
248 using values_device_view_type =
249 typename row_matrix_type::values_device_view_type;
250 using values_host_view_type =
251 typename row_matrix_type::values_host_view_type;
252 using nonconst_values_host_view_type =
253 typename row_matrix_type::nonconst_values_host_view_type;
254
255 using local_graph_device_type = typename crs_graph_type::local_graph_device_type;
256
257 using local_matrix_device_type =
258 KokkosSparse::Experimental::BsrMatrix<impl_scalar_type,
261 void,
262 typename local_graph_device_type::size_type>;
263 using local_matrix_host_type =
264 typename local_matrix_device_type::HostMirror;
265
267
269
272
282 BlockCrsMatrix (const crs_graph_type& graph, const LO blockSize);
283
285 const typename local_matrix_device_type::values_type& values,
286 const LO blockSize);
287
297 const map_type& rangePointMap,
298 const LO blockSize);
299
301 virtual ~BlockCrsMatrix () {}
302
304
306
308 Teuchos::RCP<const map_type> getDomainMap () const override;
309
311 Teuchos::RCP<const map_type> getRangeMap () const override;
312
314 Teuchos::RCP<const map_type> getRowMap () const override;
315
317 Teuchos::RCP<const map_type> getColMap () const override;
318
320 global_size_t getGlobalNumRows() const override;
321
323 size_t getLocalNumRows() const override;
324
325 size_t getLocalMaxNumRowEntries() const override;
326
336 void
337 apply (const mv_type& X,
338 mv_type& Y,
339 Teuchos::ETransp mode = Teuchos::NO_TRANS,
340 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
341 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ()) const override;
342
345 bool hasTransposeApply () const override {
346 // FIXME (mfh 04 May 2014) Transpose and conjugate transpose modes
347 // are not implemented yet. Fill in applyBlockTrans() to fix this.
348 return false;
349 }
350
352 void setAllToScalar (const Scalar& alpha);
353
355
357
359 std::string description () const override;
360
384 void
385 describe (Teuchos::FancyOStream& out,
386 const Teuchos::EVerbosityLevel verbLevel) const override;
387
389
391
393 LO getBlockSize () const { return blockSize_; }
394
396 virtual Teuchos::RCP<const ::Tpetra::RowGraph<LO,GO,Node> > getGraph () const override;
397
398 const crs_graph_type & getCrsGraph () const { return graph_; }
399
404 void
405 applyBlock (const BlockMultiVector<Scalar, LO, GO, Node>& X,
406 BlockMultiVector<Scalar, LO, GO, Node>& Y,
407 Teuchos::ETransp mode = Teuchos::NO_TRANS,
408 const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one (),
409 const Scalar beta = Teuchos::ScalarTraits<Scalar>::zero ());
410
413 void
414 importAndFillComplete (Teuchos::RCP<BlockCrsMatrix<Scalar, LO, GO, Node> >& destMatrix,
415 const Import<LO, GO, Node>& importer) const;
416
419 void
420 exportAndFillComplete (Teuchos::RCP<BlockCrsMatrix<Scalar, LO, GO, Node> >& destMatrix,
421 const Export<LO, GO, Node>& exporter) const;
422
423
450 LO
451 replaceLocalValues (const LO localRowInd,
452 const LO colInds[],
453 const Scalar vals[],
454 const LO numColInds) const;
455
482 LO
483 sumIntoLocalValues (const LO localRowInd,
484 const LO colInds[],
485 const Scalar vals[],
486 const LO numColInds) const;
487
488
521 void
522 getLocalRowView (LO LocalRow,
523 local_inds_host_view_type &indices,
524 values_host_view_type &values) const override;
525
528 void
529 getLocalRowViewNonConst (LO LocalRow,
530 local_inds_host_view_type &indices,
531 nonconst_values_host_view_type &values) const;
532
534 virtual void
535 getLocalRowCopy (LO LocalRow,
536 nonconst_local_inds_host_view_type &Indices,
537 nonconst_values_host_view_type &Values,
538 size_t& NumEntries) const override;
540 getLocalBlockDeviceNonConst (const LO localRowInd, const LO localColInd) const;
541
542 little_block_host_type
543 getLocalBlockHostNonConst (const LO localRowInd, const LO localColInd) const;
544
545
569 LO
570 getLocalRowOffsets (const LO localRowInd,
571 ptrdiff_t offsets[],
572 const LO colInds[],
573 const LO numColInds) const;
574
580 LO
581 replaceLocalValuesByOffsets (const LO localRowInd,
582 const ptrdiff_t offsets[],
583 const Scalar vals[],
584 const LO numOffsets) const;
585
586 LO
587 absMaxLocalValuesByOffsets (const LO localRowInd,
588 const ptrdiff_t offsets[],
589 const Scalar vals[],
590 const LO numOffsets) const;
591
597 LO
598 sumIntoLocalValuesByOffsets (const LO localRowInd,
599 const ptrdiff_t offsets[],
600 const Scalar vals[],
601 const LO numOffsets) const;
602
609 size_t getNumEntriesInLocalRow (const LO localRowInd) const override;
610
611
614 local_matrix_device_type getLocalMatrixDevice () const;
615
632 bool localError () const {
633 return *localError_;
634 }
635
650 std::string errorMessages () const {
651 return (*errs_).is_null () ? std::string ("") : (*errs_)->str ();
652 }
653
685 void
686 getLocalDiagOffsets (const Kokkos::View<size_t*, device_type,
687 Kokkos::MemoryUnmanaged>& offsets) const;
688
689
703 void
704 getLocalDiagCopy (const Kokkos::View<impl_scalar_type***, device_type,
705 Kokkos::MemoryUnmanaged>& diag,
706 const Kokkos::View<const size_t*, device_type,
707 Kokkos::MemoryUnmanaged>& offsets) const;
708
722protected:
724 LO
726 const LO colInds[],
727 const Scalar vals[],
728 const LO numColInds) const;
729
735
736
741 using buffer_device_type = typename DistObject<Scalar, LO, GO,
743
744 virtual bool checkSizes (const ::Tpetra::SrcDistObject& source) override;
745
746 virtual void
748 (const SrcDistObject& sourceObj,
749 const size_t numSameIDs,
750 const Kokkos::DualView<const local_ordinal_type*,
752 const Kokkos::DualView<const local_ordinal_type*,
754 const CombineMode CM) override;
755
756 virtual void
758 (const SrcDistObject& sourceObj,
759 const Kokkos::DualView<const local_ordinal_type*,
761 Kokkos::DualView<packet_type*,
762 buffer_device_type>& exports,
763 Kokkos::DualView<size_t*,
765 size_t& constantNumPackets) override;
766
767 virtual void
769 (const Kokkos::DualView<const local_ordinal_type*,
771 Kokkos::DualView<packet_type*,
772 buffer_device_type> imports,
773 Kokkos::DualView<size_t*,
775 const size_t constantNumPackets,
776 const CombineMode combineMode) override;
778
779private:
781 crs_graph_type graph_;
782 Teuchos::RCP<crs_graph_type> graphRCP_;
791 map_type rowMeshMap_;
798 map_type domainPointMap_;
805 map_type rangePointMap_;
807 LO blockSize_;
808
822 using graph_row_offset_host_type = typename crs_graph_type::local_graph_device_type::row_map_type::HostMirror;
823 graph_row_offset_host_type ptrHost_;
824
830 using graph_column_indices_host_type = typename crs_graph_type::local_graph_device_type::entries_type::HostMirror;
831 graph_column_indices_host_type indHost_;
832
838 using impl_scalar_type_dualview = Kokkos::DualView<impl_scalar_type*, device_type>;
839 using impl_scalar_type_wrapped_dualview = Details::WrappedDualView<impl_scalar_type_dualview>;
840 mutable impl_scalar_type_wrapped_dualview val_;
841
863 Teuchos::RCP<Teuchos::RCP<BMV> > X_colMap_;
867 Teuchos::RCP<Teuchos::RCP<BMV> > Y_rowMap_;
868
876 Teuchos::RCP<Teuchos::RCP<typename crs_graph_type::import_type> > pointImporter_;
877
879 LO offsetPerBlock_;
880
892 Teuchos::RCP<bool> localError_;
893
901 Teuchos::RCP<Teuchos::RCP<std::ostringstream> > errs_;
902
904 std::ostream& markLocalErrorAndGetStream ();
905
906 // //! Clear the local error state and stream.
907 // void clearLocalErrorStateAndStream ();
908
909 template<class Device>
910 struct is_cuda {
911#if defined(KOKKOS_ENABLE_CUDA)
912 // CudaHostPinnedSpace::execution_space ==
913 // HostSpace::execution_space. That's OK; it's host memory, that
914 // just happens to be Cuda accessible. But what if somebody gives
915 // us Device<Cuda, CudaHostPinnedSpace>? It looks like they mean
916 // to run on device then, so we should sync to device.
917 static constexpr bool value =
918 std::is_same<typename Device::execution_space, Kokkos::Cuda>::value;
919 // Gonna badly fake this here for other execspaces
920#elif defined(KOKKOS_ENABLE_HIP)
921 static constexpr bool value =
922 std::is_same<typename Device::execution_space, Kokkos::Experimental::HIP>::value;
923#elif defined(KOKKOS_ENABLE_SYCL)
924 static constexpr bool value =
925 std::is_same<typename Device::execution_space, Kokkos::Experimental::SYCL>::value;
926#else
927 static constexpr bool value = false;
928#endif
929 };
930
931public:
932 typename impl_scalar_type_dualview::t_host::const_type
933 getValuesHost() const;
934
935 typename impl_scalar_type_dualview::t_dev::const_type
936 getValuesDevice() const;
937
956 typename impl_scalar_type_dualview::t_host
957 getValuesHostNonConst() const;
958
959 typename impl_scalar_type_dualview::t_dev
960 getValuesDeviceNonConst() const;
961
963 typename impl_scalar_type_dualview::t_host::const_type
964 getValuesHost (const LO& lclRow) const;
965
967 typename impl_scalar_type_dualview::t_dev::const_type
968 getValuesDevice (const LO& lclRow) const;
969
971 typename impl_scalar_type_dualview::t_host
972 getValuesHostNonConst (const LO& lclRow);
973
975 typename impl_scalar_type_dualview::t_dev
976 getValuesDeviceNonConst (const LO& lclRow);
978
979private:
980
990 void
991 applyBlockTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
993 const Teuchos::ETransp mode,
994 const Scalar alpha,
995 const Scalar beta);
996
1004 void
1005 applyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1007 const Scalar alpha,
1008 const Scalar beta);
1009
1017 void
1018 localApplyBlockNoTrans (const BlockMultiVector<Scalar, LO, GO, Node>& X,
1020 const Scalar alpha,
1021 const Scalar beta);
1022
1062 LO
1063 findRelOffsetOfColumnIndex (const LO localRowIndex,
1064 const LO colIndexToFind,
1065 const LO hint = 0) const;
1066
1069 LO offsetPerBlock () const;
1070
1072 getConstLocalBlockFromInput (const impl_scalar_type* val, const size_t pointOffset) const;
1073
1075 getNonConstLocalBlockFromInput (impl_scalar_type* val, const size_t pointOffset) const;
1076
1077 little_block_host_type
1078 getNonConstLocalBlockFromInputHost (impl_scalar_type* val, const size_t pointOffset) const;
1079
1080
1081
1082public:
1083
1085 virtual Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
1086
1087
1089 virtual global_size_t getGlobalNumCols() const override;
1090
1091 virtual size_t getLocalNumCols() const override;
1092
1093 virtual GO getIndexBase() const override;
1094
1096 virtual global_size_t getGlobalNumEntries() const override;
1097
1099 virtual size_t getLocalNumEntries() const override;
1109 virtual size_t getNumEntriesInGlobalRow (GO globalRow) const override;
1110
1113 virtual size_t getGlobalMaxNumRowEntries () const override;
1114
1116 virtual bool hasColMap () const override;
1117
1127 virtual bool isLocallyIndexed () const override;
1128
1138 virtual bool isGloballyIndexed () const override;
1139
1141 virtual bool isFillComplete () const override;
1142
1144 virtual bool supportsRowViews () const override;
1145
1146
1148
1150
1171 virtual void
1173 nonconst_global_inds_host_view_type &Indices,
1174 nonconst_values_host_view_type &Values,
1175 size_t& NumEntries) const override;
1200 virtual void
1202 global_inds_host_view_type & indices,
1203 values_host_view_type & values) const override;
1204
1216 virtual void getLocalDiagCopy (::Tpetra::Vector<Scalar,LO,GO,Node>& diag) const override;
1217
1219
1221
1227 virtual void leftScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1228
1234 virtual void rightScale (const ::Tpetra::Vector<Scalar, LO, GO, Node>& x) override;
1235
1244 virtual typename ::Tpetra::RowMatrix<Scalar, LO, GO, Node>::mag_type
1245 getFrobeniusNorm () const override;
1247
1248 // Friend declaration for nonmember function.
1249 template<class BlockCrsMatrixType>
1250 friend Teuchos::RCP<BlockCrsMatrixType>
1251 Tpetra::importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1252 const Import<typename BlockCrsMatrixType::local_ordinal_type,
1253 typename BlockCrsMatrixType::global_ordinal_type,
1254 typename BlockCrsMatrixType::node_type>& importer);
1255 // Friend declaration for nonmember function.
1256 template<class BlockCrsMatrixType>
1257 friend Teuchos::RCP<BlockCrsMatrixType>
1258 Tpetra::exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1259 const Export<typename BlockCrsMatrixType::local_ordinal_type,
1260 typename BlockCrsMatrixType::global_ordinal_type,
1261 typename BlockCrsMatrixType::node_type>& exporter);
1262
1263};
1264
1265template<class BlockCrsMatrixType>
1266Teuchos::RCP<BlockCrsMatrixType>
1267importAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1268 const Import<typename BlockCrsMatrixType::local_ordinal_type,
1269 typename BlockCrsMatrixType::global_ordinal_type,
1270 typename BlockCrsMatrixType::node_type>& importer)
1271{
1272 Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1273 sourceMatrix->importAndFillComplete (destMatrix, importer);
1274 return destMatrix;
1275}
1276
1277
1278template<class BlockCrsMatrixType>
1279Teuchos::RCP<BlockCrsMatrixType>
1280exportAndFillCompleteBlockCrsMatrix (const Teuchos::RCP<const BlockCrsMatrixType>& sourceMatrix,
1281 const Export<typename BlockCrsMatrixType::local_ordinal_type,
1282 typename BlockCrsMatrixType::global_ordinal_type,
1283 typename BlockCrsMatrixType::node_type>& exporter)
1284{
1285 Teuchos::RCP<BlockCrsMatrixType> destMatrix;
1286 sourceMatrix->exportAndFillComplete (destMatrix, exporter);
1287 return destMatrix;
1288}
1289
1290} // namespace Tpetra
1291
1292#endif // TPETRA_BLOCKCRSMATRIX_DECL_HPP
Declaration of the Tpetra::CrsMatrix class.
Sparse matrix whose entries are small dense square blocks, all of the same dimensions.
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).
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.
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.
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:...
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.
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
typename DistObject< Scalar, LO, GO, Node >::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
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.
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.
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
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.
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.
LO getBlockSize() const
The number of degrees of freedom per mesh point.
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
The type of the part of the sparse graph on each MPI process.
Struct that holds views of the contents of a CrsMatrix.
Base class for distributed Tpetra objects that support data redistribution.
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.
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.