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"
62 #include "Kokkos_UnorderedMap.hpp"
64 #include "Teuchos_CommHelpers.hpp"
65 #include "Teuchos_Describable.hpp"
66 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
74 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
class crsGraph_Swap_Tester;
76 #ifndef DOXYGEN_SHOULD_SKIP_THIS
78 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
80 template<
class OutputCrsGraphType,
class InputCrsGraphType>
81 class CrsGraphCopier {
83 static Teuchos::RCP<OutputCrsGraphType>
84 clone (
const InputCrsGraphType& graphIn,
85 const Teuchos::RCP<typename OutputCrsGraphType::node_type> nodeOut,
86 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
88 #endif // TPETRA_ENABLE_DEPRECATED_CODE
90 template<
class LO,
class GO,
class NT>
93 CrsGraph<LO, GO, NT>& graph,
94 const Teuchos::ArrayView<
const typename CrsGraph<LO,GO,NT>::packet_type>& imports,
95 const Teuchos::ArrayView<const size_t>& numPacketsPerLID,
96 const Teuchos::ArrayView<const LO>& importLIDs,
97 size_t constantNumPackets,
104 template<
class ViewType>
105 struct UnmanagedView {
106 static_assert (Kokkos::is_view<ViewType>::value,
107 "ViewType must be a Kokkos::View specialization.");
111 typedef Kokkos::View<
typename ViewType::data_type,
112 typename ViewType::array_layout,
113 typename ViewType::device_type,
114 Kokkos::MemoryUnmanaged> type;
118 #endif // DOXYGEN_SHOULD_SKIP_THIS
187 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
188 class HasDeprecatedMethods2630_WarningThisClassIsNotForUsers {
198 virtual ~HasDeprecatedMethods2630_WarningThisClassIsNotForUsers () =
default;
199 virtual bool isLowerTriangularImpl ()
const = 0;
200 virtual bool isUpperTriangularImpl ()
const = 0;
201 virtual size_t getGlobalNumDiagsImpl ()
const = 0;
204 #endif // TPETRA_ENABLE_DEPRECATED_CODE
265 template <
class LocalOrdinal,
269 public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
274 public Teuchos::ParameterListAcceptorDefaultBase
275 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
276 ,
public ::Tpetra::Details::HasDeprecatedMethods2630_WarningThisClassIsNotForUsers
277 #endif // TPETRA_ENABLE_DEPRECATED_CODE
279 template <
class S,
class LO,
class GO,
class N>
281 template <
class LO2,
class GO2,
class N2>
283 template <
class LO,
class GO,
class N>
309 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
313 typedef typename local_graph_type::row_map_type t_RowPtrs TPETRA_DEPRECATED;
315 typedef typename local_graph_type::row_map_type::non_const_type t_RowPtrsNC TPETRA_DEPRECATED;
317 typedef typename local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D TPETRA_DEPRECATED;
318 #endif // TPETRA_ENABLE_DEPRECATED_CODE
348 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
349 const size_t maxNumEntriesPerRow,
350 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
351 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
370 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
371 const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
372 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
373 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
393 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
394 const Teuchos::ArrayView<const size_t>& numEntPerRow,
395 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
396 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
398 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
401 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
402 const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
403 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
404 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
405 #endif // TPETRA_ENABLE_DEPRECATED_CODE
428 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
429 const Teuchos::RCP<const map_type>& colMap,
430 const size_t maxNumEntriesPerRow,
431 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
432 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
452 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
453 const Teuchos::RCP<const map_type>& colMap,
454 const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
455 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
456 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,
479 const Teuchos::ArrayView<const size_t>& numEntPerRow,
480 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
481 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
483 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
486 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
487 const Teuchos::RCP<const map_type>& colMap,
488 const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
489 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
490 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
491 #endif // TPETRA_ENABLE_DEPRECATED_CODE
513 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
514 const Teuchos::RCP<const map_type>& colMap,
515 const typename local_graph_type::row_map_type& rowPointers,
516 const typename local_graph_type::entries_type::non_const_type& columnIndices,
517 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
539 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
540 const Teuchos::RCP<const map_type>& colMap,
541 const Teuchos::ArrayRCP<size_t>& rowPointers,
542 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices,
543 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
563 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
564 const Teuchos::RCP<const map_type>& colMap,
566 const Teuchos::RCP<Teuchos::ParameterList>& params);
593 const Teuchos::RCP<const map_type>& rowMap,
594 const Teuchos::RCP<const map_type>& colMap,
595 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
596 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
597 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
601 const Teuchos::RCP<const map_type>& rowMap,
602 const Teuchos::RCP<const map_type>& colMap,
603 const Teuchos::RCP<const map_type>& domainMap,
604 const Teuchos::RCP<const map_type>& rangeMap,
605 const Teuchos::RCP<const import_type>& importer,
606 const Teuchos::RCP<const export_type>& exporter,
607 const Teuchos::RCP<Teuchos::ParameterList>& params =
660 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
661 template<
class Node2>
662 Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node2> > TPETRA_DEPRECATED
663 clone (
const Teuchos::RCP<Node2>& node2,
664 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const
668 typedef ::Tpetra::Details::CrsGraphCopier<output_crs_graph_type, input_crs_graph_type> copier_type;
669 return copier_type::clone (*
this, node2, params);
697 setParameterList (
const Teuchos::RCP<Teuchos::ParameterList>& params)
override;
700 Teuchos::RCP<const Teuchos::ParameterList>
730 const Teuchos::ArrayView<const global_ordinal_type>& indices);
760 const Teuchos::ArrayView<const local_ordinal_type>& indices);
817 resumeFill (
const Teuchos::RCP<Teuchos::ParameterList>& params =
858 fillComplete (
const Teuchos::RCP<const map_type>& domainMap,
859 const Teuchos::RCP<const map_type>& rangeMap,
860 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
890 fillComplete (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
922 const Teuchos::RCP<const map_type>& rangeMap,
923 const Teuchos::RCP<const import_type>& importer =
925 const Teuchos::RCP<const export_type>& exporter =
927 const Teuchos::RCP<Teuchos::ParameterList>& params =
934 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const override;
936 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
937 TPETRA_DEPRECATED Teuchos::RCP<node_type> getNode()
const override;
939 #endif // TPETRA_ENABLE_DEPRECATED_CODE
942 Teuchos::RCP<const map_type>
getRowMap ()
const override;
945 Teuchos::RCP<const map_type>
getColMap ()
const override;
948 Teuchos::RCP<const map_type>
getDomainMap ()
const override;
951 Teuchos::RCP<const map_type>
getRangeMap ()
const override;
954 Teuchos::RCP<const import_type>
getImporter ()
const override;
957 Teuchos::RCP<const export_type>
getExporter ()
const override;
1088 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1104 size_t TPETRA_DEPRECATED getNodeNumDiags ()
const override;
1130 size_t getNodeNumDiagsImpl ()
const override;
1142 bool TPETRA_DEPRECATED isLowerTriangular ()
const override;
1154 bool TPETRA_DEPRECATED isUpperTriangular ()
const override;
1167 bool isLowerTriangularImpl ()
const override;
1180 bool isUpperTriangularImpl ()
const override;
1181 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1235 const Teuchos::ArrayView<global_ordinal_type>& gblColInds,
1236 size_t& numColInds)
const override;
1247 const Teuchos::ArrayView<local_ordinal_type>& lclColInds,
1248 size_t& numColInds)
const override;
1262 Teuchos::ArrayView<const global_ordinal_type>& gblColInds)
const override;
1280 Teuchos::ArrayView<const local_ordinal_type>& lclColInds)
const override;
1292 describe (Teuchos::FancyOStream& out,
1293 const Teuchos::EVerbosityLevel verbLevel =
1294 Teuchos::Describable::verbLevel_default)
const override;
1312 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1314 #else // TPETRA_ENABLE_DEPRECATED_CODE
1316 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1318 const size_t numSameIDs,
1325 applyCrsPadding (
const Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>& padding);
1327 Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1329 const size_t numSameIDs,
1330 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1331 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs)
const;
1333 Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1334 computeCrsPadding (
const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& importLIDs,
1335 Kokkos::DualView<size_t*, buffer_device_type> numPacketsPerLID)
const;
1338 computeCrsPaddingForSameIDs (Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>& padding,
1340 const size_t numSameIDs,
1341 const bool padAll)
const;
1343 computeCrsPaddingForPermutedIDs (Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>& padding,
1345 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteToLIDs,
1346 const Kokkos::DualView<const local_ordinal_type*, buffer_device_type>& permuteFromLIDs,
1347 const bool padAll)
const;
1350 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1352 #else // TPETRA_ENABLE_DEPRECATED_CODE
1354 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1360 Kokkos::DualView<
size_t*,
1362 size_t& constantNumPackets,
1366 pack (
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,
1373 packFillActive (
const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1374 Teuchos::Array<global_ordinal_type>& exports,
1375 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1376 size_t& constantNumPackets,
1384 Kokkos::DualView<
size_t*,
1386 size_t& constantNumPackets,
1390 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1392 #else // TPETRA_ENABLE_DEPRECATED_CODE
1394 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1399 Kokkos::DualView<
size_t*,
1401 const size_t constantNumPackets,
1452 getLocalDiagOffsets (
const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets)
const;
1490 size_t& boundForAllLocalRows,
1491 bool& boundSameForAllLocalRows)
const;
1502 setAllIndices (
const typename local_graph_type::row_map_type& rowPointers,
1503 const typename local_graph_type::entries_type::non_const_type& columnIndices);
1514 setAllIndices (
const Teuchos::ArrayRCP<size_t> & rowPointers,
1515 const Teuchos::ArrayRCP<local_ordinal_type> & columnIndices);
1541 void replaceColMap (
const Teuchos::RCP<const map_type>& newColMap);
1564 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1565 const bool sortIndicesInEachRow =
true);
1582 const Teuchos::RCP<const import_type>& newImporter);
1616 template<
class ViewType,
class OffsetViewType >
1617 struct pack_functor {
1621 OffsetViewType src_offset;
1622 OffsetViewType dest_offset;
1623 typedef typename OffsetViewType::non_const_value_type ScalarIndx;
1625 pack_functor(ViewType dest_, ViewType src_, OffsetViewType dest_offset_, OffsetViewType src_offset_):
1626 src(src_),dest(dest_),src_offset(src_offset_),dest_offset(dest_offset_) {};
1628 KOKKOS_INLINE_FUNCTION
1629 void operator() (
size_t row)
const {
1630 ScalarIndx i = src_offset(row);
1631 ScalarIndx j = dest_offset(row);
1632 const ScalarIndx k = dest_offset(row+1);
1641 template<
class CrsGraphType>
1642 friend Teuchos::RCP<CrsGraphType>
1643 importAndFillCompleteCrsGraph (
const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1644 const Import<
typename CrsGraphType::local_ordinal_type,
1645 typename CrsGraphType::global_ordinal_type,
1646 typename CrsGraphType::node_type>& importer,
1647 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1648 typename CrsGraphType::global_ordinal_type,
1649 typename CrsGraphType::node_type> >& domainMap,
1650 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1651 typename CrsGraphType::global_ordinal_type,
1652 typename CrsGraphType::node_type> >& rangeMap,
1653 const Teuchos::RCP<Teuchos::ParameterList>& params);
1656 template<
class CrsGraphType>
1657 friend Teuchos::RCP<CrsGraphType>
1658 importAndFillCompleteCrsGraph (
const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1659 const Import<
typename CrsGraphType::local_ordinal_type,
1660 typename CrsGraphType::global_ordinal_type,
1661 typename CrsGraphType::node_type>& rowImporter,
1662 const Import<
typename CrsGraphType::local_ordinal_type,
1663 typename CrsGraphType::global_ordinal_type,
1664 typename CrsGraphType::node_type>& domainImporter,
1665 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1666 typename CrsGraphType::global_ordinal_type,
1667 typename CrsGraphType::node_type> >& domainMap,
1668 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1669 typename CrsGraphType::global_ordinal_type,
1670 typename CrsGraphType::node_type> >& rangeMap,
1671 const Teuchos::RCP<Teuchos::ParameterList>& params);
1675 template<
class CrsGraphType>
1676 friend Teuchos::RCP<CrsGraphType>
1677 exportAndFillCompleteCrsGraph (
const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1678 const Export<
typename CrsGraphType::local_ordinal_type,
1679 typename CrsGraphType::global_ordinal_type,
1680 typename CrsGraphType::node_type>& exporter,
1681 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1682 typename CrsGraphType::global_ordinal_type,
1683 typename CrsGraphType::node_type> >& domainMap,
1684 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1685 typename CrsGraphType::global_ordinal_type,
1686 typename CrsGraphType::node_type> >& rangeMap,
1687 const Teuchos::RCP<Teuchos::ParameterList>& params);
1690 template<
class CrsGraphType>
1691 friend Teuchos::RCP<CrsGraphType>
1692 exportAndFillCompleteCrsGraph (
const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1693 const Export<
typename CrsGraphType::local_ordinal_type,
1694 typename CrsGraphType::global_ordinal_type,
1695 typename CrsGraphType::node_type>& rowExporter,
1696 const Export<
typename CrsGraphType::local_ordinal_type,
1697 typename CrsGraphType::global_ordinal_type,
1698 typename CrsGraphType::node_type>& domainExporter,
1699 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1700 typename CrsGraphType::global_ordinal_type,
1701 typename CrsGraphType::node_type> >& domainMap,
1702 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1703 typename CrsGraphType::global_ordinal_type,
1704 typename CrsGraphType::node_type> >& rangeMap,
1705 const Teuchos::RCP<Teuchos::ParameterList>& params);
1707 template<
class LO,
class GO,
class NT>
1710 CrsGraph<LO, GO, NT>& graph,
1711 const Teuchos::ArrayView<
const typename CrsGraph<LO,GO,NT>::packet_type>& imports,
1712 const Teuchos::ArrayView<const size_t>& numPacketsPerLID,
1713 const Teuchos::ArrayView<const LO>& importLIDs,
1714 size_t constantNumPackets,
1715 Distributor & distor,
1735 importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1737 const Teuchos::RCP<const map_type>& domainMap,
1738 const Teuchos::RCP<const map_type>& rangeMap,
1739 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
1757 importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1760 const Teuchos::RCP<const map_type>& domainMap,
1761 const Teuchos::RCP<const map_type>& rangeMap,
1762 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
1781 exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1783 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1784 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1785 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
1803 exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1806 const Teuchos::RCP<const map_type>& domainMap,
1807 const Teuchos::RCP<const map_type>& rangeMap,
1808 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
1833 transferAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1834 const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>& rowTransfer,
1835 const Teuchos::RCP<const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node> > & domainTransfer,
1836 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1837 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1838 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
1843 struct SLocalGlobalViews {
1844 Teuchos::ArrayView<const global_ordinal_type> ginds;
1845 Teuchos::ArrayView<const local_ordinal_type> linds;
1847 struct SLocalGlobalNCViews {
1848 Teuchos::ArrayView<global_ordinal_type> ginds;
1849 Teuchos::ArrayView<local_ordinal_type> linds;
1852 bool indicesAreAllocated ()
const;
1853 void allocateIndices (
const ELocalGlobal lg);
1867 void makeColMap (Teuchos::Array<int>& remotePIDs);
1897 const bool useRemotePIDs);
1939 const SLocalGlobalViews& newInds,
1940 const ELocalGlobal lg,
1941 const ELocalGlobal I);
1955 const size_t numInputInds);
1969 const size_t numInputInds,
1970 std::function<
void(
const size_t,
const size_t,
const size_t)> fun =
1971 std::function<
void(
const size_t,
const size_t,
const size_t)>());
1975 const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
1976 std::function<
void(
const size_t,
const size_t,
const size_t)> fun =
1977 std::function<
void(
const size_t,
const size_t,
const size_t)>());
1996 const Teuchos::ArrayView<const local_ordinal_type>& indices,
1997 std::function<
void(
const size_t,
const size_t,
const size_t)> fun)
const;
2000 findGlobalIndices(
const RowInfo& rowInfo,
2001 const Teuchos::ArrayView<const global_ordinal_type>& indices,
2002 std::function<
void(
const size_t,
const size_t,
const size_t)> fun)
const;
2041 #ifdef KOKKOS_ENABLE_SERIAL
2042 ! std::is_same<execution_space, Kokkos::Serial>::value;
2045 #endif // KOKKOS_ENABLE_SERIAL
2067 sortAndMergeAllIndices (
const bool sorted,
const bool merged);
2096 const Teuchos::RCP<const map_type>& rangeMap);
2098 void staticAssertions()
const;
2099 void clearGlobalConstants();
2193 Teuchos::ArrayView<const local_ordinal_type>
2199 Teuchos::ArrayView<local_ordinal_type>
2216 const RowInfo& rowInfo)
const;
2226 Kokkos::View<const local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2227 getLocalKokkosRowView (
const RowInfo& rowInfo)
const;
2235 Kokkos::View<local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2236 getLocalKokkosRowViewNonConst (
const RowInfo& rowInfo);
2244 Kokkos::View<const global_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2245 getGlobalKokkosRowView (
const RowInfo& rowInfo)
const;
2252 Teuchos::ArrayView<const global_ordinal_type>
2258 Teuchos::ArrayView<global_ordinal_type>
2276 const RowInfo& rowInfo)
const;
2295 void fillLocalGraph (
const Teuchos::RCP<Teuchos::ParameterList>& params);
2389 typename Kokkos::View<const size_t*, execution_space>::HostMirror
2478 Teuchos::ArrayRCP<Teuchos::Array<local_ordinal_type> >
lclInds2D_;
2491 Teuchos::ArrayRCP<Teuchos::Array<global_ordinal_type> >
gblInds2D_;
2533 bool indicesAreAllocated_;
2534 bool indicesAreLocal_;
2535 bool indicesAreGlobal_;
2552 typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type> > nonlocals_type;
2581 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2582 Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
2584 size_t maxNumEntriesPerRow = 0,
2585 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2589 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE;
2590 return rcp (
new graph_type (map, maxNumEntriesPerRow, pftype, params));
2641 template<
class CrsGraphType>
2642 Teuchos::RCP<CrsGraphType>
2644 const Import<
typename CrsGraphType::local_ordinal_type,
2645 typename CrsGraphType::global_ordinal_type,
2646 typename CrsGraphType::node_type>& importer,
2647 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2648 typename CrsGraphType::global_ordinal_type,
2649 typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2650 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2651 typename CrsGraphType::global_ordinal_type,
2652 typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2653 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2655 Teuchos::RCP<CrsGraphType> destGraph;
2656 sourceGraph->importAndFillComplete (destGraph,importer,domainMap, rangeMap, params);
2710 template<
class CrsGraphType>
2711 Teuchos::RCP<CrsGraphType>
2713 const Import<
typename CrsGraphType::local_ordinal_type,
2714 typename CrsGraphType::global_ordinal_type,
2715 typename CrsGraphType::node_type>& rowImporter,
2716 const Import<
typename CrsGraphType::local_ordinal_type,
2717 typename CrsGraphType::global_ordinal_type,
2718 typename CrsGraphType::node_type>& domainImporter,
2719 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2720 typename CrsGraphType::global_ordinal_type,
2721 typename CrsGraphType::node_type> >& domainMap,
2722 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2723 typename CrsGraphType::global_ordinal_type,
2724 typename CrsGraphType::node_type> >& rangeMap,
2725 const Teuchos::RCP<Teuchos::ParameterList>& params)
2727 Teuchos::RCP<CrsGraphType> destGraph;
2728 sourceGraph->importAndFillComplete (destGraph,rowImporter,domainImporter, domainMap, rangeMap, params);
2765 template<
class CrsGraphType>
2766 Teuchos::RCP<CrsGraphType>
2768 const Export<
typename CrsGraphType::local_ordinal_type,
2769 typename CrsGraphType::global_ordinal_type,
2770 typename CrsGraphType::node_type>& exporter,
2771 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2772 typename CrsGraphType::global_ordinal_type,
2773 typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2774 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2775 typename CrsGraphType::global_ordinal_type,
2776 typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2777 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2779 Teuchos::RCP<CrsGraphType> destGraph;
2780 sourceGraph->exportAndFillComplete (destGraph,exporter,domainMap, rangeMap, params);
2817 template<
class CrsGraphType>
2818 Teuchos::RCP<CrsGraphType>
2820 const Export<
typename CrsGraphType::local_ordinal_type,
2821 typename CrsGraphType::global_ordinal_type,
2822 typename CrsGraphType::node_type>& rowExporter,
2823 const Export<
typename CrsGraphType::local_ordinal_type,
2824 typename CrsGraphType::global_ordinal_type,
2825 typename CrsGraphType::node_type>& domainExporter,
2826 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2827 typename CrsGraphType::global_ordinal_type,
2828 typename CrsGraphType::node_type> >& domainMap,
2829 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2830 typename CrsGraphType::global_ordinal_type,
2831 typename CrsGraphType::node_type> >& rangeMap,
2832 const Teuchos::RCP<Teuchos::ParameterList>& params)
2834 Teuchos::RCP<CrsGraphType> destGraph;
2835 sourceGraph->exportAndFillComplete (destGraph,rowExporter,domainExporter,domainMap, rangeMap, params);
2839 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2841 template<
class LocalOrdinal,
2842 class GlobalOrdinal,
2843 class OutputNodeType,
2844 class InputNodeType>
2845 class CrsGraphCopier<CrsGraph<LocalOrdinal, GlobalOrdinal, OutputNodeType>,
2846 CrsGraph<LocalOrdinal, GlobalOrdinal, InputNodeType> > {
2848 typedef CrsGraph<LocalOrdinal, GlobalOrdinal, InputNodeType> input_crs_graph_type;
2849 typedef CrsGraph<LocalOrdinal, GlobalOrdinal, OutputNodeType> output_crs_graph_type;
2851 static Teuchos::RCP<output_crs_graph_type> TPETRA_DEPRECATED
2852 clone (
const input_crs_graph_type& graphIn,
2853 const Teuchos::RCP<OutputNodeType> &nodeOut,
2854 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2856 using Teuchos::arcp;
2857 using Teuchos::Array;
2858 using Teuchos::ArrayRCP;
2859 using Teuchos::ArrayView;
2860 using Teuchos::null;
2861 using Teuchos::outArg;
2862 using Teuchos::ParameterList;
2863 using Teuchos::parameterList;
2866 using Teuchos::REDUCE_MIN;
2867 using Teuchos::reduceAll;
2868 using Teuchos::sublist;
2871 typedef LocalOrdinal LO;
2872 typedef GlobalOrdinal GO;
2873 typedef typename ArrayView<const GO>::size_type size_type;
2874 typedef ::Tpetra::Map<LO, GO, InputNodeType> input_map_type;
2875 typedef ::Tpetra::Map<LO, GO, OutputNodeType> output_map_type;
2876 const char prefix[] =
"Tpetra::Details::CrsGraphCopier::clone: ";
2880 bool fillCompleteClone =
true;
2881 bool useLocalIndices = graphIn.hasColMap ();
2884 if (! params.is_null ()) {
2885 fillCompleteClone = params->get (
"fillComplete clone", fillCompleteClone);
2886 useLocalIndices = params->get (
"Locally indexed clone", useLocalIndices);
2887 if (params->get (
"Static profile clone",
true) ==
false) {
2890 debug = params->get (
"Debug", debug);
2893 const Teuchos::Comm<int>& comm = * (graphIn.getRowMap ()->getComm ());
2894 const int myRank = comm.getRank ();
2896 TEUCHOS_TEST_FOR_EXCEPTION
2897 (! graphIn.hasColMap () && useLocalIndices, std::runtime_error,
2898 prefix <<
"You asked clone() to use local indices (by setting the "
2899 "\"Locally indexed clone\" parameter to true), but the source graph "
2900 "does not yet have a column Map, so this is impossible.");
2903 std::ostringstream os;
2904 os <<
"Process " << myRank <<
": Cloning row Map" << endl;
2908 RCP<const output_map_type> clonedRowMap =
2909 graphIn.getRowMap ()->template clone<OutputNodeType> (nodeOut);
2913 RCP<output_crs_graph_type> clonedGraph;
2915 ArrayRCP<const size_t> numEntriesPerRow;
2916 size_t numEntriesForAll = 0;
2917 bool boundSameForAllLocalRows =
true;
2920 std::ostringstream os;
2921 os <<
"Process " << myRank <<
": Getting per-row bounds" << endl;
2924 graphIn.getNumEntriesPerLocalRowUpperBound (numEntriesPerRow,
2926 boundSameForAllLocalRows);
2928 std::ostringstream os;
2929 os <<
"Process " << myRank <<
": numEntriesForAll = "
2930 << numEntriesForAll << endl;
2935 std::ostringstream os;
2936 os <<
"Process " << myRank <<
": graphIn.getNodeMaxNumRowEntries() = "
2937 << graphIn.getNodeMaxNumRowEntries () << endl;
2941 RCP<ParameterList> graphparams;
2942 if (params.is_null ()) {
2943 graphparams = parameterList (
"CrsGraph");
2945 graphparams = sublist (params,
"CrsGraph");
2947 if (useLocalIndices) {
2948 RCP<const output_map_type> clonedColMap =
2949 graphIn.getColMap ()->template clone<OutputNodeType> (nodeOut);
2950 if (boundSameForAllLocalRows) {
2951 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap, clonedColMap,
2952 numEntriesForAll, pftype,
2955 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap, clonedColMap,
2956 numEntriesPerRow (), pftype,
2960 if (boundSameForAllLocalRows) {
2961 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap,
2962 numEntriesForAll, pftype,
2965 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap,
2966 numEntriesPerRow (),
2967 pftype, graphparams));
2972 std::ostringstream os;
2973 os <<
"Process " << myRank <<
": Invoked output graph's constructor" << endl;
2978 numEntriesPerRow = null;
2979 numEntriesForAll = 0;
2982 const input_map_type& inputRowMap = * (graphIn.getRowMap ());
2983 const size_type numRows =
2984 static_cast<size_type
> (inputRowMap.getNodeNumElements ());
2986 bool failed =
false;
2988 if (useLocalIndices) {
2989 const LO localMinLID = inputRowMap.getMinLocalIndex ();
2990 const LO localMaxLID = inputRowMap.getMaxLocalIndex ();
2992 if (graphIn.isLocallyIndexed ()) {
2995 ArrayView<const LO> linds;
2996 for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
2997 graphIn.getLocalRowView (lrow, linds);
2998 if (linds.size () != 0) {
2999 clonedGraph->insertLocalIndices (lrow, linds);
3003 catch (std::exception& e) {
3004 std::ostringstream os;
3005 os <<
"Process " << myRank <<
": copying (reading local by view, "
3006 "writing local) indices into the output graph threw an "
3007 "exception: " << e.what () << endl;
3014 TEUCHOS_TEST_FOR_EXCEPTION(
3015 ! graphIn.hasColMap () && useLocalIndices, std::invalid_argument,
3016 prefix <<
"You asked clone() to use local indices (by setting the "
3017 "\"Locally indexed clone\" parameter to true), but the source graph "
3018 "does not yet have a column Map, so this is impossible.");
3033 size_t myMaxNumRowEntries =
3034 graphIn.isFillActive () ?
static_cast<size_t> (0) :
3035 graphIn.getNodeMaxNumRowEntries ();
3037 Array<LO> linds (myMaxNumRowEntries);
3040 for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
3041 size_t theNumEntries = graphIn.getNumEntriesInLocalRow (lrow);
3042 if (theNumEntries > myMaxNumRowEntries) {
3043 myMaxNumRowEntries = theNumEntries;
3044 linds.resize (myMaxNumRowEntries);
3046 graphIn.getLocalRowCopy (lrow, linds (), theNumEntries);
3047 if (theNumEntries != 0) {
3048 clonedGraph->insertLocalIndices (lrow, linds (0, theNumEntries));
3052 catch (std::exception& e) {
3053 std::ostringstream os;
3054 os <<
"Process " << myRank <<
": copying (reading local by copy, "
3055 "writing local) indices into the output graph threw an exception: "
3056 << e.what () << endl;
3064 const GlobalOrdinal localMinGID = inputRowMap.getMinGlobalIndex ();
3065 const GlobalOrdinal localMaxGID = inputRowMap.getMaxGlobalIndex ();
3066 const bool inputRowMapIsContiguous = inputRowMap.isContiguous ();
3068 if (graphIn.isGloballyIndexed ()) {
3069 ArrayView<const GlobalOrdinal> ginds;
3071 if (inputRowMapIsContiguous) {
3073 for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
3074 graphIn.getGlobalRowView (grow, ginds);
3075 if (ginds.size () != 0) {
3076 clonedGraph->insertGlobalIndices (grow, ginds);
3080 catch (std::exception& e) {
3081 std::ostringstream os;
3082 os <<
"Process " << myRank <<
": copying (reading global by view, "
3083 "writing global) indices into the output graph threw an "
3084 "exception: " << e.what () << endl;
3091 ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
3092 for (size_type k = 0; k < numRows; ++k) {
3093 const GO grow = inputRowMapGIDs[k];
3094 graphIn.getGlobalRowView (grow, ginds);
3095 if (ginds.size () != 0) {
3096 clonedGraph->insertGlobalIndices (grow, ginds);
3100 catch (std::exception& e) {
3101 std::ostringstream os;
3102 os <<
"Process " << myRank <<
": copying (reading global by view, "
3103 "writing global) indices into the output graph threw an "
3104 "exception: " << e.what () << endl;
3117 size_t myMaxNumRowEntries =
3118 graphIn.isFillActive () ?
static_cast<size_t> (0) :
3119 graphIn.getNodeMaxNumRowEntries ();
3121 Array<GO> ginds (myMaxNumRowEntries);
3123 if (inputRowMapIsContiguous) {
3125 for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
3126 size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
3127 if (theNumEntries > myMaxNumRowEntries) {
3128 myMaxNumRowEntries = theNumEntries;
3129 ginds.resize (myMaxNumRowEntries);
3131 graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
3132 if (theNumEntries != 0) {
3133 clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
3137 catch (std::exception& e) {
3138 std::ostringstream os;
3139 os <<
"Process " << myRank <<
": copying (reading global by copy, "
3140 "writing global) indices into the output graph threw an "
3141 "exception: " << e.what () << endl;
3148 ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
3149 for (size_type k = 0; k < numRows; ++k) {
3150 const GO grow = inputRowMapGIDs[k];
3152 size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
3153 if (theNumEntries > myMaxNumRowEntries) {
3154 myMaxNumRowEntries = theNumEntries;
3155 ginds.resize (myMaxNumRowEntries);
3157 graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
3158 if (theNumEntries != 0) {
3159 clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
3163 catch (std::exception& e) {
3164 std::ostringstream os;
3165 os <<
"Process " << myRank <<
": copying (reading global by copy, "
3166 "writing global) indices into the output graph threw an "
3167 "exception: " << e.what () << endl;
3177 std::ostringstream os;
3178 os <<
"Process " << myRank <<
": copied entries" << endl;
3182 if (fillCompleteClone) {
3183 RCP<ParameterList> fillparams = params.is_null () ?
3184 parameterList (
"fillComplete") :
3185 sublist (params,
"fillComplete");
3187 RCP<const output_map_type> clonedRangeMap;
3188 RCP<const output_map_type> clonedDomainMap;
3189 if (! graphIn.getRangeMap ().is_null () &&
3190 graphIn.getRangeMap () != graphIn.getRowMap ()) {
3192 graphIn.getRangeMap ()->template clone<OutputNodeType> (nodeOut);
3195 clonedRangeMap = clonedRowMap;
3197 if (! graphIn.getDomainMap ().is_null ()
3198 && graphIn.getDomainMap () != graphIn.getRowMap ()) {
3200 graphIn.getDomainMap ()->template clone<OutputNodeType> (nodeOut);
3203 clonedDomainMap = clonedRowMap;
3207 std::ostringstream os;
3208 os <<
"Process " << myRank <<
": About to call fillComplete on "
3209 "cloned graph" << endl;
3212 clonedGraph->fillComplete (clonedDomainMap, clonedRangeMap, fillparams);
3214 catch (std::exception &e) {
3216 std::ostringstream os;
3217 os << prefix <<
"Process " << myRank <<
": Caught the following "
3218 "exception while calling fillComplete() on clone of type"
3219 << endl << Teuchos::typeName (*clonedGraph) << endl;
3224 int lclSuccess = failed ? 0 : 1;
3226 reduceAll<int, int> (comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
3227 TEUCHOS_TEST_FOR_EXCEPTION
3228 (gblSuccess != 1, std::logic_error,
3229 prefix <<
"Clone failed on at least one process.");
3232 std::ostringstream os;
3233 os <<
"Process " << myRank <<
": Done with CrsGraph::clone" << endl;
3240 #endif // TPETRA_ENABLE_DEPRECATED_CODE
3244 #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'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.
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 > ¶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.
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'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.
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 > ¶ms=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'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.
::Tpetra::Details::EStorageStatus storageStatus_
Status of the graph'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'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' 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.
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 "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.
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'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' 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...
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'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
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 > ¶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.
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 > ¶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.