Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_CrsMatrix_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#ifndef TPETRA_CRSMATRIX_DECL_HPP
11#define TPETRA_CRSMATRIX_DECL_HPP
12
15
18#include "KokkosSparse_Utils.hpp"
19#include "KokkosSparse_CrsMatrix.hpp"
20#include "Tpetra_Details_MatrixApplyHelper.hpp"
21#include "Tpetra_RowMatrix_decl.hpp"
22#include "Tpetra_Exceptions.hpp"
23#include "Tpetra_DistObject.hpp"
24#include "Tpetra_CrsGraph.hpp"
25#include "Tpetra_Vector.hpp"
26#include "Tpetra_Details_PackTraits.hpp" // unused here, could delete
27#include "Tpetra_Details_ExecutionSpacesUser.hpp"
28#include "Teuchos_DataAccess.hpp"
29
30#include <memory> // std::shared_ptr
31
32namespace Tpetra {
33
34// Forward declaration for CrsMatrix::swap() test
35template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
36class crsMatrix_Swap_Tester;
37
89template <class CrsMatrixType>
90Teuchos::RCP<CrsMatrixType>
91importAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
92 const Import<typename CrsMatrixType::local_ordinal_type,
93 typename CrsMatrixType::global_ordinal_type,
94 typename CrsMatrixType::node_type>& importer,
95 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
96 typename CrsMatrixType::global_ordinal_type,
97 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
98 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
99 typename CrsMatrixType::global_ordinal_type,
100 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
101 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
102
156template <class CrsMatrixType>
157Teuchos::RCP<CrsMatrixType>
158importAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
159 const Import<typename CrsMatrixType::local_ordinal_type,
160 typename CrsMatrixType::global_ordinal_type,
161 typename CrsMatrixType::node_type>& rowImporter,
162 const Import<typename CrsMatrixType::local_ordinal_type,
163 typename CrsMatrixType::global_ordinal_type,
164 typename CrsMatrixType::node_type>& domainImporter,
165 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
166 typename CrsMatrixType::global_ordinal_type,
167 typename CrsMatrixType::node_type> >& domainMap,
168 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
169 typename CrsMatrixType::global_ordinal_type,
170 typename CrsMatrixType::node_type> >& rangeMap,
171 const Teuchos::RCP<Teuchos::ParameterList>& params);
172
206template <class CrsMatrixType>
207Teuchos::RCP<CrsMatrixType>
208exportAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
209 const Export<typename CrsMatrixType::local_ordinal_type,
210 typename CrsMatrixType::global_ordinal_type,
211 typename CrsMatrixType::node_type>& exporter,
212 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
213 typename CrsMatrixType::global_ordinal_type,
214 typename CrsMatrixType::node_type> >& domainMap = Teuchos::null,
215 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
216 typename CrsMatrixType::global_ordinal_type,
217 typename CrsMatrixType::node_type> >& rangeMap = Teuchos::null,
218 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
219
253template <class CrsMatrixType>
254Teuchos::RCP<CrsMatrixType>
255exportAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
256 const Export<typename CrsMatrixType::local_ordinal_type,
257 typename CrsMatrixType::global_ordinal_type,
258 typename CrsMatrixType::node_type>& rowExporter,
259 const Export<typename CrsMatrixType::local_ordinal_type,
260 typename CrsMatrixType::global_ordinal_type,
261 typename CrsMatrixType::node_type>& domainExporter,
262 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
263 typename CrsMatrixType::global_ordinal_type,
264 typename CrsMatrixType::node_type> >& domainMap,
265 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
266 typename CrsMatrixType::global_ordinal_type,
267 typename CrsMatrixType::node_type> >& rangeMap,
268 const Teuchos::RCP<Teuchos::ParameterList>& params);
269
272namespace Details {
273template <class SC, class LO, class GO, class NO>
278}
279
393template <class Scalar,
394 class LocalOrdinal,
395 class GlobalOrdinal,
396 class Node>
397class CrsMatrix : public RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
398 public DistObject<char, LocalOrdinal, GlobalOrdinal, Node>,
399 public Details::Spaces::User {
400 private:
401 using dist_object_type =
402 DistObject<char, LocalOrdinal, GlobalOrdinal,
403 Node>;
405
406 public:
408
409
411 using scalar_type = Scalar;
413 using local_ordinal_type = LocalOrdinal;
415 using global_ordinal_type = GlobalOrdinal;
417 using device_type = typename Node::device_type;
419 using execution_space = typename device_type::execution_space;
421 using memory_space = typename device_type::memory_space;
422
427 using node_type = Node;
428
431
434
437
440
456 using mag_type = typename KokkosKernels::ArithTraits<impl_scalar_type>::mag_type;
457
460
463 using local_graph_host_type = typename crs_graph_type::local_graph_host_type;
464
468 KokkosSparse::CrsMatrix<impl_scalar_type,
471 void,
472 typename local_graph_device_type::size_type>;
473 using local_matrix_host_type =
474 typename local_matrix_device_type::host_mirror_type;
475
476 using row_ptrs_device_view_type =
477 typename row_matrix_type::row_ptrs_device_view_type;
478 using row_ptrs_host_view_type =
479 typename row_matrix_type::row_ptrs_host_view_type;
480
481 using local_inds_device_view_type =
482 typename row_matrix_type::local_inds_device_view_type;
483 using local_inds_host_view_type =
484 typename row_matrix_type::local_inds_host_view_type;
485 using nonconst_local_inds_host_view_type =
486 typename row_matrix_type::nonconst_local_inds_host_view_type;
487
488 using global_inds_device_view_type =
489 typename row_matrix_type::global_inds_device_view_type;
490 using global_inds_host_view_type =
491 typename row_matrix_type::global_inds_host_view_type;
492 using nonconst_global_inds_host_view_type =
493 typename row_matrix_type::nonconst_global_inds_host_view_type;
494
495 using values_device_view_type =
496 typename row_matrix_type::values_device_view_type;
497 using values_host_view_type =
498 typename row_matrix_type::values_host_view_type;
499 using nonconst_values_host_view_type =
500 typename row_matrix_type::nonconst_values_host_view_type;
501
503
505
507 CrsMatrix(const CrsMatrix<Scalar, LocalOrdinal,
508 GlobalOrdinal, Node>&) = default;
509
511 CrsMatrix(CrsMatrix<Scalar, LocalOrdinal,
512 GlobalOrdinal, Node>&&) = default;
513
515 CrsMatrix&
516 operator=(const CrsMatrix<Scalar, LocalOrdinal,
517 GlobalOrdinal, Node>&) = default;
518
520 CrsMatrix&
521 operator=(CrsMatrix<Scalar, LocalOrdinal,
522 GlobalOrdinal, Node>&&) = default;
523
537 CrsMatrix(const Teuchos::RCP<const map_type>& rowMap,
538 const size_t maxNumEntriesPerRow,
539 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
540
553 CrsMatrix(const Teuchos::RCP<const map_type>& rowMap,
554 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
555 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
556
575 CrsMatrix(const Teuchos::RCP<const map_type>& rowMap,
576 const Teuchos::RCP<const map_type>& colMap,
577 const size_t maxNumEntPerRow,
578 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
579
598 CrsMatrix(const Teuchos::RCP<const map_type>& rowMap,
599 const Teuchos::RCP<const map_type>& colMap,
600 const Teuchos::ArrayView<const size_t>& numEntPerRowToAlloc,
601 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
602
631 explicit CrsMatrix(CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& matrix,
632 const Teuchos::RCP<const crs_graph_type>& graph,
633 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
634
659 explicit CrsMatrix(const Teuchos::RCP<const crs_graph_type>& graph,
660 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
661
690 explicit CrsMatrix(const Teuchos::RCP<const crs_graph_type>& graph,
691 const typename local_matrix_device_type::values_type& values,
692 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
693
720 CrsMatrix(const Teuchos::RCP<const map_type>& rowMap,
721 const Teuchos::RCP<const map_type>& colMap,
722 const typename local_graph_device_type::row_map_type& rowPointers,
723 const typename local_graph_device_type::entries_type::non_const_type& columnIndices,
724 const typename local_matrix_device_type::values_type& values,
725 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
726
753 CrsMatrix(const Teuchos::RCP<const map_type>& rowMap,
754 const Teuchos::RCP<const map_type>& colMap,
755 const Teuchos::ArrayRCP<size_t>& rowPointers,
756 const Teuchos::ArrayRCP<LocalOrdinal>& columnIndices,
757 const Teuchos::ArrayRCP<Scalar>& values,
758 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
759
781 CrsMatrix(const Teuchos::RCP<const map_type>& rowMap,
782 const Teuchos::RCP<const map_type>& colMap,
783 const local_matrix_device_type& lclMatrix,
784 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
785
817 const Teuchos::RCP<const map_type>& rowMap,
818 const Teuchos::RCP<const map_type>& colMap,
819 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
820 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
821 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
822
835 const Teuchos::RCP<const map_type>& rowMap,
836 const Teuchos::RCP<const map_type>& colMap,
837 const Teuchos::RCP<const map_type>& domainMap,
838 const Teuchos::RCP<const map_type>& rangeMap,
839 const Teuchos::RCP<const import_type>& importer,
840 const Teuchos::RCP<const export_type>& exporter,
841 const Teuchos::RCP<Teuchos::ParameterList>& params =
842 Teuchos::null);
843
861 CrsMatrix(const Teuchos::RCP<const map_type>& rowMap,
862 const Teuchos::RCP<const map_type>& colMap,
863 const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& source,
864 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
865
867 // This function in 'Copy' mode is only guaranteed to work correctly for matrices
868 // which are fillComplete.
869 CrsMatrix(const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& source,
870 const Teuchos::DataAccess copyOrView);
871
881 virtual ~CrsMatrix() = default;
882
883 // This friend declaration makes the clone() method work.
884 template <class S2, class LO2, class GO2, class N2>
885 friend class CrsMatrix;
886
887 // This friend declaration allows for fused residual calculation
888 template <class S2, class LO2, class GO2, class N2>
893
894 // This friend declaration allows for batching of apply calls
895 template <class MatrixArray, class MultiVectorArray>
896 friend void batchedApply(const MatrixArray& Matrices,
897 const typename std::remove_pointer<typename MultiVectorArray::value_type>::type& X,
898 MultiVectorArray& Y,
899 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type alpha,
900 typename std::remove_pointer<typename MatrixArray::value_type>::type::scalar_type beta,
901 Teuchos::RCP<Teuchos::ParameterList> params);
902
903 public:
905
907
931 //
973 void
974 insertGlobalValues(const GlobalOrdinal globalRow,
975 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
976 const Teuchos::ArrayView<const Scalar>& vals);
977
992 void
993 insertGlobalValues(const GlobalOrdinal globalRow,
994 const LocalOrdinal numEnt,
995 const Scalar vals[],
996 const GlobalOrdinal inds[]);
997
1040 void
1041 insertLocalValues(const LocalOrdinal localRow,
1042 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1043 const Teuchos::ArrayView<const Scalar>& vals,
1044 const CombineMode CM = ADD);
1045
1065 void
1066 insertLocalValues(const LocalOrdinal localRow,
1067 const LocalOrdinal numEnt,
1068 const Scalar vals[],
1069 const LocalOrdinal cols[],
1070 const CombineMode CM = ADD);
1071
1072 protected:
1084 virtual LocalOrdinal
1086 const crs_graph_type& graph,
1087 const RowInfo& rowInfo,
1088 const GlobalOrdinal inds[],
1089 const impl_scalar_type newVals[],
1090 const LocalOrdinal numElts);
1091
1092 public:
1131 const global_ordinal_type globalRow,
1132 const Kokkos::View<const global_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1133 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals);
1134
1137 LocalOrdinal
1138 replaceGlobalValues(const GlobalOrdinal globalRow,
1139 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1140 const Teuchos::ArrayView<const Scalar>& vals);
1141
1156 LocalOrdinal
1157 replaceGlobalValues(const GlobalOrdinal globalRow,
1158 const LocalOrdinal numEnt,
1159 const Scalar vals[],
1160 const GlobalOrdinal cols[]);
1161
1162 protected:
1174 virtual LocalOrdinal
1176 const crs_graph_type& graph,
1177 const RowInfo& rowInfo,
1178 const LocalOrdinal inds[],
1179 const impl_scalar_type newVals[],
1180 const LocalOrdinal numElts);
1181
1182 public:
1220 const local_ordinal_type localRow,
1221 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1222 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals);
1223
1227 LocalOrdinal
1228 replaceLocalValues(const LocalOrdinal localRow,
1229 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1230 const Teuchos::ArrayView<const Scalar>& vals);
1231
1249 LocalOrdinal
1250 replaceLocalValues(const LocalOrdinal localRow,
1251 const LocalOrdinal numEnt,
1252 const Scalar inputVals[],
1253 const LocalOrdinal inputCols[]);
1254
1255 private:
1260 static const bool useAtomicUpdatesByDefault =
1261#ifdef KOKKOS_ENABLE_SERIAL
1262 !std::is_same<execution_space, Kokkos::Serial>::value;
1263#else
1264 true;
1265#endif // KOKKOS_ENABLE_SERIAL
1266
1292 protected:
1293 virtual LocalOrdinal
1295 const crs_graph_type& graph,
1296 const RowInfo& rowInfo,
1297 const GlobalOrdinal inds[],
1298 const impl_scalar_type newVals[],
1299 const LocalOrdinal numElts,
1300 const bool atomic = useAtomicUpdatesByDefault);
1301
1302 public:
1339 LocalOrdinal
1340 sumIntoGlobalValues(const GlobalOrdinal globalRow,
1341 const Teuchos::ArrayView<const GlobalOrdinal>& cols,
1342 const Teuchos::ArrayView<const Scalar>& vals,
1343 const bool atomic = useAtomicUpdatesByDefault);
1344
1367 LocalOrdinal
1368 sumIntoGlobalValues(const GlobalOrdinal globalRow,
1369 const LocalOrdinal numEnt,
1370 const Scalar vals[],
1371 const GlobalOrdinal cols[],
1372 const bool atomic = useAtomicUpdatesByDefault);
1373
1374 protected:
1388 virtual LocalOrdinal
1390 const crs_graph_type& graph,
1391 const RowInfo& rowInfo,
1392 const LocalOrdinal inds[],
1393 const impl_scalar_type newVals[],
1394 const LocalOrdinal numElts,
1395 const bool atomic = useAtomicUpdatesByDefault);
1396
1397 public:
1436 const local_ordinal_type localRow,
1437 const Kokkos::View<const local_ordinal_type*, Kokkos::AnonymousSpace>& inputInds,
1438 const Kokkos::View<const impl_scalar_type*, Kokkos::AnonymousSpace>& inputVals,
1439 const bool atomic = useAtomicUpdatesByDefault);
1440
1470 LocalOrdinal
1471 sumIntoLocalValues(const LocalOrdinal localRow,
1472 const Teuchos::ArrayView<const LocalOrdinal>& cols,
1473 const Teuchos::ArrayView<const Scalar>& vals,
1474 const bool atomic = useAtomicUpdatesByDefault);
1475
1497 LocalOrdinal
1498 sumIntoLocalValues(const LocalOrdinal localRow,
1499 const LocalOrdinal numEnt,
1500 const Scalar vals[],
1501 const LocalOrdinal cols[],
1502 const bool atomic = useAtomicUpdatesByDefault);
1503
1504 private:
1535 LocalOrdinal
1536 transformLocalValues(impl_scalar_type rowVals[],
1537 const crs_graph_type& graph,
1538 const RowInfo& rowInfo,
1539 const LocalOrdinal inds[],
1540 const impl_scalar_type newVals[],
1541 const LocalOrdinal numElts,
1542 std::function<impl_scalar_type(const impl_scalar_type&, const impl_scalar_type&)> f,
1543 const bool atomic = useAtomicUpdatesByDefault);
1544
1575 LocalOrdinal
1576 transformGlobalValues(impl_scalar_type rowVals[],
1577 const crs_graph_type& graph,
1578 const RowInfo& rowInfo,
1579 const GlobalOrdinal inds[],
1580 const impl_scalar_type newVals[],
1581 const LocalOrdinal numElts,
1582 std::function<impl_scalar_type(const impl_scalar_type&, const impl_scalar_type&)> f,
1583 const bool atomic = useAtomicUpdatesByDefault);
1584
1611 LocalOrdinal
1612 transformLocalValues(const LocalOrdinal lclRow,
1613 const LocalOrdinal numInputEnt,
1614 const impl_scalar_type inputVals[],
1615 const LocalOrdinal inputCols[],
1616 std::function<impl_scalar_type(const impl_scalar_type&, const impl_scalar_type&)> f,
1617 const bool atomic = useAtomicUpdatesByDefault);
1618
1645 LocalOrdinal
1646 transformGlobalValues(const GlobalOrdinal gblRow,
1647 const LocalOrdinal numInputEnt,
1648 const impl_scalar_type inputVals[],
1649 const GlobalOrdinal inputCols[],
1650 std::function<impl_scalar_type(const impl_scalar_type&, const impl_scalar_type&)> f,
1651 const bool atomic = useAtomicUpdatesByDefault);
1652
1653 public:
1697 template <class LocalIndicesViewType,
1698 class ImplScalarViewType,
1699 class BinaryFunction>
1700 LocalOrdinal
1701 transformLocalValues(const LocalOrdinal lclRow,
1702 const typename UnmanagedView<LocalIndicesViewType>::type& inputInds,
1703 const typename UnmanagedView<ImplScalarViewType>::type& inputVals,
1704 BinaryFunction f,
1705 const bool atomic = useAtomicUpdatesByDefault) {
1706 // We use static_assert here to check the template parameters,
1707 // rather than std::enable_if (e.g., on the return value, to
1708 // enable compilation only if the template parameters match the
1709 // desired attributes). This turns obscure link errors into
1710 // clear compilation errors. It also makes the return value a
1711 // lot easier to see.
1712 static_assert(Kokkos::is_view<LocalIndicesViewType>::value,
1713 "First template parameter LocalIndicesViewType must be "
1714 "a Kokkos::View.");
1715 static_assert(Kokkos::is_view<ImplScalarViewType>::value,
1716 "Second template parameter ImplScalarViewType must be a "
1717 "Kokkos::View.");
1718 static_assert(static_cast<int>(LocalIndicesViewType::rank) == 1,
1719 "First template parameter LocalIndicesViewType must "
1720 "have rank 1.");
1721 static_assert(static_cast<int>(ImplScalarViewType::rank) == 1,
1722 "Second template parameter ImplScalarViewType must have "
1723 "rank 1.");
1724 static_assert(std::is_same<
1725 typename LocalIndicesViewType::non_const_value_type,
1726 local_ordinal_type>::value,
1727 "First template parameter LocalIndicesViewType must "
1728 "contain values of type local_ordinal_type.");
1729 static_assert(std::is_same<
1730 typename ImplScalarViewType::non_const_value_type,
1731 impl_scalar_type>::value,
1732 "Second template parameter ImplScalarViewType must "
1733 "contain values of type impl_scalar_type.");
1734 typedef LocalOrdinal LO;
1735 const LO numInputEnt = inputInds.extent(0);
1736 if (static_cast<LO>(inputVals.extent(0)) != numInputEnt) {
1737 return Teuchos::OrdinalTraits<LO>::invalid();
1738 }
1739 return this->transformLocalValues(lclRow,
1740 numInputEnt,
1741 inputVals.data(),
1742 inputInds.data(),
1743 f,
1744 atomic);
1745 }
1746
1788 template <class BinaryFunction, class InputMemorySpace>
1789 LocalOrdinal
1790 transformGlobalValues(const GlobalOrdinal gblRow,
1791 const Kokkos::View<const GlobalOrdinal*,
1792 InputMemorySpace,
1793 Kokkos::MemoryUnmanaged>& inputInds,
1794 const Kokkos::View<const impl_scalar_type*,
1795 InputMemorySpace,
1796 Kokkos::MemoryUnmanaged>& inputVals,
1797 BinaryFunction f,
1798 const bool atomic = useAtomicUpdatesByDefault) {
1799 typedef LocalOrdinal LO;
1800 const LO numInputEnt = inputInds.extent(0);
1801 if (static_cast<LO>(inputVals.extent(0)) != numInputEnt) {
1802 return Teuchos::OrdinalTraits<LO>::invalid();
1803 }
1804 return this->transformGlobalValues(gblRow,
1805 numInputEnt,
1806 inputVals.data(),
1807 inputInds.data(),
1808 f,
1809 atomic);
1810 }
1811
1813 void setAllToScalar(const Scalar& alpha);
1814
1816 void scale(const Scalar& alpha);
1817
1842 void
1843 setAllValues(const typename local_graph_device_type::row_map_type& ptr,
1844 const typename local_graph_device_type::entries_type::non_const_type& ind,
1845 const typename local_matrix_device_type::values_type& val);
1846
1867 void
1869
1894 void
1895 setAllValues(const Teuchos::ArrayRCP<size_t>& ptr,
1896 const Teuchos::ArrayRCP<LocalOrdinal>& ind,
1897 const Teuchos::ArrayRCP<Scalar>& val);
1898
1900 row_ptrs_host_view_type getLocalRowPtrsHost() const { return getCrsGraph()->getLocalRowPtrsHost(); }
1901
1903 row_ptrs_device_view_type getLocalRowPtrsDevice() const { return getCrsGraph()->getLocalRowPtrsDevice(); }
1904
1906 local_inds_host_view_type getLocalIndicesHost() const { return getCrsGraph()->getLocalIndicesHost(); }
1907
1909 local_inds_device_view_type getLocalIndicesDevice() const { return getCrsGraph()->getLocalIndicesDevice(); }
1910
1912
1914
1944
1958 void resumeFill(const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
1959
2017 void
2018 fillComplete(const Teuchos::RCP<const map_type>& domainMap,
2019 const Teuchos::RCP<const map_type>& rangeMap,
2020 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2021
2048 void
2049 fillComplete(const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2050
2077 void
2078 expertStaticFillComplete(const Teuchos::RCP<const map_type>& domainMap,
2079 const Teuchos::RCP<const map_type>& rangeMap,
2080 const Teuchos::RCP<const import_type>& importer = Teuchos::null,
2081 const Teuchos::RCP<const export_type>& exporter = Teuchos::null,
2082 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
2083
2101 void
2102 replaceColMap(const Teuchos::RCP<const map_type>& newColMap);
2103
2185 void
2187 const Teuchos::RCP<const map_type>& newColMap,
2188 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
2189 const bool sortEachRow = true);
2190
2200 void
2201 replaceDomainMap(const Teuchos::RCP<const map_type>& newDomainMap);
2202
2216 void
2217 replaceDomainMapAndImporter(const Teuchos::RCP<const map_type>& newDomainMap,
2218 Teuchos::RCP<const import_type>& newImporter);
2219
2229 void
2230 replaceRangeMap(const Teuchos::RCP<const map_type>& newRangeMap);
2231
2245 void
2246 replaceRangeMapAndExporter(const Teuchos::RCP<const map_type>& newRangeMap,
2247 Teuchos::RCP<const export_type>& newExporter);
2248
2262 virtual void
2263 removeEmptyProcessesInPlace(const Teuchos::RCP<const map_type>& newMap) override;
2264
2266
2268
2270 Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
2271
2273 Teuchos::RCP<const map_type> getRowMap() const override;
2274
2276 Teuchos::RCP<const map_type> getColMap() const override;
2277
2279 Teuchos::RCP<const RowGraph<LocalOrdinal, GlobalOrdinal, Node> >
2280 getGraph() const override;
2281
2283 Teuchos::RCP<const crs_graph_type> getCrsGraph() const;
2284
2285 private:
2296 const crs_graph_type& getCrsGraphRef() const;
2297
2298 public:
2299#if __armclang_major__ == 22 && __armclang_minor__ == 1
2300 // On Stria, PR 13052 caused a 25% performance regression in the
2301 // CGSolve performance test that is fixed by forcing
2302 // getLocalMatrixDevice to always be inlined. Restrict the fix
2303 // to the specific toolchain where the problem was observed
2304#define TPETRA_DETAILS_ALWAYS_INLINE __attribute__((always_inline))
2305#else
2306#define TPETRA_DETAILS_ALWAYS_INLINE
2307#endif
2320 TPETRA_DETAILS_ALWAYS_INLINE local_matrix_device_type
2322 local_matrix_host_type getLocalMatrixHost() const;
2323#undef TPETRA_DETAILS_ALWAYS_INLINE
2324
2345
2352
2359 size_t getLocalNumRows() const override;
2360
2364 size_t getLocalNumCols() const override;
2365
2367 GlobalOrdinal getIndexBase() const override;
2368
2371
2373 size_t getLocalNumEntries() const override;
2374
2381 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const override;
2382
2389 size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const override;
2390
2398 size_t getGlobalMaxNumRowEntries() const override;
2399
2407 size_t getLocalMaxNumRowEntries() const override;
2408
2410 virtual LocalOrdinal getBlockSize() const override { return 1; }
2411
2413 bool hasColMap() const override;
2414
2435 bool isLocallyIndexed() const override;
2436
2457 bool isGloballyIndexed() const override;
2458
2481 bool isFillComplete() const override;
2482
2505 bool isFillActive() const;
2506
2508
2515
2517 bool isStaticGraph() const;
2518
2527
2531 //
2537 mag_type getNorm1(bool assumeSymmetric = false) const;
2538
2546 mag_type getFrobeniusNorm() const override;
2547
2550 virtual bool supportsRowViews() const override;
2551
2552 protected:
2553 using values_dualv_type =
2554 Kokkos::DualView<impl_scalar_type*, device_type>;
2555 using values_wdv_type =
2557 values_wdv_type valuesUnpacked_wdv;
2558 mutable values_wdv_type valuesPacked_wdv;
2559
2560 public:
2609 void
2610 getGlobalRowCopy(GlobalOrdinal GlobalRow,
2611 nonconst_global_inds_host_view_type& Indices,
2612 nonconst_values_host_view_type& Values,
2613 size_t& NumEntries) const override;
2629 void
2630 getLocalRowCopy(LocalOrdinal LocalRow,
2631 nonconst_local_inds_host_view_type& Indices,
2632 nonconst_values_host_view_type& Values,
2633 size_t& NumEntries) const override;
2634
2647
2648 void
2649 getGlobalRowView(GlobalOrdinal GlobalRow,
2650 global_inds_host_view_type& indices,
2651 values_host_view_type& values) const override;
2652
2665 void
2666 getLocalRowView(LocalOrdinal LocalRow,
2667 local_inds_host_view_type& indices,
2668 values_host_view_type& values) const override;
2669
2677
2684 void
2686
2730 void getLocalDiagOffsets(Teuchos::ArrayRCP<size_t>& offsets) const;
2731
2753 void
2755 const Kokkos::View<const size_t*, device_type,
2756 Kokkos::MemoryUnmanaged>& offsets) const;
2757
2780 void
2782 const Teuchos::ArrayView<const size_t>& offsets) const;
2783
2788 void
2790
2795 void
2797
2799
2801
2863 void
2866 const Teuchos::ETransp mode = Teuchos::NO_TRANS,
2867 const Scalar& alpha = Teuchos::ScalarTraits<Scalar>::one(),
2868 const Scalar& beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
2869
2872 template <class T>
2873 Teuchos::RCP<CrsMatrix<T, LocalOrdinal, GlobalOrdinal, Node> >
2874 convert() const;
2875
2877
2879
2897 void
2900 Teuchos::ETransp mode = Teuchos::NO_TRANS,
2901 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
2902 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const override;
2903
2906 bool hasTransposeApply() const override;
2907
2914 Teuchos::RCP<const map_type> getDomainMap() const override;
2915
2922 Teuchos::RCP<const map_type> getRangeMap() const override;
2923
2925
2927
2938 virtual Teuchos::RCP<RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
2939 add(const Scalar& alpha,
2941 const Scalar& beta,
2942 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& domainMap,
2943 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& rangeMap,
2944 const Teuchos::RCP<Teuchos::ParameterList>& params) const override;
2945
2947
2949
2951 std::string description() const override;
2952
2955 void
2956 describe(Teuchos::FancyOStream& out,
2957 const Teuchos::EVerbosityLevel verbLevel =
2958 Teuchos::Describable::verbLevel_default) const override;
2959
2961
2963
2968 typedef typename DistObject<Scalar, LocalOrdinal, GlobalOrdinal,
2970
2971 virtual bool
2972 checkSizes(const SrcDistObject& source) override;
2973
2974 void
2975 applyCrsPadding(
2976 const typename crs_graph_type::padding_type& padding,
2977 const bool verbose);
2978
2979 private:
2980 void
2981 copyAndPermuteStaticGraph(
2983 const size_t numSameIDs,
2984 const LocalOrdinal permuteToLIDs[],
2985 const LocalOrdinal permuteFromLIDs[],
2986 const size_t numPermutes);
2987
2988 void
2989 copyAndPermuteNonStaticGraph(
2991 const size_t numSameIDs,
2992 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs_dv,
2993 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs_dv,
2994 const size_t numPermutes);
2995
2996 protected:
2997 using dist_object_type::
2998 copyAndPermute;
3000
3001 virtual void
3003 const size_t numSameIDs,
3004 const Kokkos::DualView<
3005 const local_ordinal_type*,
3006 buffer_device_type>& permuteToLIDs,
3007 const Kokkos::DualView<
3008 const local_ordinal_type*,
3009 buffer_device_type>& permuteFromLIDs,
3010 const CombineMode CM) override;
3011
3012 virtual void
3013 packAndPrepare(const SrcDistObject& source,
3014 const Kokkos::DualView<
3015 const local_ordinal_type*,
3016 buffer_device_type>& exportLIDs,
3017 Kokkos::DualView<char*, buffer_device_type>& exports,
3018 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3019 size_t& constantNumPackets) override;
3020
3025
3026 private:
3029 void
3030 unpackAndCombineImpl(
3031 const Kokkos::DualView<const local_ordinal_type*,
3032 buffer_device_type>& importLIDs,
3033 Kokkos::DualView<char*, buffer_device_type> imports,
3034 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3035 const size_t constantNumPackets,
3036 const CombineMode combineMode,
3037 const bool verbose);
3038
3041 void
3042 unpackAndCombineImplNonStatic(
3043 const Kokkos::DualView<const local_ordinal_type*,
3044 buffer_device_type>& importLIDs,
3045 Kokkos::DualView<char*, buffer_device_type> imports,
3046 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3047 const size_t constantNumPackets,
3048 const CombineMode combineMode);
3049
3050 public:
3060 void
3061 unpackAndCombine(const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& importLIDs,
3062 Kokkos::DualView<char*, buffer_device_type> imports,
3063 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
3064 const size_t constantNumPackets,
3065 const CombineMode CM) override;
3066
3071
3177 void
3178 packNew(const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3179 Kokkos::DualView<char*, buffer_device_type>& exports,
3180 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3181 size_t& constantNumPackets) const;
3182
3183 private:
3190 void
3191 packNonStaticNew(const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
3192 Kokkos::DualView<char*, buffer_device_type>& exports,
3193 const Kokkos::DualView<size_t*, buffer_device_type>& numPacketsPerLID,
3194 size_t& constantNumPackets) const;
3195
3225 size_t
3226 packRow(char exports[],
3227 const size_t offset,
3228 const size_t numEnt,
3229 const GlobalOrdinal gidsIn[],
3230 const impl_scalar_type valsIn[],
3231 const size_t numBytesPerValue) const;
3232
3256 bool
3257 packRowStatic(char* const numEntOut,
3258 char* const valOut,
3259 char* const indOut,
3260 const size_t numEnt,
3261 const LocalOrdinal lclRow) const;
3262
3288 size_t
3289 unpackRow(GlobalOrdinal gidsOut[],
3290 impl_scalar_type valsOut[],
3291 const char imports[],
3292 const size_t offset,
3293 const size_t numBytes,
3294 const size_t numEnt,
3295 const size_t numBytesPerValue);
3296
3305 void
3306 allocatePackSpaceNew(Kokkos::DualView<char*, buffer_device_type>& exports,
3307 size_t& totalNumEntries,
3308 const Kokkos::DualView<const local_ordinal_type*,
3309 buffer_device_type>& exportLIDs) const;
3311
3312 public:
3314 typename local_matrix_host_type::values_type::const_type
3315 getLocalValuesHost(Access::ReadOnlyStruct s) const {
3316 return valuesPacked_wdv.getHostView(s);
3317 }
3318
3320 typename local_matrix_host_type::values_type
3321 getLocalValuesHost(Access::ReadWriteStruct s) {
3322 return valuesPacked_wdv.getHostView(s);
3323 }
3324
3326 typename local_matrix_host_type::values_type
3327 getLocalValuesHost(Access::OverwriteAllStruct s) {
3328 return valuesPacked_wdv.getHostView(s);
3329 }
3330
3332 typename local_matrix_device_type::values_type::const_type
3333 getLocalValuesDevice(Access::ReadOnlyStruct s) const {
3334 return valuesPacked_wdv.getDeviceView(s);
3335 }
3336
3338 typename local_matrix_device_type::values_type
3339 getLocalValuesDevice(Access::ReadWriteStruct s) {
3340 return valuesPacked_wdv.getDeviceView(s);
3341 }
3342
3344 typename local_matrix_device_type::values_type
3345 getLocalValuesDevice(Access::OverwriteAllStruct s) {
3346 return valuesPacked_wdv.getDeviceView(s);
3347 }
3348
3349 private:
3350 // Friend declaration for nonmember function.
3351 template <class CrsMatrixType>
3352 friend Teuchos::RCP<CrsMatrixType>
3353 Tpetra::importAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
3354 const Import<typename CrsMatrixType::local_ordinal_type,
3355 typename CrsMatrixType::global_ordinal_type,
3356 typename CrsMatrixType::node_type>& importer,
3357 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
3358 typename CrsMatrixType::global_ordinal_type,
3359 typename CrsMatrixType::node_type> >& domainMap,
3360 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
3361 typename CrsMatrixType::global_ordinal_type,
3362 typename CrsMatrixType::node_type> >& rangeMap,
3363 const Teuchos::RCP<Teuchos::ParameterList>& params);
3364
3365 // Friend declaration for nonmember function.
3366 template <class CrsMatrixType>
3367 friend Teuchos::RCP<CrsMatrixType>
3368 Tpetra::importAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
3369 const Import<typename CrsMatrixType::local_ordinal_type,
3370 typename CrsMatrixType::global_ordinal_type,
3371 typename CrsMatrixType::node_type>& rowImporter,
3372 const Import<typename CrsMatrixType::local_ordinal_type,
3373 typename CrsMatrixType::global_ordinal_type,
3374 typename CrsMatrixType::node_type>& domainImporter,
3375 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
3376 typename CrsMatrixType::global_ordinal_type,
3377 typename CrsMatrixType::node_type> >& domainMap,
3378 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
3379 typename CrsMatrixType::global_ordinal_type,
3380 typename CrsMatrixType::node_type> >& rangeMap,
3381 const Teuchos::RCP<Teuchos::ParameterList>& params);
3382
3383 // Friend declaration for nonmember function.
3384 template <class CrsMatrixType>
3385 friend Teuchos::RCP<CrsMatrixType>
3386 Tpetra::exportAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
3387 const Export<typename CrsMatrixType::local_ordinal_type,
3388 typename CrsMatrixType::global_ordinal_type,
3389 typename CrsMatrixType::node_type>& exporter,
3390 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
3391 typename CrsMatrixType::global_ordinal_type,
3392 typename CrsMatrixType::node_type> >& domainMap,
3393 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
3394 typename CrsMatrixType::global_ordinal_type,
3395 typename CrsMatrixType::node_type> >& rangeMap,
3396 const Teuchos::RCP<Teuchos::ParameterList>& params);
3397
3398 // Friend declaration for nonmember function.
3399 template <class CrsMatrixType>
3400 friend Teuchos::RCP<CrsMatrixType>
3401 Tpetra::exportAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
3402 const Export<typename CrsMatrixType::local_ordinal_type,
3403 typename CrsMatrixType::global_ordinal_type,
3404 typename CrsMatrixType::node_type>& rowExporter,
3405 const Export<typename CrsMatrixType::local_ordinal_type,
3406 typename CrsMatrixType::global_ordinal_type,
3407 typename CrsMatrixType::node_type>& domainExporter,
3408 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
3409 typename CrsMatrixType::global_ordinal_type,
3410 typename CrsMatrixType::node_type> >& domainMap,
3411 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
3412 typename CrsMatrixType::global_ordinal_type,
3413 typename CrsMatrixType::node_type> >& rangeMap,
3414 const Teuchos::RCP<Teuchos::ParameterList>& params);
3415
3416 public:
3432 void
3433 importAndFillComplete(Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& destMatrix,
3434 const import_type& importer,
3435 const Teuchos::RCP<const map_type>& domainMap,
3436 const Teuchos::RCP<const map_type>& rangeMap,
3437 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
3438
3454 void
3455 importAndFillComplete(Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& destMatrix,
3456 const import_type& rowImporter,
3457 const import_type& domainImporter,
3458 const Teuchos::RCP<const map_type>& domainMap,
3459 const Teuchos::RCP<const map_type>& rangeMap,
3460 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
3461
3477 void
3478 exportAndFillComplete(Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& destMatrix,
3479 const export_type& exporter,
3480 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3481 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3482 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
3483
3499 void
3500 exportAndFillComplete(Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& destMatrix,
3501 const export_type& rowExporter,
3502 const export_type& domainExporter,
3503 const Teuchos::RCP<const map_type>& domainMap,
3504 const Teuchos::RCP<const map_type>& rangeMap,
3505 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
3506
3507 private:
3528 void
3529 transferAndFillComplete(Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >& destMatrix,
3530 const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
3531 const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> >& domainTransfer,
3532 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
3533 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
3534 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
3535
3547 protected:
3548 virtual void
3550 RowInfo& rowInfo,
3551 const GlobalOrdinal gblColInds[],
3552 const impl_scalar_type vals[],
3553 const size_t numInputEnt);
3554
3555 private:
3565 void
3566 insertGlobalValuesFiltered(
3567 const GlobalOrdinal globalRow,
3568 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3569 const Teuchos::ArrayView<const Scalar>& values,
3570 const bool debug);
3571
3574 void
3575 insertGlobalValuesFilteredChecked(
3576 const GlobalOrdinal globalRow,
3577 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3578 const Teuchos::ArrayView<const Scalar>& values,
3579 const char* const prefix,
3580 const bool debug,
3581 const bool verbose);
3582
3594 void
3595 combineGlobalValues(
3596 const GlobalOrdinal globalRowIndex,
3597 const Teuchos::ArrayView<const GlobalOrdinal>& columnIndices,
3598 const Teuchos::ArrayView<const Scalar>& values,
3599 const Tpetra::CombineMode combineMode,
3600 const char* const prefix,
3601 const bool debug,
3602 const bool verbose);
3603
3625 LocalOrdinal
3626 combineGlobalValuesRaw(const LocalOrdinal lclRow,
3627 const LocalOrdinal numEnt,
3628 const impl_scalar_type vals[],
3629 const GlobalOrdinal cols[],
3630 const Tpetra::CombineMode combineMode,
3631 const char* const prefix,
3632 const bool debug,
3633 const bool verbose);
3634
3646 template <class BinaryFunction>
3647 LocalOrdinal
3648 transformGlobalValues(const GlobalOrdinal globalRow,
3649 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3650 const Teuchos::ArrayView<const Scalar>& values,
3651 BinaryFunction f,
3652 const bool atomic = useAtomicUpdatesByDefault) {
3653 typedef impl_scalar_type IST;
3654 typedef LocalOrdinal LO;
3655 typedef GlobalOrdinal GO;
3656
3657 const LO numInputEnt = static_cast<LO>(indices.size());
3658 if (static_cast<LO>(values.size()) != numInputEnt) {
3659 return Teuchos::OrdinalTraits<LO>::invalid();
3660 }
3661
3662 const GO* const inputCols = indices.getRawPtr();
3663 const IST* const inputVals =
3664 reinterpret_cast<const IST*>(values.getRawPtr());
3665 return this->transformGlobalValues(globalRow, numInputEnt, inputVals,
3666 inputCols, f, atomic);
3667 }
3668
3675 void
3676 insertNonownedGlobalValues(const GlobalOrdinal globalRow,
3677 const Teuchos::ArrayView<const GlobalOrdinal>& indices,
3678 const Teuchos::ArrayView<const Scalar>& values);
3679
3722 void
3723 insertIndicesAndValues(crs_graph_type& graph,
3724 RowInfo& rowInfo,
3725 const typename crs_graph_type::SLocalGlobalViews& newInds,
3726 const Teuchos::ArrayView<impl_scalar_type>& oldRowVals,
3727 const Teuchos::ArrayView<const impl_scalar_type>& newRowVals,
3728 const ELocalGlobal lg,
3729 const ELocalGlobal I);
3730
3731 protected:
3732 // useful typedefs
3733 typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
3734 typedef KokkosKernels::ArithTraits<impl_scalar_type> STS;
3735 typedef KokkosKernels::ArithTraits<mag_type> STM;
3736 typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> MV;
3737 typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> V;
3738 typedef crs_graph_type Graph;
3739
3740 // Enums
3741 enum GraphAllocationStatus {
3742 GraphAlreadyAllocated,
3743 GraphNotYetAllocated
3744 };
3745
3746 protected:
3765 void allocateValues(ELocalGlobal lg, GraphAllocationStatus gas,
3766 const bool verbose);
3767
3782 void
3784 const bool merged);
3785
3786 public:
3789
3790 protected:
3803 mutable Teuchos::RCP<MV> importMV_;
3804
3817 mutable Teuchos::RCP<MV> exportMV_;
3818
3838 Teuchos::RCP<MV>
3839 getColumnMapMultiVector(const MV& X_domainMap,
3840 const bool force = false) const;
3841
3863 Teuchos::RCP<MV>
3864 getRowMapMultiVector(const MV& Y_rangeMap,
3865 const bool force = false) const;
3866
3873 void
3874 applyNonTranspose(const MV& X_in,
3875 MV& Y_in,
3876 Scalar alpha,
3877 Scalar beta) const;
3878
3887 void
3888 applyTranspose(const MV& X_in,
3889 MV& Y_in,
3890 const Teuchos::ETransp mode,
3891 Scalar alpha,
3892 Scalar beta) const;
3893
3894 // matrix data accessors
3895
3898 typename values_dualv_type::t_host::const_type
3899 getValuesViewHost(const RowInfo& rowinfo) const;
3900
3903 typename values_dualv_type::t_dev::const_type
3904 getValuesViewDevice(const RowInfo& rowinfo) const;
3905
3908 typename values_dualv_type::t_host
3910
3913 typename values_dualv_type::t_dev
3915
3916 private:
3917 // TODO: When KokkosKernels 4.4 is released, local_matrix_device_type can be permanently modified to use the default_size_type
3918 // 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).
3919 //
3920 // At that point the ApplyHelper can be replaced with just a SPMVHandle.
3921 using local_matrix_int_rowptrs_device_type =
3922 KokkosSparse::CrsMatrix<impl_scalar_type,
3925 void,
3926 int>;
3927
3929 using ApplyHelper = Details::MatrixApplyHelper<
3931 local_matrix_int_rowptrs_device_type,
3932 typename MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::device_view_type>;
3933
3934 std::shared_ptr<ApplyHelper> getApplyHelper() const {
3935 if (!applyHelper) {
3936 auto A_lcl = getLocalMatrixDevice();
3937 applyHelper = std::make_shared<ApplyHelper>(A_lcl.nnz(), A_lcl.graph.row_map);
3938 }
3939 return applyHelper;
3940 }
3941
3942 protected:
3943 // Friend the tester for CrsMatrix::swap
3944 friend class Tpetra::crsMatrix_Swap_Tester<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
3945
3946 // Friend the matrix multiply kernels so they can access internally-cached integer
3947 // row pointers without making them part of the CrsMatrix interface
3948 template <typename S, typename LO, typename GO, typename NODE, typename LOV>
3949 friend struct Tpetra::MMdetails::KernelWrappers;
3950 template <typename S, typename LO, typename GO, typename NODE, typename LOV>
3951 friend struct Tpetra::MMdetails::KernelWrappers2;
3952 // Really we want to friend:
3953 // template <typename S, typename LO, typename GO, typename NODE, typename LOV>
3954 // friend void Tpetra::MMdetails::kokkos_kernels_mult_A_B_newmatrix(...),
3955 // but nvcc seemingly doesn't reliably honor this friendship (because it's a template class?)
3956 // Instead, we defined a little non-template wrapper class over by kokkos_kernels_mult_A_B_newmatrix so we
3957 // can friend that here instead, which seems to work.
3958 // This is needed so kokkos_kernels_mult_A_B_newmatrix can access the lazy integer row pointer
3959 // helpers
3960 friend struct Tpetra::MMdetails::CrsMatrixApplyHelperAccess;
3961
3962 // friend Matrix Matrix utility function that needs to access integer-typed rowptrs
3963 friend void Tpetra::MMdetails::import_and_extract_views<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
3964 const CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A,
3965 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > targetMap,
3966 CrsMatrixStruct<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Aview,
3967 Teuchos::RCP<const Import<LocalOrdinal, GlobalOrdinal, Node> > prototypeImporter,
3968 bool userAssertsThereAreNoRemotes,
3969 const std::string& label,
3970 const Teuchos::RCP<Teuchos::ParameterList>& params);
3971
3975 void swap(CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>& matrix);
3976
3977 protected:
3983 void fillLocalMatrix(const Teuchos::RCP<Teuchos::ParameterList>& params);
3984
3990 void fillLocalGraphAndMatrix(const Teuchos::RCP<Teuchos::ParameterList>& params);
3991
3994
4006
4007 Teuchos::RCP<const Graph> staticGraph_;
4008 Teuchos::RCP<Graph> myGraph_;
4010
4011 protected:
4022 Details::STORAGE_1D_UNPACKED;
4023
4025 bool fillComplete_ = false;
4026
4054 std::map<GlobalOrdinal, std::pair<Teuchos::Array<GlobalOrdinal>,
4055 Teuchos::Array<Scalar> > >
4057
4058 private:
4064 mutable std::shared_ptr<ApplyHelper> applyHelper;
4065
4066 public:
4067 // FIXME (mfh 24 Feb 2014) Is it _really_ necessary to make this a
4068 // public inner class of CrsMatrix? It looks like it doesn't
4069 // depend on any implementation details of CrsMatrix at all. It
4070 // should really be declared and defined outside of CrsMatrix.
4071 template <class DestViewType, class SrcViewType,
4072 class DestOffsetViewType, class SrcOffsetViewType>
4073 struct pack_functor {
4074 typedef typename DestViewType::execution_space execution_space;
4075 SrcViewType src_;
4076 DestViewType dst_;
4077 SrcOffsetViewType src_offset_;
4078 DestOffsetViewType dst_offset_;
4079 typedef typename DestOffsetViewType::non_const_value_type scalar_index_type;
4080
4081 pack_functor(DestViewType dst,
4082 const SrcViewType src,
4083 DestOffsetViewType dst_offset,
4084 const SrcOffsetViewType src_offset)
4085 : src_(src)
4086 , dst_(dst)
4087 , src_offset_(src_offset)
4088 , dst_offset_(dst_offset) {}
4089
4090 KOKKOS_INLINE_FUNCTION
4091 void operator()(const LocalOrdinal row) const {
4092 scalar_index_type srcPos = src_offset_(row);
4093 const scalar_index_type dstEnd = dst_offset_(row + 1);
4094 scalar_index_type dstPos = dst_offset_(row);
4095 for (; dstPos < dstEnd; ++dstPos, ++srcPos) {
4096 dst_(dstPos) = src_(srcPos);
4097 }
4098 }
4099 };
4100}; // class CrsMatrix
4101
4106template <class Scalar,
4107 class LocalOrdinal,
4108 class GlobalOrdinal,
4109 class Node>
4110Teuchos::RCP<CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
4112 const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& map,
4113 const size_t maxNumEntriesPerRow = 0,
4114 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
4115 using matrix_type =
4116 CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
4117 return Teuchos::rcp(new matrix_type(map, maxNumEntriesPerRow,
4118 params));
4119}
4120
4121template <class CrsMatrixType>
4122Teuchos::RCP<CrsMatrixType>
4123importAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
4124 const Import<typename CrsMatrixType::local_ordinal_type,
4125 typename CrsMatrixType::global_ordinal_type,
4126 typename CrsMatrixType::node_type>& importer,
4127 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
4128 typename CrsMatrixType::global_ordinal_type,
4129 typename CrsMatrixType::node_type> >& domainMap,
4130 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
4131 typename CrsMatrixType::global_ordinal_type,
4132 typename CrsMatrixType::node_type> >& rangeMap,
4133 const Teuchos::RCP<Teuchos::ParameterList>& params) {
4134 Teuchos::RCP<CrsMatrixType> destMatrix;
4135 sourceMatrix->importAndFillComplete(destMatrix, importer, domainMap, rangeMap, params);
4136 return destMatrix;
4137}
4138
4139template <class CrsMatrixType>
4140Teuchos::RCP<CrsMatrixType>
4141importAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
4142 const Import<typename CrsMatrixType::local_ordinal_type,
4143 typename CrsMatrixType::global_ordinal_type,
4144 typename CrsMatrixType::node_type>& rowImporter,
4145 const Import<typename CrsMatrixType::local_ordinal_type,
4146 typename CrsMatrixType::global_ordinal_type,
4147 typename CrsMatrixType::node_type>& domainImporter,
4148 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
4149 typename CrsMatrixType::global_ordinal_type,
4150 typename CrsMatrixType::node_type> >& domainMap,
4151 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
4152 typename CrsMatrixType::global_ordinal_type,
4153 typename CrsMatrixType::node_type> >& rangeMap,
4154 const Teuchos::RCP<Teuchos::ParameterList>& params) {
4155 Teuchos::RCP<CrsMatrixType> destMatrix;
4156 sourceMatrix->importAndFillComplete(destMatrix, rowImporter, domainImporter, domainMap, rangeMap, params);
4157 return destMatrix;
4158}
4159
4160template <class CrsMatrixType>
4161Teuchos::RCP<CrsMatrixType>
4162exportAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
4163 const Export<typename CrsMatrixType::local_ordinal_type,
4164 typename CrsMatrixType::global_ordinal_type,
4165 typename CrsMatrixType::node_type>& exporter,
4166 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
4167 typename CrsMatrixType::global_ordinal_type,
4168 typename CrsMatrixType::node_type> >& domainMap,
4169 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
4170 typename CrsMatrixType::global_ordinal_type,
4171 typename CrsMatrixType::node_type> >& rangeMap,
4172 const Teuchos::RCP<Teuchos::ParameterList>& params) {
4173 Teuchos::RCP<CrsMatrixType> destMatrix;
4174 sourceMatrix->exportAndFillComplete(destMatrix, exporter, domainMap, rangeMap, params);
4175 return destMatrix;
4176}
4177
4178template <class CrsMatrixType>
4179Teuchos::RCP<CrsMatrixType>
4180exportAndFillCompleteCrsMatrix(const Teuchos::RCP<const CrsMatrixType>& sourceMatrix,
4181 const Export<typename CrsMatrixType::local_ordinal_type,
4182 typename CrsMatrixType::global_ordinal_type,
4183 typename CrsMatrixType::node_type>& rowExporter,
4184 const Export<typename CrsMatrixType::local_ordinal_type,
4185 typename CrsMatrixType::global_ordinal_type,
4186 typename CrsMatrixType::node_type>& domainExporter,
4187 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
4188 typename CrsMatrixType::global_ordinal_type,
4189 typename CrsMatrixType::node_type> >& domainMap,
4190 const Teuchos::RCP<const Map<typename CrsMatrixType::local_ordinal_type,
4191 typename CrsMatrixType::global_ordinal_type,
4192 typename CrsMatrixType::node_type> >& rangeMap,
4193 const Teuchos::RCP<Teuchos::ParameterList>& params) {
4194 Teuchos::RCP<CrsMatrixType> destMatrix;
4195 sourceMatrix->exportAndFillComplete(destMatrix, rowExporter, domainExporter, domainMap, rangeMap, params);
4196 return destMatrix;
4197}
4198
4205template <class CrsMatrixType>
4206void removeCrsMatrixZeros(CrsMatrixType& matrix,
4207 typename Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::magnitudeType const& threshold =
4208 Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::magnitude(Teuchos::ScalarTraits<typename CrsMatrixType::scalar_type>::zero())) {
4209 auto localMatrix = matrix.getLocalMatrixDevice();
4210 size_t nnzBefore = localMatrix.nnz();
4211 localMatrix = KokkosSparse::removeCrsMatrixZeros(localMatrix, threshold);
4212 size_t localNNZRemoved = nnzBefore - localMatrix.nnz();
4213 // Skip the expertStaticFillComplete if no entries were removed on any process.
4214 // The fill complete can perform MPI collectives, so it can only be skipped on all processes or none.
4215 size_t globalNNZRemoved = 0;
4216 Teuchos::reduceAll<int, size_t>(*(matrix.getComm()), Teuchos::REDUCE_SUM, 1, &localNNZRemoved, &globalNNZRemoved);
4217 if (globalNNZRemoved != size_t(0)) {
4218 matrix.resumeFill();
4219 matrix.setAllValues(localMatrix);
4220 matrix.expertStaticFillComplete(matrix.getDomainMap(), matrix.getRangeMap());
4221 }
4222}
4223
4224} // namespace Tpetra
4225
4232
4233#endif // TPETRA_CRSMATRIX_DECL_HPP
Forward declaration of Tpetra::CrsMatrix.
Declaration and generic definition of traits class that tells Tpetra::CrsMatrix how to pack and unpac...
Forward declaration of some Tpetra Matrix Matrix objects.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
KokkosSparse::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.
typename local_graph_device_type::host_mirror_type local_graph_host_type
The type of the part of the sparse graph on each MPI process.
virtual void insertGlobalValuesImpl(crs_graph_type &graph, RowInfo &rowInfo, const GlobalOrdinal gblColInds[], const impl_scalar_type vals[], const size_t numInputEnt)
Common implementation detail of insertGlobalValues and insertGlobalValuesFiltered.
bool isGloballyIndexed() const override
Whether the matrix is globally indexed on the calling process.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Print this object with the given verbosity level to the given output stream.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const Teuchos::ArrayRCP< size_t > &rowPointers, const Teuchos::ArrayRCP< LocalOrdinal > &columnIndices, const Teuchos::ArrayRCP< Scalar > &values, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying column Map and arrays containing the local matrix. In almost all cases the loc...
std::map< GO, std::pair< Teuchos::Array< GO >, Teuchos::Array< SC > > > nonlocals_
void localApply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, const Teuchos::ETransp mode=Teuchos::NO_TRANS, const Scalar &alpha=Teuchos::ScalarTraits< Scalar >::one(), const Scalar &beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Compute the local part of a sparse matrix-(Multi)Vector multiply.
void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< char *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, const CombineMode CM) override
Unpack the imported column indices and values, and combine into matrix.
LocalOrdinal replaceLocalValues(const LocalOrdinal localRow, const LocalOrdinal numEnt, const Scalar inputVals[], const LocalOrdinal inputCols[])
Epetra compatibility version of replaceLocalValues, that takes raw pointers instead of Kokkos::View.
CrsMatrix & operator=(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assignment.
void replaceRangeMap(const Teuchos::RCP< const map_type > &newRangeMap)
Replace the current range Map with the given objects.
typename device_type::execution_space execution_space
void importAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const import_type &rowImporter, const import_type &domainImporter, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params) const
Import from this to the given destination matrix, and make the result fill complete.
LocalOrdinal sumIntoGlobalValues(const GlobalOrdinal globalRow, const LocalOrdinal numEnt, const Scalar vals[], const GlobalOrdinal cols[], const bool atomic=useAtomicUpdatesByDefault)
Epetra compatibility version of sumIntoGlobalValues (see above), that takes input as raw pointers ins...
void applyNonTranspose(const MV &X_in, MV &Y_in, Scalar alpha, Scalar beta) const
void importAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const import_type &importer, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null) const
Import from this to the given destination matrix, and make the result fill complete.
local_ordinal_type replaceGlobalValues(const global_ordinal_type globalRow, const Kokkos::View< const global_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals)
Replace one or more entries' values, using global indices.
Teuchos::RCP< CrsMatrixType > importAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &rowImporter, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &domainImporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, over all processes in the matrix's communicator.
void getGlobalRowCopy(GlobalOrdinal GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const override
Fill given arrays with a deep copy of the locally owned entries of the matrix in a given row,...
LocalOrdinal replaceGlobalValues(const GlobalOrdinal globalRow, const LocalOrdinal numEnt, const Scalar vals[], const GlobalOrdinal cols[])
Overload of replaceGlobalValues (see above), that takes raw pointers instead of Kokkos::View.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const override
Number of entries in the sparse matrix in the given global row, on the calling (MPI) process.
void scale(const Scalar &alpha)
Scale the matrix's values: this := alpha*this.
void sortAndMergeIndicesAndValues(const bool sorted, const bool merged)
Sort and merge duplicate local column indices in all rows on the calling process, along with their co...
void packNew(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< char *, buffer_device_type > &exports, const Kokkos::DualView< size_t *, buffer_device_type > &numPacketsPerLID, size_t &constantNumPackets) const
Pack this object's data for an Import or Export.
size_t getLocalNumCols() const override
The number of columns connected to the locally owned rows of this matrix.
Teuchos::RCP< const map_type > getDomainMap() const override
The domain Map of this matrix.
bool hasColMap() const override
Whether the matrix has a well-defined column Map.
row_ptrs_host_view_type getLocalRowPtrsHost() const
Get a host view of the CRS packed row pointers.
mag_type getNormInf() const
Compute and return the infinity norm of the matrix.
Teuchos::RCP< CrsMatrix< T, LocalOrdinal, GlobalOrdinal, Node > > convert() const
Return another CrsMatrix with the same entries, but converted to a different Scalar type T.
values_dualv_type::t_dev getValuesViewDeviceNonConst(const RowInfo &rowinfo)
Get a non-const Device view of the locally owned values row myRow, such that rowinfo = getRowInfo(myR...
void expertStaticFillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< const import_type > &importer=Teuchos::null, const Teuchos::RCP< const export_type > &exporter=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Perform a fillComplete on a matrix that already has data.
CrsMatrix(const Teuchos::RCP< const crs_graph_type > &graph, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying a previously constructed graph.
LocalOrdinal transformLocalValues(const LocalOrdinal lclRow, const typename UnmanagedView< LocalIndicesViewType >::type &inputInds, const typename UnmanagedView< ImplScalarViewType >::type &inputVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault)
Transform CrsMatrix entries in place, using local indices to select the entries in the row to transfo...
local_ordinal_type sumIntoLocalValues(const local_ordinal_type localRow, const Kokkos::View< const local_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals, const bool atomic=useAtomicUpdatesByDefault)
Sum into one or more sparse matrix entries, using local row and column indices.
LocalOrdinal sumIntoLocalValues(const LocalOrdinal localRow, const LocalOrdinal numEnt, const Scalar vals[], const LocalOrdinal cols[], const bool atomic=useAtomicUpdatesByDefault)
Epetra compatibility version of sumIntoLocalValues (see above) that takes raw pointers instead of Kok...
virtual Teuchos::RCP< RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > add(const Scalar &alpha, const RowMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params) const override
Implementation of RowMatrix::add: return alpha*A + beta*this.
CrsMatrix(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &&)=default
Move constructor.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::ArrayView< const size_t > &numEntPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying (possibly different) number of entries in each row.
void applyTranspose(const MV &X_in, MV &Y_in, const Teuchos::ETransp mode, Scalar alpha, Scalar beta) const
size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const override
Number of entries in the sparse matrix in the given local row, on the calling (MPI) process.
Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createCrsMatrix(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const size_t maxNumEntriesPerRow=0, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Create an empty CrsMatrix given a row map and a single integer upper bound on the number of stored en...
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
The communicator over which the matrix is distributed.
bool isFillActive() const
Whether the matrix is not fill complete.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const local_matrix_device_type &lclMatrix, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying column Map and a local matrix, which the resulting CrsMatrix views.
RowMatrix< SC, LO, GO, NT > row_matrix_type
void replaceDomainMapAndImporter(const Teuchos::RCP< const map_type > &newDomainMap, Teuchos::RCP< const import_type > &newImporter)
Replace the current domain Map and Import with the given objects.
local_matrix_host_type::values_type getLocalValuesHost(Access::ReadWriteStruct s)
Get the Kokkos local values on host, read write.
LocalOrdinal sumIntoGlobalValues(const GlobalOrdinal globalRow, const Teuchos::ArrayView< const GlobalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals, const bool atomic=useAtomicUpdatesByDefault)
Sum into one or more sparse matrix entries, using global indices.
mag_type getNorm1(bool assumeSymmetric=false) const
Compute and return the 1-norm of the matrix.
void setAllValues(const Teuchos::ArrayRCP< size_t > &ptr, const Teuchos::ArrayRCP< LocalOrdinal > &ind, const Teuchos::ArrayRCP< Scalar > &val)
Set the local matrix using three (compressed sparse row) arrays.
virtual ~CrsMatrix()=default
Destructor (virtual for memory safety of derived classes).
void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const override
Compute a sparse matrix-MultiVector multiply.
mag_type getFrobeniusNorm() const override
Compute and return the Frobenius norm of the matrix.
void insertLocalValues(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals, const CombineMode CM=ADD)
Insert one or more entries into the matrix, using local column indices.
global_size_t getGlobalNumCols() const override
The number of global columns in the matrix.
Teuchos::RCP< const map_type > getRangeMap() const override
The range Map of this matrix.
CrsMatrix(const local_matrix_device_type &lclMatrix, const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< const import_type > &importer, const Teuchos::RCP< const export_type > &exporter, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
void allocateValues(ELocalGlobal lg, GraphAllocationStatus gas, const bool verbose)
Allocate values (and optionally indices) using the Node.
size_t getLocalNumEntries() const override
The local number of entries in this matrix.
typename KokkosKernels::ArithTraits< impl_scalar_type >::mag_type mag_type
virtual LocalOrdinal sumIntoGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoGlobalValues.
void replaceDomainMap(const Teuchos::RCP< const map_type > &newDomainMap)
Replace the current domain Map with the given objects.
CrsMatrix(const local_matrix_device_type &lclMatrix, const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const Teuchos::RCP< const map_type > &domainMap=Teuchos::null, const Teuchos::RCP< const map_type > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying column, domain and range Maps, and a local matrix, which the resulting CrsMatr...
friend void batchedApply(const MatrixArray &Matrices, const typename std::remove_pointer< typename MultiVectorArray::value_type >::type &X, MultiVectorArray &Y, typename std::remove_pointer< typename MatrixArray::value_type >::type::scalar_type alpha, typename std::remove_pointer< typename MatrixArray::value_type >::type::scalar_type beta, Teuchos::RCP< Teuchos::ParameterList > params)
Does multiply matrix apply() calls with a single X vector.
void removeCrsMatrixZeros(CrsMatrixType &matrix, typename Teuchos::ScalarTraits< typename CrsMatrixType::scalar_type >::magnitudeType const &threshold=Teuchos::ScalarTraits< typename CrsMatrixType::scalar_type >::magnitude(Teuchos::ScalarTraits< typename CrsMatrixType::scalar_type >::zero()))
Remove zero entries from a matrix.
std::string description() const override
A one-line description of this object.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying the maximum number of entries that any row on the process can take.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const typename local_graph_device_type::row_map_type &rowPointers, const typename local_graph_device_type::entries_type::non_const_type &columnIndices, const typename local_matrix_device_type::values_type &values, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying column Map and arrays containing the matrix in local indices....
void reindexColumns(crs_graph_type *const graph, const Teuchos::RCP< const map_type > &newColMap, const Teuchos::RCP< const import_type > &newImport=Teuchos::null, const bool sortEachRow=true)
Reindex the column indices in place, and replace the column Map. Optionally, replace the Import objec...
Teuchos::RCP< MV > getColumnMapMultiVector(const MV &X_domainMap, const bool force=false) const
Create a (or fetch a cached) column Map MultiVector.
void replaceRangeMapAndExporter(const Teuchos::RCP< const map_type > &newRangeMap, Teuchos::RCP< const export_type > &newExporter)
Replace the current Range Map and Export with the given objects.
size_t getLocalMaxNumRowEntries() const override
Maximum number of entries in any row of the matrix, on this process.
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the matrix's column Map with the given Map.
global_size_t getGlobalNumRows() const override
Number of global elements in the row map of this matrix.
local_matrix_host_type::values_type::const_type getLocalValuesHost(Access::ReadOnlyStruct s) const
Get the Kokkos local values on host, read only.
void globalAssemble()
Communicate nonlocal contributions to other processes.
void checkInternalState() const
Check that this object's state is sane; throw if it's not.
bool hasTransposeApply() const override
Whether apply() allows applying the transpose or conjugate transpose.
GlobalOrdinal getIndexBase() const override
The index base for global indices for this matrix.
void insertGlobalValues(const GlobalOrdinal globalRow, const LocalOrdinal numEnt, const Scalar vals[], const GlobalOrdinal inds[])
Epetra compatibility version of insertGlobalValues (see above) that takes arguments as raw pointers,...
CrsMatrix(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &matrix, const Teuchos::RCP< const crs_graph_type > &graph, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying a matrix and a previously constructed graph, presumably a subset of the matrix...
CrsMatrix(const Teuchos::RCP< const crs_graph_type > &graph, const typename local_matrix_device_type::values_type &values, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying a previously constructed graph and entries array.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag) const override
Get a constant, nonpersisting view of a row of this matrix, using local row and column indices,...
void setAllToScalar(const Scalar &alpha)
Set all matrix entries equal to alpha.
void fillLocalGraphAndMatrix(const Teuchos::RCP< Teuchos::ParameterList > &params)
Fill data into the local graph and matrix.
DistObject< SC, LO, GO, NT >::buffer_device_type buffer_device_type
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Teuchos::ArrayView< const size_t > &offsets) const
Variant of getLocalDiagCopy() that uses precomputed offsets.
row_ptrs_device_view_type getLocalRowPtrsDevice() const
Get a device view of the CRS packed row pointers.
local_inds_host_view_type getLocalIndicesHost() const
Get a host view of the CRS packed column indicies.
TPETRA_DETAILS_ALWAYS_INLINE local_matrix_device_type getLocalMatrixDevice() const
The local sparse matrix.
void getLocalRowView(LocalOrdinal LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const override
Get a constant view of a row of this matrix, using local row and column indices.
Teuchos::RCP< const map_type > getColMap() const override
The Map that describes the column distribution in this matrix.
LocalOrdinal replaceGlobalValues(const GlobalOrdinal globalRow, const Teuchos::ArrayView< const GlobalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals)
Overload of replaceGlobalValues (see above), that takes Teuchos::ArrayView (host pointers) instead of...
void insertGlobalValues(const GlobalOrdinal globalRow, const Teuchos::ArrayView< const GlobalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals)
Insert one or more entries into the matrix, using global column indices.
void fillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Tell the matrix that you are done changing its structure or values, and that you are ready to do comp...
typename crs_graph_type::local_graph_device_type local_graph_device_type
void getGlobalRowView(GlobalOrdinal GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const override
Get a constant, nonpersisting view of a row of this matrix, using global row and column indices.
void setAllValues(const typename local_graph_device_type::row_map_type &ptr, const typename local_graph_device_type::entries_type::non_const_type &ind, const typename local_matrix_device_type::values_type &val)
Set the local matrix using three (compressed sparse row) arrays.
Teuchos::RCP< const RowGraph< LocalOrdinal, GlobalOrdinal, Node > > getGraph() const override
This matrix's graph, as a RowGraph.
virtual void copyAndPermute(const SrcDistObject &source, 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
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Maps and their communicator.
local_matrix_device_type::values_type getLocalValuesDevice(Access::ReadWriteStruct s)
Get the Kokkos local values on device, read write.
virtual LocalOrdinal sumIntoLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts, const bool atomic=useAtomicUpdatesByDefault)
Implementation detail of sumIntoLocalValues.
void swap(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &matrix)
Swaps the data from *this with the data and maps from crsMatrix.
void fillComplete(const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Tell the matrix that you are done changing its structure or values, and that you are ready to do comp...
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying a CrsMatrix and row and column maps. The resulting CrsMatrix views the same lo...
bool isStaticGraph() const
Indicates that the graph is static, so that new entries cannot be added to this matrix.
global_size_t getGlobalNumEntries() const override
The global number of entries in this matrix.
virtual LocalOrdinal replaceLocalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const LocalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Implementation detail of replaceLocalValues.
Teuchos::RCP< CrsMatrixType > importAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &importer, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
KokkosSparse::CrsMatrix< impl_scalar_type, local_ordinal_type, device_type, void, typename local_graph_device_type::size_type > local_matrix_device_type
size_t getLocalNumRows() const override
The number of matrix rows owned by the calling process.
bool isFillComplete() const override
Whether the matrix is fill complete.
LocalOrdinal transformGlobalValues(const GlobalOrdinal gblRow, const Kokkos::View< const GlobalOrdinal *, InputMemorySpace, Kokkos::MemoryUnmanaged > &inputInds, const Kokkos::View< const impl_scalar_type *, InputMemorySpace, Kokkos::MemoryUnmanaged > &inputVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault)
Transform CrsMatrix entries in place, using global indices to select the entries in the row to transf...
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
Teuchos::RCP< const map_type > getRowMap() const override
The Map that describes the row distribution in this matrix.
typename device_type::memory_space memory_space
local_matrix_device_type::values_type getLocalValuesDevice(Access::OverwriteAllStruct s)
Get the Kokkos local values on device, overwrite all.
local_ordinal_type replaceLocalValues(const local_ordinal_type localRow, const Kokkos::View< const local_ordinal_type *, Kokkos::AnonymousSpace > &inputInds, const Kokkos::View< const impl_scalar_type *, Kokkos::AnonymousSpace > &inputVals)
Replace one or more entries' values, using local row and column indices.
LocalOrdinal replaceLocalValues(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals)
Backwards compatibility version of replaceLocalValues (see above), that takes Teuchos::ArrayView (hos...
void exportAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const export_type &exporter, const Teuchos::RCP< const map_type > &domainMap=Teuchos::null, const Teuchos::RCP< const map_type > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null) const
Export from this to the given destination matrix, and make the result fill complete.
local_matrix_host_type::values_type getLocalValuesHost(Access::OverwriteAllStruct s)
Get the Kokkos local values on host, overwrite all.
values_dualv_type::t_host::const_type getValuesViewHost(const RowInfo &rowinfo) const
Get a const Host view of the locally owned values row myRow, such that rowinfo = getRowInfo(myRow).
CrsMatrix(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy constructor.
void insertLocalValues(const LocalOrdinal localRow, const LocalOrdinal numEnt, const Scalar vals[], const LocalOrdinal cols[], const CombineMode CM=ADD)
Epetra compatibility version of insertLocalValues (see above) that takes arguments as raw pointers,...
CrsMatrix(const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::DataAccess copyOrView)
Copy constructor, with option to do deep or shallow copy.
bool isLocallyIndexed() const override
Whether the matrix is locally indexed on the calling process.
typename row_matrix_type::impl_scalar_type impl_scalar_type
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const Teuchos::ArrayView< const size_t > &numEntPerRowToAlloc, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying column Map and number of entries in each row.
Teuchos::RCP< MV > getRowMapMultiVector(const MV &Y_rangeMap, const bool force=false) const
Create a (or fetch a cached) row Map MultiVector.
local_matrix_device_type::values_type::const_type getLocalValuesDevice(Access::ReadOnlyStruct s) const
Get the Kokkos local values on device, read only.
virtual LocalOrdinal replaceGlobalValuesImpl(impl_scalar_type rowVals[], const crs_graph_type &graph, const RowInfo &rowInfo, const GlobalOrdinal inds[], const impl_scalar_type newVals[], const LocalOrdinal numElts)
Implementation detail of replaceGlobalValues.
values_dualv_type::t_host getValuesViewHostNonConst(const RowInfo &rowinfo)
Get a non-const Host view of the locally owned values row myRow, such that rowinfo = getRowInfo(myRow...
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Resume operations that may change the values or structure of the matrix.
void getLocalDiagOffsets(Teuchos::ArrayRCP< size_t > &offsets) const
Get offsets of the diagonal entries in the matrix.
void fillLocalMatrix(const Teuchos::RCP< Teuchos::ParameterList > &params)
Fill data into the local matrix.
void rightScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the right with the given Vector.
Teuchos::RCP< CrsMatrixType > exportAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &rowExporter, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &domainExporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Nonmember CrsMatrix constructor that fuses Export and fillComplete().
bool isStorageOptimized() const
Returns true if storage has been optimized.
void getLocalRowCopy(LocalOrdinal LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const override
Fill given arrays with a deep copy of the locally owned entries of the matrix in a given row,...
Teuchos::RCP< CrsMatrixType > exportAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &exporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Export and fillComplete().
values_dualv_type::t_dev::const_type getValuesViewDevice(const RowInfo &rowinfo) const
Get a const Device view of the locally owned values row myRow, such that rowinfo = getRowInfo(myRow).
void setAllValues(const local_matrix_device_type &localMatrix)
Set the local matrix using an existing local matrix.
CrsMatrix(const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const size_t maxNumEntPerRow, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructor specifying column Map and fixed number of entries for each row.
void leftScale(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &x) override
Scale the matrix on the left with the given Vector.
CrsMatrix & operator=(CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &&)=default
Move assignment.
LocalOrdinal sumIntoLocalValues(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &cols, const Teuchos::ArrayView< const Scalar > &vals, const bool atomic=useAtomicUpdatesByDefault)
Sum into one or more sparse matrix entries, using local row and column indices.
void exportAndFillComplete(Teuchos::RCP< CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &destMatrix, const export_type &rowExporter, const export_type &domainExporter, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params) const
Export from this to the given destination matrix, and make the result fill complete.
virtual bool supportsRowViews() const override
Return true if getLocalRowView() and getGlobalRowView() are valid for this object.
local_inds_device_view_type getLocalIndicesDevice() const
Get a device_view of the CRS packed column indicies.
Teuchos::RCP< const crs_graph_type > getCrsGraph() const
This matrix's graph, as a CrsGraph.
virtual LocalOrdinal getBlockSize() const override
The number of degrees of freedom per mesh point.
void getLocalDiagCopy(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &diag, const Kokkos::View< const size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Variant of getLocalDiagCopy() that uses precomputed offsets.
A class can inherit from this if it wants to use Tpetra managed spaces.
A wrapper around Kokkos::DualView to safely manage data that might be replicated between host and dev...
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)
Pack data and metadata for communication (sends).
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)
Perform any unpacking and combining after communication.
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 parallel distribution of indices over processes.
One or more distributed dense vectors.
Abstract interface for operators (e.g., matrices and preconditioners).
A read-only, row-oriented interface to a sparse matrix.
typename KokkosKernels::ArithTraits< SC >::val_type impl_scalar_type
Abstract base class for objects that can be the source of an Import or Export operation.
A distributed dense vector.
Implementation details of Tpetra.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
void residual(const Operator< SC, LO, GO, NO > &A, const MultiVector< SC, LO, GO, NO > &X, const MultiVector< SC, LO, GO, NO > &B, MultiVector< SC, LO, GO, NO > &R)
Computes R = B - A * X.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Teuchos::RCP< CrsMatrixType > exportAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Export< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &exporter, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Export and fillComplete().
size_t global_size_t
Global size_t object.
Teuchos::RCP< CrsMatrixType > importAndFillCompleteCrsMatrix(const Teuchos::RCP< const CrsMatrixType > &sourceMatrix, const Import< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > &importer, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsMatrixType::local_ordinal_type, typename CrsMatrixType::global_ordinal_type, typename CrsMatrixType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Nonmember CrsMatrix constructor that fuses Import and fillComplete().
CombineMode
Rule for combining data in an Import or Export.
@ ADD
Sum new values.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.