Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
50 
51 #include "Tpetra_CrsGraph_fwd.hpp"
52 #include "Tpetra_CrsMatrix_fwd.hpp"
54 #include "Tpetra_DistObject.hpp"
55 #include "Tpetra_Exceptions.hpp"
56 #include "Tpetra_RowGraph.hpp"
57 #include "Tpetra_Util.hpp" // need this here for sort2
58 
59 #include "KokkosSparse_findRelOffset.hpp"
60 #include "Kokkos_DualView.hpp"
61 #include "Kokkos_StaticCrsGraph.hpp"
62 
63 #include "Teuchos_CommHelpers.hpp"
64 #include "Teuchos_Describable.hpp"
65 #include "Teuchos_OrdinalTraits.hpp"
66 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
67 
68 #include <functional> // std::function
69 #include <memory>
70 
71 namespace Tpetra {
72 
73 
74  // Forward declaration for CrsGraph::swap() test
75  template<class LocalOrdinal, class GlobalOrdinal, class Node> class crsGraph_Swap_Tester;
76 
77 #ifndef DOXYGEN_SHOULD_SKIP_THIS
78  namespace Details {
79  template<class LocalOrdinal,
80  class GlobalOrdinal>
81  class CrsPadding;
82  } // namespace Details
83 
84  namespace { // (anonymous)
85 
86  template<class ViewType>
87  struct UnmanagedView {
88  static_assert (Kokkos::is_view<ViewType>::value,
89  "ViewType must be a Kokkos::View specialization.");
90  // FIXME (mfh 02 Dec 2015) Right now, this strips away other
91  // memory traits. Christian will add an "AllTraits" enum which is
92  // the enum value of MemoryTraits<T>, that will help us fix this.
93  typedef Kokkos::View<typename ViewType::data_type,
94  typename ViewType::array_layout,
95  typename ViewType::device_type,
96  Kokkos::MemoryUnmanaged> type;
97  };
98 
99  } // namespace (anonymous)
100 #endif // DOXYGEN_SHOULD_SKIP_THIS
101 
110  struct RowInfo {
111  size_t localRow;
112  size_t allocSize;
113  size_t numEntries;
114  size_t offset1D;
115  };
116 
117  enum ELocalGlobal {
118  LocalIndices,
119  GlobalIndices
120  };
121 
122  namespace Details {
154  STORAGE_1D_UNPACKED, //<! 1-D "unpacked" storage
155  STORAGE_1D_PACKED, //<! 1-D "packed" storage
156  STORAGE_UB //<! Invalid value; upper bound on enum values
157  };
158 
159  } // namespace Details
160 
219  template <class LocalOrdinal,
220  class GlobalOrdinal,
221  class Node>
222  class CrsGraph :
223  public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
224  public DistObject<GlobalOrdinal,
225  LocalOrdinal,
226  GlobalOrdinal,
227  Node>,
228  public Teuchos::ParameterListAcceptorDefaultBase
229  {
230  template <class S, class LO, class GO, class N>
231  friend class CrsMatrix;
232  template <class LO2, class GO2, class N2>
233  friend class CrsGraph;
234  template <class LO, class GO, class N>
235  friend class FECrsGraph;
236 
239 
240  public:
242  using local_ordinal_type = LocalOrdinal;
244  using global_ordinal_type = GlobalOrdinal;
246  using device_type = typename Node::device_type;
248  using execution_space = typename device_type::execution_space;
249 
254  using node_type = Node;
255 
257  using local_graph_type = Kokkos::StaticCrsGraph<local_ordinal_type,
258  Kokkos::LayoutLeft,
260 
267 
269 
270 
285  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
286  const size_t maxNumEntriesPerRow,
287  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
288  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
289 
304  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
305  const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
306  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
307  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
308 
324  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
325  const Teuchos::ArrayView<const size_t>& numEntPerRow,
326  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
327  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
328 
329 
348  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
349  const Teuchos::RCP<const map_type>& colMap,
350  const size_t maxNumEntriesPerRow,
351  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
352  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
353 
370  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
371  const Teuchos::RCP<const map_type>& colMap,
372  const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
373  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
374  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
375 
393  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
394  const Teuchos::RCP<const map_type>& colMap,
395  const Teuchos::ArrayView<const size_t>& numEntPerRow,
396  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
397  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
398 
399 
422  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
423  const Teuchos::RCP<const map_type>& colMap,
424  const typename local_graph_type::row_map_type& rowPointers,
425  const typename local_graph_type::entries_type::non_const_type& columnIndices,
426  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
427 
450  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
451  const Teuchos::RCP<const map_type>& colMap,
452  const Teuchos::ArrayRCP<size_t>& rowPointers,
453  const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices,
454  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
455 
477  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
478  const Teuchos::RCP<const map_type>& colMap,
479  const local_graph_type& lclGraph,
480  const Teuchos::RCP<Teuchos::ParameterList>& params);
481 
508  CrsGraph (const local_graph_type& lclGraph,
509  const Teuchos::RCP<const map_type>& rowMap,
510  const Teuchos::RCP<const map_type>& colMap,
511  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
512  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
513  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
514 
519  CrsGraph (const local_graph_type& lclGraph,
520  const Teuchos::RCP<const map_type>& rowMap,
521  const Teuchos::RCP<const map_type>& colMap,
522  const Teuchos::RCP<const map_type>& domainMap,
523  const Teuchos::RCP<const map_type>& rangeMap,
524  const Teuchos::RCP<const import_type>& importer,
525  const Teuchos::RCP<const export_type>& exporter,
526  const Teuchos::RCP<Teuchos::ParameterList>& params =
527  Teuchos::null);
528 
531 
534 
537 
540 
550  virtual ~CrsGraph () = default;
551 
596 
598 
600 
602  void
603  setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& params) override;
604 
606  Teuchos::RCP<const Teuchos::ParameterList>
607  getValidParameters () const override;
608 
610 
612 
634  void
635  insertGlobalIndices (const global_ordinal_type globalRow,
636  const Teuchos::ArrayView<const global_ordinal_type>& indices);
637 
644  void
645  insertGlobalIndices (const global_ordinal_type globalRow,
646  const local_ordinal_type numEnt,
647  const global_ordinal_type inds[]);
648 
650 
664  void
665  insertLocalIndices (const local_ordinal_type localRow,
666  const Teuchos::ArrayView<const local_ordinal_type>& indices);
667 
674  void
675  insertLocalIndices (const local_ordinal_type localRow,
676  const local_ordinal_type numEnt,
677  const local_ordinal_type inds[]);
678 
680 
689  void removeLocalIndices (local_ordinal_type localRow);
690 
692 
694 
702  void globalAssemble ();
703 
722  void
723  resumeFill (const Teuchos::RCP<Teuchos::ParameterList>& params =
724  Teuchos::null);
725 
763  void
764  fillComplete (const Teuchos::RCP<const map_type>& domainMap,
765  const Teuchos::RCP<const map_type>& rangeMap,
766  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
767 
795  void
796  fillComplete (const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
797 
826  void
827  expertStaticFillComplete (const Teuchos::RCP<const map_type>& domainMap,
828  const Teuchos::RCP<const map_type>& rangeMap,
829  const Teuchos::RCP<const import_type>& importer =
830  Teuchos::null,
831  const Teuchos::RCP<const export_type>& exporter =
832  Teuchos::null,
833  const Teuchos::RCP<Teuchos::ParameterList>& params =
834  Teuchos::null);
836 
838 
840  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
841 
842 
844  Teuchos::RCP<const map_type> getRowMap () const override;
845 
847  Teuchos::RCP<const map_type> getColMap () const override;
848 
850  Teuchos::RCP<const map_type> getDomainMap () const override;
851 
853  Teuchos::RCP<const map_type> getRangeMap () const override;
854 
856  Teuchos::RCP<const import_type> getImporter () const override;
857 
859  Teuchos::RCP<const export_type> getExporter () const override;
860 
862 
864  global_size_t getGlobalNumRows() const override;
865 
867 
870  global_size_t getGlobalNumCols () const override;
871 
873  size_t getNodeNumRows () const override;
874 
876 
878  size_t getNodeNumCols () const override;
879 
881  global_ordinal_type getIndexBase () const override;
882 
884 
886  global_size_t getGlobalNumEntries () const override;
887 
897  size_t getNodeNumEntries() const override;
898 
900 
901  size_t
902  getNumEntriesInGlobalRow (global_ordinal_type globalRow) const override;
903 
910  size_t
911  getNumEntriesInLocalRow (local_ordinal_type localRow) const override;
912 
932  size_t getNodeAllocationSize () const;
933 
942 
951 
965  size_t getGlobalMaxNumRowEntries () const override;
966 
971  size_t getNodeMaxNumRowEntries () const override;
972 
988  bool hasColMap () const override;
989 
990 
998  bool isLocallyIndexed () const override;
999 
1007  bool isGloballyIndexed () const override;
1008 
1010  bool isFillComplete () const override;
1011 
1013  bool isFillActive () const;
1014 
1022  bool isSorted () const;
1023 
1025 
1031  bool isStorageOptimized () const;
1032 
1034  ProfileType getProfileType () const;
1035 
1041  void
1043  const Teuchos::ArrayView<global_ordinal_type>& gblColInds,
1044  size_t& numColInds) const override;
1045 
1053  void
1055  const Teuchos::ArrayView<local_ordinal_type>& lclColInds,
1056  size_t& numColInds) const override;
1057 
1068  void
1069  getGlobalRowView (const global_ordinal_type gblRow,
1070  Teuchos::ArrayView<const global_ordinal_type>& gblColInds) const override;
1071 
1074  bool supportsRowViews () const override;
1075 
1086  void
1087  getLocalRowView (const local_ordinal_type lclRow,
1088  Teuchos::ArrayView<const local_ordinal_type>& lclColInds) const override;
1089 
1091 
1093 
1095  std::string description () const override;
1096 
1099  void
1100  describe (Teuchos::FancyOStream& out,
1101  const Teuchos::EVerbosityLevel verbLevel =
1102  Teuchos::Describable::verbLevel_default) const override;
1103 
1105 
1107 
1115 
1116  virtual bool
1117  checkSizes (const SrcDistObject& source) override;
1118 
1119  virtual void
1120  copyAndPermute
1121  (const SrcDistObject& source,
1122  const size_t numSameIDs,
1123  const Kokkos::DualView<const local_ordinal_type*,
1124  buffer_device_type>& permuteToLIDs,
1125  const Kokkos::DualView<const local_ordinal_type*,
1126  buffer_device_type>& permuteFromLIDs) override;
1127 
1130 
1131  void
1132  applyCrsPadding(const padding_type& padding,
1133  const bool verbose);
1134 
1135  std::unique_ptr<padding_type>
1136  computeCrsPadding(
1138  node_type>& source,
1139  const size_t numSameIDs,
1140  const Kokkos::DualView<const local_ordinal_type*,
1141  buffer_device_type>& permuteToLIDs,
1142  const Kokkos::DualView<const local_ordinal_type*,
1143  buffer_device_type>& permuteFromLIDs,
1144  const bool verbose) const;
1145 
1146  // This actually modifies imports by sorting it.
1147  std::unique_ptr<padding_type>
1148  computeCrsPaddingForImports(
1149  const Kokkos::DualView<const local_ordinal_type*,
1150  buffer_device_type>& importLIDs,
1151  Kokkos::DualView<packet_type*, buffer_device_type> imports,
1152  Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1153  const bool verbose) const;
1154 
1155  std::unique_ptr<padding_type>
1156  computePaddingForCrsMatrixUnpack(
1157  const Kokkos::DualView<const local_ordinal_type*,
1158  buffer_device_type>& importLIDs,
1159  Kokkos::DualView<char*, buffer_device_type> imports,
1160  Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1161  const bool verbose) const;
1162 
1163  void
1164  computeCrsPaddingForSameIDs(
1165  padding_type& padding,
1167  node_type>& source,
1168  const local_ordinal_type numSameIDs) const;
1169 
1170  void
1171  computeCrsPaddingForPermutedIDs(
1172  padding_type& padding,
1174  node_type>& source,
1175  const Kokkos::DualView<const local_ordinal_type*,
1176  buffer_device_type>& permuteToLIDs,
1177  const Kokkos::DualView<const local_ordinal_type*,
1178  buffer_device_type>& permuteFromLIDs) const;
1179 
1180  virtual void
1181  packAndPrepare(
1182  const SrcDistObject& source,
1183  const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& exportLIDs,
1184  Kokkos::DualView<packet_type*, buffer_device_type>& exports,
1185  Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1186  size_t& constantNumPackets,
1187  Distributor& distor) override;
1188 
1189  virtual void
1190  pack (const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1191  Teuchos::Array<global_ordinal_type>& exports,
1192  const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1193  size_t& constantNumPackets,
1194  Distributor& distor) const override;
1195 
1196  void
1197  packFillActive (const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1198  Teuchos::Array<global_ordinal_type>& exports,
1199  const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1200  size_t& constantNumPackets,
1201  Distributor& distor) const;
1202 
1203  void
1204  packFillActiveNew (const Kokkos::DualView<const local_ordinal_type*,
1205  buffer_device_type>& exportLIDs,
1206  Kokkos::DualView<packet_type*,
1207  buffer_device_type>& exports,
1208  Kokkos::DualView<size_t*,
1209  buffer_device_type> numPacketsPerLID,
1210  size_t& constantNumPackets,
1211  Distributor& distor) const;
1212 
1213  virtual void
1214  unpackAndCombine
1215  (const Kokkos::DualView<const local_ordinal_type*,
1216  buffer_device_type>& importLIDs,
1217  Kokkos::DualView<packet_type*,
1218  buffer_device_type> imports,
1219  Kokkos::DualView<size_t*,
1220  buffer_device_type> numPacketsPerLID,
1221  const size_t constantNumPackets,
1222  Distributor& distor,
1223  const CombineMode combineMode) override;
1224 
1226 
1228 
1271  void
1272  getLocalDiagOffsets (const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets) const;
1273 
1283  void
1284  getLocalDiagOffsets (Teuchos::ArrayRCP<size_t>& offsets) const;
1285 
1308  void
1309  getNumEntriesPerLocalRowUpperBound (Teuchos::ArrayRCP<const size_t>& boundPerLocalRow,
1310  size_t& boundForAllLocalRows,
1311  bool& boundSameForAllLocalRows) const;
1312 
1322  void
1323  setAllIndices (const typename local_graph_type::row_map_type& rowPointers,
1324  const typename local_graph_type::entries_type::non_const_type& columnIndices);
1325 
1335  void
1336  setAllIndices (const Teuchos::ArrayRCP<size_t> & rowPointers,
1337  const Teuchos::ArrayRCP<local_ordinal_type> & columnIndices);
1338 
1346  Teuchos::ArrayRCP<const size_t> getNodeRowPtrs () const;
1347 
1349 
1351  Teuchos::ArrayRCP<const local_ordinal_type> getNodePackedIndices () const;
1352 
1371  void replaceColMap (const Teuchos::RCP<const map_type>& newColMap);
1372 
1392  void
1393  reindexColumns (const Teuchos::RCP<const map_type>& newColMap,
1394  const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1395  const bool sortIndicesInEachRow = true);
1396 
1410  void
1411  replaceDomainMapAndImporter (const Teuchos::RCP<const map_type>& newDomainMap,
1412  const Teuchos::RCP<const import_type>& newImporter);
1413 
1442  virtual void
1443  removeEmptyProcessesInPlace (const Teuchos::RCP<const map_type>& newMap) override;
1445 
1446  template<class ViewType, class OffsetViewType >
1447  struct pack_functor {
1448  typedef typename ViewType::execution_space execution_space;
1449  ViewType src;
1450  ViewType dest;
1451  OffsetViewType src_offset;
1452  OffsetViewType dest_offset;
1453  typedef typename OffsetViewType::non_const_value_type ScalarIndx;
1454 
1455  pack_functor(ViewType dest_, ViewType src_, OffsetViewType dest_offset_, OffsetViewType src_offset_):
1456  src(src_),dest(dest_),src_offset(src_offset_),dest_offset(dest_offset_) {};
1457 
1458  KOKKOS_INLINE_FUNCTION
1459  void operator() (size_t row) const {
1460  ScalarIndx i = src_offset(row);
1461  ScalarIndx j = dest_offset(row);
1462  const ScalarIndx k = dest_offset(row+1);
1463  for(;j<k;j++,i++) {
1464  dest(j) = src(i);
1465  }
1466  }
1467  };
1468 
1469  private:
1470  // Friend declaration for nonmember function.
1471  template<class CrsGraphType>
1472  friend Teuchos::RCP<CrsGraphType>
1473  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1474  const Import<typename CrsGraphType::local_ordinal_type,
1475  typename CrsGraphType::global_ordinal_type,
1476  typename CrsGraphType::node_type>& importer,
1477  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1478  typename CrsGraphType::global_ordinal_type,
1479  typename CrsGraphType::node_type> >& domainMap,
1480  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1481  typename CrsGraphType::global_ordinal_type,
1482  typename CrsGraphType::node_type> >& rangeMap,
1483  const Teuchos::RCP<Teuchos::ParameterList>& params);
1484 
1485  // Friend declaration for nonmember function.
1486  template<class CrsGraphType>
1487  friend Teuchos::RCP<CrsGraphType>
1488  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1489  const Import<typename CrsGraphType::local_ordinal_type,
1490  typename CrsGraphType::global_ordinal_type,
1491  typename CrsGraphType::node_type>& rowImporter,
1492  const Import<typename CrsGraphType::local_ordinal_type,
1493  typename CrsGraphType::global_ordinal_type,
1494  typename CrsGraphType::node_type>& domainImporter,
1495  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1496  typename CrsGraphType::global_ordinal_type,
1497  typename CrsGraphType::node_type> >& domainMap,
1498  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1499  typename CrsGraphType::global_ordinal_type,
1500  typename CrsGraphType::node_type> >& rangeMap,
1501  const Teuchos::RCP<Teuchos::ParameterList>& params);
1502 
1503 
1504  // Friend declaration for nonmember function.
1505  template<class CrsGraphType>
1506  friend Teuchos::RCP<CrsGraphType>
1507  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1508  const Export<typename CrsGraphType::local_ordinal_type,
1509  typename CrsGraphType::global_ordinal_type,
1510  typename CrsGraphType::node_type>& exporter,
1511  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1512  typename CrsGraphType::global_ordinal_type,
1513  typename CrsGraphType::node_type> >& domainMap,
1514  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1515  typename CrsGraphType::global_ordinal_type,
1516  typename CrsGraphType::node_type> >& rangeMap,
1517  const Teuchos::RCP<Teuchos::ParameterList>& params);
1518 
1519  // Friend declaration for nonmember function.
1520  template<class CrsGraphType>
1521  friend Teuchos::RCP<CrsGraphType>
1522  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1523  const Export<typename CrsGraphType::local_ordinal_type,
1524  typename CrsGraphType::global_ordinal_type,
1525  typename CrsGraphType::node_type>& rowExporter,
1526  const Export<typename CrsGraphType::local_ordinal_type,
1527  typename CrsGraphType::global_ordinal_type,
1528  typename CrsGraphType::node_type>& domainExporter,
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  public:
1553  void
1554  importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1555  const import_type& importer,
1556  const Teuchos::RCP<const map_type>& domainMap,
1557  const Teuchos::RCP<const map_type>& rangeMap,
1558  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1559 
1575  void
1576  importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1577  const import_type& rowImporter,
1578  const import_type& domainImporter,
1579  const Teuchos::RCP<const map_type>& domainMap,
1580  const Teuchos::RCP<const map_type>& rangeMap,
1581  const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1582 
1583 
1599  void
1600  exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1601  const export_type& exporter,
1602  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1603  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1604  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1605 
1621  void
1622  exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1623  const export_type& rowExporter,
1624  const export_type& domainExporter,
1625  const Teuchos::RCP<const map_type>& domainMap,
1626  const Teuchos::RCP<const map_type>& rangeMap,
1627  const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1628 
1629 
1630  private:
1651  void
1652  transferAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1653  const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>& rowTransfer,
1654  const Teuchos::RCP<const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node> > & domainTransfer,
1655  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1656  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1657  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1658 
1659  protected:
1660  // these structs are conveniences, to cut down on the number of
1661  // arguments to some of the methods below.
1662  struct SLocalGlobalViews {
1663  Teuchos::ArrayView<const global_ordinal_type> ginds;
1664  Teuchos::ArrayView<const local_ordinal_type> linds;
1665  };
1666  struct SLocalGlobalNCViews {
1667  Teuchos::ArrayView<global_ordinal_type> ginds;
1668  Teuchos::ArrayView<local_ordinal_type> linds;
1669  };
1670 
1671  bool indicesAreAllocated () const;
1672 
1673  void
1674  allocateIndices(const ELocalGlobal lg, const bool verbose=false);
1675 
1677 
1678 
1688  void makeColMap (Teuchos::Array<int>& remotePIDs);
1689 
1710  std::pair<size_t, std::string>
1711  makeIndicesLocal(const bool verbose=false);
1712 
1721  void
1722  makeImportExport (Teuchos::Array<int>& remotePIDs,
1723  const bool useRemotePIDs);
1724 
1726 
1728 
1763  size_t
1764  insertIndices (RowInfo& rowInfo,
1765  const SLocalGlobalViews& newInds,
1766  const ELocalGlobal lg,
1767  const ELocalGlobal I);
1768 
1778  size_t
1780  const global_ordinal_type inputGblColInds[],
1781  const size_t numInputInds);
1782 
1792  size_t
1793  insertGlobalIndicesImpl (const RowInfo& rowInfo,
1794  const global_ordinal_type inputGblColInds[],
1795  const size_t numInputInds,
1796  std::function<void(const size_t, const size_t, const size_t)> fun =
1797  std::function<void(const size_t, const size_t, const size_t)>());
1798 
1799  void
1800  insertLocalIndicesImpl (const local_ordinal_type lclRow,
1801  const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
1802  std::function<void(const size_t, const size_t, const size_t)> fun =
1803  std::function<void(const size_t, const size_t, const size_t)>());
1804 
1820  size_t
1821  findLocalIndices(const RowInfo& rowInfo,
1822  const Teuchos::ArrayView<const local_ordinal_type>& indices,
1823  std::function<void(const size_t, const size_t, const size_t)> fun) const;
1824 
1825  size_t
1826  findGlobalIndices(const RowInfo& rowInfo,
1827  const Teuchos::ArrayView<const global_ordinal_type>& indices,
1828  std::function<void(const size_t, const size_t, const size_t)> fun) const;
1829 
1841  void
1843  const global_ordinal_type gblColInds[],
1844  const local_ordinal_type numGblColInds);
1845 
1857  void
1859  const global_ordinal_type gblColInds[],
1860  const local_ordinal_type numGblColInds);
1861 
1866  static const bool useAtomicUpdatesByDefault =
1867 #ifdef KOKKOS_ENABLE_SERIAL
1868  ! std::is_same<execution_space, Kokkos::Serial>::value;
1869 #else
1870  true;
1871 #endif // KOKKOS_ENABLE_SERIAL
1872 
1874 
1876 
1878  bool isMerged () const;
1879 
1885  void setLocallyModified ();
1886 
1887  private:
1892  void
1893  sortAndMergeAllIndices (const bool sorted, const bool merged);
1894 
1895  // mfh 08 May 2017: I only restore "protected" here for backwards
1896  // compatibility.
1897  protected:
1906  size_t sortAndMergeRowIndices (const RowInfo& rowInfo,
1907  const bool sorted,
1908  const bool merged);
1910 
1920  void
1921  setDomainRangeMaps (const Teuchos::RCP<const map_type>& domainMap,
1922  const Teuchos::RCP<const map_type>& rangeMap);
1923 
1924  void staticAssertions() const;
1925  void clearGlobalConstants();
1926 
1927  public:
1930 
1948  void computeGlobalConstants ();
1949 
1950  protected:
1970  void computeLocalConstants ();
1971 
1974  RowInfo getRowInfo (const local_ordinal_type myRow) const;
1975 
1989 
1993  Teuchos::ArrayView<const local_ordinal_type>
1994  getLocalView (const RowInfo& rowinfo) const;
1995 
1999  Teuchos::ArrayView<local_ordinal_type>
2000  getLocalViewNonConst (const RowInfo& rowinfo);
2001 
2014  getLocalViewRawConst (const local_ordinal_type*& lclInds,
2015  local_ordinal_type& capacity,
2016  const RowInfo& rowInfo) const;
2017 
2018  private:
2019 
2026  Kokkos::View<const local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2027  getLocalKokkosRowView (const RowInfo& rowInfo) const;
2028 
2035  Kokkos::View<local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2036  getLocalKokkosRowViewNonConst (const RowInfo& rowInfo);
2037 
2044  Kokkos::View<const global_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2045  getGlobalKokkosRowView (const RowInfo& rowInfo) const;
2046 
2047  protected:
2048 
2052  Teuchos::ArrayView<const global_ordinal_type>
2053  getGlobalView (const RowInfo& rowinfo) const;
2054 
2058  Teuchos::ArrayView<global_ordinal_type>
2059  getGlobalViewNonConst (const RowInfo& rowinfo);
2060 
2074  getGlobalViewRawConst (const global_ordinal_type*& gblInds,
2075  local_ordinal_type& capacity,
2076  const RowInfo& rowInfo) const;
2077 
2078 
2079  public:
2080 
2081 
2090 
2091 
2092  protected:
2093 
2094 
2095  void fillLocalGraph (const Teuchos::RCP<Teuchos::ParameterList>& params);
2096 
2098  void checkInternalState () const;
2099 
2104 
2105  // Friend the tester for CrsGraph::swap
2106  friend class Tpetra::crsGraph_Swap_Tester<local_ordinal_type, global_ordinal_type, Node>;
2107 
2108 
2110  Teuchos::RCP<const map_type> rowMap_;
2112  Teuchos::RCP<const map_type> colMap_;
2114  Teuchos::RCP<const map_type> rangeMap_;
2116  Teuchos::RCP<const map_type> domainMap_;
2117 
2124  Teuchos::RCP<const import_type> importer_;
2125 
2131  Teuchos::RCP<const export_type> exporter_;
2132 
2135 
2141  Teuchos::OrdinalTraits<size_t>::invalid();
2142 
2147  Teuchos::OrdinalTraits<global_size_t>::invalid();
2148 
2154  Teuchos::OrdinalTraits<global_size_t>::invalid();
2155 
2181  typename Kokkos::View<const size_t*, execution_space>::HostMirror
2183 
2194 
2196 
2197 
2204  typename local_graph_type::entries_type::non_const_type k_lclInds1D_;
2205 
2207  typedef Kokkos::View<global_ordinal_type*, execution_space> t_GlobalOrdinal_1D;
2208 
2216 
2238  typename local_graph_type::row_map_type::const_type k_rowPtrs_;
2239 
2247  typedef typename Kokkos::View<size_t*, Kokkos::LayoutLeft, device_type>::HostMirror num_row_entries_type;
2248 
2249  // typedef Kokkos::View<
2250  // size_t*,
2251  // Kokkos::LayoutLeft,
2252  // Kokkos::Device<
2253  // typename Kokkos::View<
2254  // size_t*,
2255  // Kokkos::LayoutLeft,
2256  // device_type>::HostMirror::execution_space,
2257  // Kokkos::HostSpace> > num_row_entries_type;
2258 
2266 
2268 
2279  Details::STORAGE_1D_UNPACKED;
2280 
2281  bool indicesAreAllocated_ = false;
2282  bool indicesAreLocal_ = false;
2283  bool indicesAreGlobal_ = false;
2284  bool fillComplete_ = false;
2285 
2287  bool indicesAreSorted_ = true;
2290  bool noRedundancies_ = true;
2292  bool haveLocalConstants_ = false;
2294  bool haveGlobalConstants_ = false;
2295 
2296  typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type> > nonlocals_type;
2297 
2299  nonlocals_type nonlocals_;
2300 
2316 
2317  private:
2319  static bool getDebug();
2320 
2323  bool debug_ = getDebug();
2324 
2326  static bool getVerbose();
2327 
2331  bool verbose_ = getVerbose();
2332 
2333  }; // class CrsGraph
2334 
2342  template <class LocalOrdinal, class GlobalOrdinal, class Node>
2343  Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
2345  const Teuchos::RCP<
2347  size_t maxNumEntriesPerRow = 0,
2348  const Teuchos::RCP<Teuchos::ParameterList>& params =
2349  Teuchos::null)
2350  {
2351  using Teuchos::rcp;
2353  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE;
2354  return rcp(new graph_type(map, maxNumEntriesPerRow,
2355  pftype, params));
2356  }
2357 
2407  template<class CrsGraphType>
2408  Teuchos::RCP<CrsGraphType>
2409  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2410  const Import<typename CrsGraphType::local_ordinal_type,
2411  typename CrsGraphType::global_ordinal_type,
2412  typename CrsGraphType::node_type>& importer,
2413  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2414  typename CrsGraphType::global_ordinal_type,
2415  typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2416  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2417  typename CrsGraphType::global_ordinal_type,
2418  typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2419  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2420  {
2421  Teuchos::RCP<CrsGraphType> destGraph;
2422  sourceGraph->importAndFillComplete (destGraph,importer,domainMap, rangeMap, params);
2423  return destGraph;
2424  }
2425 
2476  template<class CrsGraphType>
2477  Teuchos::RCP<CrsGraphType>
2478  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2479  const Import<typename CrsGraphType::local_ordinal_type,
2480  typename CrsGraphType::global_ordinal_type,
2481  typename CrsGraphType::node_type>& rowImporter,
2482  const Import<typename CrsGraphType::local_ordinal_type,
2483  typename CrsGraphType::global_ordinal_type,
2484  typename CrsGraphType::node_type>& domainImporter,
2485  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2486  typename CrsGraphType::global_ordinal_type,
2487  typename CrsGraphType::node_type> >& domainMap,
2488  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2489  typename CrsGraphType::global_ordinal_type,
2490  typename CrsGraphType::node_type> >& rangeMap,
2491  const Teuchos::RCP<Teuchos::ParameterList>& params)
2492  {
2493  Teuchos::RCP<CrsGraphType> destGraph;
2494  sourceGraph->importAndFillComplete (destGraph,rowImporter,domainImporter, domainMap, rangeMap, params);
2495  return destGraph;
2496  }
2497 
2531  template<class CrsGraphType>
2532  Teuchos::RCP<CrsGraphType>
2533  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2534  const Export<typename CrsGraphType::local_ordinal_type,
2535  typename CrsGraphType::global_ordinal_type,
2536  typename CrsGraphType::node_type>& exporter,
2537  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2538  typename CrsGraphType::global_ordinal_type,
2539  typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2540  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2541  typename CrsGraphType::global_ordinal_type,
2542  typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2543  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2544  {
2545  Teuchos::RCP<CrsGraphType> destGraph;
2546  sourceGraph->exportAndFillComplete (destGraph,exporter,domainMap, rangeMap, params);
2547  return destGraph;
2548  }
2549 
2583  template<class CrsGraphType>
2584  Teuchos::RCP<CrsGraphType>
2585  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2586  const Export<typename CrsGraphType::local_ordinal_type,
2587  typename CrsGraphType::global_ordinal_type,
2588  typename CrsGraphType::node_type>& rowExporter,
2589  const Export<typename CrsGraphType::local_ordinal_type,
2590  typename CrsGraphType::global_ordinal_type,
2591  typename CrsGraphType::node_type>& domainExporter,
2592  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2593  typename CrsGraphType::global_ordinal_type,
2594  typename CrsGraphType::node_type> >& domainMap,
2595  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2596  typename CrsGraphType::global_ordinal_type,
2597  typename CrsGraphType::node_type> >& rangeMap,
2598  const Teuchos::RCP<Teuchos::ParameterList>& params)
2599  {
2600  Teuchos::RCP<CrsGraphType> destGraph;
2601  sourceGraph->exportAndFillComplete (destGraph,rowExporter,domainExporter,domainMap, rangeMap, params);
2602  return destGraph;
2603  }
2604 
2605 
2606 } // namespace Tpetra
2607 
2608 #endif // TPETRA_CRSGRAPH_DECL_HPP
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
void setDomainRangeMaps(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap)
Teuchos::RCP< const map_type > getRowMap() const override
Returns the Map that describes the row distribution in this graph.
void setAllIndices(const typename local_graph_type::row_map_type &rowPointers, const typename local_graph_type::entries_type::non_const_type &columnIndices)
Set the graph&#39;s data directly, using 1-D storage.
size_t nodeMaxNumRowEntries_
Local maximum of the number of entries in each row.
bool indicesAreSorted_
Whether the graph&#39;s indices are sorted in each row, on this process.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
::Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization used by this class.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
Teuchos::RCP< const map_type > rangeMap_
The Map describing the range of the (matrix corresponding to the) graph.
Teuchos::RCP< const map_type > getColMap() const override
Returns the Map that describes the column distribution in this graph.
GO global_ordinal_type
The type of the graph&#39;s global indices.
Kokkos::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, device_type > local_graph_type
The type of the part of the sparse graph on each MPI process.
An abstract interface for graphs accessed by rows.
size_t getNodeMaxNumRowEntries() const override
Maximum number of entries in any row of the graph, on this process.
void insertGlobalIndicesFiltered(const local_ordinal_type lclRow, const global_ordinal_type gblColInds[], const local_ordinal_type numGblColInds)
Like insertGlobalIndices(), but with column Map filtering.
bool sortGhostsAssociatedWithEachProcessor_
Whether to require makeColMap() (and therefore fillComplete()) to order column Map GIDs associated wi...
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.
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Resume fill operations.
bool haveGlobalConstants_
Whether all processes have computed global constants.
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().
Teuchos::RCP< const import_type > getImporter() const override
Returns the importer associated with this graph.
void getLocalDiagOffsets(const Kokkos::View< size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Get offsets of the diagonal entries in the graph.
Kokkos::View< global_ordinal_type *, execution_space > t_GlobalOrdinal_1D
Type of the k_gblInds1D_ array of global column indices.
t_GlobalOrdinal_1D k_gblInds1D_
Global column indices for all rows.
void insertGlobalIndices(const global_ordinal_type globalRow, const Teuchos::ArrayView< const global_ordinal_type > &indices)
Insert global indices into the graph.
size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const override
Get the number of entries in the given row (local index).
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Default parameter list suitable for validation.
void computeLocalConstants()
Compute local constants, if they have not yet been computed.
bool isIdenticalTo(const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > &graph) const
Create a cloned CrsGraph for a different Node type.
bool isMerged() const
Whether duplicate column indices in each row have been merged.
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
Forward declaration of Tpetra::BlockCrsMatrix.
Teuchos::RCP< const map_type > getDomainMap() const override
Returns the Map associated with the domain of this graph.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the graph, over all processes in the graph&#39;s communicator...
void getLocalRowView(const local_ordinal_type lclRow, Teuchos::ArrayView< const local_ordinal_type > &lclColInds) const override
Get a const, non-persisting view of the given local row&#39;s local column indices, as a Teuchos::ArrayVi...
virtual ~CrsGraph()=default
Destructor (virtual for memory safety of derived classes).
bool noRedundancies_
Whether the graph&#39;s indices are non-redundant (merged) in each row, on this process.
size_t findLocalIndices(const RowInfo &rowInfo, const Teuchos::ArrayView< const local_ordinal_type > &indices, std::function< void(const size_t, const size_t, const size_t)> fun) const
Finds indices in the given row.
size_t getNumAllocatedEntriesInGlobalRow(global_ordinal_type globalRow) const
Current number of allocated entries in the given row on the calling (MPI) process, using a global row index.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
bool hasColMap() const override
Whether the graph has a column Map.
bool isGloballyIndexed() const override
Whether the graph&#39;s column indices are stored as global 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.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
bool isStorageOptimized() const
Returns true if storage has been optimized.
bool haveLocalConstants_
Whether this process has computed local constants.
std::string description() const override
Return a one-line human-readable description of this object.
local_ordinal_type getLocalViewRawConst(const local_ordinal_type *&lclInds, local_ordinal_type &capacity, const RowInfo &rowInfo) const
Get a pointer to the local column indices of a locally owned row, using the result of getRowInfo...
void makeColMap(Teuchos::Array< int > &remotePIDs)
Make and set the graph&#39;s column Map.
Teuchos::RCP< const export_type > getExporter() const override
Returns the exporter associated with this graph.
std::pair< size_t, std::string > makeIndicesLocal(const bool verbose=false)
Convert column indices from global to local.
void getNumEntriesPerLocalRowUpperBound(Teuchos::ArrayRCP< const size_t > &boundPerLocalRow, size_t &boundForAllLocalRows, bool &boundSameForAllLocalRows) const
Get an upper bound on the number of entries that can be stored in each row.
size_t global_size_t
Global size_t object.
size_t getNodeNumEntries() const override
The local number of entries in the graph.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Maps and their communicator.
node_type node_type
This class&#39; Kokkos Node type.
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...
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 makeImportExport(Teuchos::Array< int > &remotePIDs, const bool useRemotePIDs)
Make the Import and Export objects, if needed.
size_t sortAndMergeRowIndices(const RowInfo &rowInfo, const bool sorted, const bool merged)
Sort and merge duplicate column indices in the given row.
void insertLocalIndices(const local_ordinal_type localRow, const Teuchos::ArrayView< const local_ordinal_type > &indices)
Insert local indices into the graph.
void getGlobalRowCopy(global_ordinal_type gblRow, const Teuchos::ArrayView< global_ordinal_type > &gblColInds, size_t &numColInds) const override
Get a copy of the given row, using global indices.
bool isSorted() const
Whether graph indices in all rows are known to be sorted.
Teuchos::RCP< const map_type > rowMap_
The Map describing the distribution of rows of the graph.
Teuchos::RCP< const import_type > importer_
The Import from the domain Map to the column Map.
num_row_entries_type k_numRowEntries_
The number of local entries in each locally owned row.
Teuchos::RCP< const map_type > domainMap_
The Map describing the domain of the (matrix corresponding to the) graph.
global_size_t getGlobalNumRows() const override
Returns the number of global rows in the graph.
Teuchos::ArrayView< const global_ordinal_type > getGlobalView(const RowInfo &rowinfo) const
Get a const, nonowned, globally indexed view of the locally owned row myRow, such that rowinfo = getR...
Kokkos::View< size_t *, Kokkos::LayoutLeft, device_type >::HostMirror num_row_entries_type
The type of k_numRowEntries_ (see below).
void setLocallyModified()
Report that we made a local modification to its structure.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
local_graph_type::entries_type::non_const_type k_lclInds1D_
Local column indices for all rows.
Teuchos::ArrayView< local_ordinal_type > getLocalViewNonConst(const RowInfo &rowinfo)
Get a nonconst, nonowned, locally indexed view of the locally owned row myRow, such that rowinfo = ge...
size_t getNodeNumRows() const override
Returns the number of graph rows owned on the calling node.
ProfileType getProfileType() const
Returns true if the graph was allocated with static data structures.
void checkInternalState() const
Throw an exception if the internal state is not consistent.
local_graph_type lclGraph_
Local graph; only initialized after first fillComplete() call.
Keep track of how much more space a CrsGraph or CrsMatrix needs, when the graph or matrix is the targ...
Sets up and executes a communication plan for a Tpetra DistObject.
local_graph_type::row_map_type::const_type k_rowPtrs_
Row offsets for &quot;1-D&quot; storage.
Kokkos::View< const size_t *, execution_space >::HostMirror k_numAllocPerRow_
The maximum number of entries to allow in each locally owned row, per row.
CombineMode
Rule for combining data in an Import or Export.
Teuchos::RCP< const export_type > exporter_
The Export from the row Map to the range Map.
void insertGlobalIndicesIntoNonownedRows(const global_ordinal_type gblRow, const global_ordinal_type gblColInds[], const local_ordinal_type numGblColInds)
Implementation of insertGlobalIndices for nonowned rows.
bool isFillComplete() const override
Whether fillComplete() has been called and the graph is in compute mode.
size_t getNumAllocatedEntriesInLocalRow(local_ordinal_type localRow) const
Current number of allocated entries in the given row on the calling (MPI) process, using a local row index.
Teuchos::ArrayRCP< const size_t > getNodeRowPtrs() const
Get a host view of the row offsets.
void swap(CrsGraph< local_ordinal_type, global_ordinal_type, Node > &graph)
Swaps the data from *this with the data and maps from graph.
void globalAssemble()
Communicate nonlocal contributions to other processes.
typename device_type::execution_space execution_space
This class&#39; Kokkos execution space.
RowInfo getRowInfoFromGlobalRowIndex(const global_ordinal_type gblRow) const
Get information about the locally owned row with global index gblRow.
Forward declaration of Tpetra::CrsMatrix.
Abstract base class for objects that can be the source of an Import or Export operation.
void removeLocalIndices(local_ordinal_type localRow)
Remove all graph indices from the specified local row.
size_t getNodeAllocationSize() const
The local number of indices allocated for the graph, over all rows on the calling (MPI) process...
LO local_ordinal_type
The type of the graph&#39;s local indices.
global_size_t globalNumEntries_
Global number of entries in the graph.
Teuchos::ArrayView< global_ordinal_type > getGlobalViewNonConst(const RowInfo &rowinfo)
Get a nonconst, nonowned, globally indexed view of the locally owned row myRow, such that rowinfo = g...
Teuchos::RCP< const map_type > getRangeMap() const override
Returns the Map associated with the domain of this graph.
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the graph&#39;s current column Map with the given Map.
void getGlobalRowView(const global_ordinal_type gblRow, Teuchos::ArrayView< const global_ordinal_type > &gblColInds) const override
Get a const, non-persisting view of the given global row&#39;s global column indices, as a Teuchos::Array...
global_size_t getGlobalNumCols() const override
Returns the number of global columns in the graph.
RowInfo getRowInfo(const local_ordinal_type myRow) const
Get information about the locally owned row with local index myRow.
size_t getNodeNumCols() const override
Returns the number of columns connected to the locally owned rows of this graph.
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.
bool supportsRowViews() const override
Whether this class implements getLocalRowView() and getGlobalRowView() (it does). ...
typename dist_object_type::buffer_device_type buffer_device_type
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 ...
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Teuchos::ArrayView< const local_ordinal_type > getLocalView(const RowInfo &rowinfo) const
Get a const, nonowned, locally indexed view of the locally owned row myRow, such that rowinfo = getRo...
Details::EStorageStatus storageStatus_
Status of the graph&#39;s storage, when not in a fill-complete state.
local_ordinal_type getGlobalViewRawConst(const global_ordinal_type *&gblInds, local_ordinal_type &capacity, const RowInfo &rowInfo) const
Get a pointer to the global column indices of a locally owned row, using the result of getRowInfoFrom...
CrsGraph & operator=(const CrsGraph< local_ordinal_type, global_ordinal_type, node_type > &)=default
Assignment operator (default).
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &params) override
Set the given list of parameters (must be nonnull).
size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const override
Returns the current number of entries on this node in the specified global row.
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.
typename node_type::device_type device_type
This class&#39; Kokkos device type.
bool isLocallyIndexed() const override
Whether the graph&#39;s column indices are stored as local indices.
::Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization used by this class.
Stand-alone utility functions and macros.
Teuchos::ArrayRCP< const local_ordinal_type > getNodePackedIndices() const
Get an Teuchos::ArrayRCP of the packed column-indices.
bool isFillActive() const
Whether resumeFill() has been called and the graph is in edit mode.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
Returns the communicator.
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 globalMaxNumRowEntries_
Global maximum of the number of entries in each row.
static const bool useAtomicUpdatesByDefault
Whether transformLocalValues should use atomic updates by default.
local_graph_type getLocalGraph() const
Get the local graph.
size_t insertIndices(RowInfo &rowInfo, const SLocalGlobalViews &newInds, const ELocalGlobal lg, const ELocalGlobal I)
Insert indices into the given row.
global_size_t getGlobalNumEntries() const override
Returns the global number of entries in the graph.
Kokkos::Device< typename device_type::execution_space, buffer_memory_space > buffer_device_type
size_t numAllocForAllRows_
The maximum number of entries to allow in each locally owned row.
Base class for distributed Tpetra objects that support data redistribution.
global_ordinal_type packet_type
Type of each entry of the DistObject communication buffer.
Teuchos::RCP< const map_type > colMap_
The Map describing the distribution of columns of the graph.
global_ordinal_type getIndexBase() const override
Returns the index base for global indices for this graph.
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, Distributor &distor) const override
Pack this object&#39;s data for Import or Export.
void getLocalRowCopy(local_ordinal_type lclRow, const Teuchos::ArrayView< local_ordinal_type > &lclColInds, size_t &numColInds) const override
Get a copy of the given row, using local indices.
EStorageStatus
Status of the graph&#39;s or matrix&#39;s storage, when not in a fill-complete state.
Forward declaration of Tpetra::CrsGraph.
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().
nonlocals_type nonlocals_
Nonlocal data given to insertGlobalIndices.
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 computeGlobalConstants()
Compute global constants, if they have not yet been computed.