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
25#include "KokkosSparse_findRelOffset.hpp"
26#include "Kokkos_DualView.hpp"
27
28#include "Teuchos_CommHelpers.hpp"
29#include "Teuchos_Describable.hpp"
30#include "Teuchos_OrdinalTraits.hpp"
31#include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
32
33#include "KokkosSparse_StaticCrsGraph.hpp"
34
35#include <functional> // std::function
36#include <memory>
37
38namespace Tpetra {
39
40// Forward declaration for CrsGraph::swap() test
41template <class LocalOrdinal, class GlobalOrdinal, class Node>
42class crsGraph_Swap_Tester;
43
44#ifndef DOXYGEN_SHOULD_SKIP_THIS
45namespace Details {
46template <class LocalOrdinal,
47 class GlobalOrdinal>
48class CrsPadding;
49} // namespace Details
50
51namespace { // (anonymous)
52
53template <class ViewType>
54struct UnmanagedView {
55 static_assert(Kokkos::is_view<ViewType>::value,
56 "ViewType must be a Kokkos::View specialization.");
57 // FIXME (mfh 02 Dec 2015) Right now, this strips away other
58 // memory traits. Christian will add an "AllTraits" enum which is
59 // the enum value of MemoryTraits<T>, that will help us fix this.
60 typedef Kokkos::View<typename ViewType::data_type,
61 typename ViewType::array_layout,
62 typename ViewType::device_type,
63 Kokkos::MemoryUnmanaged>
64 type;
65};
66
67} // namespace
68#endif // DOXYGEN_SHOULD_SKIP_THIS
69
78struct RowInfo {
79 size_t localRow;
80 size_t allocSize;
81 size_t numEntries;
82 size_t offset1D;
83};
84
85enum ELocalGlobal {
86 LocalIndices,
87 GlobalIndices
88};
89
90namespace Details {
122 STORAGE_1D_UNPACKED, //<! 1-D "unpacked" storage
123 STORAGE_1D_PACKED, //<! 1-D "packed" storage
124 STORAGE_UB //<! Invalid value; upper bound on enum values
125};
126
127} // namespace Details
128
187template <class LocalOrdinal,
188 class GlobalOrdinal,
189 class Node>
190class CrsGraph : public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
191 public DistObject<GlobalOrdinal,
192 LocalOrdinal,
193 GlobalOrdinal,
194 Node>,
195 public Teuchos::ParameterListAcceptorDefaultBase {
196 template <class S, class LO, class GO, class N>
197 friend class CrsMatrix;
198 template <class LO2, class GO2, class N2>
199 friend class CrsGraph;
200 template <class LO, class GO, class N>
201 friend class FECrsGraph;
202
205
206 public:
212 using device_type = typename Node::device_type;
214 using execution_space = typename device_type::execution_space;
215
220 using node_type = Node;
221
224 KokkosSparse::StaticCrsGraph<local_ordinal_type, Kokkos::LayoutLeft,
225 device_type, void, size_t>;
226
228 using local_graph_host_type = typename local_graph_device_type::host_mirror_type;
229
236
237 public:
238 // Types used for CrsGraph's storage of local column indices
239 using local_inds_dualv_type =
240 Kokkos::DualView<local_ordinal_type*, device_type>;
241 using local_inds_wdv_type =
243
244 // Types used for CrsGraph's storage of global column indices
245 using global_inds_dualv_type =
246 Kokkos::DualView<global_ordinal_type*, device_type>;
249
250 public:
252 using row_ptrs_device_view_type =
253 typename row_graph_type::row_ptrs_device_view_type;
254 using row_ptrs_host_view_type =
255 typename row_graph_type::row_ptrs_host_view_type;
256
259 typename row_graph_type::local_inds_device_view_type;
260 using local_inds_host_view_type =
261 typename row_graph_type::local_inds_host_view_type;
262 using nonconst_local_inds_host_view_type =
263 typename row_graph_type::nonconst_local_inds_host_view_type;
264
267 typename row_graph_type::global_inds_device_view_type;
268 using global_inds_host_view_type =
269 typename row_graph_type::global_inds_host_view_type;
270 using nonconst_global_inds_host_view_type =
271 typename row_graph_type::nonconst_global_inds_host_view_type;
272
273 using offset_device_view_type =
274 typename row_ptrs_device_view_type::non_const_type;
275
277
278
291 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
292 const size_t maxNumEntriesPerRow,
293 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
294
307 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
308 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
309 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
310
324 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
325 const Teuchos::ArrayView<const size_t>& numEntPerRow,
326 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
327
340
344 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
345 const Teuchos::RCP<const map_type>& colMap,
346 const size_t maxNumEntriesPerRow,
347 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
348
363 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
364 const Teuchos::RCP<const map_type>& colMap,
365 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
366 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
367
383 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
384 const Teuchos::RCP<const map_type>& colMap,
385 const Teuchos::ArrayView<const size_t>& numEntPerRow,
386 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
387
400 const Teuchos::RCP<const map_type>& rowMap,
401 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
402
425 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
426 const Teuchos::RCP<const map_type>& colMap,
427 const typename local_graph_device_type::row_map_type& rowPointers,
428 const typename local_graph_device_type::entries_type::non_const_type& columnIndices,
429 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
430
453 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
454 const Teuchos::RCP<const map_type>& colMap,
455 const Teuchos::ArrayRCP<size_t>& rowPointers,
456 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices,
457 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
458
480 CrsGraph(const Teuchos::RCP<const map_type>& rowMap,
481 const Teuchos::RCP<const map_type>& colMap,
483 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
484
512 const Teuchos::RCP<const map_type>& rowMap,
513 const Teuchos::RCP<const map_type>& colMap,
514 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
515 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
516 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
517
523 const Teuchos::RCP<const map_type>& rowMap,
524 const Teuchos::RCP<const map_type>& colMap,
525 const Teuchos::RCP<const map_type>& domainMap,
526 const Teuchos::RCP<const map_type>& rangeMap,
527 const Teuchos::RCP<const import_type>& importer,
528 const Teuchos::RCP<const export_type>& exporter,
529 const Teuchos::RCP<Teuchos::ParameterList>& params =
530 Teuchos::null);
531
573 CrsGraph(const row_ptrs_device_view_type& rowPointers,
575 const Teuchos::RCP<const map_type>& rowMap,
576 const Teuchos::RCP<const map_type>& colMap,
577 const Teuchos::RCP<const map_type>& domainMap,
578 const Teuchos::RCP<const map_type>& rangeMap,
579 const Teuchos::RCP<const import_type>& importer,
580 const Teuchos::RCP<const export_type>& exporter,
581 const Teuchos::RCP<Teuchos::ParameterList>& params =
582 Teuchos::null);
583
586
589
592
595
605 virtual ~CrsGraph() = default;
606
634
652
654
656
658 void
659 setParameterList(const Teuchos::RCP<Teuchos::ParameterList>& params) override;
660
662 Teuchos::RCP<const Teuchos::ParameterList>
663 getValidParameters() const override;
664
666
668
690 void
692 const Teuchos::ArrayView<const global_ordinal_type>& indices);
693
700 void
703 const global_ordinal_type inds[]);
704
706
720 void
722 const Teuchos::ArrayView<const local_ordinal_type>& indices);
723
730 void
733 const local_ordinal_type inds[]);
734
736
746
748
750
758 void globalAssemble();
759
778 void
779 resumeFill(const Teuchos::RCP<Teuchos::ParameterList>& params =
780 Teuchos::null);
781
819 void
820 fillComplete(const Teuchos::RCP<const map_type>& domainMap,
821 const Teuchos::RCP<const map_type>& rangeMap,
822 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
823
851 void
852 fillComplete(const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
853
882 void
883 expertStaticFillComplete(const Teuchos::RCP<const map_type>& domainMap,
884 const Teuchos::RCP<const map_type>& rangeMap,
885 const Teuchos::RCP<const import_type>& importer =
886 Teuchos::null,
887 const Teuchos::RCP<const export_type>& exporter =
888 Teuchos::null,
889 const Teuchos::RCP<Teuchos::ParameterList>& params =
890 Teuchos::null);
892
894
896 Teuchos::RCP<const Teuchos::Comm<int>> getComm() const override;
897
899 Teuchos::RCP<const map_type> getRowMap() const override;
900
902 Teuchos::RCP<const map_type> getColMap() const override;
903
905 Teuchos::RCP<const map_type> getDomainMap() const override;
906
908 Teuchos::RCP<const map_type> getRangeMap() const override;
909
911 Teuchos::RCP<const import_type> getImporter() const override;
912
914 Teuchos::RCP<const export_type> getExporter() const override;
915
917
919 global_size_t getGlobalNumRows() const override;
920
922
925 global_size_t getGlobalNumCols() const override;
926
928 size_t getLocalNumRows() const override;
929
931
933 size_t getLocalNumCols() const override;
934
936 global_ordinal_type getIndexBase() const override;
937
939
941 global_size_t getGlobalNumEntries() const override;
942
952 size_t getLocalNumEntries() const override;
953
955
956 size_t
958
965 size_t
966 getNumEntriesInLocalRow(local_ordinal_type localRow) const override;
967
987 size_t getLocalAllocationSize() const;
988
997
1006
1020 size_t getGlobalMaxNumRowEntries() const override;
1021
1026 size_t getLocalMaxNumRowEntries() const override;
1027
1043 bool hasColMap() const override;
1044
1052 bool isLocallyIndexed() const override;
1053
1061 bool isGloballyIndexed() const override;
1062
1064 bool isFillComplete() const override;
1065
1067 bool isFillActive() const;
1068
1076 bool isSorted() const;
1077
1079
1085 bool isStorageOptimized() const;
1086
1092 void
1094 nonconst_global_inds_host_view_type& gblColInds,
1095 size_t& numColInds) const override;
1096
1104 void
1106 nonconst_local_inds_host_view_type& gblColInds,
1107 size_t& numColInds) const override;
1108
1119 void
1122 global_inds_host_view_type& gblColInds) const override;
1123
1126 bool supportsRowViews() const override;
1127
1138 void
1140 const LocalOrdinal lclRow,
1141 local_inds_host_view_type& lclColInds) const override;
1142
1144
1146
1148 std::string description() const override;
1149
1152 void
1153 describe(Teuchos::FancyOStream& out,
1154 const Teuchos::EVerbosityLevel verbLevel =
1155 Teuchos::Describable::verbLevel_default) const override;
1156
1158
1160
1168
1169 virtual bool
1170 checkSizes(const SrcDistObject& source) override;
1171
1172 using dist_object_type::
1175
1176 virtual void
1178 const size_t numSameIDs,
1179 const Kokkos::DualView<const local_ordinal_type*,
1181 const Kokkos::DualView<const local_ordinal_type*,
1183 const CombineMode CM) override;
1184
1185 void copyAndPermuteNew(
1186 const row_graph_type& source,
1188 const size_t numSameIDs,
1189 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1190 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
1191 const CombineMode CM);
1192
1193 void insertGlobalIndicesDevice(
1196 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1197 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
1199
1202
1203 void
1204 applyCrsPadding(const padding_type& padding,
1205 const bool verbose);
1206
1207 std::unique_ptr<padding_type>
1208 computeCrsPadding(
1210 node_type>& source,
1211 const size_t numSameIDs,
1212 const Kokkos::DualView<const local_ordinal_type*,
1214 const Kokkos::DualView<const local_ordinal_type*,
1216 const bool verbose) const;
1217
1218 // This actually modifies imports by sorting it.
1219 std::unique_ptr<padding_type>
1220 computeCrsPaddingForImports(
1221 const Kokkos::DualView<const local_ordinal_type*,
1223 Kokkos::DualView<packet_type*, buffer_device_type> imports,
1224 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1225 const bool verbose) const;
1226
1227 std::unique_ptr<padding_type>
1228 computePaddingForCrsMatrixUnpack(
1229 const Kokkos::DualView<const local_ordinal_type*,
1231 Kokkos::DualView<char*, buffer_device_type> imports,
1232 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1233 const bool verbose) const;
1234
1235 void
1236 computeCrsPaddingForSameIDs(
1239 node_type>& source,
1240 const local_ordinal_type numSameIDs) const;
1241
1242 void
1243 computeCrsPaddingForPermutedIDs(
1246 node_type>& source,
1247 const Kokkos::DualView<const local_ordinal_type*,
1249 const Kokkos::DualView<const local_ordinal_type*,
1251
1252 virtual void
1253 packAndPrepare(
1254 const SrcDistObject& source,
1255 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
1256 Kokkos::DualView<packet_type*, buffer_device_type>& exports,
1257 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1258 size_t& constantNumPackets) override;
1259
1264
1265 virtual void
1266 pack(const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1267 Teuchos::Array<global_ordinal_type>& exports,
1268 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1269 size_t& constantNumPackets) const override;
1270
1271 void
1272 packFillActive(const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1273 Teuchos::Array<global_ordinal_type>& exports,
1274 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1275 size_t& constantNumPackets) const;
1276
1277 void
1278 packFillActiveNew(const Kokkos::DualView<const local_ordinal_type*,
1280 Kokkos::DualView<packet_type*,
1281 buffer_device_type>& exports,
1282 Kokkos::DualView<size_t*,
1285 size_t& constantNumPackets) const;
1286
1291
1292 virtual void
1293 unpackAndCombine(const Kokkos::DualView<const local_ordinal_type*,
1295 Kokkos::DualView<packet_type*,
1297 imports,
1298 Kokkos::DualView<size_t*,
1301 const size_t constantNumPackets,
1302 const CombineMode combineMode) override;
1303
1305
1307
1350 void
1351 getLocalDiagOffsets(const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets) const;
1352
1354 void
1355 getLocalOffRankOffsets(offset_device_view_type& offsets) const;
1356
1366 void
1367 getLocalDiagOffsets(Teuchos::ArrayRCP<size_t>& offsets) const;
1368
1378 void
1379 setAllIndices(const typename local_graph_device_type::row_map_type& rowPointers,
1380 const typename local_graph_device_type::entries_type::non_const_type& columnIndices);
1381
1391 void
1392 setAllIndices(const Teuchos::ArrayRCP<size_t>& rowPointers,
1393 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices);
1394
1397 row_ptrs_host_view_type getLocalRowPtrsHost() const;
1398
1401 row_ptrs_device_view_type getLocalRowPtrsDevice() const;
1402
1404 local_inds_host_view_type getLocalIndicesHost() const;
1405
1408
1427 void replaceColMap(const Teuchos::RCP<const map_type>& newColMap);
1428
1448 void
1449 reindexColumns(const Teuchos::RCP<const map_type>& newColMap,
1450 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1451 const bool sortIndicesInEachRow = true);
1452
1459 void
1460 replaceDomainMap(const Teuchos::RCP<const map_type>& newDomainMap);
1461
1475 void
1476 replaceDomainMapAndImporter(const Teuchos::RCP<const map_type>& newDomainMap,
1477 const Teuchos::RCP<const import_type>& newImporter);
1478
1485 void
1486 replaceRangeMap(const Teuchos::RCP<const map_type>& newRangeMap);
1487
1501 void
1502 replaceRangeMapAndExporter(const Teuchos::RCP<const map_type>& newRangeMap,
1503 const Teuchos::RCP<const export_type>& newExporter);
1504
1533 virtual void
1534 removeEmptyProcessesInPlace(const Teuchos::RCP<const map_type>& newMap) override;
1536
1537 template <class DestViewType, class SrcViewType,
1539 struct pack_functor {
1540 typedef typename DestViewType::execution_space execution_space;
1541 SrcViewType src;
1542 DestViewType dest;
1543 SrcOffsetViewType src_offset;
1544 DestOffsetViewType dest_offset;
1545 typedef typename DestOffsetViewType::non_const_value_type ScalarIndx;
1546
1547 pack_functor(DestViewType dest_,
1548 const SrcViewType src_,
1550 const SrcOffsetViewType src_offset_)
1551 : src(src_)
1552 , dest(dest_)
1553 , src_offset(src_offset_)
1554 , dest_offset(dest_offset_){};
1555
1557 void operator()(size_t row) const {
1558 ScalarIndx i = src_offset(row);
1559 ScalarIndx j = dest_offset(row);
1560 const ScalarIndx k = dest_offset(row + 1);
1561 for (; j < k; j++, i++) {
1562 dest(j) = src(i);
1563 }
1564 }
1565 };
1566
1567 private:
1568 // Friend declaration for nonmember function.
1569 template <class CrsGraphType>
1570 friend Teuchos::RCP<CrsGraphType>
1571 importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1572 const Import<typename CrsGraphType::local_ordinal_type,
1573 typename CrsGraphType::global_ordinal_type,
1574 typename CrsGraphType::node_type>& importer,
1575 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1576 typename CrsGraphType::global_ordinal_type,
1577 typename CrsGraphType::node_type>>& domainMap,
1578 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1579 typename CrsGraphType::global_ordinal_type,
1580 typename CrsGraphType::node_type>>& rangeMap,
1581 const Teuchos::RCP<Teuchos::ParameterList>& params);
1582
1583 // Friend declaration for nonmember function.
1584 template <class CrsGraphType>
1585 friend Teuchos::RCP<CrsGraphType>
1586 importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1587 const Import<typename CrsGraphType::local_ordinal_type,
1588 typename CrsGraphType::global_ordinal_type,
1589 typename CrsGraphType::node_type>& rowImporter,
1590 const Import<typename CrsGraphType::local_ordinal_type,
1591 typename CrsGraphType::global_ordinal_type,
1592 typename CrsGraphType::node_type>& domainImporter,
1593 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1594 typename CrsGraphType::global_ordinal_type,
1595 typename CrsGraphType::node_type>>& domainMap,
1596 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1597 typename CrsGraphType::global_ordinal_type,
1598 typename CrsGraphType::node_type>>& rangeMap,
1599 const Teuchos::RCP<Teuchos::ParameterList>& params);
1600
1601 // Friend declaration for nonmember function.
1602 template <class CrsGraphType>
1603 friend Teuchos::RCP<CrsGraphType>
1604 exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1605 const Export<typename CrsGraphType::local_ordinal_type,
1606 typename CrsGraphType::global_ordinal_type,
1607 typename CrsGraphType::node_type>& exporter,
1608 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1609 typename CrsGraphType::global_ordinal_type,
1610 typename CrsGraphType::node_type>>& domainMap,
1611 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1612 typename CrsGraphType::global_ordinal_type,
1613 typename CrsGraphType::node_type>>& rangeMap,
1614 const Teuchos::RCP<Teuchos::ParameterList>& params);
1615
1616 // Friend declaration for nonmember function.
1617 template <class CrsGraphType>
1618 friend Teuchos::RCP<CrsGraphType>
1619 exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1620 const Export<typename CrsGraphType::local_ordinal_type,
1621 typename CrsGraphType::global_ordinal_type,
1622 typename CrsGraphType::node_type>& rowExporter,
1623 const Export<typename CrsGraphType::local_ordinal_type,
1624 typename CrsGraphType::global_ordinal_type,
1625 typename CrsGraphType::node_type>& domainExporter,
1626 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1627 typename CrsGraphType::global_ordinal_type,
1628 typename CrsGraphType::node_type>>& domainMap,
1629 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1630 typename CrsGraphType::global_ordinal_type,
1631 typename CrsGraphType::node_type>>& rangeMap,
1632 const Teuchos::RCP<Teuchos::ParameterList>& params);
1633
1634 public:
1650 void
1651 importAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1652 const import_type& importer,
1653 const Teuchos::RCP<const map_type>& domainMap,
1654 const Teuchos::RCP<const map_type>& rangeMap,
1655 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1656
1672 void
1673 importAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1674 const import_type& rowImporter,
1675 const import_type& domainImporter,
1676 const Teuchos::RCP<const map_type>& domainMap,
1677 const Teuchos::RCP<const map_type>& rangeMap,
1678 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1679
1695 void
1696 exportAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1697 const export_type& exporter,
1698 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1699 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1700 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1701
1717 void
1718 exportAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1719 const export_type& rowExporter,
1720 const export_type& domainExporter,
1721 const Teuchos::RCP<const map_type>& domainMap,
1722 const Teuchos::RCP<const map_type>& rangeMap,
1723 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1724
1725 private:
1746 void
1747 transferAndFillComplete(Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node>>& destGraph,
1748 const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>& rowTransfer,
1749 const Teuchos::RCP<const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>>& domainTransfer,
1750 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1751 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1752 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1753
1754 protected:
1755 // these structs are conveniences, to cut down on the number of
1756 // arguments to some of the methods below.
1757 struct SLocalGlobalViews {
1758 Teuchos::ArrayView<const global_ordinal_type> ginds;
1759 Teuchos::ArrayView<const local_ordinal_type> linds;
1760 };
1761 struct SLocalGlobalNCViews {
1762 Teuchos::ArrayView<global_ordinal_type> ginds;
1763 Teuchos::ArrayView<local_ordinal_type> linds;
1764 };
1765
1766 bool indicesAreAllocated() const;
1767
1768 void
1769 allocateIndices(const ELocalGlobal lg, const bool verbose = false);
1770
1772
1773
1783 void makeColMap(Teuchos::Array<int>& remotePIDs);
1784
1805 std::pair<size_t, std::string>
1806 makeIndicesLocal(const bool verbose = false);
1807
1816 void
1817 makeImportExport(Teuchos::Array<int>& remotePIDs,
1818 const bool useRemotePIDs);
1819
1821
1823
1858 size_t
1859 insertIndices(RowInfo& rowInfo,
1860 const SLocalGlobalViews& newInds,
1861 const ELocalGlobal lg,
1862 const ELocalGlobal I);
1863
1873 size_t
1875 const global_ordinal_type inputGblColInds[],
1876 const size_t numInputInds);
1877
1887 size_t
1888 insertGlobalIndicesImpl(const RowInfo& rowInfo,
1889 const global_ordinal_type inputGblColInds[],
1890 const size_t numInputInds,
1891 std::function<void(const size_t, const size_t, const size_t)> fun =
1892 std::function<void(const size_t, const size_t, const size_t)>());
1893
1894 void
1895 insertLocalIndicesImpl(const local_ordinal_type lclRow,
1896 const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
1897 std::function<void(const size_t, const size_t, const size_t)> fun =
1898 std::function<void(const size_t, const size_t, const size_t)>());
1899
1915 size_t
1916 findGlobalIndices(const RowInfo& rowInfo,
1917 const Teuchos::ArrayView<const global_ordinal_type>& indices,
1918 std::function<void(const size_t, const size_t, const size_t)> fun) const;
1919
1931 void
1933 const global_ordinal_type gblColInds[],
1934 const local_ordinal_type numGblColInds);
1935
1947 void
1949 const global_ordinal_type gblColInds[],
1950 const local_ordinal_type numGblColInds);
1951
1956 static const bool useAtomicUpdatesByDefault =
1957#ifdef KOKKOS_ENABLE_SERIAL
1958 !std::is_same<execution_space, Kokkos::Serial>::value;
1959#else
1960 true;
1961#endif // KOKKOS_ENABLE_SERIAL
1962
1964
1966
1968 bool isMerged() const;
1969
1975 void setLocallyModified();
1976
1977 private:
1982 void
1983 sortAndMergeAllIndices(const bool sorted, const bool merged);
1984
1985 // mfh 08 May 2017: I only restore "protected" here for backwards
1986 // compatibility.
1987 protected:
1989
1999 void
2000 setDomainRangeMaps(const Teuchos::RCP<const map_type>& domainMap,
2001 const Teuchos::RCP<const map_type>& rangeMap);
2002
2003 void staticAssertions() const;
2004 void clearGlobalConstants();
2005
2006 public:
2009
2028
2029 bool haveLocalOffRankOffsets() const { return haveLocalOffRankOffsets_; }
2030
2031 protected:
2051 void computeLocalConstants();
2052
2055 RowInfo getRowInfo(const local_ordinal_type myRow) const;
2056
2069 RowInfo getRowInfoFromGlobalRowIndex(const global_ordinal_type gblRow) const;
2070
2071 public:
2080 local_graph_host_type getLocalGraphHost() const;
2081
2082 protected:
2083 void fillLocalGraph(const Teuchos::RCP<Teuchos::ParameterList>& params);
2084
2086 void checkInternalState() const;
2087
2091 void swap(CrsGraph<local_ordinal_type, global_ordinal_type, Node>& graph);
2092
2093 // Friend the tester for CrsGraph::swap
2094 friend class Tpetra::crsGraph_Swap_Tester<local_ordinal_type, global_ordinal_type, Node>;
2095
2097 Teuchos::RCP<const map_type> rowMap_;
2099 Teuchos::RCP<const map_type> colMap_;
2101 Teuchos::RCP<const map_type> rangeMap_;
2103 Teuchos::RCP<const map_type> domainMap_;
2104
2111 Teuchos::RCP<const import_type> importer_;
2112
2118 Teuchos::RCP<const export_type> exporter_;
2119
2125 Teuchos::OrdinalTraits<size_t>::invalid();
2126
2131 Teuchos::OrdinalTraits<global_size_t>::invalid();
2132
2138 Teuchos::OrdinalTraits<global_size_t>::invalid();
2139
2140 private:
2141 // Replacement for device view k_rowPtrs_
2142 // Device view rowPtrsUnpacked_dev_ takes place of k_rowPtrs_
2143 // Host view rowPtrsUnpacked_host_ takes place of copies and use of getEntryOnHost
2144 // Wish this could be a WrappedDualView, but deep_copies in DualView
2145 // don't work with const data views (e.g., StaticCrsGraph::row_map)
2146 // k_rowPtrs_ is offsets wrt the ALLOCATED indices array, not necessarily
2147 // the ACTUAL compressed indices array.
2148 // When !OptimizedStorage, k_rowPtrs_ may differ from ACTUAL compressed
2149 // indices array. (Karen is skeptical that !OptimizedStorage works)
2150 // When OptimizedStorage, rowPtrsUnpacked_ = k_rowPtrsPacked_
2151
2152 row_ptrs_device_view_type rowPtrsUnpacked_dev_;
2153 mutable row_ptrs_host_view_type rowPtrsUnpacked_host_;
2154
2155 // Row offsets into the actual graph local indices
2156 // Device view rowPtrsUnpacked_dev_ takes place of lclGraph_.row_map
2157
2158 row_ptrs_device_view_type rowPtrsPacked_dev_;
2159 mutable row_ptrs_host_view_type rowPtrsPacked_host_;
2160
2162 bool packedUnpackedRowPtrsMatch_ = false;
2163
2164 protected:
2165 void setRowPtrsUnpacked(const row_ptrs_device_view_type& dview) {
2166 packedUnpackedRowPtrsMatch_ = false;
2167 rowPtrsUnpacked_dev_ = dview;
2168 // Make sure stale host rowptrs are not kept
2169 rowPtrsUnpacked_host_ = row_ptrs_host_view_type();
2170 }
2171
2173 const row_ptrs_device_view_type& getRowPtrsUnpackedDevice() const {
2174 return rowPtrsUnpacked_dev_;
2175 }
2176
2178 const row_ptrs_host_view_type& getRowPtrsUnpackedHost() const {
2179 if (rowPtrsUnpacked_host_.extent(0) != rowPtrsUnpacked_dev_.extent(0)) {
2180 // NOTE: not just using create_mirror_view here, because
2181 // we do want host/device to be in different memory, even if we're using a SharedSpace.
2182 // This is so that reads will never trigger a host-device transfer.
2183 // The exception is when 'device' views are HostSpace, then don't make another copy.
2184 if constexpr (std::is_same_v<typename Node::memory_space, Kokkos::HostSpace>) {
2185 rowPtrsUnpacked_host_ = rowPtrsUnpacked_dev_;
2186 } else {
2187 // Have to make this temporary because rowptrs are const-valued
2188 typename row_ptrs_host_view_type::non_const_type rowPtrsTemp(
2189 Kokkos::view_alloc(Kokkos::WithoutInitializing, "rowPtrsUnpacked_host_"), rowPtrsUnpacked_dev_.extent(0));
2190 Kokkos::deep_copy(rowPtrsTemp, rowPtrsUnpacked_dev_);
2191 rowPtrsUnpacked_host_ = rowPtrsTemp;
2192 }
2193 // Also keep packed/unpacked views in sync, if they are known to have the same contents
2194 if (packedUnpackedRowPtrsMatch_) {
2195 rowPtrsPacked_host_ = rowPtrsUnpacked_host_;
2196 }
2197 }
2198 return rowPtrsUnpacked_host_;
2199 }
2200
2201 void setRowPtrsPacked(const row_ptrs_device_view_type& dview) {
2202 packedUnpackedRowPtrsMatch_ = false;
2203 rowPtrsPacked_dev_ = dview;
2204 // Make sure stale host rowptrs are not kept
2205 rowPtrsPacked_host_ = row_ptrs_host_view_type();
2206 }
2207
2209 const row_ptrs_device_view_type& getRowPtrsPackedDevice() const {
2210 return rowPtrsPacked_dev_;
2211 }
2212
2214 const row_ptrs_host_view_type& getRowPtrsPackedHost() const {
2215 if (rowPtrsPacked_host_.extent(0) != rowPtrsPacked_dev_.extent(0)) {
2216 // NOTE: not just using create_mirror_view here, because
2217 // we do want host/device to be in different memory, even if we're using a SharedSpace.
2218 // This is so that reads will never trigger a host-device transfer.
2219 // The exception is when 'device' views are HostSpace, then don't make another copy.
2220 if constexpr (std::is_same_v<typename Node::memory_space, Kokkos::HostSpace>) {
2221 rowPtrsPacked_host_ = rowPtrsPacked_dev_;
2222 } else {
2223 // Have to make this temporary because rowptrs are const-valued
2224 typename row_ptrs_host_view_type::non_const_type rowPtrsTemp(
2225 Kokkos::view_alloc(Kokkos::WithoutInitializing, "rowPtrsPacked_host_"), rowPtrsPacked_dev_.extent(0));
2226 Kokkos::deep_copy(rowPtrsTemp, rowPtrsPacked_dev_);
2227 rowPtrsPacked_host_ = rowPtrsTemp;
2228 }
2229 // Also keep packed/unpacked views in sync, if they are known to have the same contents
2230 if (packedUnpackedRowPtrsMatch_) {
2231 rowPtrsUnpacked_host_ = rowPtrsPacked_host_;
2232 }
2233 }
2234 return rowPtrsPacked_host_;
2235 }
2236
2237 // There are common cases where both packed and unpacked views are set to the same array.
2238 // Doing this in a single call can reduce dataspace on host, and reduce runtime by
2239 // removing a deep_copy from device to host.
2240
2241 void setRowPtrs(const row_ptrs_device_view_type& dview) {
2242 packedUnpackedRowPtrsMatch_ = true;
2243 rowPtrsUnpacked_dev_ = dview;
2244 rowPtrsPacked_dev_ = dview;
2245 // Make sure stale host rowptrs are not kept
2246 rowPtrsUnpacked_host_ = row_ptrs_host_view_type();
2247 rowPtrsPacked_host_ = row_ptrs_host_view_type();
2248 }
2249
2250 // TODO: Make private -- matrix shouldn't access directly the guts of graph
2251
2266
2281
2282 // TODO: Make private -- matrix shouldn't access directly the guts of graph
2283
2293
2294 // TODO: Make private -- matrix shouldn't access directly
2296
2300 typename local_inds_dualv_type::t_host::const_type
2301 getLocalIndsViewHost(const RowInfo& rowinfo) const;
2302
2306 typename local_inds_dualv_type::t_dev::const_type
2308
2312 typename global_inds_dualv_type::t_host::const_type
2314
2318 typename global_inds_dualv_type::t_dev::const_type
2320
2324 typename local_inds_dualv_type::t_host
2326
2327 // FOR NOW...
2328 // KEEP k_numRowEntries_ (though switch from host_mirror_type to Host)
2329 // KEEP k_numAllocPerRow_ (though perhaps switch from host_mirror_type to Host)
2330
2356 typename Kokkos::View<const size_t*, device_type>::host_mirror_type
2358
2369
2371
2372
2394
2402 typedef typename Kokkos::View<size_t*, Kokkos::LayoutLeft, device_type>::host_mirror_type num_row_entries_type;
2403
2404 // typedef Kokkos::View<
2405 // size_t*,
2406 // Kokkos::LayoutLeft,
2407 // Kokkos::Device<
2408 // typename Kokkos::View<
2409 // size_t*,
2410 // Kokkos::LayoutLeft,
2411 // device_type>::host_mirror_type::execution_space,
2412 // Kokkos::HostSpace> > num_row_entries_type;
2413
2421
2427 mutable offset_device_view_type k_offRankOffsets_;
2428
2430
2441 Details::STORAGE_1D_UNPACKED;
2442
2443 bool indicesAreAllocated_ = false;
2444 bool indicesAreLocal_ = false;
2445 bool indicesAreGlobal_ = false;
2446 bool fillComplete_ = false;
2447
2452 bool noRedundancies_ = true;
2458 mutable bool haveLocalOffRankOffsets_ = false;
2459
2460 typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type>> nonlocals_type;
2461
2463 nonlocals_type nonlocals_;
2464
2480
2481 private:
2483 static bool getDebug();
2484
2487 bool debug_ = getDebug();
2488
2490 static bool getVerbose();
2491
2495 bool verbose_ = getVerbose();
2496
2497 private:
2499 mutable bool need_sync_host_uvm_access = false;
2500
2502 void set_need_sync_host_uvm_access() {
2503 need_sync_host_uvm_access = true;
2504 }
2505
2507 void execute_sync_host_uvm_access() const {
2508 if (need_sync_host_uvm_access) {
2509 Kokkos::fence("CrsGraph::execute_sync_host_uvm_access");
2510 need_sync_host_uvm_access = false;
2511 }
2512 }
2513}; // class CrsGraph
2514
2522template <class LocalOrdinal, class GlobalOrdinal, class Node>
2523Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node>>
2525 const Teuchos::RCP<
2527 size_t maxNumEntriesPerRow = 0,
2528 const Teuchos::RCP<Teuchos::ParameterList>& params =
2529 Teuchos::null) {
2530 using Teuchos::rcp;
2533 params));
2534}
2535
2585template <class CrsGraphType>
2586Teuchos::RCP<CrsGraphType>
2587importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2588 const Import<typename CrsGraphType::local_ordinal_type,
2589 typename CrsGraphType::global_ordinal_type,
2590 typename CrsGraphType::node_type>& importer,
2591 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2592 typename CrsGraphType::global_ordinal_type,
2593 typename CrsGraphType::node_type>>& domainMap = Teuchos::null,
2594 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2595 typename CrsGraphType::global_ordinal_type,
2596 typename CrsGraphType::node_type>>& rangeMap = Teuchos::null,
2597 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
2598 Teuchos::RCP<CrsGraphType> destGraph;
2599 sourceGraph->importAndFillComplete(destGraph, importer, domainMap, rangeMap, params);
2600 return destGraph;
2601}
2602
2653template <class CrsGraphType>
2654Teuchos::RCP<CrsGraphType>
2655importAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2656 const Import<typename CrsGraphType::local_ordinal_type,
2657 typename CrsGraphType::global_ordinal_type,
2658 typename CrsGraphType::node_type>& rowImporter,
2659 const Import<typename CrsGraphType::local_ordinal_type,
2660 typename CrsGraphType::global_ordinal_type,
2661 typename CrsGraphType::node_type>& domainImporter,
2662 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2663 typename CrsGraphType::global_ordinal_type,
2664 typename CrsGraphType::node_type>>& domainMap,
2665 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2666 typename CrsGraphType::global_ordinal_type,
2667 typename CrsGraphType::node_type>>& rangeMap,
2668 const Teuchos::RCP<Teuchos::ParameterList>& params) {
2669 Teuchos::RCP<CrsGraphType> destGraph;
2670 sourceGraph->importAndFillComplete(destGraph, rowImporter, domainImporter, domainMap, rangeMap, params);
2671 return destGraph;
2672}
2673
2707template <class CrsGraphType>
2708Teuchos::RCP<CrsGraphType>
2709exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2710 const Export<typename CrsGraphType::local_ordinal_type,
2711 typename CrsGraphType::global_ordinal_type,
2712 typename CrsGraphType::node_type>& exporter,
2713 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2714 typename CrsGraphType::global_ordinal_type,
2715 typename CrsGraphType::node_type>>& domainMap = Teuchos::null,
2716 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2717 typename CrsGraphType::global_ordinal_type,
2718 typename CrsGraphType::node_type>>& rangeMap = Teuchos::null,
2719 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) {
2720 Teuchos::RCP<CrsGraphType> destGraph;
2721 sourceGraph->exportAndFillComplete(destGraph, exporter, domainMap, rangeMap, params);
2722 return destGraph;
2723}
2724
2758template <class CrsGraphType>
2759Teuchos::RCP<CrsGraphType>
2760exportAndFillCompleteCrsGraph(const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2761 const Export<typename CrsGraphType::local_ordinal_type,
2762 typename CrsGraphType::global_ordinal_type,
2763 typename CrsGraphType::node_type>& rowExporter,
2764 const Export<typename CrsGraphType::local_ordinal_type,
2765 typename CrsGraphType::global_ordinal_type,
2766 typename CrsGraphType::node_type>& domainExporter,
2767 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2768 typename CrsGraphType::global_ordinal_type,
2769 typename CrsGraphType::node_type>>& domainMap,
2770 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2771 typename CrsGraphType::global_ordinal_type,
2772 typename CrsGraphType::node_type>>& rangeMap,
2773 const Teuchos::RCP<Teuchos::ParameterList>& params) {
2774 Teuchos::RCP<CrsGraphType> destGraph;
2775 sourceGraph->exportAndFillComplete(destGraph, rowExporter, domainExporter, domainMap, rangeMap, params);
2776 return destGraph;
2777}
2778
2779} // namespace Tpetra
2780
2781#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.
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.