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
401 const Teuchos::RCP<const map_type>& rowMap,
402 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
403
426 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
427 const Teuchos::RCP<const map_type>& colMap,
428 const typename local_graph_device_type::row_map_type& rowPointers,
429 const typename local_graph_device_type::entries_type::non_const_type& columnIndices,
430 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
431
454 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
455 const Teuchos::RCP<const map_type>& colMap,
456 const Teuchos::ArrayRCP<size_t>& rowPointers,
457 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices,
458 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
459
481 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
482 const Teuchos::RCP<const map_type>& colMap,
484 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
485
513 const Teuchos::RCP<const map_type>& rowMap,
514 const Teuchos::RCP<const map_type>& colMap,
515 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
516 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
517 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
518
524 const Teuchos::RCP<const map_type>& rowMap,
525 const Teuchos::RCP<const map_type>& colMap,
526 const Teuchos::RCP<const map_type>& domainMap,
527 const Teuchos::RCP<const map_type>& rangeMap,
528 const Teuchos::RCP<const import_type>& importer,
529 const Teuchos::RCP<const export_type>& exporter,
530 const Teuchos::RCP<Teuchos::ParameterList>& params =
531 Teuchos::null);
532
574 CrsGraph(const row_ptrs_device_view_type& rowPointers,
576 const Teuchos::RCP<const map_type>& rowMap,
577 const Teuchos::RCP<const map_type>& colMap,
578 const Teuchos::RCP<const map_type>& domainMap,
579 const Teuchos::RCP<const map_type>& rangeMap,
580 const Teuchos::RCP<const import_type>& importer,
581 const Teuchos::RCP<const export_type>& exporter,
582 const Teuchos::RCP<Teuchos::ParameterList>& params =
583 Teuchos::null);
584
587
590
593
596
606 virtual ~CrsGraph() = default;
607
635
653
655
657
659 void
660 setParameterList(const Teuchos::RCP<Teuchos::ParameterList>& params) override;
661
663 Teuchos::RCP<const Teuchos::ParameterList>
664 getValidParameters() const override;
665
667
669
691 void
693 const Teuchos::ArrayView<const global_ordinal_type>& indices);
694
701 void
704 const global_ordinal_type inds[]);
705
707
721 void
723 const Teuchos::ArrayView<const local_ordinal_type>& indices);
724
731 void
734 const local_ordinal_type inds[]);
735
737
747
749
751
759 void globalAssemble();
760
779 void
780 resumeFill(const Teuchos::RCP<Teuchos::ParameterList>& params =
781 Teuchos::null);
782
820 void
821 fillComplete(const Teuchos::RCP<const map_type>& domainMap,
822 const Teuchos::RCP<const map_type>& rangeMap,
823 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
824
852 void
853 fillComplete(const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
854
883 void
884 expertStaticFillComplete(const Teuchos::RCP<const map_type>& domainMap,
885 const Teuchos::RCP<const map_type>& rangeMap,
886 const Teuchos::RCP<const import_type>& importer =
887 Teuchos::null,
888 const Teuchos::RCP<const export_type>& exporter =
889 Teuchos::null,
890 const Teuchos::RCP<Teuchos::ParameterList>& params =
891 Teuchos::null);
893
895
897 Teuchos::RCP<const Teuchos::Comm<int>> getComm() const override;
898
900 Teuchos::RCP<const map_type> getRowMap() const override;
901
903 Teuchos::RCP<const map_type> getColMap() const override;
904
906 Teuchos::RCP<const map_type> getDomainMap() const override;
907
909 Teuchos::RCP<const map_type> getRangeMap() const override;
910
912 Teuchos::RCP<const import_type> getImporter() const override;
913
915 Teuchos::RCP<const export_type> getExporter() const override;
916
918
920 global_size_t getGlobalNumRows() const override;
921
923
926 global_size_t getGlobalNumCols() const override;
927
929 size_t getLocalNumRows() const override;
930
932
934 size_t getLocalNumCols() const override;
935
937 global_ordinal_type getIndexBase() const override;
938
940
942 global_size_t getGlobalNumEntries() const override;
943
953 size_t getLocalNumEntries() const override;
954
956
957 size_t
959
966 size_t
967 getNumEntriesInLocalRow(local_ordinal_type localRow) const override;
968
988 size_t getLocalAllocationSize() const;
989
998
1007
1021 size_t getGlobalMaxNumRowEntries() const override;
1022
1027 size_t getLocalMaxNumRowEntries() const override;
1028
1044 bool hasColMap() const override;
1045
1053 bool isLocallyIndexed() const override;
1054
1062 bool isGloballyIndexed() const override;
1063
1065 bool isFillComplete() const override;
1066
1068 bool isFillActive() const;
1069
1077 bool isSorted() const;
1078
1080
1086 bool isStorageOptimized() const;
1087
1093 void
1095 nonconst_global_inds_host_view_type& gblColInds,
1096 size_t& numColInds) const override;
1097
1105 void
1107 nonconst_local_inds_host_view_type& gblColInds,
1108 size_t& numColInds) const override;
1109
1120 void
1123 global_inds_host_view_type& gblColInds) const override;
1124
1127 bool supportsRowViews() const override;
1128
1139 void
1141 const LocalOrdinal lclRow,
1142 local_inds_host_view_type& lclColInds) const override;
1143
1145
1147
1149 std::string description() const override;
1150
1153 void
1154 describe(Teuchos::FancyOStream& out,
1155 const Teuchos::EVerbosityLevel verbLevel =
1156 Teuchos::Describable::verbLevel_default) const override;
1157
1159
1161
1169
1170 virtual bool
1171 checkSizes(const SrcDistObject& source) override;
1172
1173 using dist_object_type::
1176
1177 virtual void
1179 const size_t numSameIDs,
1180 const Kokkos::DualView<const local_ordinal_type*,
1182 const Kokkos::DualView<const local_ordinal_type*,
1184 const CombineMode CM) override;
1185
1186 void copyAndPermuteNew(
1187 const row_graph_type& source,
1189 const size_t numSameIDs,
1190 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1191 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
1192 const CombineMode CM);
1193
1194 void insertGlobalIndicesDevice(
1197 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1198 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
1200
1203
1204 void
1205 applyCrsPadding(const padding_type& padding,
1206 const bool verbose);
1207
1208 std::unique_ptr<padding_type>
1209 computeCrsPadding(
1211 node_type>& source,
1212 const size_t numSameIDs,
1213 const Kokkos::DualView<const local_ordinal_type*,
1215 const Kokkos::DualView<const local_ordinal_type*,
1217 const bool verbose) const;
1218
1219 // This actually modifies imports by sorting it.
1220 std::unique_ptr<padding_type>
1221 computeCrsPaddingForImports(
1222 const Kokkos::DualView<const local_ordinal_type*,
1224 Kokkos::DualView<packet_type*, buffer_device_type> imports,
1225 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1226 const bool verbose) const;
1227
1228 std::unique_ptr<padding_type>
1229 computePaddingForCrsMatrixUnpack(
1230 const Kokkos::DualView<const local_ordinal_type*,
1232 Kokkos::DualView<char*, buffer_device_type> imports,
1233 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1234 const bool verbose) const;
1235
1236 void
1237 computeCrsPaddingForSameIDs(
1240 node_type>& source,
1241 const local_ordinal_type numSameIDs) const;
1242
1243 void
1244 computeCrsPaddingForPermutedIDs(
1247 node_type>& source,
1248 const Kokkos::DualView<const local_ordinal_type*,
1250 const Kokkos::DualView<const local_ordinal_type*,
1252
1253 virtual void
1254 packAndPrepare(
1255 const SrcDistObject& source,
1256 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
1257 Kokkos::DualView<packet_type*, buffer_device_type>& exports,
1258 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1259 size_t& constantNumPackets) override;
1260
1265
1266 virtual void
1267 pack(const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1268 Teuchos::Array<global_ordinal_type>& exports,
1269 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1270 size_t& constantNumPackets) const override;
1271
1272 void
1273 packFillActive(const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1274 Teuchos::Array<global_ordinal_type>& exports,
1275 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1276 size_t& constantNumPackets) const;
1277
1278 void
1279 packFillActiveNew(const Kokkos::DualView<const local_ordinal_type*,
1281 Kokkos::DualView<packet_type*,
1282 buffer_device_type>& exports,
1283 Kokkos::DualView<size_t*,
1286 size_t& constantNumPackets) const;
1287
1292
1293 virtual void
1294 unpackAndCombine(const Kokkos::DualView<const local_ordinal_type*,
1296 Kokkos::DualView<packet_type*,
1298 imports,
1299 Kokkos::DualView<size_t*,
1302 const size_t constantNumPackets,
1303 const CombineMode combineMode) override;
1304
1306
1308
1351 void
1352 getLocalDiagOffsets(const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets) const;
1353
1355 void
1356 getLocalOffRankOffsets(offset_device_view_type& offsets) const;
1357
1367 void
1368 getLocalDiagOffsets(Teuchos::ArrayRCP<size_t>& offsets) const;
1369
1379 void
1380 setAllIndices(const typename local_graph_device_type::row_map_type& rowPointers,
1381 const typename local_graph_device_type::entries_type::non_const_type& columnIndices);
1382
1392 void
1393 setAllIndices(const Teuchos::ArrayRCP<size_t>& rowPointers,
1394 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices);
1395
1398 row_ptrs_host_view_type getLocalRowPtrsHost() const;
1399
1402 row_ptrs_device_view_type getLocalRowPtrsDevice() const;
1403
1405 local_inds_host_view_type getLocalIndicesHost() const;
1406
1409
1428 void replaceColMap(const Teuchos::RCP<const map_type>& newColMap);
1429
1449 void
1450 reindexColumns(const Teuchos::RCP<const map_type>& newColMap,
1451 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1452 const bool sortIndicesInEachRow = true);
1453
1460 void
1461 replaceDomainMap(const Teuchos::RCP<const map_type>& newDomainMap);
1462
1476 void
1477 replaceDomainMapAndImporter(const Teuchos::RCP<const map_type>& newDomainMap,
1478 const Teuchos::RCP<const import_type>& newImporter);
1479
1486 void
1487 replaceRangeMap(const Teuchos::RCP<const map_type>& newRangeMap);
1488
1502 void
1503 replaceRangeMapAndExporter(const Teuchos::RCP<const map_type>& newRangeMap,
1504 const Teuchos::RCP<const export_type>& newExporter);
1505
1534 virtual void
1535 removeEmptyProcessesInPlace(const Teuchos::RCP<const map_type>& newMap) override;
1537
1538 template <class DestViewType, class SrcViewType,
1540 struct pack_functor {
1541 typedef typename DestViewType::execution_space execution_space;
1542 SrcViewType src;
1543 DestViewType dest;
1544 SrcOffsetViewType src_offset;
1545 DestOffsetViewType dest_offset;
1546 typedef typename DestOffsetViewType::non_const_value_type ScalarIndx;
1547
1548 pack_functor(DestViewType dest_,
1549 const SrcViewType src_,
1551 const SrcOffsetViewType src_offset_)
1552 : src(src_)
1553 , dest(dest_)
1554 , src_offset(src_offset_)
1555 , dest_offset(dest_offset_){};
1556
1558 void operator()(size_t row) const {
1559 ScalarIndx i = src_offset(row);
1560 ScalarIndx j = dest_offset(row);
1561 const ScalarIndx k = dest_offset(row + 1);
1562 for (; j < k; j++, i++) {
1563 dest(j) = src(i);
1564 }
1565 }
1566 };
1567
1568 private:
1569 // Friend declaration for nonmember function.
1570 template <class CrsGraphType>
1571 friend Teuchos::RCP<CrsGraphType>
1572 importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1573 const Import<typename CrsGraphType::local_ordinal_type,
1574 typename CrsGraphType::global_ordinal_type,
1575 typename CrsGraphType::node_type>& importer,
1576 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1577 typename CrsGraphType::global_ordinal_type,
1578 typename CrsGraphType::node_type>>& domainMap,
1579 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1580 typename CrsGraphType::global_ordinal_type,
1581 typename CrsGraphType::node_type>>& rangeMap,
1582 const Teuchos::RCP<Teuchos::ParameterList>& params);
1583
1584 // Friend declaration for nonmember function.
1585 template <class CrsGraphType>
1586 friend Teuchos::RCP<CrsGraphType>
1587 importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1588 const Import<typename CrsGraphType::local_ordinal_type,
1589 typename CrsGraphType::global_ordinal_type,
1590 typename CrsGraphType::node_type>& rowImporter,
1591 const Import<typename CrsGraphType::local_ordinal_type,
1592 typename CrsGraphType::global_ordinal_type,
1593 typename CrsGraphType::node_type>& domainImporter,
1594 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1595 typename CrsGraphType::global_ordinal_type,
1596 typename CrsGraphType::node_type>>& domainMap,
1597 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1598 typename CrsGraphType::global_ordinal_type,
1599 typename CrsGraphType::node_type>>& rangeMap,
1600 const Teuchos::RCP<Teuchos::ParameterList>& params);
1601
1602 // Friend declaration for nonmember function.
1603 template <class CrsGraphType>
1604 friend Teuchos::RCP<CrsGraphType>
1605 exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1606 const Export<typename CrsGraphType::local_ordinal_type,
1607 typename CrsGraphType::global_ordinal_type,
1608 typename CrsGraphType::node_type>& exporter,
1609 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1610 typename CrsGraphType::global_ordinal_type,
1611 typename CrsGraphType::node_type>>& domainMap,
1612 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1613 typename CrsGraphType::global_ordinal_type,
1614 typename CrsGraphType::node_type>>& rangeMap,
1615 const Teuchos::RCP<Teuchos::ParameterList>& params);
1616
1617 // Friend declaration for nonmember function.
1618 template <class CrsGraphType>
1619 friend Teuchos::RCP<CrsGraphType>
1620 exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1621 const Export<typename CrsGraphType::local_ordinal_type,
1622 typename CrsGraphType::global_ordinal_type,
1623 typename CrsGraphType::node_type>& rowExporter,
1624 const Export<typename CrsGraphType::local_ordinal_type,
1625 typename CrsGraphType::global_ordinal_type,
1626 typename CrsGraphType::node_type>& domainExporter,
1627 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1628 typename CrsGraphType::global_ordinal_type,
1629 typename CrsGraphType::node_type>>& domainMap,
1630 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1631 typename CrsGraphType::global_ordinal_type,
1632 typename CrsGraphType::node_type>>& rangeMap,
1633 const Teuchos::RCP<Teuchos::ParameterList>& params);
1634
1635 // Friend declaration for nonmember function.
1636 template <class LO, class GO, class NT>
1637 friend int
1638 Details::makeColMap(Teuchos::RCP<const Tpetra::Map<LO, GO, NT>>& colMap,
1639 Teuchos::Array<int>& remotePIDs,
1640 const Teuchos::RCP<const Tpetra::Map<LO, GO, NT>>& domMap,
1641 const CrsGraph<LO, GO, NT>& graph,
1642 const bool sortEachProcsGids,
1643 std::ostream* errStrm);
1644
1645 public:
1661 void
1662 importAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1663 const import_type& importer,
1664 const Teuchos::RCP<const map_type>& domainMap,
1665 const Teuchos::RCP<const map_type>& rangeMap,
1666 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1667
1683 void
1684 importAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1685 const import_type& rowImporter,
1686 const import_type& domainImporter,
1687 const Teuchos::RCP<const map_type>& domainMap,
1688 const Teuchos::RCP<const map_type>& rangeMap,
1689 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1690
1706 void
1707 exportAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1708 const export_type& exporter,
1709 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1710 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1711 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1712
1728 void
1729 exportAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1730 const export_type& rowExporter,
1731 const export_type& domainExporter,
1732 const Teuchos::RCP<const map_type>& domainMap,
1733 const Teuchos::RCP<const map_type>& rangeMap,
1734 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1735
1736 private:
1757 void
1758 transferAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1759 const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>& rowTransfer,
1760 const Teuchos::RCP<const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>>& domainTransfer,
1761 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1762 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1763 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1764
1765 protected:
1766 // these structs are conveniences, to cut down on the number of
1767 // arguments to some of the methods below.
1768 struct SLocalGlobalViews {
1769 Teuchos::ArrayView<const global_ordinal_type> ginds;
1770 Teuchos::ArrayView<const local_ordinal_type> linds;
1771 };
1772 struct SLocalGlobalNCViews {
1773 Teuchos::ArrayView<global_ordinal_type> ginds;
1774 Teuchos::ArrayView<local_ordinal_type> linds;
1775 };
1776
1777 bool indicesAreAllocated() const;
1778
1779 void
1780 allocateIndices(const ELocalGlobal lg, const bool verbose = false);
1781
1783
1784
1794 void makeColMap(Teuchos::Array<int>& remotePIDs);
1795
1816 std::pair<size_t, std::string>
1817 makeIndicesLocal(const bool verbose = false);
1818
1827 void
1828 makeImportExport(Teuchos::Array<int>& remotePIDs,
1829 const bool useRemotePIDs);
1830
1832
1834
1869 size_t
1870 insertIndices(RowInfo& rowInfo,
1871 const SLocalGlobalViews& newInds,
1872 const ELocalGlobal lg,
1873 const ELocalGlobal I);
1874
1884 size_t
1886 const global_ordinal_type inputGblColInds[],
1887 const size_t numInputInds);
1888
1898 size_t
1899 insertGlobalIndicesImpl(const RowInfo& rowInfo,
1900 const global_ordinal_type inputGblColInds[],
1901 const size_t numInputInds,
1902 std::function<void(const size_t, const size_t, const size_t)> fun =
1903 std::function<void(const size_t, const size_t, const size_t)>());
1904
1905 void
1906 insertLocalIndicesImpl(const local_ordinal_type lclRow,
1907 const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
1908 std::function<void(const size_t, const size_t, const size_t)> fun =
1909 std::function<void(const size_t, const size_t, const size_t)>());
1910
1926 size_t
1927 findGlobalIndices(const RowInfo& rowInfo,
1928 const Teuchos::ArrayView<const global_ordinal_type>& indices,
1929 std::function<void(const size_t, const size_t, const size_t)> fun) const;
1930
1942 void
1944 const global_ordinal_type gblColInds[],
1945 const local_ordinal_type numGblColInds);
1946
1958 void
1960 const global_ordinal_type gblColInds[],
1961 const local_ordinal_type numGblColInds);
1962
1967 static const bool useAtomicUpdatesByDefault =
1968#ifdef KOKKOS_ENABLE_SERIAL
1969 !std::is_same<execution_space, Kokkos::Serial>::value;
1970#else
1971 true;
1972#endif // KOKKOS_ENABLE_SERIAL
1973
1975
1977
1979 bool isMerged() const;
1980
1986 void setLocallyModified();
1987
1988 private:
1993 void
1994 sortAndMergeAllIndices(const bool sorted, const bool merged);
1995
1996 // mfh 08 May 2017: I only restore "protected" here for backwards
1997 // compatibility.
1998 protected:
2000
2010 void
2011 setDomainRangeMaps(const Teuchos::RCP<const map_type>& domainMap,
2012 const Teuchos::RCP<const map_type>& rangeMap);
2013
2014 void staticAssertions() const;
2015 void clearGlobalConstants();
2016
2017 public:
2020
2039
2040 bool haveLocalOffRankOffsets() const { return haveLocalOffRankOffsets_; }
2041
2042 protected:
2062 void computeLocalConstants();
2063
2066 RowInfo getRowInfo(const local_ordinal_type myRow) const;
2067
2080 RowInfo getRowInfoFromGlobalRowIndex(const global_ordinal_type gblRow) const;
2081
2082 public:
2091 local_graph_host_type getLocalGraphHost() const;
2092
2093 protected:
2094 void fillLocalGraph(const Teuchos::RCP<Teuchos::ParameterList>& params);
2095
2097 void checkInternalState() const;
2098
2102 void swap(CrsGraph<local_ordinal_type, global_ordinal_type, Node>& graph);
2103
2104 // Friend the tester for CrsGraph::swap
2105 friend class Tpetra::crsGraph_Swap_Tester<local_ordinal_type, global_ordinal_type, Node>;
2106
2108 Teuchos::RCP<const map_type> rowMap_;
2110 Teuchos::RCP<const map_type> colMap_;
2112 Teuchos::RCP<const map_type> rangeMap_;
2114 Teuchos::RCP<const map_type> domainMap_;
2115
2122 Teuchos::RCP<const import_type> importer_;
2123
2129 Teuchos::RCP<const export_type> exporter_;
2130
2136 Teuchos::OrdinalTraits<size_t>::invalid();
2137
2142 Teuchos::OrdinalTraits<global_size_t>::invalid();
2143
2149 Teuchos::OrdinalTraits<global_size_t>::invalid();
2150
2151 private:
2152 // Replacement for device view k_rowPtrs_
2153 // Device view rowPtrsUnpacked_dev_ takes place of k_rowPtrs_
2154 // Host view rowPtrsUnpacked_host_ takes place of copies and use of getEntryOnHost
2155 // Wish this could be a WrappedDualView, but deep_copies in DualView
2156 // don't work with const data views (e.g., StaticCrsGraph::row_map)
2157 // k_rowPtrs_ is offsets wrt the ALLOCATED indices array, not necessarily
2158 // the ACTUAL compressed indices array.
2159 // When !OptimizedStorage, k_rowPtrs_ may differ from ACTUAL compressed
2160 // indices array. (Karen is skeptical that !OptimizedStorage works)
2161 // When OptimizedStorage, rowPtrsUnpacked_ = k_rowPtrsPacked_
2162
2163 row_ptrs_device_view_type rowPtrsUnpacked_dev_;
2164 mutable row_ptrs_host_view_type rowPtrsUnpacked_host_;
2165
2166 // Row offsets into the actual graph local indices
2167 // Device view rowPtrsUnpacked_dev_ takes place of lclGraph_.row_map
2168
2169 row_ptrs_device_view_type rowPtrsPacked_dev_;
2170 mutable row_ptrs_host_view_type rowPtrsPacked_host_;
2171
2173 bool packedUnpackedRowPtrsMatch_ = false;
2174
2175 protected:
2176 void setRowPtrsUnpacked(const row_ptrs_device_view_type& dview) {
2177 packedUnpackedRowPtrsMatch_ = false;
2178 rowPtrsUnpacked_dev_ = dview;
2179 // Make sure stale host rowptrs are not kept
2180 rowPtrsUnpacked_host_ = row_ptrs_host_view_type();
2181 }
2182
2184 const row_ptrs_device_view_type& getRowPtrsUnpackedDevice() const {
2185 return rowPtrsUnpacked_dev_;
2186 }
2187
2189 const row_ptrs_host_view_type& getRowPtrsUnpackedHost() const {
2190 if (rowPtrsUnpacked_host_.extent(0) != rowPtrsUnpacked_dev_.extent(0)) {
2191 // NOTE: not just using create_mirror_view here, because
2192 // we do want host/device to be in different memory, even if we're using a SharedSpace.
2193 // This is so that reads will never trigger a host-device transfer.
2194 // The exception is when 'device' views are HostSpace, then don't make another copy.
2195 if constexpr (std::is_same_v<typename Node::memory_space, Kokkos::HostSpace>) {
2196 rowPtrsUnpacked_host_ = rowPtrsUnpacked_dev_;
2197 } else {
2198 // Have to make this temporary because rowptrs are const-valued
2199 typename row_ptrs_host_view_type::non_const_type rowPtrsTemp(
2200 Kokkos::view_alloc(Kokkos::WithoutInitializing, "rowPtrsUnpacked_host_"), rowPtrsUnpacked_dev_.extent(0));
2201 Kokkos::deep_copy(rowPtrsTemp, rowPtrsUnpacked_dev_);
2202 rowPtrsUnpacked_host_ = rowPtrsTemp;
2203 }
2204 // Also keep packed/unpacked views in sync, if they are known to have the same contents
2205 if (packedUnpackedRowPtrsMatch_) {
2206 rowPtrsPacked_host_ = rowPtrsUnpacked_host_;
2207 }
2208 }
2209 return rowPtrsUnpacked_host_;
2210 }
2211
2212 void setRowPtrsPacked(const row_ptrs_device_view_type& dview) {
2213 packedUnpackedRowPtrsMatch_ = false;
2214 rowPtrsPacked_dev_ = dview;
2215 // Make sure stale host rowptrs are not kept
2216 rowPtrsPacked_host_ = row_ptrs_host_view_type();
2217 }
2218
2220 const row_ptrs_device_view_type& getRowPtrsPackedDevice() const {
2221 return rowPtrsPacked_dev_;
2222 }
2223
2225 const row_ptrs_host_view_type& getRowPtrsPackedHost() const {
2226 if (rowPtrsPacked_host_.extent(0) != rowPtrsPacked_dev_.extent(0)) {
2227 // NOTE: not just using create_mirror_view here, because
2228 // we do want host/device to be in different memory, even if we're using a SharedSpace.
2229 // This is so that reads will never trigger a host-device transfer.
2230 // The exception is when 'device' views are HostSpace, then don't make another copy.
2231 if constexpr (std::is_same_v<typename Node::memory_space, Kokkos::HostSpace>) {
2232 rowPtrsPacked_host_ = rowPtrsPacked_dev_;
2233 } else {
2234 // Have to make this temporary because rowptrs are const-valued
2235 typename row_ptrs_host_view_type::non_const_type rowPtrsTemp(
2236 Kokkos::view_alloc(Kokkos::WithoutInitializing, "rowPtrsPacked_host_"), rowPtrsPacked_dev_.extent(0));
2237 Kokkos::deep_copy(rowPtrsTemp, rowPtrsPacked_dev_);
2238 rowPtrsPacked_host_ = rowPtrsTemp;
2239 }
2240 // Also keep packed/unpacked views in sync, if they are known to have the same contents
2241 if (packedUnpackedRowPtrsMatch_) {
2242 rowPtrsUnpacked_host_ = rowPtrsPacked_host_;
2243 }
2244 }
2245 return rowPtrsPacked_host_;
2246 }
2247
2248 // There are common cases where both packed and unpacked views are set to the same array.
2249 // Doing this in a single call can reduce dataspace on host, and reduce runtime by
2250 // removing a deep_copy from device to host.
2251
2252 void setRowPtrs(const row_ptrs_device_view_type& dview) {
2253 packedUnpackedRowPtrsMatch_ = true;
2254 rowPtrsUnpacked_dev_ = dview;
2255 rowPtrsPacked_dev_ = dview;
2256 // Make sure stale host rowptrs are not kept
2257 rowPtrsUnpacked_host_ = row_ptrs_host_view_type();
2258 rowPtrsPacked_host_ = row_ptrs_host_view_type();
2259 }
2260
2261 // TODO: Make private -- matrix shouldn't access directly the guts of graph
2262
2277
2292
2293 // TODO: Make private -- matrix shouldn't access directly the guts of graph
2294
2304
2305 // TODO: Make private -- matrix shouldn't access directly
2307
2311 typename local_inds_dualv_type::t_host::const_type
2312 getLocalIndsViewHost(const RowInfo& rowinfo) const;
2313
2317 typename local_inds_dualv_type::t_dev::const_type
2319
2323 typename global_inds_dualv_type::t_host::const_type
2325
2329 typename global_inds_dualv_type::t_dev::const_type
2331
2335 typename local_inds_dualv_type::t_host
2337
2338 // FOR NOW...
2339 // KEEP k_numRowEntries_ (though switch from host_mirror_type to Host)
2340 // KEEP k_numAllocPerRow_ (though perhaps switch from host_mirror_type to Host)
2341
2367 typename Kokkos::View<const size_t*, device_type>::host_mirror_type
2369
2380
2382
2383
2405
2413 typedef typename Kokkos::View<size_t*, Kokkos::LayoutLeft, device_type>::host_mirror_type num_row_entries_type;
2414
2415 // typedef Kokkos::View<
2416 // size_t*,
2417 // Kokkos::LayoutLeft,
2418 // Kokkos::Device<
2419 // typename Kokkos::View<
2420 // size_t*,
2421 // Kokkos::LayoutLeft,
2422 // device_type>::host_mirror_type::execution_space,
2423 // Kokkos::HostSpace> > num_row_entries_type;
2424
2432
2438 mutable offset_device_view_type k_offRankOffsets_;
2439
2441
2452 Details::STORAGE_1D_UNPACKED;
2453
2454 bool indicesAreAllocated_ = false;
2455 bool indicesAreLocal_ = false;
2456 bool indicesAreGlobal_ = false;
2457 bool fillComplete_ = false;
2458
2463 bool noRedundancies_ = true;
2469 mutable bool haveLocalOffRankOffsets_ = false;
2470
2471 typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type>> nonlocals_type;
2472
2474 nonlocals_type nonlocals_;
2475
2491
2492 private:
2494 static bool getDebug();
2495
2498 bool debug_ = getDebug();
2499
2501 static bool getVerbose();
2502
2506 bool verbose_ = getVerbose();
2507
2508 private:
2510 mutable bool need_sync_host_uvm_access = false;
2511
2513 void set_need_sync_host_uvm_access() {
2514 need_sync_host_uvm_access = true;
2515 }
2516
2518 void execute_sync_host_uvm_access() const {
2519 if (need_sync_host_uvm_access) {
2520 Kokkos::fence("CrsGraph::execute_sync_host_uvm_access");
2521 need_sync_host_uvm_access = false;
2522 }
2523 }
2524}; // class CrsGraph
2525
2533template <class LocalOrdinal, class GlobalOrdinal, class Node>
2534Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node>>
2536 const Teuchos::RCP<
2538 size_t maxNumEntriesPerRow = 0,
2539 const Teuchos::RCP<Teuchos::ParameterList>& params =
2540 Teuchos::null) {
2541 using Teuchos::rcp;
2544 params));
2545}
2546
2596template <class CrsGraphType>
2597Teuchos::RCP<CrsGraphType>
2598importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2599 const Import<typename CrsGraphType::local_ordinal_type,
2600 typename CrsGraphType::global_ordinal_type,
2601 typename CrsGraphType::node_type>& importer,
2602 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2603 typename CrsGraphType::global_ordinal_type,
2604 typename CrsGraphType::node_type>>& domainMap = Teuchos::null,
2605 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2606 typename CrsGraphType::global_ordinal_type,
2607 typename CrsGraphType::node_type>>& rangeMap = Teuchos::null,
2608 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
2609 Teuchos::RCP<CrsGraphType> destGraph;
2610 sourceGraph->importAndFillComplete(destGraph, importer, domainMap, rangeMap, params);
2611 return destGraph;
2612}
2613
2664template <class CrsGraphType>
2665Teuchos::RCP<CrsGraphType>
2666importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2667 const Import<typename CrsGraphType::local_ordinal_type,
2668 typename CrsGraphType::global_ordinal_type,
2669 typename CrsGraphType::node_type>& rowImporter,
2670 const Import<typename CrsGraphType::local_ordinal_type,
2671 typename CrsGraphType::global_ordinal_type,
2672 typename CrsGraphType::node_type>& domainImporter,
2673 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2674 typename CrsGraphType::global_ordinal_type,
2675 typename CrsGraphType::node_type>>& domainMap,
2676 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2677 typename CrsGraphType::global_ordinal_type,
2678 typename CrsGraphType::node_type>>& rangeMap,
2679 const Teuchos::RCP<Teuchos::ParameterList>& params) {
2680 Teuchos::RCP<CrsGraphType> destGraph;
2681 sourceGraph->importAndFillComplete(destGraph, rowImporter, domainImporter, domainMap, rangeMap, params);
2682 return destGraph;
2683}
2684
2718template <class CrsGraphType>
2719Teuchos::RCP<CrsGraphType>
2720exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2721 const Export<typename CrsGraphType::local_ordinal_type,
2722 typename CrsGraphType::global_ordinal_type,
2723 typename CrsGraphType::node_type>& exporter,
2724 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2725 typename CrsGraphType::global_ordinal_type,
2726 typename CrsGraphType::node_type>>& domainMap = Teuchos::null,
2727 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2728 typename CrsGraphType::global_ordinal_type,
2729 typename CrsGraphType::node_type>>& rangeMap = Teuchos::null,
2730 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
2731 Teuchos::RCP<CrsGraphType> destGraph;
2732 sourceGraph->exportAndFillComplete(destGraph, exporter, domainMap, rangeMap, params);
2733 return destGraph;
2734}
2735
2769template <class CrsGraphType>
2770Teuchos::RCP<CrsGraphType>
2771exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2772 const Export<typename CrsGraphType::local_ordinal_type,
2773 typename CrsGraphType::global_ordinal_type,
2774 typename CrsGraphType::node_type>& rowExporter,
2775 const Export<typename CrsGraphType::local_ordinal_type,
2776 typename CrsGraphType::global_ordinal_type,
2777 typename CrsGraphType::node_type>& domainExporter,
2778 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2779 typename CrsGraphType::global_ordinal_type,
2780 typename CrsGraphType::node_type>>& domainMap,
2781 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2782 typename CrsGraphType::global_ordinal_type,
2783 typename CrsGraphType::node_type>>& rangeMap,
2784 const Teuchos::RCP<Teuchos::ParameterList>& params) {
2785 Teuchos::RCP<CrsGraphType> destGraph;
2786 sourceGraph->exportAndFillComplete(destGraph, rowExporter, domainExporter, domainMap, rangeMap, params);
2787 return destGraph;
2788}
2789
2790} // namespace Tpetra
2791
2792#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 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.
void getLocalRowCopy(local_ordinal_type gblRow, nonconst_local_inds_host_view_type &gblColInds, size_t &numColInds) const override
Get a copy of the given row, using local indices.
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.