Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_CrsGraph_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_CRSGRAPH_DECL_HPP
11#define TPETRA_CRSGRAPH_DECL_HPP
12
15
19#include "Tpetra_DistObject.hpp"
20#include "Tpetra_Exceptions.hpp"
21#include "Tpetra_RowGraph.hpp"
22#include "Tpetra_Util.hpp" // need this here for sort2
23#include "Tpetra_Details_WrappedDualView.hpp"
24#include "Tpetra_Details_makeColMap.hpp"
25
26#include "KokkosSparse_findRelOffset.hpp"
27#include "Kokkos_DualView.hpp"
28
29#include "Teuchos_CommHelpers.hpp"
30#include "Teuchos_Describable.hpp"
31#include "Teuchos_OrdinalTraits.hpp"
32#include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
33
34#include "KokkosSparse_StaticCrsGraph.hpp"
35
36#include <functional> // std::function
37#include <memory>
38
39namespace Tpetra {
40
41// Forward declaration for CrsGraph::swap() test
42template <class LocalOrdinal, class GlobalOrdinal, class Node>
43class crsGraph_Swap_Tester;
44
45#ifndef DOXYGEN_SHOULD_SKIP_THIS
46namespace Details {
47template <class LocalOrdinal,
48 class GlobalOrdinal>
49class CrsPadding;
50} // namespace Details
51
52namespace { // (anonymous)
53
54template <class ViewType>
55struct UnmanagedView {
56 static_assert(Kokkos::is_view<ViewType>::value,
57 "ViewType must be a Kokkos::View specialization.");
58 // FIXME (mfh 02 Dec 2015) Right now, this strips away other
59 // memory traits. Christian will add an "AllTraits" enum which is
60 // the enum value of MemoryTraits<T>, that will help us fix this.
61 typedef Kokkos::View<typename ViewType::data_type,
62 typename ViewType::array_layout,
63 typename ViewType::device_type,
64 Kokkos::MemoryUnmanaged>
65 type;
66};
67
68} // namespace
69#endif // DOXYGEN_SHOULD_SKIP_THIS
70
79struct RowInfo {
80 size_t localRow;
81 size_t allocSize;
82 size_t numEntries;
83 size_t offset1D;
84};
85
86enum ELocalGlobal {
87 LocalIndices,
88 GlobalIndices
89};
90
91namespace Details {
123 STORAGE_1D_UNPACKED, //<! 1-D "unpacked" storage
124 STORAGE_1D_PACKED, //<! 1-D "packed" storage
125 STORAGE_UB //<! Invalid value; upper bound on enum values
126};
127
128} // namespace Details
129
188template <class LocalOrdinal,
189 class GlobalOrdinal,
190 class Node>
191class CrsGraph : public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
192 public DistObject<GlobalOrdinal,
193 LocalOrdinal,
194 GlobalOrdinal,
195 Node>,
196 public Teuchos::ParameterListAcceptorDefaultBase {
197 template <class S, class LO, class GO, class N>
198 friend class CrsMatrix;
199 template <class LO2, class GO2, class N2>
200 friend class CrsGraph;
201 template <class LO, class GO, class N>
202 friend class FECrsGraph;
203
206
207 public:
213 using device_type = typename Node::device_type;
215 using execution_space = typename device_type::execution_space;
216
221 using node_type = Node;
222
225 KokkosSparse::StaticCrsGraph<local_ordinal_type, Kokkos::LayoutLeft,
226 device_type, void, size_t>;
227
229 using local_graph_host_type = typename local_graph_device_type::host_mirror_type;
230
237
238 public:
239 // Types used for CrsGraph's storage of local column indices
240 using local_inds_dualv_type =
241 Kokkos::DualView<local_ordinal_type*, device_type>;
242 using local_inds_wdv_type =
244
245 // Types used for CrsGraph's storage of global column indices
246 using global_inds_dualv_type =
247 Kokkos::DualView<global_ordinal_type*, device_type>;
250
251 public:
253 using row_ptrs_device_view_type =
254 typename row_graph_type::row_ptrs_device_view_type;
255 using row_ptrs_host_view_type =
256 typename row_graph_type::row_ptrs_host_view_type;
257
260 typename row_graph_type::local_inds_device_view_type;
261 using local_inds_host_view_type =
262 typename row_graph_type::local_inds_host_view_type;
263 using nonconst_local_inds_host_view_type =
264 typename row_graph_type::nonconst_local_inds_host_view_type;
265
268 typename row_graph_type::global_inds_device_view_type;
269 using global_inds_host_view_type =
270 typename row_graph_type::global_inds_host_view_type;
271 using nonconst_global_inds_host_view_type =
272 typename row_graph_type::nonconst_global_inds_host_view_type;
273
274 using offset_device_view_type =
275 typename row_ptrs_device_view_type::non_const_type;
276
278
279
292 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
293 const size_t maxNumEntriesPerRow,
294 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
295
308 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
309 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
310 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
311
325 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
326 const Teuchos::ArrayView<const size_t>& numEntPerRow,
327 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
328
341
345 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
346 const Teuchos::RCP<const map_type>& colMap,
347 const size_t maxNumEntriesPerRow,
348 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
349
364 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
365 const Teuchos::RCP<const map_type>& colMap,
366 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
367 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
368
384 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
385 const Teuchos::RCP<const map_type>& colMap,
386 const Teuchos::ArrayView<const size_t>& numEntPerRow,
387 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
388
402 const Teuchos::RCP<const map_type>& rowMap,
403 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
404
427 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
428 const Teuchos::RCP<const map_type>& colMap,
429 const typename local_graph_device_type::row_map_type& rowPointers,
430 const typename local_graph_device_type::entries_type::non_const_type& columnIndices,
431 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
432
455 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
456 const Teuchos::RCP<const map_type>& colMap,
457 const Teuchos::ArrayRCP<size_t>& rowPointers,
458 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices,
459 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
460
482 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
483 const Teuchos::RCP<const map_type>& colMap,
485 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
486
514 const Teuchos::RCP<const map_type>& rowMap,
515 const Teuchos::RCP<const map_type>& colMap,
516 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
517 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
518 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
519
532 const Teuchos::RCP<const map_type>& rowMap,
533 const Teuchos::RCP<const map_type>& colMap,
534 const Teuchos::RCP<const map_type>& domainMap,
535 const Teuchos::RCP<const map_type>& rangeMap,
536 const Teuchos::RCP<const import_type>& importer,
537 const Teuchos::RCP<const export_type>& exporter,
538 const Teuchos::RCP<Teuchos::ParameterList>& params =
539 Teuchos::null);
540
582 CrsGraph(const row_ptrs_device_view_type& rowPointers,
584 const Teuchos::RCP<const map_type>& rowMap,
585 const Teuchos::RCP<const map_type>& colMap,
586 const Teuchos::RCP<const map_type>& domainMap,
587 const Teuchos::RCP<const map_type>& rangeMap,
588 const Teuchos::RCP<const import_type>& importer,
589 const Teuchos::RCP<const export_type>& exporter,
590 const Teuchos::RCP<Teuchos::ParameterList>& params =
591 Teuchos::null);
592
595
598
601
604
614 virtual ~CrsGraph() = default;
615
643
661
663
665
667 void
668 setParameterList(const Teuchos::RCP<Teuchos::ParameterList>& params) override;
669
671 Teuchos::RCP<const Teuchos::ParameterList>
672 getValidParameters() const override;
673
675
677
699 void
701 const Teuchos::ArrayView<const global_ordinal_type>& indices);
702
709 void
712 const global_ordinal_type inds[]);
713
715
729 void
731 const Teuchos::ArrayView<const local_ordinal_type>& indices);
732
739 void
742 const local_ordinal_type inds[]);
743
745
755
757
759
767 void globalAssemble();
768
787 void
788 resumeFill(const Teuchos::RCP<Teuchos::ParameterList>& params =
789 Teuchos::null);
790
828 void
829 fillComplete(const Teuchos::RCP<const map_type>& domainMap,
830 const Teuchos::RCP<const map_type>& rangeMap,
831 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
832
860 void
861 fillComplete(const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
862
891 void
892 expertStaticFillComplete(const Teuchos::RCP<const map_type>& domainMap,
893 const Teuchos::RCP<const map_type>& rangeMap,
894 const Teuchos::RCP<const import_type>& importer =
895 Teuchos::null,
896 const Teuchos::RCP<const export_type>& exporter =
897 Teuchos::null,
898 const Teuchos::RCP<Teuchos::ParameterList>& params =
899 Teuchos::null);
901
903
905 Teuchos::RCP<const Teuchos::Comm<int>> getComm() const override;
906
908 Teuchos::RCP<const map_type> getRowMap() const override;
909
911 Teuchos::RCP<const map_type> getColMap() const override;
912
914 Teuchos::RCP<const map_type> getDomainMap() const override;
915
917 Teuchos::RCP<const map_type> getRangeMap() const override;
918
920 Teuchos::RCP<const import_type> getImporter() const override;
921
923 Teuchos::RCP<const export_type> getExporter() const override;
924
926
928 global_size_t getGlobalNumRows() const override;
929
931
934 global_size_t getGlobalNumCols() const override;
935
937 size_t getLocalNumRows() const override;
938
940
942 size_t getLocalNumCols() const override;
943
945 global_ordinal_type getIndexBase() const override;
946
948
950 global_size_t getGlobalNumEntries() const override;
951
961 size_t getLocalNumEntries() const override;
962
964
965 size_t
967
974 size_t
975 getNumEntriesInLocalRow(local_ordinal_type localRow) const override;
976
996 size_t getLocalAllocationSize() const;
997
1006
1015
1029 size_t getGlobalMaxNumRowEntries() const override;
1030
1035 size_t getLocalMaxNumRowEntries() const override;
1036
1052 bool hasColMap() const override;
1053
1061 bool isLocallyIndexed() const override;
1062
1070 bool isGloballyIndexed() const override;
1071
1073 bool isFillComplete() const override;
1074
1076 bool isFillActive() const;
1077
1085 bool isSorted() const;
1086
1088
1094 bool isStorageOptimized() const;
1095
1101 void
1103 nonconst_global_inds_host_view_type& gblColInds,
1104 size_t& numColInds) const override;
1105
1113 void
1115 nonconst_local_inds_host_view_type& lclColInds,
1116 size_t& numColInds) const override;
1117
1128 void
1131 global_inds_host_view_type& gblColInds) const override;
1132
1135 bool supportsRowViews() const override;
1136
1147 void
1149 const LocalOrdinal lclRow,
1150 local_inds_host_view_type& lclColInds) const override;
1151
1153
1155
1157 std::string description() const override;
1158
1161 void
1162 describe(Teuchos::FancyOStream& out,
1163 const Teuchos::EVerbosityLevel verbLevel =
1164 Teuchos::Describable::verbLevel_default) const override;
1165
1167
1169
1177
1178 virtual bool
1179 checkSizes(const SrcDistObject& source) override;
1180
1181 using dist_object_type::
1184
1185 virtual void
1187 const size_t numSameIDs,
1188 const Kokkos::DualView<const local_ordinal_type*,
1190 const Kokkos::DualView<const local_ordinal_type*,
1192 const CombineMode CM) override;
1193
1194 void copyAndPermuteNew(
1195 const row_graph_type& source,
1197 const size_t numSameIDs,
1198 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1199 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
1200 const CombineMode CM);
1201
1202 void insertGlobalIndicesDevice(
1205 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1206 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
1208
1211
1212 void
1213 applyCrsPadding(const padding_type& padding,
1214 const bool verbose);
1215
1216 std::unique_ptr<padding_type>
1217 computeCrsPadding(
1219 node_type>& source,
1220 const size_t numSameIDs,
1221 const Kokkos::DualView<const local_ordinal_type*,
1223 const Kokkos::DualView<const local_ordinal_type*,
1225 const bool verbose) const;
1226
1227 // This actually modifies imports by sorting it.
1228 std::unique_ptr<padding_type>
1229 computeCrsPaddingForImports(
1230 const Kokkos::DualView<const local_ordinal_type*,
1232 Kokkos::DualView<packet_type*, buffer_device_type> imports,
1233 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1234 const bool verbose) const;
1235
1236 std::unique_ptr<padding_type>
1237 computePaddingForCrsMatrixUnpack(
1238 const Kokkos::DualView<const local_ordinal_type*,
1240 Kokkos::DualView<char*, buffer_device_type> imports,
1241 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1242 const bool verbose) const;
1243
1244 void
1245 computeCrsPaddingForSameIDs(
1248 node_type>& source,
1249 const local_ordinal_type numSameIDs) const;
1250
1251 void
1252 computeCrsPaddingForPermutedIDs(
1255 node_type>& source,
1256 const Kokkos::DualView<const local_ordinal_type*,
1258 const Kokkos::DualView<const local_ordinal_type*,
1260
1261 virtual void
1262 packAndPrepare(
1263 const SrcDistObject& source,
1264 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
1265 Kokkos::DualView<packet_type*, buffer_device_type>& exports,
1266 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1267 size_t& constantNumPackets) override;
1268
1273
1274 virtual void
1275 pack(const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1276 Teuchos::Array<global_ordinal_type>& exports,
1277 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1278 size_t& constantNumPackets) const override;
1279
1280 void
1281 packFillActive(const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1282 Teuchos::Array<global_ordinal_type>& exports,
1283 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1284 size_t& constantNumPackets) const;
1285
1286 void
1287 packFillActiveNew(const Kokkos::DualView<const local_ordinal_type*,
1289 Kokkos::DualView<packet_type*,
1290 buffer_device_type>& exports,
1291 Kokkos::DualView<size_t*,
1294 size_t& constantNumPackets) const;
1295
1300
1301 virtual void
1302 unpackAndCombine(const Kokkos::DualView<const local_ordinal_type*,
1304 Kokkos::DualView<packet_type*,
1306 imports,
1307 Kokkos::DualView<size_t*,
1310 const size_t constantNumPackets,
1311 const CombineMode combineMode) override;
1312
1314
1316
1359 void
1360 getLocalDiagOffsets(const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets) const;
1361
1363 void
1364 getLocalOffRankOffsets(offset_device_view_type& offsets) const;
1365
1375 void
1376 getLocalDiagOffsets(Teuchos::ArrayRCP<size_t>& offsets) const;
1377
1387 void
1388 setAllIndices(const typename local_graph_device_type::row_map_type& rowPointers,
1389 const typename local_graph_device_type::entries_type::non_const_type& columnIndices);
1390
1400 void
1401 setAllIndices(const Teuchos::ArrayRCP<size_t>& rowPointers,
1402 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices);
1403
1406 row_ptrs_host_view_type getLocalRowPtrsHost() const;
1407
1410 row_ptrs_device_view_type getLocalRowPtrsDevice() const;
1411
1413 local_inds_host_view_type getLocalIndicesHost() const;
1414
1417
1436 void replaceColMap(const Teuchos::RCP<const map_type>& newColMap);
1437
1457 void
1458 reindexColumns(const Teuchos::RCP<const map_type>& newColMap,
1459 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1460 const bool sortIndicesInEachRow = true);
1461
1468 void
1469 replaceDomainMap(const Teuchos::RCP<const map_type>& newDomainMap);
1470
1484 void
1485 replaceDomainMapAndImporter(const Teuchos::RCP<const map_type>& newDomainMap,
1486 const Teuchos::RCP<const import_type>& newImporter);
1487
1494 void
1495 replaceRangeMap(const Teuchos::RCP<const map_type>& newRangeMap);
1496
1510 void
1511 replaceRangeMapAndExporter(const Teuchos::RCP<const map_type>& newRangeMap,
1512 const Teuchos::RCP<const export_type>& newExporter);
1513
1542 virtual void
1543 removeEmptyProcessesInPlace(const Teuchos::RCP<const map_type>& newMap) override;
1545
1546 template <class DestViewType, class SrcViewType,
1548 struct pack_functor {
1549 typedef typename DestViewType::execution_space execution_space;
1550 SrcViewType src;
1551 DestViewType dest;
1552 SrcOffsetViewType src_offset;
1553 DestOffsetViewType dest_offset;
1554 typedef typename DestOffsetViewType::non_const_value_type ScalarIndx;
1555
1556 pack_functor(DestViewType dest_,
1557 const SrcViewType src_,
1559 const SrcOffsetViewType src_offset_)
1560 : src(src_)
1561 , dest(dest_)
1562 , src_offset(src_offset_)
1563 , dest_offset(dest_offset_){};
1564
1566 void operator()(size_t row) const {
1567 ScalarIndx i = src_offset(row);
1568 ScalarIndx j = dest_offset(row);
1569 const ScalarIndx k = dest_offset(row + 1);
1570 for (; j < k; j++, i++) {
1571 dest(j) = src(i);
1572 }
1573 }
1574 };
1575
1576 private:
1577 // Friend declaration for nonmember function.
1578 template <class CrsGraphType>
1579 friend Teuchos::RCP<CrsGraphType>
1580 importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1581 const Import<typename CrsGraphType::local_ordinal_type,
1582 typename CrsGraphType::global_ordinal_type,
1583 typename CrsGraphType::node_type>& importer,
1584 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1585 typename CrsGraphType::global_ordinal_type,
1586 typename CrsGraphType::node_type>>& domainMap,
1587 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1588 typename CrsGraphType::global_ordinal_type,
1589 typename CrsGraphType::node_type>>& rangeMap,
1590 const Teuchos::RCP<Teuchos::ParameterList>& params);
1591
1592 // Friend declaration for nonmember function.
1593 template <class CrsGraphType>
1594 friend Teuchos::RCP<CrsGraphType>
1595 importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1596 const Import<typename CrsGraphType::local_ordinal_type,
1597 typename CrsGraphType::global_ordinal_type,
1598 typename CrsGraphType::node_type>& rowImporter,
1599 const Import<typename CrsGraphType::local_ordinal_type,
1600 typename CrsGraphType::global_ordinal_type,
1601 typename CrsGraphType::node_type>& domainImporter,
1602 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1603 typename CrsGraphType::global_ordinal_type,
1604 typename CrsGraphType::node_type>>& domainMap,
1605 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1606 typename CrsGraphType::global_ordinal_type,
1607 typename CrsGraphType::node_type>>& rangeMap,
1608 const Teuchos::RCP<Teuchos::ParameterList>& params);
1609
1610 // Friend declaration for nonmember function.
1611 template <class CrsGraphType>
1612 friend Teuchos::RCP<CrsGraphType>
1613 exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1614 const Export<typename CrsGraphType::local_ordinal_type,
1615 typename CrsGraphType::global_ordinal_type,
1616 typename CrsGraphType::node_type>& exporter,
1617 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1618 typename CrsGraphType::global_ordinal_type,
1619 typename CrsGraphType::node_type>>& domainMap,
1620 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1621 typename CrsGraphType::global_ordinal_type,
1622 typename CrsGraphType::node_type>>& rangeMap,
1623 const Teuchos::RCP<Teuchos::ParameterList>& params);
1624
1625 // Friend declaration for nonmember function.
1626 template <class CrsGraphType>
1627 friend Teuchos::RCP<CrsGraphType>
1628 exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1629 const Export<typename CrsGraphType::local_ordinal_type,
1630 typename CrsGraphType::global_ordinal_type,
1631 typename CrsGraphType::node_type>& rowExporter,
1632 const Export<typename CrsGraphType::local_ordinal_type,
1633 typename CrsGraphType::global_ordinal_type,
1634 typename CrsGraphType::node_type>& domainExporter,
1635 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1636 typename CrsGraphType::global_ordinal_type,
1637 typename CrsGraphType::node_type>>& domainMap,
1638 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1639 typename CrsGraphType::global_ordinal_type,
1640 typename CrsGraphType::node_type>>& rangeMap,
1641 const Teuchos::RCP<Teuchos::ParameterList>& params);
1642
1643 // Friend declaration for nonmember function.
1644 template <class LO, class GO, class NT>
1645 friend int
1646 Details::makeColMap(Teuchos::RCP<const Tpetra::Map<LO, GO, NT>>& colMap,
1647 Teuchos::Array<int>& remotePIDs,
1648 const Teuchos::RCP<const Tpetra::Map<LO, GO, NT>>& domMap,
1649 const CrsGraph<LO, GO, NT>& graph,
1650 const bool sortEachProcsGids,
1651 std::ostream* errStrm);
1652
1653 public:
1669 void
1670 importAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1671 const import_type& importer,
1672 const Teuchos::RCP<const map_type>& domainMap,
1673 const Teuchos::RCP<const map_type>& rangeMap,
1674 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1675
1691 void
1692 importAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1693 const import_type& rowImporter,
1694 const import_type& domainImporter,
1695 const Teuchos::RCP<const map_type>& domainMap,
1696 const Teuchos::RCP<const map_type>& rangeMap,
1697 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1698
1714 void
1715 exportAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1716 const export_type& exporter,
1717 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1718 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1719 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1720
1736 void
1737 exportAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1738 const export_type& rowExporter,
1739 const export_type& domainExporter,
1740 const Teuchos::RCP<const map_type>& domainMap,
1741 const Teuchos::RCP<const map_type>& rangeMap,
1742 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1743
1744 private:
1765 void
1766 transferAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1767 const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>& rowTransfer,
1768 const Teuchos::RCP<const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>>& domainTransfer,
1769 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1770 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1771 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1772
1773 protected:
1774 // these structs are conveniences, to cut down on the number of
1775 // arguments to some of the methods below.
1776 struct SLocalGlobalViews {
1777 Teuchos::ArrayView<const global_ordinal_type> ginds;
1778 Teuchos::ArrayView<const local_ordinal_type> linds;
1779 };
1780 struct SLocalGlobalNCViews {
1781 Teuchos::ArrayView<global_ordinal_type> ginds;
1782 Teuchos::ArrayView<local_ordinal_type> linds;
1783 };
1784
1785 bool indicesAreAllocated() const;
1786
1787 void
1788 allocateIndices(const ELocalGlobal lg, const bool verbose = false);
1789
1791
1792
1802 void makeColMap(Teuchos::Array<int>& remotePIDs);
1803
1824 std::pair<size_t, std::string>
1825 makeIndicesLocal(const bool verbose = false);
1826
1835 void
1836 makeImportExport(Teuchos::Array<int>& remotePIDs,
1837 const bool useRemotePIDs);
1838
1840
1842
1877 size_t
1878 insertIndices(RowInfo& rowInfo,
1879 const SLocalGlobalViews& newInds,
1880 const ELocalGlobal lg,
1881 const ELocalGlobal I);
1882
1891 size_t
1893 const global_ordinal_type inputGblColInds[],
1894 const size_t numInputInds);
1895
1906 size_t
1907 insertGlobalIndicesImpl(const RowInfo& rowInfo,
1908 const global_ordinal_type inputGblColInds[],
1909 const size_t numInputInds,
1910 std::function<void(const size_t, const size_t, const size_t)> fun =
1911 std::function<void(const size_t, const size_t, const size_t)>());
1912
1913 void
1914 insertLocalIndicesImpl(const local_ordinal_type lclRow,
1915 const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
1916 std::function<void(const size_t, const size_t, const size_t)> fun =
1917 std::function<void(const size_t, const size_t, const size_t)>());
1918
1934 size_t
1935 findGlobalIndices(const RowInfo& rowInfo,
1936 const Teuchos::ArrayView<const global_ordinal_type>& indices,
1937 std::function<void(const size_t, const size_t, const size_t)> fun) const;
1938
1950 void
1952 const global_ordinal_type gblColInds[],
1953 const local_ordinal_type numGblColInds);
1954
1966 void
1968 const global_ordinal_type gblColInds[],
1969 const local_ordinal_type numGblColInds);
1970
1975 static const bool useAtomicUpdatesByDefault =
1976#ifdef KOKKOS_ENABLE_SERIAL
1977 !std::is_same<execution_space, Kokkos::Serial>::value;
1978#else
1979 true;
1980#endif // KOKKOS_ENABLE_SERIAL
1981
1983
1985
1987 bool isMerged() const;
1988
1994 void setLocallyModified();
1995
1996 private:
2001 void
2002 sortAndMergeAllIndices(const bool sorted, const bool merged);
2003
2004 // mfh 08 May 2017: I only restore "protected" here for backwards
2005 // compatibility.
2006 protected:
2008
2018 void
2019 setDomainRangeMaps(const Teuchos::RCP<const map_type>& domainMap,
2020 const Teuchos::RCP<const map_type>& rangeMap);
2021
2022 void staticAssertions() const;
2023 void clearGlobalConstants();
2024
2025 public:
2028
2047
2048 bool haveLocalOffRankOffsets() const { return haveLocalOffRankOffsets_; }
2049
2050 protected:
2070 void computeLocalConstants();
2071
2074 RowInfo getRowInfo(const local_ordinal_type myRow) const;
2075
2088 RowInfo getRowInfoFromGlobalRowIndex(const global_ordinal_type gblRow) const;
2089
2090 public:
2099 local_graph_host_type getLocalGraphHost() const;
2100
2101 protected:
2102 void fillLocalGraph(const Teuchos::RCP<Teuchos::ParameterList>& params);
2103
2105 void checkInternalState() const;
2106
2110 void swap(CrsGraph<local_ordinal_type, global_ordinal_type, Node>& graph);
2111
2112 // Friend the tester for CrsGraph::swap
2113 friend class Tpetra::crsGraph_Swap_Tester<local_ordinal_type, global_ordinal_type, Node>;
2114
2116 Teuchos::RCP<const map_type> rowMap_;
2118 Teuchos::RCP<const map_type> colMap_;
2120 Teuchos::RCP<const map_type> rangeMap_;
2122 Teuchos::RCP<const map_type> domainMap_;
2123
2130 Teuchos::RCP<const import_type> importer_;
2131
2137 Teuchos::RCP<const export_type> exporter_;
2138
2144 Teuchos::OrdinalTraits<size_t>::invalid();
2145
2150 Teuchos::OrdinalTraits<global_size_t>::invalid();
2151
2157 Teuchos::OrdinalTraits<global_size_t>::invalid();
2158
2159 private:
2160 // Replacement for device view k_rowPtrs_
2161 // Device view rowPtrsUnpacked_dev_ takes place of k_rowPtrs_
2162 // Host view rowPtrsUnpacked_host_ takes place of copies and use of getEntryOnHost
2163 // Wish this could be a WrappedDualView, but deep_copies in DualView
2164 // don't work with const data views (e.g., StaticCrsGraph::row_map)
2165 // k_rowPtrs_ is offsets wrt the ALLOCATED indices array, not necessarily
2166 // the ACTUAL compressed indices array.
2167 // When !OptimizedStorage, k_rowPtrs_ may differ from ACTUAL compressed
2168 // indices array. (Karen is skeptical that !OptimizedStorage works)
2169 // When OptimizedStorage, rowPtrsUnpacked_ = k_rowPtrsPacked_
2170
2171 row_ptrs_device_view_type rowPtrsUnpacked_dev_;
2172 mutable row_ptrs_host_view_type rowPtrsUnpacked_host_;
2173
2174 // Row offsets into the actual graph local indices
2175 // Device view rowPtrsUnpacked_dev_ takes place of lclGraph_.row_map
2176
2177 row_ptrs_device_view_type rowPtrsPacked_dev_;
2178 mutable row_ptrs_host_view_type rowPtrsPacked_host_;
2179
2181 bool packedUnpackedRowPtrsMatch_ = false;
2182
2183 protected:
2184 void setRowPtrsUnpacked(const row_ptrs_device_view_type& dview) {
2185 packedUnpackedRowPtrsMatch_ = false;
2186 rowPtrsUnpacked_dev_ = dview;
2187 // Make sure stale host rowptrs are not kept
2188 rowPtrsUnpacked_host_ = row_ptrs_host_view_type();
2189 }
2190
2192 const row_ptrs_device_view_type& getRowPtrsUnpackedDevice() const {
2193 return rowPtrsUnpacked_dev_;
2194 }
2195
2197 const row_ptrs_host_view_type& getRowPtrsUnpackedHost() const {
2198 if (rowPtrsUnpacked_host_.extent(0) != rowPtrsUnpacked_dev_.extent(0)) {
2199 // NOTE: not just using create_mirror_view here, because
2200 // we do want host/device to be in different memory, even if we're using a SharedSpace.
2201 // This is so that reads will never trigger a host-device transfer.
2202 // The exception is when 'device' views are HostSpace, then don't make another copy.
2203 if constexpr (std::is_same_v<typename Node::memory_space, Kokkos::HostSpace>) {
2204 rowPtrsUnpacked_host_ = rowPtrsUnpacked_dev_;
2205 } else {
2206 // Have to make this temporary because rowptrs are const-valued
2207 typename row_ptrs_host_view_type::non_const_type rowPtrsTemp(
2208 Kokkos::view_alloc(Kokkos::WithoutInitializing, "rowPtrsUnpacked_host_"), rowPtrsUnpacked_dev_.extent(0));
2209 Kokkos::deep_copy(rowPtrsTemp, rowPtrsUnpacked_dev_);
2210 rowPtrsUnpacked_host_ = rowPtrsTemp;
2211 }
2212 // Also keep packed/unpacked views in sync, if they are known to have the same contents
2213 if (packedUnpackedRowPtrsMatch_) {
2214 rowPtrsPacked_host_ = rowPtrsUnpacked_host_;
2215 }
2216 }
2217 return rowPtrsUnpacked_host_;
2218 }
2219
2220 void setRowPtrsPacked(const row_ptrs_device_view_type& dview) {
2221 packedUnpackedRowPtrsMatch_ = false;
2222 rowPtrsPacked_dev_ = dview;
2223 // Make sure stale host rowptrs are not kept
2224 rowPtrsPacked_host_ = row_ptrs_host_view_type();
2225 }
2226
2228 const row_ptrs_device_view_type& getRowPtrsPackedDevice() const {
2229 return rowPtrsPacked_dev_;
2230 }
2231
2233 const row_ptrs_host_view_type& getRowPtrsPackedHost() const {
2234 if (rowPtrsPacked_host_.extent(0) != rowPtrsPacked_dev_.extent(0)) {
2235 // NOTE: not just using create_mirror_view here, because
2236 // we do want host/device to be in different memory, even if we're using a SharedSpace.
2237 // This is so that reads will never trigger a host-device transfer.
2238 // The exception is when 'device' views are HostSpace, then don't make another copy.
2239 if constexpr (std::is_same_v<typename Node::memory_space, Kokkos::HostSpace>) {
2240 rowPtrsPacked_host_ = rowPtrsPacked_dev_;
2241 } else {
2242 // Have to make this temporary because rowptrs are const-valued
2243 typename row_ptrs_host_view_type::non_const_type rowPtrsTemp(
2244 Kokkos::view_alloc(Kokkos::WithoutInitializing, "rowPtrsPacked_host_"), rowPtrsPacked_dev_.extent(0));
2245 Kokkos::deep_copy(rowPtrsTemp, rowPtrsPacked_dev_);
2246 rowPtrsPacked_host_ = rowPtrsTemp;
2247 }
2248 // Also keep packed/unpacked views in sync, if they are known to have the same contents
2249 if (packedUnpackedRowPtrsMatch_) {
2250 rowPtrsUnpacked_host_ = rowPtrsPacked_host_;
2251 }
2252 }
2253 return rowPtrsPacked_host_;
2254 }
2255
2256 // There are common cases where both packed and unpacked views are set to the same array.
2257 // Doing this in a single call can reduce dataspace on host, and reduce runtime by
2258 // removing a deep_copy from device to host.
2259
2260 void setRowPtrs(const row_ptrs_device_view_type& dview) {
2261 packedUnpackedRowPtrsMatch_ = true;
2262 rowPtrsUnpacked_dev_ = dview;
2263 rowPtrsPacked_dev_ = dview;
2264 // Make sure stale host rowptrs are not kept
2265 rowPtrsUnpacked_host_ = row_ptrs_host_view_type();
2266 rowPtrsPacked_host_ = row_ptrs_host_view_type();
2267 }
2268
2269 // TODO: Make private -- matrix shouldn't access directly the guts of graph
2270
2285
2300
2301 // TODO: Make private -- matrix shouldn't access directly the guts of graph
2302
2312
2313 // TODO: Make private -- matrix shouldn't access directly
2315
2319 typename local_inds_dualv_type::t_host::const_type
2320 getLocalIndsViewHost(const RowInfo& rowinfo) const;
2321
2325 typename local_inds_dualv_type::t_dev::const_type
2327
2331 typename global_inds_dualv_type::t_host::const_type
2333
2337 typename global_inds_dualv_type::t_dev::const_type
2339
2343 typename local_inds_dualv_type::t_host
2345
2346 // FOR NOW...
2347 // KEEP k_numRowEntries_ (though switch from host_mirror_type to Host)
2348 // KEEP k_numAllocPerRow_ (though perhaps switch from host_mirror_type to Host)
2349
2375 typename Kokkos::View<const size_t*, device_type>::host_mirror_type
2377
2388
2390
2391
2413
2421 typedef typename Kokkos::View<size_t*, Kokkos::LayoutLeft, device_type>::host_mirror_type num_row_entries_type;
2422
2423 // typedef Kokkos::View<
2424 // size_t*,
2425 // Kokkos::LayoutLeft,
2426 // Kokkos::Device<
2427 // typename Kokkos::View<
2428 // size_t*,
2429 // Kokkos::LayoutLeft,
2430 // device_type>::host_mirror_type::execution_space,
2431 // Kokkos::HostSpace> > num_row_entries_type;
2432
2440
2446 mutable offset_device_view_type k_offRankOffsets_;
2447
2449
2460 Details::STORAGE_1D_UNPACKED;
2461
2462 bool indicesAreAllocated_ = false;
2463 bool indicesAreLocal_ = false;
2464 bool indicesAreGlobal_ = false;
2465 bool fillComplete_ = false;
2466
2471 bool noRedundancies_ = true;
2477 mutable bool haveLocalOffRankOffsets_ = false;
2478
2479 typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type>> nonlocals_type;
2480
2482 nonlocals_type nonlocals_;
2483
2499
2500 private:
2502 static bool getDebug();
2503
2506 bool debug_ = getDebug();
2507
2509 static bool getVerbose();
2510
2514 bool verbose_ = getVerbose();
2515
2516 private:
2518 mutable bool need_sync_host_uvm_access = false;
2519
2521 void set_need_sync_host_uvm_access() {
2522 need_sync_host_uvm_access = true;
2523 }
2524
2526 void execute_sync_host_uvm_access() const {
2527 if (need_sync_host_uvm_access) {
2528 Kokkos::fence("CrsGraph::execute_sync_host_uvm_access");
2529 need_sync_host_uvm_access = false;
2530 }
2531 }
2532}; // class CrsGraph
2533
2541template <class LocalOrdinal, class GlobalOrdinal, class Node>
2542Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node>>
2544 const Teuchos::RCP<
2546 size_t maxNumEntriesPerRow = 0,
2547 const Teuchos::RCP<Teuchos::ParameterList>& params =
2548 Teuchos::null) {
2549 using Teuchos::rcp;
2552 params));
2553}
2554
2604template <class CrsGraphType>
2605Teuchos::RCP<CrsGraphType>
2606importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2607 const Import<typename CrsGraphType::local_ordinal_type,
2608 typename CrsGraphType::global_ordinal_type,
2609 typename CrsGraphType::node_type>& importer,
2610 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2611 typename CrsGraphType::global_ordinal_type,
2612 typename CrsGraphType::node_type>>& domainMap = Teuchos::null,
2613 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2614 typename CrsGraphType::global_ordinal_type,
2615 typename CrsGraphType::node_type>>& rangeMap = Teuchos::null,
2616 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
2617 Teuchos::RCP<CrsGraphType> destGraph;
2618 sourceGraph->importAndFillComplete(destGraph, importer, domainMap, rangeMap, params);
2619 return destGraph;
2620}
2621
2672template <class CrsGraphType>
2673Teuchos::RCP<CrsGraphType>
2674importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2675 const Import<typename CrsGraphType::local_ordinal_type,
2676 typename CrsGraphType::global_ordinal_type,
2677 typename CrsGraphType::node_type>& rowImporter,
2678 const Import<typename CrsGraphType::local_ordinal_type,
2679 typename CrsGraphType::global_ordinal_type,
2680 typename CrsGraphType::node_type>& domainImporter,
2681 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2682 typename CrsGraphType::global_ordinal_type,
2683 typename CrsGraphType::node_type>>& domainMap,
2684 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2685 typename CrsGraphType::global_ordinal_type,
2686 typename CrsGraphType::node_type>>& rangeMap,
2687 const Teuchos::RCP<Teuchos::ParameterList>& params) {
2688 Teuchos::RCP<CrsGraphType> destGraph;
2689 sourceGraph->importAndFillComplete(destGraph, rowImporter, domainImporter, domainMap, rangeMap, params);
2690 return destGraph;
2691}
2692
2726template <class CrsGraphType>
2727Teuchos::RCP<CrsGraphType>
2728exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2729 const Export<typename CrsGraphType::local_ordinal_type,
2730 typename CrsGraphType::global_ordinal_type,
2731 typename CrsGraphType::node_type>& exporter,
2732 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2733 typename CrsGraphType::global_ordinal_type,
2734 typename CrsGraphType::node_type>>& domainMap = Teuchos::null,
2735 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2736 typename CrsGraphType::global_ordinal_type,
2737 typename CrsGraphType::node_type>>& rangeMap = Teuchos::null,
2738 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
2739 Teuchos::RCP<CrsGraphType> destGraph;
2740 sourceGraph->exportAndFillComplete(destGraph, exporter, domainMap, rangeMap, params);
2741 return destGraph;
2742}
2743
2777template <class CrsGraphType>
2778Teuchos::RCP<CrsGraphType>
2779exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2780 const Export<typename CrsGraphType::local_ordinal_type,
2781 typename CrsGraphType::global_ordinal_type,
2782 typename CrsGraphType::node_type>& rowExporter,
2783 const Export<typename CrsGraphType::local_ordinal_type,
2784 typename CrsGraphType::global_ordinal_type,
2785 typename CrsGraphType::node_type>& domainExporter,
2786 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2787 typename CrsGraphType::global_ordinal_type,
2788 typename CrsGraphType::node_type>>& domainMap,
2789 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2790 typename CrsGraphType::global_ordinal_type,
2791 typename CrsGraphType::node_type>>& rangeMap,
2792 const Teuchos::RCP<Teuchos::ParameterList>& params) {
2793 Teuchos::RCP<CrsGraphType> destGraph;
2794 sourceGraph->exportAndFillComplete(destGraph, rowExporter, domainExporter, domainMap, rangeMap, params);
2795 return destGraph;
2796}
2797
2798} // namespace Tpetra
2799
2800#endif // TPETRA_CRSGRAPH_DECL_HPP
Forward declaration of Tpetra::BlockCrsMatrix.
Forward declaration of Tpetra::CrsGraph.
Forward declaration of Tpetra::CrsMatrix.
Stand-alone utility functions and macros.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
bool isMerged() const
Whether duplicate column indices in each row have been merged.
virtual void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< packet_type *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, const CombineMode combineMode) override
local_inds_dualv_type::t_dev::const_type getLocalIndsViewDevice(const RowInfo &rowinfo) const
Get a const, locally indexed view of the locally owned row myRow, such that rowinfo = getRowInfo(myRo...
global_size_t globalMaxNumRowEntries_
Global maximum of the number of entries in each row.
void reindexColumns(const Teuchos::RCP< const map_type > &newColMap, const Teuchos::RCP< const import_type > &newImport=Teuchos::null, const bool sortIndicesInEachRow=true)
Reindex the column indices in place, and replace the column Map. Optionally, replace the Import objec...
Kokkos::View< size_t *, Kokkos::LayoutLeft, device_type >::host_mirror_type num_row_entries_type
Row offsets for "1-D" storage.
global_inds_dualv_type::t_host::const_type getGlobalIndsViewHost(const RowInfo &rowinfo) const
Get a const, globally indexed view of the locally owned row myRow, such that rowinfo = getRowInfo(myR...
size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const override
Get the number of entries in the given row (local index).
Teuchos::RCP< CrsGraphType > importAndFillCompleteCrsGraph(const Teuchos::RCP< const CrsGraphType > &sourceGraph, const Import< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > &rowImporter, const Import< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > &domainImporter, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Nonmember CrsGraph constructor that fuses Import and fillComplete().
Teuchos::RCP< const map_type > getColMap() const override
Returns the Map that describes the column distribution in this graph.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Default parameter list suitable for validation.
Details::EStorageStatus storageStatus_
Status of the graph's storage, when not in a fill-complete state.
::Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization used by this class.
global_ordinal_type packet_type
Type of each entry of the DistObject communication buffer.
GlobalOrdinal global_ordinal_type
The type of the graph's global indices.
void insertGlobalIndicesIntoNonownedRows(const global_ordinal_type gblRow, const global_ordinal_type gblColInds[], const local_ordinal_type numGblColInds)
Implementation of insertGlobalIndices for nonowned rows.
Teuchos::RCP< const map_type > rangeMap_
The Map describing the range of the (matrix corresponding to the) graph.
std::pair< size_t, std::string > makeIndicesLocal(const bool verbose=false)
Convert column indices from global to local.
local_inds_device_view_type getLocalIndicesDevice() const
Get a device view of the packed column indicies.
global_size_t getGlobalNumEntries() const override
Returns the global number of entries in the graph.
bool isIdenticalTo(const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > &graph) const
Create a cloned CrsGraph for a different Node type.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
Returns the communicator.
local_inds_wdv_type lclIndsUnpacked_wdv
Local ordinals of column indices for all rows Valid when isLocallyIndexed is true If OptimizedStorage...
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
void globalAssemble()
Communicate nonlocal contributions to other processes.
RowInfo getRowInfoFromGlobalRowIndex(const global_ordinal_type gblRow) const
Get information about the locally owned row with global index gblRow.
void getLocalDiagOffsets(const Kokkos::View< size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Get offsets of the diagonal entries in the graph.
size_t findGlobalIndices(const RowInfo &rowInfo, const Teuchos::ArrayView< const global_ordinal_type > &indices, std::function< void(const size_t, const size_t, const size_t)> fun) const
Finds indices in the given row.
CrsGraph(const CrsGraph< local_ordinal_type, global_ordinal_type, node_type > &)=default
Copy constructor (default).
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 graph that you are done changing its structure.
global_inds_wdv_type gblInds_wdv
Global ordinals of column indices for all rows.
size_t nodeMaxNumRowEntries_
Local maximum of the number of entries in each row.
Teuchos::RCP< const import_type > importer_
The Import from the domain Map to the column Map.
Teuchos::RCP< CrsGraphType > exportAndFillCompleteCrsGraph(const Teuchos::RCP< const CrsGraphType > &sourceGraph, const Export< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > &exporter, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Nonmember CrsGraph constructor that fuses Export and fillComplete().
num_row_entries_type k_numRowEntries_
The number of local entries in each locally owned row.
CrsGraph(CrsGraph< local_ordinal_type, global_ordinal_type, node_type > &&)=default
Move constructor (default).
const row_ptrs_device_view_type & getRowPtrsUnpackedDevice() const
Get the unpacked row pointers on device.
size_t numAllocForAllRows_
The maximum number of entries to allow in each locally owned row.
bool hasColMap() const override
Whether the graph has a column Map.
LocalOrdinal local_ordinal_type
The type of the graph's local indices.
std::string description() const override
Return a one-line human-readable description of this object.
bool isStorageOptimized() const
Returns true if storage has been optimized.
void getGlobalRowCopy(global_ordinal_type gblRow, nonconst_global_inds_host_view_type &gblColInds, size_t &numColInds) const override
Get a copy of the given row, using global indices.
void removeLocalIndices(local_ordinal_type localRow)
Remove all graph indices from the specified local row.
void importAndFillComplete(Teuchos::RCP< CrsGraph< local_ordinal_type, global_ordinal_type, Node > > &destGraph, 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 graph, and make the result fill complete.
global_size_t getGlobalNumRows() const override
Returns the number of global rows in the graph.
Teuchos::RCP< const map_type > getDomainMap() const override
Returns the Map associated with the domain of this graph.
void replaceRangeMapAndExporter(const Teuchos::RCP< const map_type > &newRangeMap, const Teuchos::RCP< const export_type > &newExporter)
Replace the current Range Map and Export with the given parameters.
void computeLocalConstants()
Compute local constants, if they have not yet been computed.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Print this object to the given output stream with the given verbosity level.
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.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &params) override
Set the given list of parameters (must be nonnull).
static const bool useAtomicUpdatesByDefault
Whether transformLocalValues should use atomic updates by default.
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Resume fill operations.
size_t insertIndices(RowInfo &rowInfo, const SLocalGlobalViews &newInds, const ELocalGlobal lg, const ELocalGlobal I)
Insert indices into the given row.
typename Node::device_type device_type
This class' Kokkos device type.
Teuchos::RCP< CrsGraphType > importAndFillCompleteCrsGraph(const Teuchos::RCP< const CrsGraphType > &sourceGraph, const Import< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > &importer, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Nonmember CrsGraph constructor that fuses Import and fillComplete().
void insertGlobalIndicesFiltered(const local_ordinal_type lclRow, const global_ordinal_type gblColInds[], const local_ordinal_type numGblColInds)
Like insertGlobalIndices(), but with column Map filtering.
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
RowInfo getRowInfo(const local_ordinal_type myRow) const
Get information about the locally owned row with local index myRow.
global_inds_dualv_type::t_dev::const_type getGlobalIndsViewDevice(const RowInfo &rowinfo) const
Get a const, globally indexed view of the locally owned row myRow, such that rowinfo = getRowInfo(myR...
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.
Teuchos::RCP< const map_type > colMap_
The Map describing the distribution of columns of the graph.
bool noRedundancies_
Whether the graph's indices are non-redundant (merged) in each row, on this process.
row_ptrs_host_view_type getLocalRowPtrsHost() const
Get a host view of the packed row offsets.
bool isSorted() const
Whether graph indices in all rows are known to be sorted.
Teuchos::RCP< CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > createCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t maxNumEntriesPerRow=0, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Nonmember function to create an empty CrsGraph given a row Map and the max number of entries allowed ...
void setAllIndices(const typename local_graph_device_type::row_map_type &rowPointers, const typename local_graph_device_type::entries_type::non_const_type &columnIndices)
Set the graph's data directly, using 1-D storage.
void insertLocalIndices(const local_ordinal_type localRow, const Teuchos::ArrayView< const local_ordinal_type > &indices)
Insert local indices into the graph.
local_inds_host_view_type getLocalIndicesHost() const
Get a host view of the packed column indicies.
bool supportsRowViews() const override
Whether this class implements getLocalRowView() and getGlobalRowView() (it does).
size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const override
Returns the current number of entries on this node in the specified global row.
bool isFillComplete() const override
Whether fillComplete() has been called and the graph is in compute mode.
void setDomainRangeMaps(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap)
void swap(CrsGraph< local_ordinal_type, global_ordinal_type, Node > &graph)
Swaps the data from *this with the data and maps from graph.
CrsGraph & operator=(const CrsGraph< local_ordinal_type, global_ordinal_type, node_type > &)=default
Assignment operator (default).
void getLocalRowCopy(local_ordinal_type lclRow, nonconst_local_inds_host_view_type &lclColInds, size_t &numColInds) const override
Get a copy of the given row, using local indices.
void getGlobalRowView(const global_ordinal_type gblRow, global_inds_host_view_type &gblColInds) const override
Get a const view of the given global row's global column indices.
const row_ptrs_host_view_type & getRowPtrsUnpackedHost() const
Get the unpacked row pointers on host. Lazily make a copy from device.
void exportAndFillComplete(Teuchos::RCP< CrsGraph< local_ordinal_type, global_ordinal_type, Node > > &destGraph, 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 graph, and make the result fill complete.
void makeColMap(Teuchos::Array< int > &remotePIDs)
Make and set the graph's column Map.
bool haveGlobalConstants_
Whether all processes have computed global constants.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the graph, over all processes in the graph's communicator.
void checkInternalState() const
Throw an exception if the internal state is not consistent.
typename dist_object_type::buffer_device_type buffer_device_type
Kokkos::Device specialization for communication buffers.
Teuchos::RCP< const map_type > getRangeMap() const override
Returns the Map associated with the domain of this graph.
typename row_graph_type::global_inds_device_view_type global_inds_device_view_type
The Kokkos::View type for views of global ordinals on device and host.
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 graph that already has data, via setAllIndices().
bool sortGhostsAssociatedWithEachProcessor_
Whether to require makeColMap() (and therefore fillComplete()) to order column Map GIDs associated wi...
size_t getNumAllocatedEntriesInGlobalRow(global_ordinal_type globalRow) const
Current number of allocated entries in the given row on the calling (MPI) process,...
Teuchos::RCP< const export_type > getExporter() const override
Returns the exporter associated with this graph.
typename device_type::execution_space execution_space
This class' Kokkos execution space.
void makeImportExport(Teuchos::Array< int > &remotePIDs, const bool useRemotePIDs)
Make the Import and Export objects, if needed.
global_ordinal_type getIndexBase() const override
Returns the index base for global indices for this graph.
row_ptrs_device_view_type getLocalRowPtrsDevice() const
Get a device view of the packed row offsets.
local_inds_dualv_type::t_host::const_type getLocalIndsViewHost(const RowInfo &rowinfo) const
Get a const, locally indexed view of the locally owned row myRow, such that rowinfo = getRowInfo(myRo...
bool isFillActive() const
Whether resumeFill() has been called and the graph is in edit mode.
Teuchos::RCP< const map_type > getRowMap() const override
Returns the Map that describes the row distribution in this graph.
global_size_t globalNumEntries_
Global number of entries in the graph.
size_t insertGlobalIndicesImpl(const local_ordinal_type lclRow, const global_ordinal_type inputGblColInds[], const size_t numInputInds)
Insert global indices, using an input local row index.
::Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization used by this class.
size_t getLocalNumEntries() const override
The local number of entries in the graph.
Teuchos::RCP< const import_type > getImporter() const override
Returns the importer associated with this graph.
local_inds_wdv_type lclIndsPacked_wdv
Local ordinals of column indices for all rows Valid when isLocallyIndexed is true Built during fillCo...
Teuchos::RCP< const map_type > domainMap_
The Map describing the domain of the (matrix corresponding to the) graph.
const row_ptrs_host_view_type & getRowPtrsPackedHost() const
Get the packed row pointers on host. Lazily make a copy from device.
size_t getLocalNumCols() const override
Returns the number of columns connected to the locally owned rows of this graph.
nonlocals_type nonlocals_
Nonlocal data given to insertGlobalIndices.
virtual void pack(const Teuchos::ArrayView< const local_ordinal_type > &exportLIDs, Teuchos::Array< global_ordinal_type > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets) const override
void getLocalOffRankOffsets(offset_device_view_type &offsets) const
Get offsets of the off-rank entries in the graph.
global_size_t getGlobalNumCols() const override
Returns the number of global columns in the graph.
typename row_graph_type::local_inds_device_view_type local_inds_device_view_type
The Kokkos::View type for views of local ordinals on device and host.
Kokkos::View< constsize_t *, device_type >::host_mirror_type k_numAllocPerRow_
The maximum number of entries to allow in each locally owned row, per row.
bool indicesAreSorted_
Whether the graph's indices are sorted in each row, on this process.
Node node_type
This class' Kokkos Node type.
Teuchos::RCP< const export_type > exporter_
The Export from the row Map to the range Map.
void insertGlobalIndices(const global_ordinal_type globalRow, const Teuchos::ArrayView< const global_ordinal_type > &indices)
Insert global indices into the graph.
local_inds_dualv_type::t_host getLocalIndsViewHostNonConst(const RowInfo &rowinfo)
Get a ReadWrite locally indexed view of the locally owned row myRow, such that rowinfo = getRowInfo(m...
void replaceDomainMap(const Teuchos::RCP< const map_type > &newDomainMap)
Replace the current domain Map with the given objects.
CrsGraph & operator=(CrsGraph< local_ordinal_type, global_ordinal_type, node_type > &&)=default
Move assignment (default).
void computeGlobalConstants()
Compute global constants, if they have not yet been computed.
size_t getNumAllocatedEntriesInLocalRow(local_ordinal_type localRow) const
Current number of allocated entries in the given row on the calling (MPI) process,...
virtual ~CrsGraph()=default
Destructor (virtual for memory safety of derived classes).
offset_device_view_type k_offRankOffsets_
The offsets for off-rank entries.
void replaceDomainMapAndImporter(const Teuchos::RCP< const map_type > &newDomainMap, const Teuchos::RCP< const import_type > &newImporter)
Replace the current domain Map and Import with the given parameters.
void setLocallyModified()
Report that we made a local modification to its structure.
size_t getLocalAllocationSize() const
The local number of indices allocated for the graph, over all rows on the calling (MPI) process.
void replaceRangeMap(const Teuchos::RCP< const map_type > &newRangeMap)
Replace the current Range Map with the given objects.
Teuchos::RCP< const map_type > rowMap_
The Map describing the distribution of rows of the graph.
Teuchos::RCP< CrsGraphType > exportAndFillCompleteCrsGraph(const Teuchos::RCP< const CrsGraphType > &sourceGraph, const Export< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > &rowExporter, const Export< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > &domainExporter, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &domainMap, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params)
Nonmember CrsGraph constructor that fuses Export and fillComplete().
const row_ptrs_device_view_type & getRowPtrsPackedDevice() const
Get the packed row pointers on device.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Maps and their communicator.
void getLocalRowView(const LocalOrdinal lclRow, local_inds_host_view_type &lclColInds) const override
Get a const view of the given local row's local column indices.
bool isGloballyIndexed() const override
Whether the graph's column indices are stored as global indices.
bool isLocallyIndexed() const override
Whether the graph's column indices are stored as local indices.
size_t getLocalMaxNumRowEntries() const override
Maximum number of entries in any row of the graph, on this process.
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
local_graph_device_type getLocalGraphDevice() const
Get the local graph.
size_t getLocalNumRows() const override
Returns the number of graph rows owned on the calling node.
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the graph's current column Map with the given Map.
bool haveLocalConstants_
Whether this process has computed local constants.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries.
Struct that holds views of the contents of a CrsMatrix.
Keep track of how much more space a CrsGraph or CrsMatrix needs, when the graph or matrix is the targ...
Base class for distributed Tpetra objects that support data redistribution.
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).
Kokkos::Device< typename device_type::execution_space, buffer_memory_space > buffer_device_type
Kokkos::Device specialization for communication buffers.
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...
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
A parallel distribution of indices over processes.
An abstract interface for graphs accessed by rows.
Abstract base class for objects that can be the source of an Import or Export operation.
Implementation details of Tpetra.
int makeColMap(Teuchos::RCP< const Tpetra::Map< LO, GO, NT > > &colMap, Teuchos::Array< int > &remotePIDs, const Teuchos::RCP< const Tpetra::Map< LO, GO, NT > > &domMap, const CrsGraph< LO, GO, NT > &graph, const bool sortEachProcsGids=true, std::ostream *errStrm=NULL)
Make the graph's column Map.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
CombineMode
Rule for combining data in an Import or Export.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.