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//
4// Tpetra: Templated Linear Algebra Services Package
5// Copyright (2008) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// ************************************************************************
38// @HEADER
39
40#ifndef TPETRA_CRSGRAPH_DECL_HPP
41#define TPETRA_CRSGRAPH_DECL_HPP
42
45
49#include "Tpetra_DistObject.hpp"
50#include "Tpetra_Exceptions.hpp"
51#include "Tpetra_RowGraph.hpp"
52#include "Tpetra_Util.hpp" // need this here for sort2
53#include "Tpetra_Details_WrappedDualView.hpp"
54
55#include "KokkosSparse_findRelOffset.hpp"
56#include "Kokkos_DualView.hpp"
57#include "Kokkos_StaticCrsGraph.hpp"
58
59#include "Teuchos_CommHelpers.hpp"
60#include "Teuchos_Describable.hpp"
61#include "Teuchos_OrdinalTraits.hpp"
62#include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
63
64#include <functional> // std::function
65#include <memory>
66
67namespace Tpetra {
68
69
70 // Forward declaration for CrsGraph::swap() test
71 template<class LocalOrdinal, class GlobalOrdinal, class Node> class crsGraph_Swap_Tester;
72
73#ifndef DOXYGEN_SHOULD_SKIP_THIS
74 namespace Details {
75 template<class LocalOrdinal,
76 class GlobalOrdinal>
77 class CrsPadding;
78 } // namespace Details
79
80 namespace { // (anonymous)
81
82 template<class ViewType>
83 struct UnmanagedView {
84 static_assert (Kokkos::is_view<ViewType>::value,
85 "ViewType must be a Kokkos::View specialization.");
86 // FIXME (mfh 02 Dec 2015) Right now, this strips away other
87 // memory traits. Christian will add an "AllTraits" enum which is
88 // the enum value of MemoryTraits<T>, that will help us fix this.
89 typedef Kokkos::View<typename ViewType::data_type,
90 typename ViewType::array_layout,
91 typename ViewType::device_type,
92 Kokkos::MemoryUnmanaged> type;
93 };
94
95 } // namespace (anonymous)
96#endif // DOXYGEN_SHOULD_SKIP_THIS
97
106 struct RowInfo {
107 size_t localRow;
108 size_t allocSize;
109 size_t numEntries;
110 size_t offset1D;
111 };
112
113 enum ELocalGlobal {
114 LocalIndices,
115 GlobalIndices
116 };
117
118 namespace Details {
150 STORAGE_1D_UNPACKED, //<! 1-D "unpacked" storage
151 STORAGE_1D_PACKED, //<! 1-D "packed" storage
152 STORAGE_UB //<! Invalid value; upper bound on enum values
153 };
154
155 } // namespace Details
156
215 template <class LocalOrdinal,
216 class GlobalOrdinal,
217 class Node>
218 class CrsGraph :
219 public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
220 public DistObject<GlobalOrdinal,
221 LocalOrdinal,
222 GlobalOrdinal,
223 Node>,
224 public Teuchos::ParameterListAcceptorDefaultBase
225 {
226 template <class S, class LO, class GO, class N>
227 friend class CrsMatrix;
228 template <class LO2, class GO2, class N2>
229 friend class CrsGraph;
230 template <class LO, class GO, class N>
231 friend class FECrsGraph;
232
235
236 public:
238 using local_ordinal_type = LocalOrdinal;
240 using global_ordinal_type = GlobalOrdinal;
242 using device_type = typename Node::device_type;
244 using execution_space = typename device_type::execution_space;
245
250 using node_type = Node;
251
254 Kokkos::StaticCrsGraph<local_ordinal_type, Kokkos::LayoutLeft,
255 device_type, void, size_t>;
256
258 using local_graph_host_type = typename local_graph_device_type::HostMirror;
259
266
267protected:
268 // Types used for CrsGraph's storage of local column indices
269 using local_inds_dualv_type =
270 Kokkos::DualView<local_ordinal_type*, device_type>;
271 using local_inds_wdv_type =
272 Details::WrappedDualView<local_inds_dualv_type>;
273
274 // Types used for CrsGraph's storage of global column indices
275 using global_inds_dualv_type =
276 Kokkos::DualView<global_ordinal_type*, device_type>;
277 using global_inds_wdv_type =
278 Details::WrappedDualView<global_inds_dualv_type>;
279
280public:
282 using row_ptrs_device_view_type =
283 typename row_graph_type::row_ptrs_device_view_type;
284 using row_ptrs_host_view_type =
285 typename row_graph_type::row_ptrs_host_view_type;
286
289 typename row_graph_type::local_inds_device_view_type;
290 using local_inds_host_view_type =
291 typename row_graph_type::local_inds_host_view_type;
292 using nonconst_local_inds_host_view_type =
293 typename row_graph_type::nonconst_local_inds_host_view_type;
294
297 typename row_graph_type::global_inds_device_view_type;
298 using global_inds_host_view_type =
299 typename row_graph_type::global_inds_host_view_type;
300 using nonconst_global_inds_host_view_type =
301 typename row_graph_type::nonconst_global_inds_host_view_type;
302
303 using offset_device_view_type =
304 typename row_ptrs_device_view_type::non_const_type;
305
307
308
321 CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
322 const size_t maxNumEntriesPerRow,
323 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
324
337 CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
338 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
339 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
340
354 CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
355 const Teuchos::ArrayView<const size_t>& numEntPerRow,
356 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
357
358
371
375 CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
376 const Teuchos::RCP<const map_type>& colMap,
377 const size_t maxNumEntriesPerRow,
378 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
379
394 CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
395 const Teuchos::RCP<const map_type>& colMap,
396 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
397 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
398
414 CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
415 const Teuchos::RCP<const map_type>& colMap,
416 const Teuchos::ArrayView<const size_t>& numEntPerRow,
417 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
418
419
432 const Teuchos::RCP<const map_type>& rowMap,
433 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
434
457 CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
458 const Teuchos::RCP<const map_type>& colMap,
459 const typename local_graph_device_type::row_map_type& rowPointers,
460 const typename local_graph_device_type::entries_type::non_const_type& columnIndices,
461 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
462
485 CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
486 const Teuchos::RCP<const map_type>& colMap,
487 const Teuchos::ArrayRCP<size_t>& rowPointers,
488 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices,
489 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
490
512 CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
513 const Teuchos::RCP<const map_type>& colMap,
514 const local_graph_device_type& lclGraph,
515 const Teuchos::RCP<Teuchos::ParameterList>& params);
516
543 CrsGraph (const local_graph_device_type& lclGraph,
544 const Teuchos::RCP<const map_type>& rowMap,
545 const Teuchos::RCP<const map_type>& colMap,
546 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
547 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
548 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
549
554 CrsGraph (const local_graph_device_type& lclGraph,
555 const Teuchos::RCP<const map_type>& rowMap,
556 const Teuchos::RCP<const map_type>& colMap,
557 const Teuchos::RCP<const map_type>& domainMap,
558 const Teuchos::RCP<const map_type>& rangeMap,
559 const Teuchos::RCP<const import_type>& importer,
560 const Teuchos::RCP<const export_type>& exporter,
561 const Teuchos::RCP<Teuchos::ParameterList>& params =
562 Teuchos::null);
563
566
569
572
575
585 virtual ~CrsGraph () = default;
586
614
632
634
636
638 void
639 setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& params) override;
640
642 Teuchos::RCP<const Teuchos::ParameterList>
643 getValidParameters () const override;
644
646
648
670 void
672 const Teuchos::ArrayView<const global_ordinal_type>& indices);
673
680 void
682 const local_ordinal_type numEnt,
683 const global_ordinal_type inds[]);
684
686
700 void
702 const Teuchos::ArrayView<const local_ordinal_type>& indices);
703
710 void
712 const local_ordinal_type numEnt,
713 const local_ordinal_type inds[]);
714
716
726
728
730
738 void globalAssemble ();
739
758 void
759 resumeFill (const Teuchos::RCP<Teuchos::ParameterList>& params =
760 Teuchos::null);
761
799 void
800 fillComplete (const Teuchos::RCP<const map_type>& domainMap,
801 const Teuchos::RCP<const map_type>& rangeMap,
802 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
803
831 void
832 fillComplete (const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
833
862 void
863 expertStaticFillComplete (const Teuchos::RCP<const map_type>& domainMap,
864 const Teuchos::RCP<const map_type>& rangeMap,
865 const Teuchos::RCP<const import_type>& importer =
866 Teuchos::null,
867 const Teuchos::RCP<const export_type>& exporter =
868 Teuchos::null,
869 const Teuchos::RCP<Teuchos::ParameterList>& params =
870 Teuchos::null);
872
874
876 Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
877
878
880 Teuchos::RCP<const map_type> getRowMap () const override;
881
883 Teuchos::RCP<const map_type> getColMap () const override;
884
886 Teuchos::RCP<const map_type> getDomainMap () const override;
887
889 Teuchos::RCP<const map_type> getRangeMap () const override;
890
892 Teuchos::RCP<const import_type> getImporter () const override;
893
895 Teuchos::RCP<const export_type> getExporter () const override;
896
898
900 global_size_t getGlobalNumRows() const override;
901
903
906 global_size_t getGlobalNumCols () const override;
907
909 size_t getLocalNumRows () const override;
910
912
914 size_t getLocalNumCols () const override;
915
917 global_ordinal_type getIndexBase () const override;
918
920
922 global_size_t getGlobalNumEntries () const override;
923
933 size_t getLocalNumEntries() const override;
934
936
937 size_t
938 getNumEntriesInGlobalRow (global_ordinal_type globalRow) const override;
939
946 size_t
947 getNumEntriesInLocalRow (local_ordinal_type localRow) const override;
948
968 size_t getLocalAllocationSize () const;
969
978
987
1001 size_t getGlobalMaxNumRowEntries () const override;
1002
1007 size_t getLocalMaxNumRowEntries () const override;
1008
1024 bool hasColMap () const override;
1025
1026
1034 bool isLocallyIndexed () const override;
1035
1043 bool isGloballyIndexed () const override;
1044
1046 bool isFillComplete () const override;
1047
1049 bool isFillActive () const;
1050
1058 bool isSorted () const;
1059
1061
1067 bool isStorageOptimized () const;
1068
1069
1075 void
1077 nonconst_global_inds_host_view_type &gblColInds,
1078 size_t& numColInds) const override;
1079
1087 void
1089 nonconst_local_inds_host_view_type &gblColInds,
1090 size_t& numColInds) const override;
1091
1102 void
1104 const global_ordinal_type gblRow,
1105 global_inds_host_view_type &gblColInds) const override;
1106
1107
1110 bool supportsRowViews () const override;
1111
1112
1123 void
1125 const LocalOrdinal lclRow,
1126 local_inds_host_view_type &lclColInds) const override;
1127
1128
1130
1132
1134 std::string description () const override;
1135
1138 void
1139 describe (Teuchos::FancyOStream& out,
1140 const Teuchos::EVerbosityLevel verbLevel =
1141 Teuchos::Describable::verbLevel_default) const override;
1142
1144
1146
1154
1155 virtual bool
1156 checkSizes (const SrcDistObject& source) override;
1157
1158 virtual void
1159 copyAndPermute
1160 (const SrcDistObject& source,
1161 const size_t numSameIDs,
1162 const Kokkos::DualView<const local_ordinal_type*,
1163 buffer_device_type>& permuteToLIDs,
1164 const Kokkos::DualView<const local_ordinal_type*,
1165 buffer_device_type>& permuteFromLIDs,
1166 const CombineMode CM) override;
1167
1170
1171 void
1172 applyCrsPadding(const padding_type& padding,
1173 const bool verbose);
1174
1175 std::unique_ptr<padding_type>
1176 computeCrsPadding(
1178 node_type>& source,
1179 const size_t numSameIDs,
1180 const Kokkos::DualView<const local_ordinal_type*,
1181 buffer_device_type>& permuteToLIDs,
1182 const Kokkos::DualView<const local_ordinal_type*,
1183 buffer_device_type>& permuteFromLIDs,
1184 const bool verbose) const;
1185
1186 // This actually modifies imports by sorting it.
1187 std::unique_ptr<padding_type>
1188 computeCrsPaddingForImports(
1189 const Kokkos::DualView<const local_ordinal_type*,
1190 buffer_device_type>& importLIDs,
1191 Kokkos::DualView<packet_type*, buffer_device_type> imports,
1192 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1193 const bool verbose) const;
1194
1195 std::unique_ptr<padding_type>
1196 computePaddingForCrsMatrixUnpack(
1197 const Kokkos::DualView<const local_ordinal_type*,
1198 buffer_device_type>& importLIDs,
1199 Kokkos::DualView<char*, buffer_device_type> imports,
1200 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1201 const bool verbose) const;
1202
1203 void
1204 computeCrsPaddingForSameIDs(
1205 padding_type& padding,
1207 node_type>& source,
1208 const local_ordinal_type numSameIDs) const;
1209
1210 void
1211 computeCrsPaddingForPermutedIDs(
1212 padding_type& padding,
1214 node_type>& source,
1215 const Kokkos::DualView<const local_ordinal_type*,
1216 buffer_device_type>& permuteToLIDs,
1217 const Kokkos::DualView<const local_ordinal_type*,
1218 buffer_device_type>& permuteFromLIDs) const;
1219
1220 virtual void
1221 packAndPrepare(
1222 const SrcDistObject& source,
1223 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
1224 Kokkos::DualView<packet_type*, buffer_device_type>& exports,
1225 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1226 size_t& constantNumPackets) override;
1227
1228 virtual void
1229 pack (const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1230 Teuchos::Array<global_ordinal_type>& exports,
1231 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1232 size_t& constantNumPackets) const override;
1233
1234 void
1235 packFillActive (const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1236 Teuchos::Array<global_ordinal_type>& exports,
1237 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1238 size_t& constantNumPackets) const;
1239
1240 void
1241 packFillActiveNew (const Kokkos::DualView<const local_ordinal_type*,
1242 buffer_device_type>& exportLIDs,
1243 Kokkos::DualView<packet_type*,
1244 buffer_device_type>& exports,
1245 Kokkos::DualView<size_t*,
1246 buffer_device_type> numPacketsPerLID,
1247 size_t& constantNumPackets) const;
1248
1249 virtual void
1250 unpackAndCombine
1251 (const Kokkos::DualView<const local_ordinal_type*,
1252 buffer_device_type>& importLIDs,
1253 Kokkos::DualView<packet_type*,
1254 buffer_device_type> imports,
1255 Kokkos::DualView<size_t*,
1256 buffer_device_type> numPacketsPerLID,
1257 const size_t constantNumPackets,
1258 const CombineMode combineMode) override;
1259
1261
1263
1306 void
1307 getLocalDiagOffsets (const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets) const;
1308
1310 void
1311 getLocalOffRankOffsets (offset_device_view_type& offsets) const;
1312
1322 void
1323 getLocalDiagOffsets (Teuchos::ArrayRCP<size_t>& offsets) const;
1324
1334 void
1335 setAllIndices (const typename local_graph_device_type::row_map_type& rowPointers,
1336 const typename local_graph_device_type::entries_type::non_const_type& columnIndices);
1337
1347 void
1348 setAllIndices (const Teuchos::ArrayRCP<size_t> & rowPointers,
1349 const Teuchos::ArrayRCP<local_ordinal_type> & columnIndices);
1350
1353 row_ptrs_host_view_type getLocalRowPtrsHost () const;
1354
1357 row_ptrs_device_view_type getLocalRowPtrsDevice () const;
1358
1360 local_inds_host_view_type getLocalIndicesHost () const;
1361
1364
1383 void replaceColMap (const Teuchos::RCP<const map_type>& newColMap);
1384
1404 void
1405 reindexColumns (const Teuchos::RCP<const map_type>& newColMap,
1406 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1407 const bool sortIndicesInEachRow = true);
1408
1415 void
1416 replaceDomainMap (const Teuchos::RCP<const map_type>& newDomainMap);
1417
1431 void
1432 replaceDomainMapAndImporter (const Teuchos::RCP<const map_type>& newDomainMap,
1433 const Teuchos::RCP<const import_type>& newImporter);
1434
1441 void
1442 replaceRangeMap (const Teuchos::RCP<const map_type>& newRangeMap);
1443
1457 void
1458 replaceRangeMapAndExporter (const Teuchos::RCP<const map_type>& newRangeMap,
1459 const Teuchos::RCP<const export_type>& newExporter);
1460
1489 virtual void
1490 removeEmptyProcessesInPlace (const Teuchos::RCP<const map_type>& newMap) override;
1492
1493 template<class DestViewType, class SrcViewType,
1494 class DestOffsetViewType, class SrcOffsetViewType >
1495 struct pack_functor {
1496 typedef typename DestViewType::execution_space execution_space;
1497 SrcViewType src;
1498 DestViewType dest;
1499 SrcOffsetViewType src_offset;
1500 DestOffsetViewType dest_offset;
1501 typedef typename DestOffsetViewType::non_const_value_type ScalarIndx;
1502
1503 pack_functor(DestViewType dest_,
1504 const SrcViewType src_,
1505 DestOffsetViewType dest_offset_,
1506 const SrcOffsetViewType src_offset_):
1507 src(src_),dest(dest_),
1508 src_offset(src_offset_),dest_offset(dest_offset_) {};
1509
1510 KOKKOS_INLINE_FUNCTION
1511 void operator() (size_t row) const {
1512 ScalarIndx i = src_offset(row);
1513 ScalarIndx j = dest_offset(row);
1514 const ScalarIndx k = dest_offset(row+1);
1515 for(;j<k;j++,i++) {
1516 dest(j) = src(i);
1517 }
1518 }
1519 };
1520
1521 private:
1522 // Friend declaration for nonmember function.
1523 template<class CrsGraphType>
1524 friend Teuchos::RCP<CrsGraphType>
1525 importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1526 const Import<typename CrsGraphType::local_ordinal_type,
1527 typename CrsGraphType::global_ordinal_type,
1528 typename CrsGraphType::node_type>& importer,
1529 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1530 typename CrsGraphType::global_ordinal_type,
1531 typename CrsGraphType::node_type> >& domainMap,
1532 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1533 typename CrsGraphType::global_ordinal_type,
1534 typename CrsGraphType::node_type> >& rangeMap,
1535 const Teuchos::RCP<Teuchos::ParameterList>& params);
1536
1537 // Friend declaration for nonmember function.
1538 template<class CrsGraphType>
1539 friend Teuchos::RCP<CrsGraphType>
1540 importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1541 const Import<typename CrsGraphType::local_ordinal_type,
1542 typename CrsGraphType::global_ordinal_type,
1543 typename CrsGraphType::node_type>& rowImporter,
1544 const Import<typename CrsGraphType::local_ordinal_type,
1545 typename CrsGraphType::global_ordinal_type,
1546 typename CrsGraphType::node_type>& domainImporter,
1547 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1548 typename CrsGraphType::global_ordinal_type,
1549 typename CrsGraphType::node_type> >& domainMap,
1550 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1551 typename CrsGraphType::global_ordinal_type,
1552 typename CrsGraphType::node_type> >& rangeMap,
1553 const Teuchos::RCP<Teuchos::ParameterList>& params);
1554
1555
1556 // Friend declaration for nonmember function.
1557 template<class CrsGraphType>
1558 friend Teuchos::RCP<CrsGraphType>
1559 exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1560 const Export<typename CrsGraphType::local_ordinal_type,
1561 typename CrsGraphType::global_ordinal_type,
1562 typename CrsGraphType::node_type>& exporter,
1563 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1564 typename CrsGraphType::global_ordinal_type,
1565 typename CrsGraphType::node_type> >& domainMap,
1566 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1567 typename CrsGraphType::global_ordinal_type,
1568 typename CrsGraphType::node_type> >& rangeMap,
1569 const Teuchos::RCP<Teuchos::ParameterList>& params);
1570
1571 // Friend declaration for nonmember function.
1572 template<class CrsGraphType>
1573 friend Teuchos::RCP<CrsGraphType>
1574 exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1575 const Export<typename CrsGraphType::local_ordinal_type,
1576 typename CrsGraphType::global_ordinal_type,
1577 typename CrsGraphType::node_type>& rowExporter,
1578 const Export<typename CrsGraphType::local_ordinal_type,
1579 typename CrsGraphType::global_ordinal_type,
1580 typename CrsGraphType::node_type>& domainExporter,
1581 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1582 typename CrsGraphType::global_ordinal_type,
1583 typename CrsGraphType::node_type> >& domainMap,
1584 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1585 typename CrsGraphType::global_ordinal_type,
1586 typename CrsGraphType::node_type> >& rangeMap,
1587 const Teuchos::RCP<Teuchos::ParameterList>& params);
1588
1589 public:
1605 void
1606 importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1607 const import_type& importer,
1608 const Teuchos::RCP<const map_type>& domainMap,
1609 const Teuchos::RCP<const map_type>& rangeMap,
1610 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1611
1627 void
1628 importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1629 const import_type& rowImporter,
1630 const import_type& domainImporter,
1631 const Teuchos::RCP<const map_type>& domainMap,
1632 const Teuchos::RCP<const map_type>& rangeMap,
1633 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1634
1635
1651 void
1652 exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1653 const export_type& exporter,
1654 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1655 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1656 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1657
1673 void
1674 exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1675 const export_type& rowExporter,
1676 const export_type& domainExporter,
1677 const Teuchos::RCP<const map_type>& domainMap,
1678 const Teuchos::RCP<const map_type>& rangeMap,
1679 const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1680
1681
1682 private:
1703 void
1704 transferAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1705 const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>& rowTransfer,
1706 const Teuchos::RCP<const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node> > & domainTransfer,
1707 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1708 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1709 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1710
1711 protected:
1712 // these structs are conveniences, to cut down on the number of
1713 // arguments to some of the methods below.
1714 struct SLocalGlobalViews {
1715 Teuchos::ArrayView<const global_ordinal_type> ginds;
1716 Teuchos::ArrayView<const local_ordinal_type> linds;
1717 };
1718 struct SLocalGlobalNCViews {
1719 Teuchos::ArrayView<global_ordinal_type> ginds;
1720 Teuchos::ArrayView<local_ordinal_type> linds;
1721 };
1722
1723 bool indicesAreAllocated () const;
1724
1725 void
1726 allocateIndices(const ELocalGlobal lg, const bool verbose=false);
1727
1729
1730
1740 void makeColMap (Teuchos::Array<int>& remotePIDs);
1741
1762 std::pair<size_t, std::string>
1763 makeIndicesLocal(const bool verbose=false);
1764
1773 void
1774 makeImportExport (Teuchos::Array<int>& remotePIDs,
1775 const bool useRemotePIDs);
1776
1778
1780
1815 size_t
1816 insertIndices (RowInfo& rowInfo,
1817 const SLocalGlobalViews& newInds,
1818 const ELocalGlobal lg,
1819 const ELocalGlobal I);
1820
1830 size_t
1832 const global_ordinal_type inputGblColInds[],
1833 const size_t numInputInds);
1834
1844 size_t
1845 insertGlobalIndicesImpl (const RowInfo& rowInfo,
1846 const global_ordinal_type inputGblColInds[],
1847 const size_t numInputInds,
1848 std::function<void(const size_t, const size_t, const size_t)> fun =
1849 std::function<void(const size_t, const size_t, const size_t)>());
1850
1851 void
1852 insertLocalIndicesImpl (const local_ordinal_type lclRow,
1853 const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
1854 std::function<void(const size_t, const size_t, const size_t)> fun =
1855 std::function<void(const size_t, const size_t, const size_t)>());
1856
1872 size_t
1873 findGlobalIndices(const RowInfo& rowInfo,
1874 const Teuchos::ArrayView<const global_ordinal_type>& indices,
1875 std::function<void(const size_t, const size_t, const size_t)> fun) const;
1876
1888 void
1890 const global_ordinal_type gblColInds[],
1891 const local_ordinal_type numGblColInds);
1892
1904 void
1906 const global_ordinal_type gblColInds[],
1907 const local_ordinal_type numGblColInds);
1908
1913 static const bool useAtomicUpdatesByDefault =
1914#ifdef KOKKOS_ENABLE_SERIAL
1915 ! std::is_same<execution_space, Kokkos::Serial>::value;
1916#else
1917 true;
1918#endif // KOKKOS_ENABLE_SERIAL
1919
1921
1923
1925 bool isMerged () const;
1926
1932 void setLocallyModified ();
1933
1934 private:
1939 void
1940 sortAndMergeAllIndices (const bool sorted, const bool merged);
1941
1942 // mfh 08 May 2017: I only restore "protected" here for backwards
1943 // compatibility.
1944 protected:
1953 size_t sortAndMergeRowIndices (const RowInfo& rowInfo,
1954 const bool sorted,
1955 const bool merged);
1957
1967 void
1968 setDomainRangeMaps (const Teuchos::RCP<const map_type>& domainMap,
1969 const Teuchos::RCP<const map_type>& rangeMap);
1970
1971 void staticAssertions() const;
1972 void clearGlobalConstants();
1973
1974 public:
1977
1995 void computeGlobalConstants ();
1996
1997 bool haveLocalOffRankOffsets() const { return haveLocalOffRankOffsets_;}
1998
1999 protected:
2019 void computeLocalConstants ();
2020
2023 RowInfo getRowInfo (const local_ordinal_type myRow) const;
2024
2037 RowInfo getRowInfoFromGlobalRowIndex (const global_ordinal_type gblRow) const;
2038
2039 public:
2040
2049 local_graph_host_type getLocalGraphHost () const;
2050
2051 protected:
2052
2053 void fillLocalGraph (const Teuchos::RCP<Teuchos::ParameterList>& params);
2054
2056 void checkInternalState () const;
2057
2061 void swap(CrsGraph<local_ordinal_type, global_ordinal_type, Node> & graph);
2062
2063 // Friend the tester for CrsGraph::swap
2064 friend class Tpetra::crsGraph_Swap_Tester<local_ordinal_type, global_ordinal_type, Node>;
2065
2066
2068 Teuchos::RCP<const map_type> rowMap_;
2070 Teuchos::RCP<const map_type> colMap_;
2072 Teuchos::RCP<const map_type> rangeMap_;
2074 Teuchos::RCP<const map_type> domainMap_;
2075
2082 Teuchos::RCP<const import_type> importer_;
2083
2089 Teuchos::RCP<const export_type> exporter_;
2090
2096 Teuchos::OrdinalTraits<size_t>::invalid();
2097
2102 Teuchos::OrdinalTraits<global_size_t>::invalid();
2103
2109 Teuchos::OrdinalTraits<global_size_t>::invalid();
2110
2111 // Replacement for device view k_rowPtrs_
2112 // Device view rowPtrsUnpacked_dev_ takes place of k_rowPtrs_
2113 // Host view rowPtrsUnpacked_host_ takes place of copies and use of getEntryOnHost
2114 // Wish this could be a WrappedDualView, but deep_copies in DualView
2115 // don't work with const data views (e.g., StaticCrsGraph::row_map)
2116 // k_rowPtrs_ is offsets wrt the ALLOCATED indices array, not necessarily
2117 // the ACTUAL compressed indices array.
2118 // When !OptimizedStorage, k_rowPtrs_ may differ from ACTUAL compressed
2119 // indices array. (Karen is skeptical that !OptimizedStorage works)
2120 // When OptimizedStorage, rowPtrsUnpacked_ = k_rowPtrsPacked_
2121
2122 row_ptrs_device_view_type rowPtrsUnpacked_dev_;
2123 row_ptrs_host_view_type rowPtrsUnpacked_host_;
2124
2125 void setRowPtrsUnpacked(const row_ptrs_device_view_type &dview) {
2126 rowPtrsUnpacked_dev_ = dview;
2127 rowPtrsUnpacked_host_ =
2128 Kokkos::create_mirror_view_and_copy(
2129 typename row_ptrs_device_view_type::host_mirror_space(),
2130 dview);
2131 }
2132
2133 // Row offsets into the actual graph local indices
2134 // Device view rowPtrsUnpacked_dev_ takes place of lclGraph_.row_map
2135
2136 row_ptrs_device_view_type rowPtrsPacked_dev_;
2137 row_ptrs_host_view_type rowPtrsPacked_host_;
2138
2139 void setRowPtrsPacked(const row_ptrs_device_view_type &dview) {
2140 rowPtrsPacked_dev_ = dview;
2141 rowPtrsPacked_host_ =
2142 Kokkos::create_mirror_view_and_copy(
2143 typename row_ptrs_device_view_type::host_mirror_space(),
2144 dview);
2145 }
2146
2147 // There are common cases where both packed and unpacked views are set to the same array.
2148 // Doing this in a single call can reduce dataspace on host, and reduce runtime by
2149 // removing a deep_copy from device to host.
2150
2151 void setRowPtrs(const row_ptrs_device_view_type &dview) {
2152 setRowPtrsUnpacked(dview);
2153 rowPtrsPacked_dev_ = rowPtrsUnpacked_dev_;
2154 rowPtrsPacked_host_ = rowPtrsUnpacked_host_;
2155 }
2156
2157 //TODO: Make private -- matrix shouldn't access directly the guts of graph
2158
2172 local_inds_wdv_type lclIndsUnpacked_wdv;
2173
2187 mutable local_inds_wdv_type lclIndsPacked_wdv;
2188
2189 //TODO: Make private -- matrix shouldn't access directly the guts of graph
2190
2200
2201 // TODO: Make private -- matrix shouldn't access directly
2202 global_inds_wdv_type gblInds_wdv;
2203
2207 typename local_inds_dualv_type::t_host::const_type
2208 getLocalIndsViewHost (const RowInfo& rowinfo) const;
2209
2213 typename local_inds_dualv_type::t_dev::const_type
2214 getLocalIndsViewDevice (const RowInfo& rowinfo) const;
2215
2219 typename global_inds_dualv_type::t_host::const_type
2220 getGlobalIndsViewHost (const RowInfo& rowinfo) const;
2221
2225 typename global_inds_dualv_type::t_dev::const_type
2226 getGlobalIndsViewDevice (const RowInfo& rowinfo) const;
2227
2231 typename local_inds_dualv_type::t_host
2232 getLocalIndsViewHostNonConst (const RowInfo& rowinfo);
2233
2234 // FOR NOW...
2235 // KEEP k_numRowEntries_ (though switch from HostMirror to Host)
2236 // KEEP k_numAllocPerRow_ (though perhaps switch from HostMirror to Host)
2237
2263 typename Kokkos::View<const size_t*, device_type>::HostMirror
2265
2276
2278
2279
2301
2309 typedef typename Kokkos::View<size_t*, Kokkos::LayoutLeft, device_type>::HostMirror num_row_entries_type;
2310
2311 // typedef Kokkos::View<
2312 // size_t*,
2313 // Kokkos::LayoutLeft,
2314 // Kokkos::Device<
2315 // typename Kokkos::View<
2316 // size_t*,
2317 // Kokkos::LayoutLeft,
2318 // device_type>::HostMirror::execution_space,
2319 // Kokkos::HostSpace> > num_row_entries_type;
2320
2328
2334 mutable offset_device_view_type k_offRankOffsets_;
2335
2337
2348 Details::STORAGE_1D_UNPACKED;
2349
2350 bool indicesAreAllocated_ = false;
2351 bool indicesAreLocal_ = false;
2352 bool indicesAreGlobal_ = false;
2353 bool fillComplete_ = false;
2354
2359 bool noRedundancies_ = true;
2365 mutable bool haveLocalOffRankOffsets_ = false;
2366
2367 typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type> > nonlocals_type;
2368
2370 nonlocals_type nonlocals_;
2371
2387
2388 private:
2390 static bool getDebug();
2391
2394 bool debug_ = getDebug();
2395
2397 static bool getVerbose();
2398
2402 bool verbose_ = getVerbose();
2403
2404 private:
2406 mutable bool need_sync_host_uvm_access = false;
2407
2409 void set_need_sync_host_uvm_access() {
2410 need_sync_host_uvm_access = true;
2411 }
2412
2414 void execute_sync_host_uvm_access() const {
2415 if(need_sync_host_uvm_access) {
2416 Kokkos::fence();
2417 need_sync_host_uvm_access = false;
2418 }
2419 }
2420 }; // class CrsGraph
2421
2429 template <class LocalOrdinal, class GlobalOrdinal, class Node>
2430 Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
2432 const Teuchos::RCP<
2434 size_t maxNumEntriesPerRow = 0,
2435 const Teuchos::RCP<Teuchos::ParameterList>& params =
2436 Teuchos::null)
2437 {
2438 using Teuchos::rcp;
2440 return rcp(new graph_type(map, maxNumEntriesPerRow,
2441 params));
2442 }
2443
2493 template<class CrsGraphType>
2494 Teuchos::RCP<CrsGraphType>
2495 importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2496 const Import<typename CrsGraphType::local_ordinal_type,
2497 typename CrsGraphType::global_ordinal_type,
2498 typename CrsGraphType::node_type>& importer,
2499 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2500 typename CrsGraphType::global_ordinal_type,
2501 typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2502 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2503 typename CrsGraphType::global_ordinal_type,
2504 typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2505 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2506 {
2507 Teuchos::RCP<CrsGraphType> destGraph;
2508 sourceGraph->importAndFillComplete (destGraph,importer,domainMap, rangeMap, params);
2509 return destGraph;
2510 }
2511
2562 template<class CrsGraphType>
2563 Teuchos::RCP<CrsGraphType>
2564 importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2565 const Import<typename CrsGraphType::local_ordinal_type,
2566 typename CrsGraphType::global_ordinal_type,
2567 typename CrsGraphType::node_type>& rowImporter,
2568 const Import<typename CrsGraphType::local_ordinal_type,
2569 typename CrsGraphType::global_ordinal_type,
2570 typename CrsGraphType::node_type>& domainImporter,
2571 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2572 typename CrsGraphType::global_ordinal_type,
2573 typename CrsGraphType::node_type> >& domainMap,
2574 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2575 typename CrsGraphType::global_ordinal_type,
2576 typename CrsGraphType::node_type> >& rangeMap,
2577 const Teuchos::RCP<Teuchos::ParameterList>& params)
2578 {
2579 Teuchos::RCP<CrsGraphType> destGraph;
2580 sourceGraph->importAndFillComplete (destGraph,rowImporter,domainImporter, domainMap, rangeMap, params);
2581 return destGraph;
2582 }
2583
2617 template<class CrsGraphType>
2618 Teuchos::RCP<CrsGraphType>
2619 exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2620 const Export<typename CrsGraphType::local_ordinal_type,
2621 typename CrsGraphType::global_ordinal_type,
2622 typename CrsGraphType::node_type>& exporter,
2623 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2624 typename CrsGraphType::global_ordinal_type,
2625 typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2626 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2627 typename CrsGraphType::global_ordinal_type,
2628 typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2629 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2630 {
2631 Teuchos::RCP<CrsGraphType> destGraph;
2632 sourceGraph->exportAndFillComplete (destGraph,exporter,domainMap, rangeMap, params);
2633 return destGraph;
2634 }
2635
2669 template<class CrsGraphType>
2670 Teuchos::RCP<CrsGraphType>
2671 exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2672 const Export<typename CrsGraphType::local_ordinal_type,
2673 typename CrsGraphType::global_ordinal_type,
2674 typename CrsGraphType::node_type>& rowExporter,
2675 const Export<typename CrsGraphType::local_ordinal_type,
2676 typename CrsGraphType::global_ordinal_type,
2677 typename CrsGraphType::node_type>& domainExporter,
2678 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2679 typename CrsGraphType::global_ordinal_type,
2680 typename CrsGraphType::node_type> >& domainMap,
2681 const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2682 typename CrsGraphType::global_ordinal_type,
2683 typename CrsGraphType::node_type> >& rangeMap,
2684 const Teuchos::RCP<Teuchos::ParameterList>& params)
2685 {
2686 Teuchos::RCP<CrsGraphType> destGraph;
2687 sourceGraph->exportAndFillComplete (destGraph,rowExporter,domainExporter,domainMap, rangeMap, params);
2688 return destGraph;
2689 }
2690
2691
2692} // namespace Tpetra
2693
2694#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.
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...
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.
size_t sortAndMergeRowIndices(const RowInfo &rowInfo, const bool sorted, const bool merged)
Sort and merge duplicate column indices in the given 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).
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.
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.
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...
typename local_graph_device_type::HostMirror local_graph_host_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.
Kokkos::View< size_t *, Kokkos::LayoutLeft, device_type >::HostMirror num_row_entries_type
Row offsets for "1-D" storage.
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.
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...
Kokkos::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 > domainMap_
The Map describing the domain of the (matrix corresponding to the) graph.
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
Pack this object's data for Import or Export.
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.
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.
Kokkos::View< constsize_t *, device_type >::HostMirror k_numAllocPerRow_
The maximum number of entries to allow in each locally owned row, per row.
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().
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.
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.
Kokkos::Device< typename device_type::execution_space, buffer_memory_space > buffer_device_type
Kokkos::Device specialization for communication buffers.
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.
size_t global_size_t
Global size_t object.
CombineMode
Rule for combining data in an Import or Export.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.