40 #ifndef TPETRA_CRSGRAPH_DECL_HPP
41 #define TPETRA_CRSGRAPH_DECL_HPP
54 #include "Tpetra_DistObject.hpp"
55 #include "Tpetra_Exceptions.hpp"
56 #include "Tpetra_RowGraph.hpp"
59 #include "KokkosSparse_findRelOffset.hpp"
60 #include "Kokkos_DualView.hpp"
61 #include "Kokkos_StaticCrsGraph.hpp"
63 #include "Teuchos_CommHelpers.hpp"
64 #include "Teuchos_Describable.hpp"
65 #include "Teuchos_OrdinalTraits.hpp"
66 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
75 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
class crsGraph_Swap_Tester;
77 #ifndef DOXYGEN_SHOULD_SKIP_THIS
79 template<
class LocalOrdinal,
86 template<
class ViewType>
87 struct UnmanagedView {
88 static_assert (Kokkos::is_view<ViewType>::value,
89 "ViewType must be a Kokkos::View specialization.");
93 typedef Kokkos::View<
typename ViewType::data_type,
94 typename ViewType::array_layout,
95 typename ViewType::device_type,
96 Kokkos::MemoryUnmanaged> type;
100 #endif // DOXYGEN_SHOULD_SKIP_THIS
219 template <
class LocalOrdinal,
223 public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
228 public Teuchos::ParameterListAcceptorDefaultBase
230 template <
class S,
class LO,
class GO,
class N>
232 template <
class LO2,
class GO2,
class N2>
234 template <
class LO,
class GO,
class N>
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);
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);
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);
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);
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);
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);
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);
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);
477 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
478 const Teuchos::RCP<const map_type>& colMap,
480 const Teuchos::RCP<Teuchos::ParameterList>& params);
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);
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 =
603 setParameterList (
const Teuchos::RCP<Teuchos::ParameterList>& params)
override;
606 Teuchos::RCP<const Teuchos::ParameterList>
636 const Teuchos::ArrayView<const global_ordinal_type>& indices);
666 const Teuchos::ArrayView<const local_ordinal_type>& indices);
723 resumeFill (
const Teuchos::RCP<Teuchos::ParameterList>& params =
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);
796 fillComplete (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
828 const Teuchos::RCP<const map_type>& rangeMap,
829 const Teuchos::RCP<const import_type>& importer =
831 const Teuchos::RCP<const export_type>& exporter =
833 const Teuchos::RCP<Teuchos::ParameterList>& params =
840 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const override;
844 Teuchos::RCP<const map_type>
getRowMap ()
const override;
847 Teuchos::RCP<const map_type>
getColMap ()
const override;
850 Teuchos::RCP<const map_type>
getDomainMap ()
const override;
853 Teuchos::RCP<const map_type>
getRangeMap ()
const override;
856 Teuchos::RCP<const import_type>
getImporter ()
const override;
859 Teuchos::RCP<const export_type>
getExporter ()
const override;
1043 const Teuchos::ArrayView<global_ordinal_type>& gblColInds,
1044 size_t& numColInds)
const override;
1055 const Teuchos::ArrayView<local_ordinal_type>& lclColInds,
1056 size_t& numColInds)
const override;
1070 Teuchos::ArrayView<const global_ordinal_type>& gblColInds)
const override;
1088 Teuchos::ArrayView<const local_ordinal_type>& lclColInds)
const override;
1100 describe (Teuchos::FancyOStream& out,
1101 const Teuchos::EVerbosityLevel verbLevel =
1102 Teuchos::Describable::verbLevel_default)
const override;
1122 const size_t numSameIDs,
1133 const bool verbose);
1135 std::unique_ptr<padding_type>
1139 const size_t numSameIDs,
1144 const bool verbose)
const;
1147 std::unique_ptr<padding_type>
1148 computeCrsPaddingForImports(
1151 Kokkos::DualView<packet_type*, buffer_device_type> imports,
1152 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1153 const bool verbose)
const;
1155 std::unique_ptr<padding_type>
1156 computePaddingForCrsMatrixUnpack(
1159 Kokkos::DualView<char*, buffer_device_type> imports,
1160 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID,
1161 const bool verbose)
const;
1164 computeCrsPaddingForSameIDs(
1171 computeCrsPaddingForPermutedIDs(
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,
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,
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,
1208 Kokkos::DualView<
size_t*,
1210 size_t& constantNumPackets,
1219 Kokkos::DualView<
size_t*,
1221 const size_t constantNumPackets,
1272 getLocalDiagOffsets (
const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets)
const;
1310 size_t& boundForAllLocalRows,
1311 bool& boundSameForAllLocalRows)
const;
1323 setAllIndices (
const typename local_graph_type::row_map_type& rowPointers,
1324 const typename local_graph_type::entries_type::non_const_type& columnIndices);
1336 setAllIndices (
const Teuchos::ArrayRCP<size_t> & rowPointers,
1337 const Teuchos::ArrayRCP<local_ordinal_type> & columnIndices);
1371 void replaceColMap (
const Teuchos::RCP<const map_type>& newColMap);
1394 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1395 const bool sortIndicesInEachRow =
true);
1412 const Teuchos::RCP<const import_type>& newImporter);
1446 template<
class ViewType,
class OffsetViewType >
1447 struct pack_functor {
1451 OffsetViewType src_offset;
1452 OffsetViewType dest_offset;
1453 typedef typename OffsetViewType::non_const_value_type ScalarIndx;
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_) {};
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);
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);
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);
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);
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);
1554 importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
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;
1576 importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1579 const Teuchos::RCP<const map_type>& domainMap,
1580 const Teuchos::RCP<const map_type>& rangeMap,
1581 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
1600 exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
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;
1622 exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1625 const Teuchos::RCP<const map_type>& domainMap,
1626 const Teuchos::RCP<const map_type>& rangeMap,
1627 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
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;
1662 struct SLocalGlobalViews {
1663 Teuchos::ArrayView<const global_ordinal_type> ginds;
1664 Teuchos::ArrayView<const local_ordinal_type> linds;
1666 struct SLocalGlobalNCViews {
1667 Teuchos::ArrayView<global_ordinal_type> ginds;
1668 Teuchos::ArrayView<local_ordinal_type> linds;
1671 bool indicesAreAllocated ()
const;
1674 allocateIndices(
const ELocalGlobal lg,
const bool verbose=
false);
1688 void makeColMap (Teuchos::Array<int>& remotePIDs);
1710 std::pair<size_t, std::string>
1723 const bool useRemotePIDs);
1765 const SLocalGlobalViews& newInds,
1766 const ELocalGlobal lg,
1767 const ELocalGlobal I);
1781 const size_t numInputInds);
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)>());
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)>());
1822 const Teuchos::ArrayView<const local_ordinal_type>& indices,
1823 std::function<
void(
const size_t,
const size_t,
const size_t)> fun)
const;
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;
1867 #ifdef KOKKOS_ENABLE_SERIAL
1868 ! std::is_same<execution_space, Kokkos::Serial>::value;
1871 #endif // KOKKOS_ENABLE_SERIAL
1893 sortAndMergeAllIndices (
const bool sorted,
const bool merged);
1922 const Teuchos::RCP<const map_type>& rangeMap);
1924 void staticAssertions()
const;
1925 void clearGlobalConstants();
1993 Teuchos::ArrayView<const local_ordinal_type>
1999 Teuchos::ArrayView<local_ordinal_type>
2016 const RowInfo& rowInfo)
const;
2026 Kokkos::View<const local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2027 getLocalKokkosRowView (
const RowInfo& rowInfo)
const;
2035 Kokkos::View<local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2036 getLocalKokkosRowViewNonConst (
const RowInfo& rowInfo);
2044 Kokkos::View<const global_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2045 getGlobalKokkosRowView (
const RowInfo& rowInfo)
const;
2052 Teuchos::ArrayView<const global_ordinal_type>
2058 Teuchos::ArrayView<global_ordinal_type>
2076 const RowInfo& rowInfo)
const;
2095 void fillLocalGraph (
const Teuchos::RCP<Teuchos::ParameterList>& params);
2141 Teuchos::OrdinalTraits<size_t>::invalid();
2147 Teuchos::OrdinalTraits<global_size_t>::invalid();
2154 Teuchos::OrdinalTraits<global_size_t>::invalid();
2181 typename Kokkos::View<const size_t*, execution_space>::HostMirror
2279 Details::STORAGE_1D_UNPACKED;
2281 bool indicesAreAllocated_ =
false;
2282 bool indicesAreLocal_ =
false;
2283 bool indicesAreGlobal_ =
false;
2284 bool fillComplete_ =
false;
2296 typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type> > nonlocals_type;
2319 static bool getDebug();
2323 bool debug_ = getDebug();
2326 static bool getVerbose();
2331 bool verbose_ = getVerbose();
2342 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2343 Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
2347 size_t maxNumEntriesPerRow = 0,
2348 const Teuchos::RCP<Teuchos::ParameterList>& params =
2353 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE;
2354 return rcp(
new graph_type(map, maxNumEntriesPerRow,
2407 template<
class CrsGraphType>
2408 Teuchos::RCP<CrsGraphType>
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)
2421 Teuchos::RCP<CrsGraphType> destGraph;
2422 sourceGraph->importAndFillComplete (destGraph,importer,domainMap, rangeMap, params);
2476 template<
class CrsGraphType>
2477 Teuchos::RCP<CrsGraphType>
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)
2493 Teuchos::RCP<CrsGraphType> destGraph;
2494 sourceGraph->importAndFillComplete (destGraph,rowImporter,domainImporter, domainMap, rangeMap, params);
2531 template<
class CrsGraphType>
2532 Teuchos::RCP<CrsGraphType>
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)
2545 Teuchos::RCP<CrsGraphType> destGraph;
2546 sourceGraph->exportAndFillComplete (destGraph,exporter,domainMap, rangeMap, params);
2583 template<
class CrsGraphType>
2584 Teuchos::RCP<CrsGraphType>
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)
2600 Teuchos::RCP<CrsGraphType> destGraph;
2601 sourceGraph->exportAndFillComplete (destGraph,rowExporter,domainExporter,domainMap, rangeMap, params);
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'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'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'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 > ¶ms=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 > ¶ms=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'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's local column indices, as a Teuchos::ArrayVi...
virtual ~CrsGraph()=default
Destructor (virtual for memory safety of derived classes).
bool noRedundancies_
Whether the graph'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'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 > ¶ms=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'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' 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 > ¶ms=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 "1-D" 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' 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'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'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'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 > ¶ms=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'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 > ¶ms) 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 > ¶ms=Teuchos::null)
Tell the graph that you are done changing its structure.
typename node_type::device_type device_type
This class' Kokkos device type.
bool isLocallyIndexed() const override
Whether the graph'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 > ¶ms=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'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's or matrix'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 > ¶ms=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.