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,
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,
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