Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #ifndef TPETRA_CRSGRAPH_DECL_HPP
43 #define TPETRA_CRSGRAPH_DECL_HPP
44 
52 
53 #include "Tpetra_CrsGraph_fwd.hpp"
54 #include "Tpetra_CrsMatrix_fwd.hpp"
56 #include "Tpetra_DistObject.hpp"
57 #include "Tpetra_Exceptions.hpp"
58 #include "Tpetra_RowGraph.hpp"
59 #include "Tpetra_Util.hpp" // need this here for sort2
60 
61 #include "KokkosSparse_findRelOffset.hpp"
62 #include "Kokkos_DualView.hpp"
63 #include "Kokkos_StaticCrsGraph.hpp"
64 #include "Kokkos_UnorderedMap.hpp"
65 
66 #include "Teuchos_CommHelpers.hpp"
67 #include "Teuchos_Describable.hpp"
68 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
69 
70 #include <functional> // std::function
71 
72 namespace Tpetra {
73 
74 
75  // Forward declaration for CrsGraph::swap() test
76  template<class LocalOrdinal, class GlobalOrdinal, class Node> class crsGraph_Swap_Tester;
77 
78 #ifndef DOXYGEN_SHOULD_SKIP_THIS
79  namespace Details {
80 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
81  // Forward declaration of an implementation detail of CrsGraph::clone.
82  template<class OutputCrsGraphType, class InputCrsGraphType>
83  class CrsGraphCopier {
84  public:
85  static Teuchos::RCP<OutputCrsGraphType>
86  clone (const InputCrsGraphType& graphIn,
87  const Teuchos::RCP<typename OutputCrsGraphType::node_type> nodeOut,
88  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
89  }; // class CrsGraphCopier
90 #endif // TPETRA_ENABLE_DEPRECATED_CODE
91 
92  template<class LO, class GO, class NT>
93  void
95  CrsGraph<LO, GO, NT>& graph,
96  const Teuchos::ArrayView<const typename CrsGraph<LO,GO,NT>::packet_type>& imports,
97  const Teuchos::ArrayView<const size_t>& numPacketsPerLID,
98  const Teuchos::ArrayView<const LO>& importLIDs,
99  size_t constantNumPackets,
100  Distributor & distor,
101  CombineMode combineMode);
102  } // namespace Details
103 
104  namespace { // (anonymous)
105 
106  template<class ViewType>
107  struct UnmanagedView {
108  static_assert (Kokkos::is_view<ViewType>::value,
109  "ViewType must be a Kokkos::View specialization.");
110  // FIXME (mfh 02 Dec 2015) Right now, this strips away other
111  // memory traits. Christian will add an "AllTraits" enum which is
112  // the enum value of MemoryTraits<T>, that will help us fix this.
113  typedef Kokkos::View<typename ViewType::data_type,
114  typename ViewType::array_layout,
115  typename ViewType::device_type,
116  Kokkos::MemoryUnmanaged> type;
117  };
118 
119  } // namespace (anonymous)
120 #endif // DOXYGEN_SHOULD_SKIP_THIS
121 
130  struct RowInfo {
131  size_t localRow;
132  size_t allocSize;
133  size_t numEntries;
134  size_t offset1D;
135  };
136 
137  enum ELocalGlobal {
138  LocalIndices,
139  GlobalIndices
140  };
141 
142  namespace Details {
183  STORAGE_2D, //<! 2-D storage
184  STORAGE_1D_UNPACKED, //<! 1-D "unpacked" storage
185  STORAGE_1D_PACKED, //<! 1-D "packed" storage
186  STORAGE_UB //<! Invalid value; upper bound on enum values
187  };
188 
189 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
190  class HasDeprecatedMethods2630_WarningThisClassIsNotForUsers {
199  public:
200  virtual ~HasDeprecatedMethods2630_WarningThisClassIsNotForUsers () = default;
201  virtual bool isLowerTriangularImpl () const = 0;
202  virtual bool isUpperTriangularImpl () const = 0;
203  virtual size_t getGlobalNumDiagsImpl () const = 0;
204  virtual global_size_t getNodeNumDiagsImpl () const = 0;
205  }; // class HasDeprecatedMethods2630_WarningThisClassIsNotForUsers
206 #endif // TPETRA_ENABLE_DEPRECATED_CODE
207  } // namespace Details
208 
267  template <class LocalOrdinal,
268  class GlobalOrdinal,
269  class Node>
270  class CrsGraph :
271  public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
272  public DistObject<GlobalOrdinal,
273  LocalOrdinal,
274  GlobalOrdinal,
275  Node>,
276  public Teuchos::ParameterListAcceptorDefaultBase
277 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
278  , public ::Tpetra::Details::HasDeprecatedMethods2630_WarningThisClassIsNotForUsers
279 #endif // TPETRA_ENABLE_DEPRECATED_CODE
280  {
281  template <class S, class LO, class GO, class N>
282  friend class CrsMatrix;
283  template <class LO2, class GO2, class N2>
284  friend class CrsGraph;
285  template <class LO, class GO, class N>
286  friend class FECrsGraph;
287 
290 
291  public:
293  using local_ordinal_type = LocalOrdinal;
295  using global_ordinal_type = GlobalOrdinal;
297  using device_type = typename Node::device_type;
299  using execution_space = typename device_type::execution_space;
300 
305  using node_type = Node;
306 
308  using local_graph_type = Kokkos::StaticCrsGraph<local_ordinal_type,
309  Kokkos::LayoutLeft,
311 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
312  typedef local_graph_type LocalStaticCrsGraphType TPETRA_DEPRECATED;
315  typedef typename local_graph_type::row_map_type t_RowPtrs TPETRA_DEPRECATED;
317  typedef typename local_graph_type::row_map_type::non_const_type t_RowPtrsNC TPETRA_DEPRECATED;
319  typedef typename local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D TPETRA_DEPRECATED;
320 #endif // TPETRA_ENABLE_DEPRECATED_CODE
321 
328 
330 
331 
350  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
351  const size_t maxNumEntriesPerRow,
352  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
353  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
354 
372  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
373  const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
374  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
375  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
376 
395  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
396  const Teuchos::ArrayView<const size_t>& numEntPerRow,
397  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
398  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
399 
400 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
401  TPETRA_DEPRECATED
403  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
404  const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
405  const ProfileType pftype = DynamicProfile,
406  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
407 #endif // TPETRA_ENABLE_DEPRECATED_CODE
408 
430  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
431  const Teuchos::RCP<const map_type>& colMap,
432  const size_t maxNumEntriesPerRow,
433  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
434  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
435 
454  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
455  const Teuchos::RCP<const map_type>& colMap,
456  const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
457  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
458  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
459 
479  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
480  const Teuchos::RCP<const map_type>& colMap,
481  const Teuchos::ArrayView<const size_t>& numEntPerRow,
482  const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
483  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
484 
485 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
486  TPETRA_DEPRECATED
488  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
489  const Teuchos::RCP<const map_type>& colMap,
490  const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
491  const ProfileType pftype = DynamicProfile,
492  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
493 #endif // TPETRA_ENABLE_DEPRECATED_CODE
494 
515  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
516  const Teuchos::RCP<const map_type>& colMap,
517  const typename local_graph_type::row_map_type& rowPointers,
518  const typename local_graph_type::entries_type::non_const_type& columnIndices,
519  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
520 
541  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
542  const Teuchos::RCP<const map_type>& colMap,
543  const Teuchos::ArrayRCP<size_t>& rowPointers,
544  const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices,
545  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
546 
565  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
566  const Teuchos::RCP<const map_type>& colMap,
567  const local_graph_type& lclGraph,
568  const Teuchos::RCP<Teuchos::ParameterList>& params);
569 
594  CrsGraph (const local_graph_type& lclGraph,
595  const Teuchos::RCP<const map_type>& rowMap,
596  const Teuchos::RCP<const map_type>& colMap,
597  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
598  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
599  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
600 
603 
606 
609 
612 
622  virtual ~CrsGraph () = default;
623 
651 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
652  template<class Node2>
653  Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node2> > TPETRA_DEPRECATED
654  clone (const Teuchos::RCP<Node2>& node2,
655  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const
656  {
657  typedef CrsGraph<local_ordinal_type, global_ordinal_type, Node2> output_crs_graph_type;
659  typedef ::Tpetra::Details::CrsGraphCopier<output_crs_graph_type, input_crs_graph_type> copier_type;
660  return copier_type::clone (*this, node2, params);
661  }
662 #endif
663 
681 
683 
685 
687  void
688  setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& params) override;
689 
691  Teuchos::RCP<const Teuchos::ParameterList>
692  getValidParameters () const override;
693 
695 
697 
719  void
720  insertGlobalIndices (const global_ordinal_type globalRow,
721  const Teuchos::ArrayView<const global_ordinal_type>& indices);
722 
729  void
730  insertGlobalIndices (const global_ordinal_type globalRow,
731  const local_ordinal_type numEnt,
732  const global_ordinal_type inds[]);
733 
735 
749  void
750  insertLocalIndices (const local_ordinal_type localRow,
751  const Teuchos::ArrayView<const local_ordinal_type>& indices);
752 
759  void
760  insertLocalIndices (const local_ordinal_type localRow,
761  const local_ordinal_type numEnt,
762  const local_ordinal_type inds[]);
763 
765 
774  void removeLocalIndices (local_ordinal_type localRow);
775 
777 
779 
787  void globalAssemble ();
788 
807  void
808  resumeFill (const Teuchos::RCP<Teuchos::ParameterList>& params =
809  Teuchos::null);
810 
848  void
849  fillComplete (const Teuchos::RCP<const map_type>& domainMap,
850  const Teuchos::RCP<const map_type>& rangeMap,
851  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
852 
880  void
881  fillComplete (const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
882 
911  void
912  expertStaticFillComplete (const Teuchos::RCP<const map_type>& domainMap,
913  const Teuchos::RCP<const map_type>& rangeMap,
914  const Teuchos::RCP<const import_type>& importer =
915  Teuchos::null,
916  const Teuchos::RCP<const export_type>& exporter =
917  Teuchos::null,
918  const Teuchos::RCP<Teuchos::ParameterList>& params =
919  Teuchos::null);
921 
923 
925  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
926 
927 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
928  TPETRA_DEPRECATED Teuchos::RCP<node_type> getNode() const override;
930 #endif // TPETRA_ENABLE_DEPRECATED_CODE
931 
933  Teuchos::RCP<const map_type> getRowMap () const override;
934 
936  Teuchos::RCP<const map_type> getColMap () const override;
937 
939  Teuchos::RCP<const map_type> getDomainMap () const override;
940 
942  Teuchos::RCP<const map_type> getRangeMap () const override;
943 
945  Teuchos::RCP<const import_type> getImporter () const override;
946 
948  Teuchos::RCP<const export_type> getExporter () const override;
949 
951 
953  global_size_t getGlobalNumRows() const override;
954 
956 
959  global_size_t getGlobalNumCols () const override;
960 
962  size_t getNodeNumRows () const override;
963 
965 
967  size_t getNodeNumCols () const override;
968 
970  global_ordinal_type getIndexBase () const override;
971 
973 
975  global_size_t getGlobalNumEntries () const override;
976 
986  size_t getNodeNumEntries() const override;
987 
989 
990  size_t
991  getNumEntriesInGlobalRow (global_ordinal_type globalRow) const override;
992 
999  size_t
1000  getNumEntriesInLocalRow (local_ordinal_type localRow) const override;
1001 
1021  size_t getNodeAllocationSize () const;
1022 
1030  size_t getNumAllocatedEntriesInGlobalRow (global_ordinal_type globalRow) const;
1031 
1039  size_t getNumAllocatedEntriesInLocalRow (local_ordinal_type localRow) const;
1040 
1054  size_t getGlobalMaxNumRowEntries () const override;
1055 
1060  size_t getNodeMaxNumRowEntries () const override;
1061 
1077  bool hasColMap () const override;
1078 
1079 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1080  global_size_t TPETRA_DEPRECATED getGlobalNumDiags () const override;
1088 
1095  size_t TPETRA_DEPRECATED getNodeNumDiags () const override;
1096 
1108  global_size_t getGlobalNumDiagsImpl () const override;
1109 
1121  size_t getNodeNumDiagsImpl () const override;
1122 
1133  bool TPETRA_DEPRECATED isLowerTriangular () const override;
1134 
1145  bool TPETRA_DEPRECATED isUpperTriangular () const override;
1146 
1158  bool isLowerTriangularImpl () const override;
1159 
1171  bool isUpperTriangularImpl () const override;
1172 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1173 
1181  bool isLocallyIndexed () const override;
1182 
1190  bool isGloballyIndexed () const override;
1191 
1193  bool isFillComplete () const override;
1194 
1196  bool isFillActive () const;
1197 
1205  bool isSorted () const;
1206 
1208 
1214  bool isStorageOptimized () const;
1215 
1217  ProfileType getProfileType () const;
1218 
1224  void
1226  const Teuchos::ArrayView<global_ordinal_type>& gblColInds,
1227  size_t& numColInds) const override;
1228 
1236  void
1238  const Teuchos::ArrayView<local_ordinal_type>& lclColInds,
1239  size_t& numColInds) const override;
1240 
1251  void
1252  getGlobalRowView (const global_ordinal_type gblRow,
1253  Teuchos::ArrayView<const global_ordinal_type>& gblColInds) const override;
1254 
1257  bool supportsRowViews () const override;
1258 
1269  void
1270  getLocalRowView (const local_ordinal_type lclRow,
1271  Teuchos::ArrayView<const local_ordinal_type>& lclColInds) const override;
1272 
1274 
1276 
1278  std::string description () const override;
1279 
1282  void
1283  describe (Teuchos::FancyOStream& out,
1284  const Teuchos::EVerbosityLevel verbLevel =
1285  Teuchos::Describable::verbLevel_default) const override;
1286 
1288 
1290 
1298 
1299  virtual bool
1300  checkSizes (const SrcDistObject& source) override;
1301 
1302  virtual void
1303 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1304  copyAndPermuteNew
1305 #else // TPETRA_ENABLE_DEPRECATED_CODE
1306  copyAndPermute
1307 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1308  (const SrcDistObject& source,
1309  const size_t numSameIDs,
1310  const Kokkos::DualView<const local_ordinal_type*,
1311  buffer_device_type>& permuteToLIDs,
1312  const Kokkos::DualView<const local_ordinal_type*,
1313  buffer_device_type>& permuteFromLIDs) override;
1314 
1315  void
1316  applyCrsPadding (const Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>& padding);
1317 
1318  Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1319  computeCrsPadding (const RowGraph<local_ordinal_type, global_ordinal_type, Node>& source,
1320  size_t numSameIDs,
1321  const Teuchos::ArrayView<const local_ordinal_type> &permuteToLIDs,
1322  const Teuchos::ArrayView<const local_ordinal_type> &permuteFromLIDs);
1323 
1324  Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1325  computeCrsPaddingNew (const RowGraph<local_ordinal_type, global_ordinal_type, node_type>& source,
1326  const size_t numSameIDs,
1327  const Kokkos::DualView<const local_ordinal_type*,
1328  buffer_device_type>& permuteToLIDs,
1329  const Kokkos::DualView<const local_ordinal_type*,
1330  buffer_device_type>& permuteFromLIDs);
1331 
1332  Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1333  computeCrsPadding (const Teuchos::ArrayView<const local_ordinal_type>& importLIDs,
1334  const Teuchos::ArrayView<size_t>& numPacketsPerLID);
1335 
1336  Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1337  computeCrsPaddingNew (const Kokkos::DualView<const local_ordinal_type*,
1338  buffer_device_type>& importLIDs,
1339  Kokkos::DualView<size_t*,
1340  buffer_device_type> numPacketsPerLID) const;
1341 
1342  virtual void
1343 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1344  packAndPrepareNew
1345 #else // TPETRA_ENABLE_DEPRECATED_CODE
1346  packAndPrepare
1347 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1348  (const SrcDistObject& source,
1349  const Kokkos::DualView<const local_ordinal_type*,
1350  buffer_device_type>& exportLIDs,
1351  Kokkos::DualView<packet_type*,
1352  buffer_device_type>& exports,
1353  Kokkos::DualView<size_t*,
1354  buffer_device_type> numPacketsPerLID,
1355  size_t& constantNumPackets,
1356  Distributor& distor) override;
1357 
1358  virtual void
1359  pack (const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1360  Teuchos::Array<global_ordinal_type>& exports,
1361  const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1362  size_t& constantNumPackets,
1363  Distributor& distor) const override;
1364 
1365  void
1366  packFillActive (const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1367  Teuchos::Array<global_ordinal_type>& exports,
1368  const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1369  size_t& constantNumPackets,
1370  Distributor& distor) const;
1371 
1372  void
1373  packFillActiveNew (const Kokkos::DualView<const local_ordinal_type*,
1374  buffer_device_type>& exportLIDs,
1375  Kokkos::DualView<packet_type*,
1376  buffer_device_type>& exports,
1377  Kokkos::DualView<size_t*,
1378  buffer_device_type> numPacketsPerLID,
1379  size_t& constantNumPackets,
1380  Distributor& distor) const;
1381 
1382  virtual void
1383 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1384  unpackAndCombineNew
1385 #else // TPETRA_ENABLE_DEPRECATED_CODE
1386  unpackAndCombine
1387 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1388  (const Kokkos::DualView<const local_ordinal_type*,
1389  buffer_device_type>& importLIDs,
1390  Kokkos::DualView<packet_type*,
1391  buffer_device_type> imports,
1392  Kokkos::DualView<size_t*,
1393  buffer_device_type> numPacketsPerLID,
1394  const size_t constantNumPackets,
1395  Distributor& distor,
1396  const CombineMode combineMode) override;
1397 
1399 
1401 
1444  void
1445  getLocalDiagOffsets (const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets) const;
1446 
1456  void
1457  getLocalDiagOffsets (Teuchos::ArrayRCP<size_t>& offsets) const;
1458 
1481  void
1482  getNumEntriesPerLocalRowUpperBound (Teuchos::ArrayRCP<const size_t>& boundPerLocalRow,
1483  size_t& boundForAllLocalRows,
1484  bool& boundSameForAllLocalRows) const;
1485 
1494  void
1495  setAllIndices (const typename local_graph_type::row_map_type& rowPointers,
1496  const typename local_graph_type::entries_type::non_const_type& columnIndices);
1497 
1506  void
1507  setAllIndices (const Teuchos::ArrayRCP<size_t> & rowPointers,
1508  const Teuchos::ArrayRCP<local_ordinal_type> & columnIndices);
1509 
1517  Teuchos::ArrayRCP<const size_t> getNodeRowPtrs () const;
1518 
1520 
1522  Teuchos::ArrayRCP<const local_ordinal_type> getNodePackedIndices () const;
1523 
1534  void replaceColMap (const Teuchos::RCP<const map_type>& newColMap);
1535 
1555  void
1556  reindexColumns (const Teuchos::RCP<const map_type>& newColMap,
1557  const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1558  const bool sortIndicesInEachRow = true);
1559 
1573  void
1574  replaceDomainMapAndImporter (const Teuchos::RCP<const map_type>& newDomainMap,
1575  const Teuchos::RCP<const import_type>& newImporter);
1576 
1605  virtual void
1606  removeEmptyProcessesInPlace (const Teuchos::RCP<const map_type>& newMap) override;
1608 
1609  template<class ViewType, class OffsetViewType >
1610  struct pack_functor {
1611  typedef typename ViewType::execution_space execution_space;
1612  ViewType src;
1613  ViewType dest;
1614  OffsetViewType src_offset;
1615  OffsetViewType dest_offset;
1616  typedef typename OffsetViewType::non_const_value_type ScalarIndx;
1617 
1618  pack_functor(ViewType dest_, ViewType src_, OffsetViewType dest_offset_, OffsetViewType src_offset_):
1619  src(src_),dest(dest_),src_offset(src_offset_),dest_offset(dest_offset_) {};
1620 
1621  KOKKOS_INLINE_FUNCTION
1622  void operator() (size_t row) const {
1623  ScalarIndx i = src_offset(row);
1624  ScalarIndx j = dest_offset(row);
1625  const ScalarIndx k = dest_offset(row+1);
1626  for(;j<k;j++,i++) {
1627  dest(j) = src(i);
1628  }
1629  }
1630  };
1631 
1632  private:
1633  // Friend declaration for nonmember function.
1634  template<class CrsGraphType>
1635  friend Teuchos::RCP<CrsGraphType>
1636  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1637  const Import<typename CrsGraphType::local_ordinal_type,
1638  typename CrsGraphType::global_ordinal_type,
1639  typename CrsGraphType::node_type>& importer,
1640  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1641  typename CrsGraphType::global_ordinal_type,
1642  typename CrsGraphType::node_type> >& domainMap,
1643  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1644  typename CrsGraphType::global_ordinal_type,
1645  typename CrsGraphType::node_type> >& rangeMap,
1646  const Teuchos::RCP<Teuchos::ParameterList>& params);
1647 
1648  // Friend declaration for nonmember function.
1649  template<class CrsGraphType>
1650  friend Teuchos::RCP<CrsGraphType>
1651  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1652  const Import<typename CrsGraphType::local_ordinal_type,
1653  typename CrsGraphType::global_ordinal_type,
1654  typename CrsGraphType::node_type>& rowImporter,
1655  const Import<typename CrsGraphType::local_ordinal_type,
1656  typename CrsGraphType::global_ordinal_type,
1657  typename CrsGraphType::node_type>& domainImporter,
1658  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1659  typename CrsGraphType::global_ordinal_type,
1660  typename CrsGraphType::node_type> >& domainMap,
1661  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1662  typename CrsGraphType::global_ordinal_type,
1663  typename CrsGraphType::node_type> >& rangeMap,
1664  const Teuchos::RCP<Teuchos::ParameterList>& params);
1665 
1666 
1667  // Friend declaration for nonmember function.
1668  template<class CrsGraphType>
1669  friend Teuchos::RCP<CrsGraphType>
1670  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1671  const Export<typename CrsGraphType::local_ordinal_type,
1672  typename CrsGraphType::global_ordinal_type,
1673  typename CrsGraphType::node_type>& exporter,
1674  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1675  typename CrsGraphType::global_ordinal_type,
1676  typename CrsGraphType::node_type> >& domainMap,
1677  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1678  typename CrsGraphType::global_ordinal_type,
1679  typename CrsGraphType::node_type> >& rangeMap,
1680  const Teuchos::RCP<Teuchos::ParameterList>& params);
1681 
1682  // Friend declaration for nonmember function.
1683  template<class CrsGraphType>
1684  friend Teuchos::RCP<CrsGraphType>
1685  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1686  const Export<typename CrsGraphType::local_ordinal_type,
1687  typename CrsGraphType::global_ordinal_type,
1688  typename CrsGraphType::node_type>& rowExporter,
1689  const Export<typename CrsGraphType::local_ordinal_type,
1690  typename CrsGraphType::global_ordinal_type,
1691  typename CrsGraphType::node_type>& domainExporter,
1692  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1693  typename CrsGraphType::global_ordinal_type,
1694  typename CrsGraphType::node_type> >& domainMap,
1695  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1696  typename CrsGraphType::global_ordinal_type,
1697  typename CrsGraphType::node_type> >& rangeMap,
1698  const Teuchos::RCP<Teuchos::ParameterList>& params);
1699 
1700  template<class LO, class GO, class NT>
1701  friend void
1703  CrsGraph<LO, GO, NT>& graph,
1704  const Teuchos::ArrayView<const typename CrsGraph<LO,GO,NT>::packet_type>& imports,
1705  const Teuchos::ArrayView<const size_t>& numPacketsPerLID,
1706  const Teuchos::ArrayView<const LO>& importLIDs,
1707  size_t constantNumPackets,
1708  Distributor & distor,
1709  CombineMode combineMode);
1710 
1711  public:
1727  void
1728  importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1729  const import_type& importer,
1730  const Teuchos::RCP<const map_type>& domainMap,
1731  const Teuchos::RCP<const map_type>& rangeMap,
1732  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1733 
1749  void
1750  importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1751  const import_type& rowImporter,
1752  const import_type& domainImporter,
1753  const Teuchos::RCP<const map_type>& domainMap,
1754  const Teuchos::RCP<const map_type>& rangeMap,
1755  const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1756 
1757 
1773  void
1774  exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1775  const export_type& exporter,
1776  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1777  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1778  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1779 
1795  void
1796  exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1797  const export_type& rowExporter,
1798  const export_type& domainExporter,
1799  const Teuchos::RCP<const map_type>& domainMap,
1800  const Teuchos::RCP<const map_type>& rangeMap,
1801  const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1802 
1803 
1804  private:
1825  void
1826  transferAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1827  const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>& rowTransfer,
1828  const Teuchos::RCP<const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node> > & domainTransfer,
1829  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1830  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1831  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1832 
1833  protected:
1834  // these structs are conveniences, to cut down on the number of
1835  // arguments to some of the methods below.
1836  struct SLocalGlobalViews {
1837  Teuchos::ArrayView<const global_ordinal_type> ginds;
1838  Teuchos::ArrayView<const local_ordinal_type> linds;
1839  };
1840  struct SLocalGlobalNCViews {
1841  Teuchos::ArrayView<global_ordinal_type> ginds;
1842  Teuchos::ArrayView<local_ordinal_type> linds;
1843  };
1844 
1845  bool indicesAreAllocated () const;
1846  void allocateIndices (const ELocalGlobal lg);
1847 
1849 
1850 
1860  void makeColMap (Teuchos::Array<int>& remotePIDs);
1861 
1878  std::pair<size_t, std::string> makeIndicesLocal ();
1879 
1888  void
1889  makeImportExport (Teuchos::Array<int>& remotePIDs,
1890  const bool useRemotePIDs);
1891 
1893 
1895 
1930  size_t
1931  insertIndices (RowInfo& rowInfo,
1932  const SLocalGlobalViews& newInds,
1933  const ELocalGlobal lg,
1934  const ELocalGlobal I);
1935 
1945  size_t
1947  const global_ordinal_type inputGblColInds[],
1948  const size_t numInputInds);
1949 
1959  size_t
1960  insertGlobalIndicesImpl (const RowInfo& rowInfo,
1961  const global_ordinal_type inputGblColInds[],
1962  const size_t numInputInds,
1963  std::function<void(const size_t, const size_t, const size_t)> fun =
1964  std::function<void(const size_t, const size_t, const size_t)>());
1965 
1966  void
1967  insertLocalIndicesImpl (const local_ordinal_type lclRow,
1968  const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
1969  std::function<void(const size_t, const size_t, const size_t)> fun =
1970  std::function<void(const size_t, const size_t, const size_t)>());
1971 
1987  size_t
1988  findLocalIndices(const RowInfo& rowInfo,
1989  const Teuchos::ArrayView<const local_ordinal_type>& indices,
1990  std::function<void(const size_t, const size_t, const size_t)> fun) const;
1991 
1992  size_t
1993  findGlobalIndices(const RowInfo& rowInfo,
1994  const Teuchos::ArrayView<const global_ordinal_type>& indices,
1995  std::function<void(const size_t, const size_t, const size_t)> fun) const;
1996 
2008  void
2010  const global_ordinal_type gblColInds[],
2011  const local_ordinal_type numGblColInds);
2012 
2024  void
2026  const global_ordinal_type gblColInds[],
2027  const local_ordinal_type numGblColInds);
2028 
2033  static const bool useAtomicUpdatesByDefault =
2034 #ifdef KOKKOS_ENABLE_SERIAL
2035  ! std::is_same<execution_space, Kokkos::Serial>::value;
2036 #else
2037  true;
2038 #endif // KOKKOS_ENABLE_SERIAL
2039 
2041 
2043 
2045  bool isMerged () const;
2046 
2052  void setLocallyModified ();
2053 
2054  private:
2059  void
2060  sortAndMergeAllIndices (const bool sorted, const bool merged);
2061 
2062  // mfh 08 May 2017: I only restore "protected" here for backwards
2063  // compatibility.
2064  protected:
2073  size_t sortAndMergeRowIndices (const RowInfo& rowInfo,
2074  const bool sorted,
2075  const bool merged);
2077 
2087  void
2088  setDomainRangeMaps (const Teuchos::RCP<const map_type>& domainMap,
2089  const Teuchos::RCP<const map_type>& rangeMap);
2090 
2091  void staticAssertions() const;
2092  void clearGlobalConstants();
2093 
2094  public:
2097 
2126  void computeGlobalConstants (const bool computeLocalTriangularConstants);
2127 
2128  protected:
2163  void computeLocalConstants (const bool computeLocalTriangularConstants);
2164 
2167  RowInfo getRowInfo (const local_ordinal_type myRow) const;
2168 
2182 
2186  Teuchos::ArrayView<const local_ordinal_type>
2187  getLocalView (const RowInfo& rowinfo) const;
2188 
2192  Teuchos::ArrayView<local_ordinal_type>
2193  getLocalViewNonConst (const RowInfo& rowinfo);
2194 
2207  getLocalViewRawConst (const local_ordinal_type*& lclInds,
2208  local_ordinal_type& capacity,
2209  const RowInfo& rowInfo) const;
2210 
2211  private:
2212 
2219  Kokkos::View<const local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2220  getLocalKokkosRowView (const RowInfo& rowInfo) const;
2221 
2228  Kokkos::View<local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2229  getLocalKokkosRowViewNonConst (const RowInfo& rowInfo);
2230 
2237  Kokkos::View<const global_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2238  getGlobalKokkosRowView (const RowInfo& rowInfo) const;
2239 
2240  protected:
2241 
2245  Teuchos::ArrayView<const global_ordinal_type>
2246  getGlobalView (const RowInfo& rowinfo) const;
2247 
2251  Teuchos::ArrayView<global_ordinal_type>
2252  getGlobalViewNonConst (const RowInfo& rowinfo);
2253 
2267  getGlobalViewRawConst (const global_ordinal_type*& gblInds,
2268  local_ordinal_type& capacity,
2269  const RowInfo& rowInfo) const;
2270 
2271 
2272  public:
2273 
2274 
2283 
2284 
2285  protected:
2286 
2287 
2288  void fillLocalGraph (const Teuchos::RCP<Teuchos::ParameterList>& params);
2289 
2291  void checkInternalState () const;
2292 
2297 
2298  // Friend the tester for CrsGraph::swap
2299  friend class Tpetra::crsGraph_Swap_Tester<local_ordinal_type, global_ordinal_type, Node>;
2300 
2301 
2303  Teuchos::RCP<const map_type> rowMap_;
2305  Teuchos::RCP<const map_type> colMap_;
2307  Teuchos::RCP<const map_type> rangeMap_;
2309  Teuchos::RCP<const map_type> domainMap_;
2310 
2317  Teuchos::RCP<const import_type> importer_;
2318 
2324  Teuchos::RCP<const export_type> exporter_;
2325 
2328 
2333 
2338 
2343 
2348 
2353 
2356 
2382  typename Kokkos::View<const size_t*, execution_space>::HostMirror
2384 
2395 
2397 
2398 
2406  typename local_graph_type::entries_type::non_const_type k_lclInds1D_;
2407 
2409  typedef Kokkos::View<global_ordinal_type*, execution_space> t_GlobalOrdinal_1D;
2410 
2419 
2444  typename local_graph_type::row_map_type::const_type k_rowPtrs_;
2445 
2447 
2459 
2471  Teuchos::ArrayRCP<Teuchos::Array<local_ordinal_type> > lclInds2D_;
2472 
2484  Teuchos::ArrayRCP<Teuchos::Array<global_ordinal_type> > gblInds2D_;
2485 
2493  typedef typename Kokkos::View<size_t*, Kokkos::LayoutLeft, device_type>::HostMirror num_row_entries_type;
2494 
2495  // typedef Kokkos::View<
2496  // size_t*,
2497  // Kokkos::LayoutLeft,
2498  // Kokkos::Device<
2499  // typename Kokkos::View<
2500  // size_t*,
2501  // Kokkos::LayoutLeft,
2502  // device_type>::HostMirror::execution_space,
2503  // Kokkos::HostSpace> > num_row_entries_type;
2504 
2512 
2514 
2525 
2526  bool indicesAreAllocated_;
2527  bool indicesAreLocal_;
2528  bool indicesAreGlobal_;
2529  bool fillComplete_;
2530 
2544 
2545  typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type> > nonlocals_type;
2546 
2548  nonlocals_type nonlocals_;
2549 
2565 
2566  }; // class CrsGraph
2567 
2574  template <class LocalOrdinal, class GlobalOrdinal, class Node>
2575  Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
2576  createCrsGraph (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map,
2577  size_t maxNumEntriesPerRow = 0,
2578  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2579  {
2580  using Teuchos::rcp;
2582  return rcp (new graph_type (map, maxNumEntriesPerRow, DynamicProfile, params));
2583  }
2584 
2633  template<class CrsGraphType>
2634  Teuchos::RCP<CrsGraphType>
2635  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2636  const Import<typename CrsGraphType::local_ordinal_type,
2637  typename CrsGraphType::global_ordinal_type,
2638  typename CrsGraphType::node_type>& importer,
2639  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2640  typename CrsGraphType::global_ordinal_type,
2641  typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2642  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2643  typename CrsGraphType::global_ordinal_type,
2644  typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2645  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2646  {
2647  Teuchos::RCP<CrsGraphType> destGraph;
2648  sourceGraph->importAndFillComplete (destGraph,importer,domainMap, rangeMap, params);
2649  return destGraph;
2650  }
2651 
2702  template<class CrsGraphType>
2703  Teuchos::RCP<CrsGraphType>
2704  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2705  const Import<typename CrsGraphType::local_ordinal_type,
2706  typename CrsGraphType::global_ordinal_type,
2707  typename CrsGraphType::node_type>& rowImporter,
2708  const Import<typename CrsGraphType::local_ordinal_type,
2709  typename CrsGraphType::global_ordinal_type,
2710  typename CrsGraphType::node_type>& domainImporter,
2711  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2712  typename CrsGraphType::global_ordinal_type,
2713  typename CrsGraphType::node_type> >& domainMap,
2714  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2715  typename CrsGraphType::global_ordinal_type,
2716  typename CrsGraphType::node_type> >& rangeMap,
2717  const Teuchos::RCP<Teuchos::ParameterList>& params)
2718  {
2719  Teuchos::RCP<CrsGraphType> destGraph;
2720  sourceGraph->importAndFillComplete (destGraph,rowImporter,domainImporter, domainMap, rangeMap, params);
2721  return destGraph;
2722  }
2723 
2757  template<class CrsGraphType>
2758  Teuchos::RCP<CrsGraphType>
2759  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2760  const Export<typename CrsGraphType::local_ordinal_type,
2761  typename CrsGraphType::global_ordinal_type,
2762  typename CrsGraphType::node_type>& exporter,
2763  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2764  typename CrsGraphType::global_ordinal_type,
2765  typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2766  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2767  typename CrsGraphType::global_ordinal_type,
2768  typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2769  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2770  {
2771  Teuchos::RCP<CrsGraphType> destGraph;
2772  sourceGraph->exportAndFillComplete (destGraph,exporter,domainMap, rangeMap, params);
2773  return destGraph;
2774  }
2775 
2809  template<class CrsGraphType>
2810  Teuchos::RCP<CrsGraphType>
2811  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2812  const Export<typename CrsGraphType::local_ordinal_type,
2813  typename CrsGraphType::global_ordinal_type,
2814  typename CrsGraphType::node_type>& rowExporter,
2815  const Export<typename CrsGraphType::local_ordinal_type,
2816  typename CrsGraphType::global_ordinal_type,
2817  typename CrsGraphType::node_type>& domainExporter,
2818  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2819  typename CrsGraphType::global_ordinal_type,
2820  typename CrsGraphType::node_type> >& domainMap,
2821  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2822  typename CrsGraphType::global_ordinal_type,
2823  typename CrsGraphType::node_type> >& rangeMap,
2824  const Teuchos::RCP<Teuchos::ParameterList>& params)
2825  {
2826  Teuchos::RCP<CrsGraphType> destGraph;
2827  sourceGraph->exportAndFillComplete (destGraph,rowExporter,domainExporter,domainMap, rangeMap, params);
2828  return destGraph;
2829  }
2830 
2831 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2832  namespace Details {
2833  template<class LocalOrdinal,
2834  class GlobalOrdinal,
2835  class OutputNodeType,
2836  class InputNodeType>
2837  class CrsGraphCopier<CrsGraph<LocalOrdinal, GlobalOrdinal, OutputNodeType>,
2838  CrsGraph<LocalOrdinal, GlobalOrdinal, InputNodeType> > {
2839  public:
2840  typedef CrsGraph<LocalOrdinal, GlobalOrdinal, InputNodeType> input_crs_graph_type;
2841  typedef CrsGraph<LocalOrdinal, GlobalOrdinal, OutputNodeType> output_crs_graph_type;
2842 
2843  static Teuchos::RCP<output_crs_graph_type> TPETRA_DEPRECATED
2844  clone (const input_crs_graph_type& graphIn,
2845  const Teuchos::RCP<OutputNodeType> &nodeOut,
2846  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2847  {
2848  using Teuchos::arcp;
2849  using Teuchos::Array;
2850  using Teuchos::ArrayRCP;
2851  using Teuchos::ArrayView;
2852  using Teuchos::null;
2853  using Teuchos::outArg;
2854  using Teuchos::ParameterList;
2855  using Teuchos::parameterList;
2856  using Teuchos::RCP;
2857  using Teuchos::rcp;
2858  using Teuchos::REDUCE_MIN;
2859  using Teuchos::reduceAll;
2860  using Teuchos::sublist;
2861  using std::cerr;
2862  using std::endl;
2863  typedef LocalOrdinal LO;
2864  typedef GlobalOrdinal GO;
2865  typedef typename ArrayView<const GO>::size_type size_type;
2866  typedef ::Tpetra::Map<LO, GO, InputNodeType> input_map_type;
2867  typedef ::Tpetra::Map<LO, GO, OutputNodeType> output_map_type;
2868  const char prefix[] = "Tpetra::Details::CrsGraphCopier::clone: ";
2869 
2870  // Set parameters' default values.
2871  bool debug = false;
2872  bool fillCompleteClone = true;
2873  bool useLocalIndices = graphIn.hasColMap ();
2874  ProfileType pftype = StaticProfile;
2875  // If the user provided a ParameterList, get values from there.
2876  if (! params.is_null ()) {
2877  fillCompleteClone = params->get ("fillComplete clone", fillCompleteClone);
2878  useLocalIndices = params->get ("Locally indexed clone", useLocalIndices);
2879  if (params->get ("Static profile clone", true) == false) {
2880  pftype = DynamicProfile;
2881  }
2882  debug = params->get ("Debug", debug);
2883  }
2884 
2885  const Teuchos::Comm<int>& comm = * (graphIn.getRowMap ()->getComm ());
2886  const int myRank = comm.getRank ();
2887 
2888  TEUCHOS_TEST_FOR_EXCEPTION
2889  (! graphIn.hasColMap () && useLocalIndices, std::runtime_error,
2890  prefix << "You asked clone() to use local indices (by setting the "
2891  "\"Locally indexed clone\" parameter to true), but the source graph "
2892  "does not yet have a column Map, so this is impossible.");
2893 
2894  if (debug) {
2895  std::ostringstream os;
2896  os << "Process " << myRank << ": Cloning row Map" << endl;
2897  cerr << os.str ();
2898  }
2899 
2900  RCP<const output_map_type> clonedRowMap =
2901  graphIn.getRowMap ()->template clone<OutputNodeType> (nodeOut);
2902 
2903  // Invoke the output graph's constructor, using the input graph's
2904  // upper bounds on the number of entries in each local row.
2905  RCP<output_crs_graph_type> clonedGraph; // returned by this function
2906  {
2907  ArrayRCP<const size_t> numEntriesPerRow;
2908  size_t numEntriesForAll = 0;
2909  bool boundSameForAllLocalRows = true;
2910 
2911  if (debug) {
2912  std::ostringstream os;
2913  os << "Process " << myRank << ": Getting per-row bounds" << endl;
2914  cerr << os.str ();
2915  }
2916  graphIn.getNumEntriesPerLocalRowUpperBound (numEntriesPerRow,
2917  numEntriesForAll,
2918  boundSameForAllLocalRows);
2919  if (debug) {
2920  std::ostringstream os;
2921  os << "Process " << myRank << ": numEntriesForAll = "
2922  << numEntriesForAll << endl;
2923  cerr << os.str ();
2924  }
2925 
2926  if (debug) {
2927  std::ostringstream os;
2928  os << "Process " << myRank << ": graphIn.getNodeMaxNumRowEntries() = "
2929  << graphIn.getNodeMaxNumRowEntries () << endl;
2930  cerr << os.str ();
2931  }
2932 
2933  RCP<ParameterList> graphparams;
2934  if (params.is_null ()) {
2935  graphparams = parameterList ("CrsGraph");
2936  } else {
2937  graphparams = sublist (params, "CrsGraph");
2938  }
2939  if (useLocalIndices) {
2940  RCP<const output_map_type> clonedColMap =
2941  graphIn.getColMap ()->template clone<OutputNodeType> (nodeOut);
2942  if (boundSameForAllLocalRows) {
2943  clonedGraph = rcp (new output_crs_graph_type (clonedRowMap, clonedColMap,
2944  numEntriesForAll, pftype,
2945  graphparams));
2946  } else {
2947  clonedGraph = rcp (new output_crs_graph_type (clonedRowMap, clonedColMap,
2948  numEntriesPerRow (), pftype,
2949  graphparams));
2950  }
2951  } else {
2952  if (boundSameForAllLocalRows) {
2953  clonedGraph = rcp (new output_crs_graph_type (clonedRowMap,
2954  numEntriesForAll, pftype,
2955  graphparams));
2956  } else {
2957  clonedGraph = rcp (new output_crs_graph_type (clonedRowMap,
2958  numEntriesPerRow (),
2959  pftype, graphparams));
2960  }
2961  }
2962 
2963  if (debug) {
2964  std::ostringstream os;
2965  os << "Process " << myRank << ": Invoked output graph's constructor" << endl;
2966  cerr << os.str ();
2967  }
2968 
2969  // done with these
2970  numEntriesPerRow = null;
2971  numEntriesForAll = 0;
2972  }
2973 
2974  const input_map_type& inputRowMap = * (graphIn.getRowMap ());
2975  const size_type numRows =
2976  static_cast<size_type> (inputRowMap.getNodeNumElements ());
2977 
2978  bool failed = false;
2979 
2980  if (useLocalIndices) {
2981  const LO localMinLID = inputRowMap.getMinLocalIndex ();
2982  const LO localMaxLID = inputRowMap.getMaxLocalIndex ();
2983 
2984  if (graphIn.isLocallyIndexed ()) {
2985  if (numRows != 0) {
2986  try {
2987  ArrayView<const LO> linds;
2988  for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
2989  graphIn.getLocalRowView (lrow, linds);
2990  if (linds.size () != 0) {
2991  clonedGraph->insertLocalIndices (lrow, linds);
2992  }
2993  }
2994  }
2995  catch (std::exception& e) {
2996  std::ostringstream os;
2997  os << "Process " << myRank << ": copying (reading local by view, "
2998  "writing local) indices into the output graph threw an "
2999  "exception: " << e.what () << endl;
3000  cerr << os.str ();
3001  failed = true;
3002  }
3003  }
3004  }
3005  else { // graphIn.isGloballyIndexed()
3006  TEUCHOS_TEST_FOR_EXCEPTION(
3007  ! graphIn.hasColMap () && useLocalIndices, std::invalid_argument,
3008  prefix << "You asked clone() to use local indices (by setting the "
3009  "\"Locally indexed clone\" parameter to true), but the source graph "
3010  "does not yet have a column Map, so this is impossible.");
3011 
3012  // The input graph has a column Map, but is globally indexed.
3013  // That's a bit weird, but we'll run with it. In this case,
3014  // getLocalRowView won't work, but getLocalRowCopy should
3015  // still work; it will just have to convert from global to
3016  // local indices internally.
3017 
3018  try {
3019  // Make space for getLocalRowCopy to put column indices.
3020  //
3021  // This is only a hint; we may have to resize in the loop
3022  // below. getNodeMaxNumRowEntries() may return nonsense if
3023  // fill is active. The key bool in CrsGraph is
3024  // haveLocalConstants_.
3025  size_t myMaxNumRowEntries =
3026  graphIn.isFillActive () ? static_cast<size_t> (0) :
3027  graphIn.getNodeMaxNumRowEntries ();
3028 
3029  Array<LO> linds (myMaxNumRowEntries);
3030 
3031  // Copy each row into the new graph, using local indices.
3032  for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
3033  size_t theNumEntries = graphIn.getNumEntriesInLocalRow (lrow);
3034  if (theNumEntries > myMaxNumRowEntries) {
3035  myMaxNumRowEntries = theNumEntries;
3036  linds.resize (myMaxNumRowEntries);
3037  }
3038  graphIn.getLocalRowCopy (lrow, linds (), theNumEntries);
3039  if (theNumEntries != 0) {
3040  clonedGraph->insertLocalIndices (lrow, linds (0, theNumEntries));
3041  }
3042  }
3043  }
3044  catch (std::exception& e) {
3045  std::ostringstream os;
3046  os << "Process " << myRank << ": copying (reading local by copy, "
3047  "writing local) indices into the output graph threw an exception: "
3048  << e.what () << endl;
3049  cerr << os.str ();
3050  failed = true;
3051  }
3052  }
3053  }
3054  else { /* useGlobalIndices */
3055  if (numRows != 0) {
3056  const GlobalOrdinal localMinGID = inputRowMap.getMinGlobalIndex ();
3057  const GlobalOrdinal localMaxGID = inputRowMap.getMaxGlobalIndex ();
3058  const bool inputRowMapIsContiguous = inputRowMap.isContiguous ();
3059 
3060  if (graphIn.isGloballyIndexed ()) {
3061  ArrayView<const GlobalOrdinal> ginds;
3062 
3063  if (inputRowMapIsContiguous) {
3064  try {
3065  for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
3066  graphIn.getGlobalRowView (grow, ginds);
3067  if (ginds.size () != 0) {
3068  clonedGraph->insertGlobalIndices (grow, ginds);
3069  }
3070  }
3071  }
3072  catch (std::exception& e) {
3073  std::ostringstream os;
3074  os << "Process " << myRank << ": copying (reading global by view, "
3075  "writing global) indices into the output graph threw an "
3076  "exception: " << e.what () << endl;
3077  cerr << os.str ();
3078  failed = true;
3079  }
3080  }
3081  else { // input row Map is not contiguous
3082  try {
3083  ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
3084  for (size_type k = 0; k < numRows; ++k) {
3085  const GO grow = inputRowMapGIDs[k];
3086  graphIn.getGlobalRowView (grow, ginds);
3087  if (ginds.size () != 0) {
3088  clonedGraph->insertGlobalIndices (grow, ginds);
3089  }
3090  }
3091  }
3092  catch (std::exception& e) {
3093  std::ostringstream os;
3094  os << "Process " << myRank << ": copying (reading global by view, "
3095  "writing global) indices into the output graph threw an "
3096  "exception: " << e.what () << endl;
3097  cerr << os.str ();
3098  failed = true;
3099  }
3100  }
3101  }
3102  else { // graphIn.isLocallyIndexed()
3103  // Make space for getGlobalRowCopy to put column indices.
3104  //
3105  // This is only a hint; we may have to resize in the loop
3106  // below. getNodeMaxNumRowEntries() may return nonsense if
3107  // fill is active. The key bool in CrsGraph is
3108  // haveLocalConstants_.
3109  size_t myMaxNumRowEntries =
3110  graphIn.isFillActive () ? static_cast<size_t> (0) :
3111  graphIn.getNodeMaxNumRowEntries ();
3112 
3113  Array<GO> ginds (myMaxNumRowEntries);
3114 
3115  if (inputRowMapIsContiguous) {
3116  try {
3117  for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
3118  size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
3119  if (theNumEntries > myMaxNumRowEntries) {
3120  myMaxNumRowEntries = theNumEntries;
3121  ginds.resize (myMaxNumRowEntries);
3122  }
3123  graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
3124  if (theNumEntries != 0) {
3125  clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
3126  }
3127  }
3128  }
3129  catch (std::exception& e) {
3130  std::ostringstream os;
3131  os << "Process " << myRank << ": copying (reading global by copy, "
3132  "writing global) indices into the output graph threw an "
3133  "exception: " << e.what () << endl;
3134  cerr << os.str ();
3135  failed = true;
3136  }
3137  }
3138  else { // input row Map is not contiguous
3139  try {
3140  ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
3141  for (size_type k = 0; k < numRows; ++k) {
3142  const GO grow = inputRowMapGIDs[k];
3143 
3144  size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
3145  if (theNumEntries > myMaxNumRowEntries) {
3146  myMaxNumRowEntries = theNumEntries;
3147  ginds.resize (myMaxNumRowEntries);
3148  }
3149  graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
3150  if (theNumEntries != 0) {
3151  clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
3152  }
3153  }
3154  }
3155  catch (std::exception& e) {
3156  std::ostringstream os;
3157  os << "Process " << myRank << ": copying (reading global by copy, "
3158  "writing global) indices into the output graph threw an "
3159  "exception: " << e.what () << endl;
3160  cerr << os.str ();
3161  failed = true;
3162  }
3163  }
3164  }
3165  } // numRows != 0
3166  }
3167 
3168  if (debug) {
3169  std::ostringstream os;
3170  os << "Process " << myRank << ": copied entries" << endl;
3171  cerr << os.str ();
3172  }
3173 
3174  if (fillCompleteClone) {
3175  RCP<ParameterList> fillparams = params.is_null () ?
3176  parameterList ("fillComplete") :
3177  sublist (params, "fillComplete");
3178  try {
3179  RCP<const output_map_type> clonedRangeMap;
3180  RCP<const output_map_type> clonedDomainMap;
3181  if (! graphIn.getRangeMap ().is_null () &&
3182  graphIn.getRangeMap () != graphIn.getRowMap ()) {
3183  clonedRangeMap =
3184  graphIn.getRangeMap ()->template clone<OutputNodeType> (nodeOut);
3185  }
3186  else {
3187  clonedRangeMap = clonedRowMap;
3188  }
3189  if (! graphIn.getDomainMap ().is_null ()
3190  && graphIn.getDomainMap () != graphIn.getRowMap ()) {
3191  clonedDomainMap =
3192  graphIn.getDomainMap ()->template clone<OutputNodeType> (nodeOut);
3193  }
3194  else {
3195  clonedDomainMap = clonedRowMap;
3196  }
3197 
3198  if (debug) {
3199  std::ostringstream os;
3200  os << "Process " << myRank << ": About to call fillComplete on "
3201  "cloned graph" << endl;
3202  cerr << os.str ();
3203  }
3204  clonedGraph->fillComplete (clonedDomainMap, clonedRangeMap, fillparams);
3205  }
3206  catch (std::exception &e) {
3207  failed = true;
3208  std::ostringstream os;
3209  os << prefix << "Process " << myRank << ": Caught the following "
3210  "exception while calling fillComplete() on clone of type"
3211  << endl << Teuchos::typeName (*clonedGraph) << endl;
3212  cerr << os.str ();
3213  }
3214  }
3215 
3216  int lclSuccess = failed ? 0 : 1;
3217  int gblSuccess = 1;
3218  reduceAll<int, int> (comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
3219  TEUCHOS_TEST_FOR_EXCEPTION
3220  (gblSuccess != 1, std::logic_error,
3221  prefix << "Clone failed on at least one process.");
3222 
3223  if (debug) {
3224  std::ostringstream os;
3225  os << "Process " << myRank << ": Done with CrsGraph::clone" << endl;
3226  cerr << os.str ();
3227  }
3228  return clonedGraph;
3229  }
3230  }; // class CrsGraphCopier
3231  } // namespace Details
3232 #endif // TPETRA_ENABLE_DEPRECATED_CODE
3233 
3234 } // namespace Tpetra
3235 
3236 #endif // TPETRA_CRSGRAPH_DECL_HPP
Teuchos::ArrayRCP< Teuchos::Array< local_ordinal_type > > lclInds2D_
Local column indices for all rows.
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.
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 lowerTriangular_
Whether the graph is locally lower triangular.
size_t nodeNumDiags_
Local number of (populated) diagonal entries.
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.
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.
global_size_t globalNumDiags_
Global number of (populated) diagonal entries.
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.
bool upperTriangular_
Whether the graph is locally upper triangular.
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 ...
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.
std::pair< size_t, std::string > makeIndicesLocal()
Convert column indices from global to local.
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.
::Tpetra::Details::EStorageStatus storageStatus_
Status of the graph&#39;s storage, when not in a fill-complete state.
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.
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.
Kokkos::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, execution_space > local_graph_type
The type of the part of the sparse graph on each MPI process.
local_graph_type lclGraph_
Local graph; only initialized after first fillComplete() call.
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.
void computeLocalConstants(const bool computeLocalTriangularConstants)
Compute local constants, if they have not yet been computed.
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.
CrsGraphType::global_ordinal_type getGlobalNumDiags(const CrsGraphType &G)
Number of populated diagonal entries in the given sparse graph, over all processes in the graph&#39;s (MP...
Teuchos::ArrayRCP< Teuchos::Array< global_ordinal_type > > gblInds2D_
Global column indices for all rows.
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...
ProfileType pftype_
Whether the graph was allocated with static or dynamic profile.
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
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
void computeGlobalConstants(const bool computeLocalTriangularConstants)
Compute global constants, if they have not yet been computed.
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...
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.
void unpackCrsGraphAndCombine(CrsGraph< LO, GO, NT > &sourceGraph, const Teuchos::ArrayView< const typename CrsGraph< LO, GO, NT >::packet_type > &imports, const Teuchos::ArrayView< const size_t > &numPacketsPerLID, const Teuchos::ArrayView< const LO > &importLIDs, size_t constantNumPackets, Distributor &distor, CombineMode combineMode)
Unpack the imported column indices and combine into graph.
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.