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
525 const Teuchos::RCP<const map_type>& rowMap,
526 const Teuchos::RCP<const map_type>& colMap,
527 const Teuchos::RCP<const map_type>& domainMap,
528 const Teuchos::RCP<const map_type>& rangeMap,
529 const Teuchos::RCP<const import_type>& importer,
530 const Teuchos::RCP<const export_type>& exporter,
531 const Teuchos::RCP<Teuchos::ParameterList>& params =
532 Teuchos::null);
533
575 CrsGraph(const row_ptrs_device_view_type& rowPointers,
577 const Teuchos::RCP<const map_type>& rowMap,
578 const Teuchos::RCP<const map_type>& colMap,
579 const Teuchos::RCP<const map_type>& domainMap,
580 const Teuchos::RCP<const map_type>& rangeMap,
581 const Teuchos::RCP<const import_type>& importer,
582 const Teuchos::RCP<const export_type>& exporter,
583 const Teuchos::RCP<Teuchos::ParameterList>& params =
584 Teuchos::null);
585
588
591
594
597
607 virtual ~CrsGraph() = default;
608
636
654
656
658
660 void
661 setParameterList(const Teuchos::RCP<Teuchos::ParameterList>& params) override;
662
664 Teuchos::RCP<const Teuchos::ParameterList>
665 getValidParameters() const override;
666
668
670
692 void
694 const Teuchos::ArrayView<const global_ordinal_type>& indices);
695
702 void
705 const global_ordinal_type inds[]);
706
708
722 void
724 const Teuchos::ArrayView<const local_ordinal_type>& indices);
725
732 void
735 const local_ordinal_type inds[]);
736
738
748
750
752
760 void globalAssemble();
761
780 void
781 resumeFill(const Teuchos::RCP<Teuchos::ParameterList>& params =
782 Teuchos::null);
783
821 void
822 fillComplete(const Teuchos::RCP<const map_type>& domainMap,
823 const Teuchos::RCP<const map_type>& rangeMap,
824 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
825
853 void
854 fillComplete(const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
855
884 void
885 expertStaticFillComplete(const Teuchos::RCP<const map_type>& domainMap,
886 const Teuchos::RCP<const map_type>& rangeMap,
887 const Teuchos::RCP<const import_type>& importer =
888 Teuchos::null,
889 const Teuchos::RCP<const export_type>& exporter =
890 Teuchos::null,
891 const Teuchos::RCP<Teuchos::ParameterList>& params =
892 Teuchos::null);
894
896
898 Teuchos::RCP<const Teuchos::Comm<int>> getComm() const override;
899
901 Teuchos::RCP<const map_type> getRowMap() const override;
902
904 Teuchos::RCP<const map_type> getColMap() const override;
905
907 Teuchos::RCP<const map_type> getDomainMap() const override;
908
910 Teuchos::RCP<const map_type> getRangeMap() const override;
911
913 Teuchos::RCP<const import_type> getImporter() const override;
914
916 Teuchos::RCP<const export_type> getExporter() const override;
917
919
921 global_size_t getGlobalNumRows() const override;
922
924
927 global_size_t getGlobalNumCols() const override;
928
930 size_t getLocalNumRows() const override;
931
933
935 size_t getLocalNumCols() const override;
936
938 global_ordinal_type getIndexBase() const override;
939
941
943 global_size_t getGlobalNumEntries() const override;
944
954 size_t getLocalNumEntries() const override;
955
957
958 size_t
960
967 size_t
968 getNumEntriesInLocalRow(local_ordinal_type localRow) const override;
969
989 size_t getLocalAllocationSize() const;
990
999
1008
1022 size_t getGlobalMaxNumRowEntries() const override;
1023
1028 size_t getLocalMaxNumRowEntries() const override;
1029
1045 bool hasColMap() const override;
1046
1054 bool isLocallyIndexed() const override;
1055
1063 bool isGloballyIndexed() const override;
1064
1066 bool isFillComplete() const override;
1067
1069 bool isFillActive() const;
1070
1078 bool isSorted() const;
1079
1081
1087 bool isStorageOptimized() const;
1088
1094 void
1096 nonconst_global_inds_host_view_type& gblColInds,
1097 size_t& numColInds) const override;
1098
1106 void
1108 nonconst_local_inds_host_view_type& lclColInds,
1109 size_t& numColInds) const override;
1110
1121 void
1124 global_inds_host_view_type& gblColInds) const override;
1125
1128 bool supportsRowViews() const override;
1129
1140 void
1142 const LocalOrdinal lclRow,
1143 local_inds_host_view_type& lclColInds) const override;
1144
1146
1148
1150 std::string description() const override;
1151
1154 void
1155 describe(Teuchos::FancyOStream& out,
1156 const Teuchos::EVerbosityLevel verbLevel =
1157 Teuchos::Describable::verbLevel_default) const override;
1158
1160
1162
1170
1171 virtual bool
1172 checkSizes(const SrcDistObject& source) override;
1173
1174 using dist_object_type::
1177
1178 virtual void
1180 const size_t numSameIDs,
1181 const Kokkos::DualView<const local_ordinal_type*,
1183 const Kokkos::DualView<const local_ordinal_type*,
1185 const CombineMode CM) override;
1186
1187 void copyAndPermuteNew(
1188 const row_graph_type& source,
1190 const size_t numSameIDs,
1191 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1192 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
1193 const CombineMode CM);
1194
1195 void insertGlobalIndicesDevice(
1198 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1199 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
1201
1204
1205 void
1206 applyCrsPadding(const padding_type& padding,
1207 const bool verbose);
1208
1209 std::unique_ptr<padding_type>
1210 computeCrsPadding(
1212 node_type>& source,
1213 const size_t numSameIDs,
1214 const Kokkos::DualView<const local_ordinal_type*,
1216 const Kokkos::DualView<const local_ordinal_type*,
1218 const bool verbose) const;
1219
1220 // This actually modifies imports by sorting it.
1221 std::unique_ptr<padding_type>
1222 computeCrsPaddingForImports(
1223 const Kokkos::DualView<const local_ordinal_type*,
1225 Kokkos::DualView<packet_type*, buffer_device_type> imports,
1226 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1227 const bool verbose) const;
1228
1229 std::unique_ptr<padding_type>
1230 computePaddingForCrsMatrixUnpack(
1231 const Kokkos::DualView<const local_ordinal_type*,
1233 Kokkos::DualView<char*, buffer_device_type> imports,
1234 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1235 const bool verbose) const;
1236
1237 void
1238 computeCrsPaddingForSameIDs(
1241 node_type>& source,
1242 const local_ordinal_type numSameIDs) const;
1243
1244 void
1245 computeCrsPaddingForPermutedIDs(
1248 node_type>& source,
1249 const Kokkos::DualView<const local_ordinal_type*,
1251 const Kokkos::DualView<const local_ordinal_type*,
1253
1254 virtual void
1255 packAndPrepare(
1256 const SrcDistObject& source,
1257 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
1258 Kokkos::DualView<packet_type*, buffer_device_type>& exports,
1259 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1260 size_t& constantNumPackets) override;
1261
1266
1267 virtual void
1268 pack(const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1269 Teuchos::Array<global_ordinal_type>& exports,
1270 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1271 size_t& constantNumPackets) const override;
1272
1273 void
1274 packFillActive(const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1275 Teuchos::Array<global_ordinal_type>& exports,
1276 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1277 size_t& constantNumPackets) const;
1278
1279 void
1280 packFillActiveNew(const Kokkos::DualView<const local_ordinal_type*,
1282 Kokkos::DualView<packet_type*,
1283 buffer_device_type>& exports,
1284 Kokkos::DualView<size_t*,
1287 size_t& constantNumPackets) const;
1288
1293
1294 virtual void
1295 unpackAndCombine(const Kokkos::DualView<const local_ordinal_type*,
1297 Kokkos::DualView<packet_type*,
1299 imports,
1300 Kokkos::DualView<size_t*,
1303 const size_t constantNumPackets,
1304 const CombineMode combineMode) override;
1305
1307
1309
1352 void
1353 getLocalDiagOffsets(const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets) const;
1354
1356 void
1357 getLocalOffRankOffsets(offset_device_view_type& offsets) const;
1358
1368 void
1369 getLocalDiagOffsets(Teuchos::ArrayRCP<size_t>& offsets) const;
1370
1380 void
1381 setAllIndices(const typename local_graph_device_type::row_map_type& rowPointers,
1382 const typename local_graph_device_type::entries_type::non_const_type& columnIndices);
1383
1393 void
1394 setAllIndices(const Teuchos::ArrayRCP<size_t>& rowPointers,
1395 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices);
1396
1399 row_ptrs_host_view_type getLocalRowPtrsHost() const;
1400
1403 row_ptrs_device_view_type getLocalRowPtrsDevice() const;
1404
1406 local_inds_host_view_type getLocalIndicesHost() const;
1407
1410
1429 void replaceColMap(const Teuchos::RCP<const map_type>& newColMap);
1430
1450 void
1451 reindexColumns(const Teuchos::RCP<const map_type>& newColMap,
1452 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1453 const bool sortIndicesInEachRow = true);
1454
1461 void
1462 replaceDomainMap(const Teuchos::RCP<const map_type>& newDomainMap);
1463
1477 void
1478 replaceDomainMapAndImporter(const Teuchos::RCP<const map_type>& newDomainMap,
1479 const Teuchos::RCP<const import_type>& newImporter);
1480
1487 void
1488 replaceRangeMap(const Teuchos::RCP<const map_type>& newRangeMap);
1489
1503 void
1504 replaceRangeMapAndExporter(const Teuchos::RCP<const map_type>& newRangeMap,
1505 const Teuchos::RCP<const export_type>& newExporter);
1506
1535 virtual void
1536 removeEmptyProcessesInPlace(const Teuchos::RCP<const map_type>& newMap) override;
1538
1539 template <class DestViewType, class SrcViewType,
1541 struct pack_functor {
1542 typedef typename DestViewType::execution_space execution_space;
1543 SrcViewType src;
1544 DestViewType dest;
1545 SrcOffsetViewType src_offset;
1546 DestOffsetViewType dest_offset;
1547 typedef typename DestOffsetViewType::non_const_value_type ScalarIndx;
1548
1549 pack_functor(DestViewType dest_,
1550 const SrcViewType src_,
1552 const SrcOffsetViewType src_offset_)
1553 : src(src_)
1554 , dest(dest_)
1555 , src_offset(src_offset_)
1556 , dest_offset(dest_offset_){};
1557
1559 void operator()(size_t row) const {
1560 ScalarIndx i = src_offset(row);
1561 ScalarIndx j = dest_offset(row);
1562 const ScalarIndx k = dest_offset(row + 1);
1563 for (; j < k; j++, i++) {
1564 dest(j) = src(i);
1565 }
1566 }
1567 };
1568
1569 private:
1570 // Friend declaration for nonmember function.
1571 template <class CrsGraphType>
1572 friend Teuchos::RCP<CrsGraphType>
1573 importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1574 const Import<typename CrsGraphType::local_ordinal_type,
1575 typename CrsGraphType::global_ordinal_type,
1576 typename CrsGraphType::node_type>& importer,
1577 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1578 typename CrsGraphType::global_ordinal_type,
1579 typename CrsGraphType::node_type>>& domainMap,
1580 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1581 typename CrsGraphType::global_ordinal_type,
1582 typename CrsGraphType::node_type>>& rangeMap,
1583 const Teuchos::RCP<Teuchos::ParameterList>& params);
1584
1585 // Friend declaration for nonmember function.
1586 template <class CrsGraphType>
1587 friend Teuchos::RCP<CrsGraphType>
1588 importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1589 const Import<typename CrsGraphType::local_ordinal_type,
1590 typename CrsGraphType::global_ordinal_type,
1591 typename CrsGraphType::node_type>& rowImporter,
1592 const Import<typename CrsGraphType::local_ordinal_type,
1593 typename CrsGraphType::global_ordinal_type,
1594 typename CrsGraphType::node_type>& domainImporter,
1595 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1596 typename CrsGraphType::global_ordinal_type,
1597 typename CrsGraphType::node_type>>& domainMap,
1598 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1599 typename CrsGraphType::global_ordinal_type,
1600 typename CrsGraphType::node_type>>& rangeMap,
1601 const Teuchos::RCP<Teuchos::ParameterList>& params);
1602
1603 // Friend declaration for nonmember function.
1604 template <class CrsGraphType>
1605 friend Teuchos::RCP<CrsGraphType>
1606 exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1607 const Export<typename CrsGraphType::local_ordinal_type,
1608 typename CrsGraphType::global_ordinal_type,
1609 typename CrsGraphType::node_type>& exporter,
1610 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1611 typename CrsGraphType::global_ordinal_type,
1612 typename CrsGraphType::node_type>>& domainMap,
1613 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1614 typename CrsGraphType::global_ordinal_type,
1615 typename CrsGraphType::node_type>>& rangeMap,
1616 const Teuchos::RCP<Teuchos::ParameterList>& params);
1617
1618 // Friend declaration for nonmember function.
1619 template <class CrsGraphType>
1620 friend Teuchos::RCP<CrsGraphType>
1621 exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1622 const Export<typename CrsGraphType::local_ordinal_type,
1623 typename CrsGraphType::global_ordinal_type,
1624 typename CrsGraphType::node_type>& rowExporter,
1625 const Export<typename CrsGraphType::local_ordinal_type,
1626 typename CrsGraphType::global_ordinal_type,
1627 typename CrsGraphType::node_type>& domainExporter,
1628 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1629 typename CrsGraphType::global_ordinal_type,
1630 typename CrsGraphType::node_type>>& domainMap,
1631 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1632 typename CrsGraphType::global_ordinal_type,
1633 typename CrsGraphType::node_type>>& rangeMap,
1634 const Teuchos::RCP<Teuchos::ParameterList>& params);
1635
1636 // Friend declaration for nonmember function.
1637 template <class LO, class GO, class NT>
1638 friend int
1639 Details::makeColMap(Teuchos::RCP<const Tpetra::Map<LO, GO, NT>>& colMap,
1640 Teuchos::Array<int>& remotePIDs,
1641 const Teuchos::RCP<const Tpetra::Map<LO, GO, NT>>& domMap,
1642 const CrsGraph<LO, GO, NT>& graph,
1643 const bool sortEachProcsGids,
1644 std::ostream* errStrm);
1645
1646 public:
1662 void
1663 importAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1664 const import_type& importer,
1665 const Teuchos::RCP<const map_type>& domainMap,
1666 const Teuchos::RCP<const map_type>& rangeMap,
1667 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1668
1684 void
1685 importAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1686 const import_type& rowImporter,
1687 const import_type& domainImporter,
1688 const Teuchos::RCP<const map_type>& domainMap,
1689 const Teuchos::RCP<const map_type>& rangeMap,
1690 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1691
1707 void
1708 exportAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1709 const export_type& exporter,
1710 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1711 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1712 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1713
1729 void
1730 exportAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1731 const export_type& rowExporter,
1732 const export_type& domainExporter,
1733 const Teuchos::RCP<const map_type>& domainMap,
1734 const Teuchos::RCP<const map_type>& rangeMap,
1735 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1736
1737 private:
1758 void
1759 transferAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1760 const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>& rowTransfer,
1761 const Teuchos::RCP<const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>>& domainTransfer,
1762 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1763 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1764 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1765
1766 protected:
1767 // these structs are conveniences, to cut down on the number of
1768 // arguments to some of the methods below.
1769 struct SLocalGlobalViews {
1770 Teuchos::ArrayView<const global_ordinal_type> ginds;
1771 Teuchos::ArrayView<const local_ordinal_type> linds;
1772 };
1773 struct SLocalGlobalNCViews {
1774 Teuchos::ArrayView<global_ordinal_type> ginds;
1775 Teuchos::ArrayView<local_ordinal_type> linds;
1776 };
1777
1778 bool indicesAreAllocated() const;
1779
1780 void
1781 allocateIndices(const ELocalGlobal lg, const bool verbose = false);
1782
1784
1785
1795 void makeColMap(Teuchos::Array<int>& remotePIDs);
1796
1817 std::pair<size_t, std::string>
1818 makeIndicesLocal(const bool verbose = false);
1819
1828 void
1829 makeImportExport(Teuchos::Array<int>& remotePIDs,
1830 const bool useRemotePIDs);
1831
1833
1835
1870 size_t
1871 insertIndices(RowInfo& rowInfo,
1872 const SLocalGlobalViews& newInds,
1873 const ELocalGlobal lg,
1874 const ELocalGlobal I);
1875
1884 size_t
1886 const global_ordinal_type inputGblColInds[],
1887 const size_t numInputInds);
1888
1899 size_t
1900 insertGlobalIndicesImpl(const RowInfo& rowInfo,
1901 const global_ordinal_type inputGblColInds[],
1902 const size_t numInputInds,
1903 std::function<void(const size_t, const size_t, const size_t)> fun =
1904 std::function<void(const size_t, const size_t, const size_t)>());
1905
1906 void
1907 insertLocalIndicesImpl(const local_ordinal_type lclRow,
1908 const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
1909 std::function<void(const size_t, const size_t, const size_t)> fun =
1910 std::function<void(const size_t, const size_t, const size_t)>());
1911
1927 size_t
1928 findGlobalIndices(const RowInfo& rowInfo,
1929 const Teuchos::ArrayView<const global_ordinal_type>& indices,
1930 std::function<void(const size_t, const size_t, const size_t)> fun) const;
1931
1943 void
1945 const global_ordinal_type gblColInds[],
1946 const local_ordinal_type numGblColInds);
1947
1959 void
1961 const global_ordinal_type gblColInds[],
1962 const local_ordinal_type numGblColInds);
1963
1968 static const bool useAtomicUpdatesByDefault =
1969#ifdef KOKKOS_ENABLE_SERIAL
1970 !std::is_same<execution_space, Kokkos::Serial>::value;
1971#else
1972 true;
1973#endif // KOKKOS_ENABLE_SERIAL
1974
1976
1978
1980 bool isMerged() const;
1981
1987 void setLocallyModified();
1988
1989 private:
1994 void
1995 sortAndMergeAllIndices(const bool sorted, const bool merged);
1996
1997 // mfh 08 May 2017: I only restore "protected" here for backwards
1998 // compatibility.
1999 protected:
2001
2011 void
2012 setDomainRangeMaps(const Teuchos::RCP<const map_type>& domainMap,
2013 const Teuchos::RCP<const map_type>& rangeMap);
2014
2015 void staticAssertions() const;
2016 void clearGlobalConstants();
2017
2018 public:
2021
2040
2041 bool haveLocalOffRankOffsets() const { return haveLocalOffRankOffsets_; }
2042
2043 protected:
2063 void computeLocalConstants();
2064
2067 RowInfo getRowInfo(const local_ordinal_type myRow) const;
2068
2081 RowInfo getRowInfoFromGlobalRowIndex(const global_ordinal_type gblRow) const;
2082
2083 public:
2092 local_graph_host_type getLocalGraphHost() const;
2093
2094 protected:
2095 void fillLocalGraph(const Teuchos::RCP<Teuchos::ParameterList>& params);
2096
2098 void checkInternalState() const;
2099
2103 void swap(CrsGraph<local_ordinal_type, global_ordinal_type, Node>& graph);
2104
2105 // Friend the tester for CrsGraph::swap
2106 friend class Tpetra::crsGraph_Swap_Tester<local_ordinal_type, global_ordinal_type, Node>;
2107
2109 Teuchos::RCP<const map_type> rowMap_;
2111 Teuchos::RCP<const map_type> colMap_;
2113 Teuchos::RCP<const map_type> rangeMap_;
2115 Teuchos::RCP<const map_type> domainMap_;
2116
2123 Teuchos::RCP<const import_type> importer_;
2124
2130 Teuchos::RCP<const export_type> exporter_;
2131
2137 Teuchos::OrdinalTraits<size_t>::invalid();
2138
2143 Teuchos::OrdinalTraits<global_size_t>::invalid();
2144
2150 Teuchos::OrdinalTraits<global_size_t>::invalid();
2151
2152 private:
2153 // Replacement for device view k_rowPtrs_
2154 // Device view rowPtrsUnpacked_dev_ takes place of k_rowPtrs_
2155 // Host view rowPtrsUnpacked_host_ takes place of copies and use of getEntryOnHost
2156 // Wish this could be a WrappedDualView, but deep_copies in DualView
2157 // don't work with const data views (e.g., StaticCrsGraph::row_map)
2158 // k_rowPtrs_ is offsets wrt the ALLOCATED indices array, not necessarily
2159 // the ACTUAL compressed indices array.
2160 // When !OptimizedStorage, k_rowPtrs_ may differ from ACTUAL compressed
2161 // indices array. (Karen is skeptical that !OptimizedStorage works)
2162 // When OptimizedStorage, rowPtrsUnpacked_ = k_rowPtrsPacked_
2163
2164 row_ptrs_device_view_type rowPtrsUnpacked_dev_;
2165 mutable row_ptrs_host_view_type rowPtrsUnpacked_host_;
2166
2167 // Row offsets into the actual graph local indices
2168 // Device view rowPtrsUnpacked_dev_ takes place of lclGraph_.row_map
2169
2170 row_ptrs_device_view_type rowPtrsPacked_dev_;
2171 mutable row_ptrs_host_view_type rowPtrsPacked_host_;
2172
2174 bool packedUnpackedRowPtrsMatch_ = false;
2175
2176 protected:
2177 void setRowPtrsUnpacked(const row_ptrs_device_view_type& dview) {
2178 packedUnpackedRowPtrsMatch_ = false;
2179 rowPtrsUnpacked_dev_ = dview;
2180 // Make sure stale host rowptrs are not kept
2181 rowPtrsUnpacked_host_ = row_ptrs_host_view_type();
2182 }
2183
2185 const row_ptrs_device_view_type& getRowPtrsUnpackedDevice() const {
2186 return rowPtrsUnpacked_dev_;
2187 }
2188
2190 const row_ptrs_host_view_type& getRowPtrsUnpackedHost() const {
2191 if (rowPtrsUnpacked_host_.extent(0) != rowPtrsUnpacked_dev_.extent(0)) {
2192 // NOTE: not just using create_mirror_view here, because
2193 // we do want host/device to be in different memory, even if we're using a SharedSpace.
2194 // This is so that reads will never trigger a host-device transfer.
2195 // The exception is when 'device' views are HostSpace, then don't make another copy.
2196 if constexpr (std::is_same_v<typename Node::memory_space, Kokkos::HostSpace>) {
2197 rowPtrsUnpacked_host_ = rowPtrsUnpacked_dev_;
2198 } else {
2199 // Have to make this temporary because rowptrs are const-valued
2200 typename row_ptrs_host_view_type::non_const_type rowPtrsTemp(
2201 Kokkos::view_alloc(Kokkos::WithoutInitializing, "rowPtrsUnpacked_host_"), rowPtrsUnpacked_dev_.extent(0));
2202 Kokkos::deep_copy(rowPtrsTemp, rowPtrsUnpacked_dev_);
2203 rowPtrsUnpacked_host_ = rowPtrsTemp;
2204 }
2205 // Also keep packed/unpacked views in sync, if they are known to have the same contents
2206 if (packedUnpackedRowPtrsMatch_) {
2207 rowPtrsPacked_host_ = rowPtrsUnpacked_host_;
2208 }
2209 }
2210 return rowPtrsUnpacked_host_;
2211 }
2212
2213 void setRowPtrsPacked(const row_ptrs_device_view_type& dview) {
2214 packedUnpackedRowPtrsMatch_ = false;
2215 rowPtrsPacked_dev_ = dview;
2216 // Make sure stale host rowptrs are not kept
2217 rowPtrsPacked_host_ = row_ptrs_host_view_type();
2218 }
2219
2221 const row_ptrs_device_view_type& getRowPtrsPackedDevice() const {
2222 return rowPtrsPacked_dev_;
2223 }
2224
2226 const row_ptrs_host_view_type& getRowPtrsPackedHost() const {
2227 if (rowPtrsPacked_host_.extent(0) != rowPtrsPacked_dev_.extent(0)) {
2228 // NOTE: not just using create_mirror_view here, because
2229 // we do want host/device to be in different memory, even if we're using a SharedSpace.
2230 // This is so that reads will never trigger a host-device transfer.
2231 // The exception is when 'device' views are HostSpace, then don't make another copy.
2232 if constexpr (std::is_same_v<typename Node::memory_space, Kokkos::HostSpace>) {
2233 rowPtrsPacked_host_ = rowPtrsPacked_dev_;
2234 } else {
2235 // Have to make this temporary because rowptrs are const-valued
2236 typename row_ptrs_host_view_type::non_const_type rowPtrsTemp(
2237 Kokkos::view_alloc(Kokkos::WithoutInitializing, "rowPtrsPacked_host_"), rowPtrsPacked_dev_.extent(0));
2238 Kokkos::deep_copy(rowPtrsTemp, rowPtrsPacked_dev_);
2239 rowPtrsPacked_host_ = rowPtrsTemp;
2240 }
2241 // Also keep packed/unpacked views in sync, if they are known to have the same contents
2242 if (packedUnpackedRowPtrsMatch_) {
2243 rowPtrsUnpacked_host_ = rowPtrsPacked_host_;
2244 }
2245 }
2246 return rowPtrsPacked_host_;
2247 }
2248
2249 // There are common cases where both packed and unpacked views are set to the same array.
2250 // Doing this in a single call can reduce dataspace on host, and reduce runtime by
2251 // removing a deep_copy from device to host.
2252
2253 void setRowPtrs(const row_ptrs_device_view_type& dview) {
2254 packedUnpackedRowPtrsMatch_ = true;
2255 rowPtrsUnpacked_dev_ = dview;
2256 rowPtrsPacked_dev_ = dview;
2257 // Make sure stale host rowptrs are not kept
2258 rowPtrsUnpacked_host_ = row_ptrs_host_view_type();
2259 rowPtrsPacked_host_ = row_ptrs_host_view_type();
2260 }
2261
2262 // TODO: Make private -- matrix shouldn't access directly the guts of graph
2263
2278
2293
2294 // TODO: Make private -- matrix shouldn't access directly the guts of graph
2295
2305
2306 // TODO: Make private -- matrix shouldn't access directly
2308
2312 typename local_inds_dualv_type::t_host::const_type
2313 getLocalIndsViewHost(const RowInfo& rowinfo) const;
2314
2318 typename local_inds_dualv_type::t_dev::const_type
2320
2324 typename global_inds_dualv_type::t_host::const_type
2326
2330 typename global_inds_dualv_type::t_dev::const_type
2332
2336 typename local_inds_dualv_type::t_host
2338
2339 // FOR NOW...
2340 // KEEP k_numRowEntries_ (though switch from host_mirror_type to Host)
2341 // KEEP k_numAllocPerRow_ (though perhaps switch from host_mirror_type to Host)
2342
2368 typename Kokkos::View<const size_t*, device_type>::host_mirror_type
2370
2381
2383
2384
2406
2414 typedef typename Kokkos::View<size_t*, Kokkos::LayoutLeft, device_type>::host_mirror_type num_row_entries_type;
2415
2416 // typedef Kokkos::View<
2417 // size_t*,
2418 // Kokkos::LayoutLeft,
2419 // Kokkos::Device<
2420 // typename Kokkos::View<
2421 // size_t*,
2422 // Kokkos::LayoutLeft,
2423 // device_type>::host_mirror_type::execution_space,
2424 // Kokkos::HostSpace> > num_row_entries_type;
2425
2433
2439 mutable offset_device_view_type k_offRankOffsets_;
2440
2442
2453 Details::STORAGE_1D_UNPACKED;
2454
2455 bool indicesAreAllocated_ = false;
2456 bool indicesAreLocal_ = false;
2457 bool indicesAreGlobal_ = false;
2458 bool fillComplete_ = false;
2459
2464 bool noRedundancies_ = true;
2470 mutable bool haveLocalOffRankOffsets_ = false;
2471
2472 typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type>> nonlocals_type;
2473
2475 nonlocals_type nonlocals_;
2476
2492
2493 private:
2495 static bool getDebug();
2496
2499 bool debug_ = getDebug();
2500
2502 static bool getVerbose();
2503
2507 bool verbose_ = getVerbose();
2508
2509 private:
2511 mutable bool need_sync_host_uvm_access = false;
2512
2514 void set_need_sync_host_uvm_access() {
2515 need_sync_host_uvm_access = true;
2516 }
2517
2519 void execute_sync_host_uvm_access() const {
2520 if (need_sync_host_uvm_access) {
2521 Kokkos::fence("CrsGraph::execute_sync_host_uvm_access");
2522 need_sync_host_uvm_access = false;
2523 }
2524 }
2525}; // class CrsGraph
2526
2534template <class LocalOrdinal, class GlobalOrdinal, class Node>
2535Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node>>
2537 const Teuchos::RCP<
2539 size_t maxNumEntriesPerRow = 0,
2540 const Teuchos::RCP<Teuchos::ParameterList>& params =
2541 Teuchos::null) {
2542 using Teuchos::rcp;
2545 params));
2546}
2547
2597template <class CrsGraphType>
2598Teuchos::RCP<CrsGraphType>
2599importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2600 const Import<typename CrsGraphType::local_ordinal_type,
2601 typename CrsGraphType::global_ordinal_type,
2602 typename CrsGraphType::node_type>& importer,
2603 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2604 typename CrsGraphType::global_ordinal_type,
2605 typename CrsGraphType::node_type>>& domainMap = Teuchos::null,
2606 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2607 typename CrsGraphType::global_ordinal_type,
2608 typename CrsGraphType::node_type>>& rangeMap = Teuchos::null,
2609 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
2610 Teuchos::RCP<CrsGraphType> destGraph;
2611 sourceGraph->importAndFillComplete(destGraph, importer, domainMap, rangeMap, params);
2612 return destGraph;
2613}
2614
2665template <class CrsGraphType>
2666Teuchos::RCP<CrsGraphType>
2667importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2668 const Import<typename CrsGraphType::local_ordinal_type,
2669 typename CrsGraphType::global_ordinal_type,
2670 typename CrsGraphType::node_type>& rowImporter,
2671 const Import<typename CrsGraphType::local_ordinal_type,
2672 typename CrsGraphType::global_ordinal_type,
2673 typename CrsGraphType::node_type>& domainImporter,
2674 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2675 typename CrsGraphType::global_ordinal_type,
2676 typename CrsGraphType::node_type>>& domainMap,
2677 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2678 typename CrsGraphType::global_ordinal_type,
2679 typename CrsGraphType::node_type>>& rangeMap,
2680 const Teuchos::RCP<Teuchos::ParameterList>& params) {
2681 Teuchos::RCP<CrsGraphType> destGraph;
2682 sourceGraph->importAndFillComplete(destGraph, rowImporter, domainImporter, domainMap, rangeMap, params);
2683 return destGraph;
2684}
2685
2719template <class CrsGraphType>
2720Teuchos::RCP<CrsGraphType>
2721exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2722 const Export<typename CrsGraphType::local_ordinal_type,
2723 typename CrsGraphType::global_ordinal_type,
2724 typename CrsGraphType::node_type>& exporter,
2725 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2726 typename CrsGraphType::global_ordinal_type,
2727 typename CrsGraphType::node_type>>& domainMap = Teuchos::null,
2728 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2729 typename CrsGraphType::global_ordinal_type,
2730 typename CrsGraphType::node_type>>& rangeMap = Teuchos::null,
2731 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
2732 Teuchos::RCP<CrsGraphType> destGraph;
2733 sourceGraph->exportAndFillComplete(destGraph, exporter, domainMap, rangeMap, params);
2734 return destGraph;
2735}
2736
2770template <class CrsGraphType>
2771Teuchos::RCP<CrsGraphType>
2772exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2773 const Export<typename CrsGraphType::local_ordinal_type,
2774 typename CrsGraphType::global_ordinal_type,
2775 typename CrsGraphType::node_type>& rowExporter,
2776 const Export<typename CrsGraphType::local_ordinal_type,
2777 typename CrsGraphType::global_ordinal_type,
2778 typename CrsGraphType::node_type>& domainExporter,
2779 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2780 typename CrsGraphType::global_ordinal_type,
2781 typename CrsGraphType::node_type>>& domainMap,
2782 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2783 typename CrsGraphType::global_ordinal_type,
2784 typename CrsGraphType::node_type>>& rangeMap,
2785 const Teuchos::RCP<Teuchos::ParameterList>& params) {
2786 Teuchos::RCP<CrsGraphType> destGraph;
2787 sourceGraph->exportAndFillComplete(destGraph, rowExporter, domainExporter, domainMap, rangeMap, params);
2788 return destGraph;
2789}
2790
2791} // namespace Tpetra
2792
2793#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.