42 #ifndef TPETRA_CRSGRAPH_DECL_HPP 43 #define TPETRA_CRSGRAPH_DECL_HPP 53 #include "Tpetra_ConfigDefs.hpp" 54 #include "Tpetra_RowGraph.hpp" 55 #include "Tpetra_DistObject.hpp" 56 #include "Tpetra_Exceptions.hpp" 58 #include "KokkosCompat_ClassicNodeAPI_Wrapper.hpp" 59 #include "Kokkos_DualView.hpp" 60 #include "Kokkos_StaticCrsGraph.hpp" 62 #include "Teuchos_Describable.hpp" 63 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp" 68 #ifndef DOXYGEN_SHOULD_SKIP_THIS 74 template <
class LO,
class GO,
class N, const
bool isClassic>
78 template <
class S,
class LO,
class GO,
class N, const
bool isClassic>
81 namespace Experimental {
83 template<
class S,
class LO,
class GO,
class N>
89 template<
class OutputCrsGraphType,
class InputCrsGraphType>
90 class CrsGraphCopier {
92 static Teuchos::RCP<OutputCrsGraphType>
93 clone (
const InputCrsGraphType& graphIn,
94 const Teuchos::RCP<typename OutputCrsGraphType::node_type> nodeOut,
95 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
101 template<
class ViewType>
102 struct UnmanagedView {
103 static_assert (Kokkos::is_view<ViewType>::value,
104 "ViewType must be a Kokkos::View specialization.");
108 typedef Kokkos::View<
typename ViewType::data_type,
109 typename ViewType::array_layout,
110 typename ViewType::device_type,
111 Kokkos::MemoryUnmanaged> type;
114 template<
class T,
class BinaryFunction>
115 T atomic_binary_function_update (
volatile T*
const dest,
const T& inputVal, BinaryFunction f)
127 T newVal = f (assume, inputVal);
128 oldVal = Kokkos::atomic_compare_exchange (dest, assume, newVal);
129 }
while (assume != oldVal);
135 #endif // DOXYGEN_SHOULD_SKIP_THIS 264 class GlobalOrdinal = Details::DefaultTypes::global_ordinal_type,
266 const bool classic = Node::classic>
268 public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
273 public Teuchos::ParameterListAcceptorDefaultBase
275 static_assert (! classic,
"The 'classic' version of Tpetra was deprecated long ago, and has been removed.");
277 template <
class S,
class LO,
class GO,
class N, const
bool isClassic>
279 template <
class LO2,
class GO2,
class N2, const
bool isClassic>
281 template <
class S,
class LO,
class GO,
class N>
282 friend class ::Tpetra::Experimental::BlockCrsMatrix;
301 typedef Kokkos::StaticCrsGraph<LocalOrdinal,
312 typedef typename local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D
TPETRA_DEPRECATED;
342 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
343 size_t maxNumEntriesPerRow,
345 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
364 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
365 const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
367 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
387 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
388 const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
390 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
413 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
414 const Teuchos::RCP<const map_type>& colMap,
415 const size_t maxNumEntriesPerRow,
417 const Teuchos::RCP<Teuchos::ParameterList>& params = null);
437 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
438 const Teuchos::RCP<const map_type>& colMap,
439 const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
441 const Teuchos::RCP<Teuchos::ParameterList>& params = null);
462 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
463 const Teuchos::RCP<const map_type>& colMap,
464 const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
466 const Teuchos::RCP<Teuchos::ParameterList>& params = null);
487 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
488 const Teuchos::RCP<const map_type>& colMap,
489 const typename local_graph_type::row_map_type& rowPointers,
490 const typename local_graph_type::entries_type::non_const_type& columnIndices,
491 const Teuchos::RCP<Teuchos::ParameterList>& params = null);
512 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
513 const Teuchos::RCP<const map_type>& colMap,
514 const Teuchos::ArrayRCP<size_t> & rowPointers,
515 const Teuchos::ArrayRCP<LocalOrdinal> & columnIndices,
516 const Teuchos::RCP<Teuchos::ParameterList>& params = null);
536 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
537 const Teuchos::RCP<const map_type>& colMap,
538 const local_graph_type& lclGraph,
539 const Teuchos::RCP<Teuchos::ParameterList>& params);
568 template<
class Node2>
569 Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node2, Node2::classic> >
570 clone (
const Teuchos::RCP<Node2>& node2,
571 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const 575 typedef Details::CrsGraphCopier<output_crs_graph_type, input_crs_graph_type> copier_type;
576 return copier_type::clone (*
this, node2, params);
587 void setParameterList (
const Teuchos::RCP<Teuchos::ParameterList>& params);
590 Teuchos::RCP<const ParameterList> getValidParameters ()
const;
618 insertGlobalIndices (GlobalOrdinal globalRow,
619 const Teuchos::ArrayView<const GlobalOrdinal>& indices);
637 insertLocalIndices (
const LocalOrdinal localRow,
638 const Teuchos::ArrayView<const LocalOrdinal> &indices);
650 void removeLocalIndices (LocalOrdinal localRow);
666 void globalAssemble ();
676 void resumeFill (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
696 fillComplete (
const Teuchos::RCP<const map_type> &domainMap,
697 const Teuchos::RCP<const map_type> &rangeMap,
698 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
706 void fillComplete (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
719 expertStaticFillComplete (
const Teuchos::RCP<const map_type> & domainMap,
720 const Teuchos::RCP<const map_type> & rangeMap,
721 const Teuchos::RCP<const import_type> &importer=Teuchos::null,
722 const Teuchos::RCP<const export_type> &exporter=Teuchos::null,
723 const Teuchos::RCP<Teuchos::ParameterList> ¶ms=Teuchos::null);
729 Teuchos::RCP<const Comm<int> > getComm()
const;
732 Teuchos::RCP<node_type> getNode()
const;
735 Teuchos::RCP<const map_type> getRowMap ()
const;
738 Teuchos::RCP<const map_type> getColMap ()
const;
741 Teuchos::RCP<const map_type> getDomainMap ()
const;
744 Teuchos::RCP<const map_type> getRangeMap ()
const;
747 Teuchos::RCP<const import_type> getImporter ()
const;
750 Teuchos::RCP<const export_type> getExporter ()
const;
764 size_t getNodeNumRows()
const;
769 size_t getNodeNumCols()
const;
772 GlobalOrdinal getIndexBase()
const;
780 size_t getNodeNumEntries()
const;
784 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow)
const;
788 size_t getNumEntriesInLocalRow(LocalOrdinal localRow)
const;
798 size_t getNodeAllocationSize()
const;
802 size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow)
const;
806 size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow)
const;
816 size_t getNodeNumDiags()
const;
830 size_t getGlobalMaxNumRowEntries()
const;
835 size_t getNodeMaxNumRowEntries()
const;
851 bool hasColMap()
const;
860 bool isLowerTriangular()
const;
869 bool isUpperTriangular()
const;
872 bool isLocallyIndexed()
const;
875 bool isGloballyIndexed()
const;
878 bool isFillComplete()
const;
881 bool isFillActive()
const;
890 bool isSorted()
const;
899 bool isStorageOptimized()
const;
910 getGlobalRowCopy (GlobalOrdinal GlobalRow,
911 const Teuchos::ArrayView<GlobalOrdinal>& Indices,
912 size_t& NumIndices)
const;
922 getLocalRowCopy (LocalOrdinal LocalRow,
923 const Teuchos::ArrayView<LocalOrdinal>& indices,
924 size_t& NumIndices)
const;
936 getGlobalRowView (GlobalOrdinal GlobalRow,
937 Teuchos::ArrayView<const GlobalOrdinal>& Indices)
const;
949 getLocalRowView (LocalOrdinal LocalRow,
950 Teuchos::ArrayView<const LocalOrdinal>& indices)
const;
957 std::string description()
const;
961 describe (Teuchos::FancyOStream& out,
962 const Teuchos::EVerbosityLevel verbLevel =
963 Teuchos::Describable::verbLevel_default)
const;
975 const Teuchos::ArrayView<const LocalOrdinal> &permuteToLIDs,
976 const Teuchos::ArrayView<const LocalOrdinal> &permuteFromLIDs);
980 const Teuchos::ArrayView<const LocalOrdinal> &exportLIDs,
981 Teuchos::Array<GlobalOrdinal> &exports,
982 const Teuchos::ArrayView<size_t> & numPacketsPerLID,
983 size_t& constantNumPackets,
987 pack (
const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
988 Teuchos::Array<GlobalOrdinal>& exports,
989 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
990 size_t& constantNumPackets,
994 unpackAndCombine (
const Teuchos::ArrayView<const LocalOrdinal> &importLIDs,
995 const Teuchos::ArrayView<const GlobalOrdinal> &imports,
996 const Teuchos::ArrayView<size_t> &numPacketsPerLID,
997 size_t constantNumPackets,
1027 getNumEntriesPerLocalRowUpperBound (Teuchos::ArrayRCP<const size_t>& boundPerLocalRow,
1028 size_t& boundForAllLocalRows,
1029 bool& boundSameForAllLocalRows)
const;
1040 setAllIndices (
const typename local_graph_type::row_map_type& rowPointers,
1041 const typename local_graph_type::entries_type::non_const_type& columnIndices);
1052 setAllIndices (
const Teuchos::ArrayRCP<size_t> & rowPointers,
1053 const Teuchos::ArrayRCP<LocalOrdinal> & columnIndices);
1062 Teuchos::ArrayRCP<const size_t> getNodeRowPtrs ()
const;
1067 Teuchos::ArrayRCP<const LocalOrdinal> getNodePackedIndices()
const;
1079 void replaceColMap (
const Teuchos::RCP<const map_type>& newColMap);
1101 reindexColumns (
const Teuchos::RCP<const map_type>& newColMap,
1102 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1103 const bool sortIndicesInEachRow =
true);
1118 replaceDomainMapAndImporter (
const Teuchos::RCP<const map_type>& newDomainMap,
1119 const Teuchos::RCP<const import_type>& newImporter);
1152 template<
class ViewType,
class OffsetViewType >
1153 struct pack_functor {
1154 typedef typename ViewType::execution_space execution_space;
1157 OffsetViewType src_offset;
1158 OffsetViewType dest_offset;
1159 typedef typename OffsetViewType::non_const_value_type ScalarIndx;
1161 pack_functor(ViewType dest_, ViewType src_, OffsetViewType dest_offset_, OffsetViewType src_offset_):
1162 src(src_),dest(dest_),src_offset(src_offset_),dest_offset(dest_offset_) {};
1164 KOKKOS_INLINE_FUNCTION
1165 void operator() (
size_t row)
const {
1166 ScalarIndx i = src_offset(row);
1167 ScalarIndx j = dest_offset(row);
1168 const ScalarIndx k = dest_offset(row+1);
1178 struct SLocalGlobalViews {
1179 Teuchos::ArrayView<const GlobalOrdinal> ginds;
1180 Teuchos::ArrayView<const LocalOrdinal> linds;
1182 struct SLocalGlobalNCViews {
1183 Teuchos::ArrayView<GlobalOrdinal> ginds;
1184 Teuchos::ArrayView<LocalOrdinal> linds;
1187 bool indicesAreAllocated ()
const;
1188 void allocateIndices (
const ELocalGlobal lg);
1191 Teuchos::ArrayRCP<Teuchos::Array<T> > allocateValues2D ()
const;
1195 const size_t newAllocSize,
1196 Teuchos::Array<T>& rowVals)
1198 #ifdef HAVE_TPETRA_DEBUG 1199 TEUCHOS_TEST_FOR_EXCEPT( ! isLocallyIndexed () );
1200 TEUCHOS_TEST_FOR_EXCEPT( ! indicesAreAllocated() );
1201 TEUCHOS_TEST_FOR_EXCEPT( newAllocSize == 0 );
1202 TEUCHOS_TEST_FOR_EXCEPT( newAllocSize < rowInfo.allocSize );
1203 TEUCHOS_TEST_FOR_EXCEPT( ! rowMap_->isNodeLocalElement (rowInfo.localRow) );
1204 #endif // HAVE_TPETRA_DEBUG 1207 lclInds2D_[rowInfo.localRow].resize (newAllocSize);
1208 rowVals.resize (newAllocSize);
1209 nodeNumAllocated_ += (newAllocSize - rowInfo.allocSize);
1212 rowInfoOut.allocSize = newAllocSize;
1218 updateGlobalAllocAndValues (
const RowInfo rowInfo,
1219 const size_t newAllocSize,
1220 Teuchos::Array<T>& rowVals)
1222 #ifdef HAVE_TPETRA_DEBUG 1223 TEUCHOS_TEST_FOR_EXCEPT( ! isGloballyIndexed () );
1224 TEUCHOS_TEST_FOR_EXCEPT( ! indicesAreAllocated () );
1225 TEUCHOS_TEST_FOR_EXCEPT( newAllocSize == 0 );
1226 TEUCHOS_TEST_FOR_EXCEPT( newAllocSize < rowInfo.allocSize );
1227 TEUCHOS_TEST_FOR_EXCEPT( ! rowMap_->isNodeLocalElement (rowInfo.localRow) );
1228 #endif // HAVE_TPETRA_DEBUG 1231 gblInds2D_[rowInfo.localRow].resize (newAllocSize);
1232 rowVals.resize (newAllocSize);
1233 nodeNumAllocated_ += (newAllocSize - rowInfo.allocSize);
1236 rowInfoOut.allocSize = newAllocSize;
1245 void makeIndicesLocal ();
1246 void makeImportExport ();
1252 template<ELocalGlobal lg>
1253 size_t filterIndices (
const SLocalGlobalNCViews& inds)
const 1255 using Teuchos::ArrayView;
1256 static_assert (lg == GlobalIndices || lg == LocalIndices,
1257 "Tpetra::CrsGraph::filterIndices: The template parameter " 1258 "lg must be either GlobalIndices or LocalIndicies.");
1260 const map_type& cmap = *colMap_;
1261 size_t numFiltered = 0;
1262 #ifdef HAVE_TPETRA_DEBUG 1263 size_t numFiltered_debug = 0;
1265 if (lg == GlobalIndices) {
1266 ArrayView<GlobalOrdinal> ginds = inds.ginds;
1267 typename ArrayView<GlobalOrdinal>::iterator fend = ginds.begin();
1268 typename ArrayView<GlobalOrdinal>::iterator cptr = ginds.begin();
1269 while (cptr != ginds.end()) {
1272 #ifdef HAVE_TPETRA_DEBUG 1273 ++numFiltered_debug;
1278 numFiltered = fend - ginds.begin();
1280 else if (lg == LocalIndices) {
1281 ArrayView<LocalOrdinal> linds = inds.linds;
1282 typename ArrayView<LocalOrdinal>::iterator fend = linds.begin();
1283 typename ArrayView<LocalOrdinal>::iterator cptr = linds.begin();
1284 while (cptr != linds.end()) {
1287 #ifdef HAVE_TPETRA_DEBUG 1288 ++numFiltered_debug;
1293 numFiltered = fend - linds.begin();
1295 #ifdef HAVE_TPETRA_DEBUG 1296 TEUCHOS_TEST_FOR_EXCEPT( numFiltered != numFiltered_debug );
1304 filterGlobalIndicesAndValues (
const Teuchos::ArrayView<GlobalOrdinal>& ginds,
1305 const Teuchos::ArrayView<T>& vals)
const 1307 using Teuchos::ArrayView;
1308 const map_type& cmap = *colMap_;
1309 size_t numFiltered = 0;
1310 typename ArrayView<T>::iterator fvalsend = vals.begin();
1311 typename ArrayView<T>::iterator valscptr = vals.begin();
1312 #ifdef HAVE_TPETRA_DEBUG 1313 size_t numFiltered_debug = 0;
1315 typename ArrayView<GlobalOrdinal>::iterator fend = ginds.begin();
1316 typename ArrayView<GlobalOrdinal>::iterator cptr = ginds.begin();
1317 while (cptr != ginds.end()) {
1320 *fvalsend++ = *valscptr;
1321 #ifdef HAVE_TPETRA_DEBUG 1322 ++numFiltered_debug;
1328 numFiltered = fend - ginds.begin();
1329 #ifdef HAVE_TPETRA_DEBUG 1330 TEUCHOS_TEST_FOR_EXCEPT( numFiltered != numFiltered_debug );
1331 TEUCHOS_TEST_FOR_EXCEPT( valscptr != vals.end() );
1332 const size_t numFilteredActual =
1333 static_cast<size_t> (fvalsend - vals.begin ());
1334 TEUCHOS_TEST_FOR_EXCEPT( numFiltered != numFilteredActual );
1335 #endif // HAVE_TPETRA_DEBUG 1341 filterLocalIndicesAndValues (
const Teuchos::ArrayView<LocalOrdinal>& linds,
1342 const Teuchos::ArrayView<T>& vals)
const 1344 using Teuchos::ArrayView;
1345 const map_type& cmap = *colMap_;
1346 size_t numFiltered = 0;
1347 typename ArrayView<T>::iterator fvalsend = vals.begin();
1348 typename ArrayView<T>::iterator valscptr = vals.begin();
1349 #ifdef HAVE_TPETRA_DEBUG 1350 size_t numFiltered_debug = 0;
1352 typename ArrayView<LocalOrdinal>::iterator fend = linds.begin();
1353 typename ArrayView<LocalOrdinal>::iterator cptr = linds.begin();
1354 while (cptr != linds.end()) {
1357 *fvalsend++ = *valscptr;
1358 #ifdef HAVE_TPETRA_DEBUG 1359 ++numFiltered_debug;
1365 numFiltered = fend - linds.begin();
1366 #ifdef HAVE_TPETRA_DEBUG 1367 TEUCHOS_TEST_FOR_EXCEPT( numFiltered != numFiltered_debug );
1368 TEUCHOS_TEST_FOR_EXCEPT( valscptr != vals.end() );
1369 const size_t numFilteredActual =
1370 Teuchos::as<size_t> (fvalsend - vals.begin ());
1371 TEUCHOS_TEST_FOR_EXCEPT( numFiltered != numFilteredActual );
1406 insertIndices (
const RowInfo& rowInfo,
1407 const SLocalGlobalViews& newInds,
1408 const ELocalGlobal lg,
1409 const ELocalGlobal I);
1450 template<
class Scalar>
1452 insertIndicesAndValues (
const RowInfo& rowInfo,
1453 const SLocalGlobalViews& newInds,
1454 const Teuchos::ArrayView<Scalar>& oldRowVals,
1455 const Teuchos::ArrayView<const Scalar>& newRowVals,
1456 const ELocalGlobal lg,
1457 const ELocalGlobal I);
1459 insertGlobalIndicesImpl (
const LocalOrdinal myRow,
1460 const Teuchos::ArrayView<const GlobalOrdinal> &indices);
1462 insertLocalIndicesImpl (
const LocalOrdinal myRow,
1463 const Teuchos::ArrayView<const LocalOrdinal> &indices);
1466 insertLocalIndicesFiltered (
const LocalOrdinal localRow,
1467 const Teuchos::ArrayView<const LocalOrdinal> &indices);
1471 insertGlobalIndicesFiltered (
const GlobalOrdinal localRow,
1472 const Teuchos::ArrayView<const GlobalOrdinal> &indices);
1478 static const bool useAtomicUpdatesByDefault =
1479 #ifdef KOKKOS_HAVE_SERIAL 1480 ! std::is_same<execution_space, Kokkos::Serial>::value;
1483 #endif // KOKKOS_HAVE_SERIAL 1523 template<
class OutputScalarViewType,
1524 class LocalIndicesViewType,
1525 class InputScalarViewType,
1526 class BinaryFunction>
1527 typename std::enable_if<Kokkos::is_view<OutputScalarViewType>::value &&
1528 Kokkos::is_view<LocalIndicesViewType>::value &&
1529 Kokkos::is_view<InputScalarViewType>::value &&
1530 std::is_same<
typename OutputScalarViewType::non_const_value_type,
1531 typename InputScalarViewType::non_const_value_type>::value &&
1532 std::is_same<
typename LocalIndicesViewType::non_const_value_type,
1533 local_ordinal_type>::value,
1536 const typename UnmanagedView<OutputScalarViewType>::type& rowVals,
1537 const typename UnmanagedView<LocalIndicesViewType>::type& inds,
1538 const typename UnmanagedView<InputScalarViewType>::type& newVals,
1540 const bool atomic = useAtomicUpdatesByDefault)
const 1542 typedef typename OutputScalarViewType::non_const_value_type ST;
1543 typedef LocalOrdinal LO;
1544 typedef GlobalOrdinal GO;
1546 if (newVals.dimension_0 () != inds.dimension_0 ()) {
1548 return Teuchos::OrdinalTraits<LO>::invalid ();
1550 const size_t STINV = Teuchos::OrdinalTraits<size_t>::invalid ();
1551 const LO numElts =
static_cast<LO
> (inds.dimension_0 ());
1555 if (isLocallyIndexed ()) {
1558 auto colInds = this->getLocalKokkosRowView (rowInfo);
1560 for (LO j = 0; j < numElts; ++j) {
1562 this->findLocalIndex (rowInfo, inds(j), colInds, hint);
1572 volatile ST*
const dest = &rowVals(k);
1573 (void) atomic_binary_function_update (dest, newVals(j), f);
1576 rowVals(k) = f (rowVals(k), newVals(j));
1583 else if (isGloballyIndexed ()) {
1587 if (colMap_.is_null ()) {
1594 const map_type& colMap = *colMap_;
1597 auto colInds = this->getGlobalKokkosRowView (rowInfo);
1599 const GO GINV = Teuchos::OrdinalTraits<GO>::invalid ();
1600 for (LO j = 0; j < numElts; ++j) {
1602 if (gblColInd != GINV) {
1604 this->findGlobalIndex (rowInfo, gblColInd, colInds, hint);
1614 volatile ST*
const dest = &rowVals(k);
1615 (void) atomic_binary_function_update (dest, newVals(j), f);
1618 rowVals(k) = f (rowVals(k), newVals(j));
1652 template<
class OutputScalarViewType,
1653 class LocalIndicesViewType,
1654 class InputScalarViewType>
1655 typename std::enable_if<Kokkos::is_view<OutputScalarViewType>::value &&
1656 Kokkos::is_view<LocalIndicesViewType>::value &&
1657 Kokkos::is_view<InputScalarViewType>::value &&
1658 std::is_same<
typename OutputScalarViewType::non_const_value_type,
1659 typename InputScalarViewType::non_const_value_type>::value &&
1660 std::is_same<
typename LocalIndicesViewType::non_const_value_type,
1661 local_ordinal_type>::value,
1664 const typename UnmanagedView<OutputScalarViewType>::type& rowVals,
1665 const typename UnmanagedView<LocalIndicesViewType>::type& inds,
1666 const typename UnmanagedView<InputScalarViewType>::type& newVals,
1667 const bool atomic = useAtomicUpdatesByDefault)
const 1669 typedef LocalOrdinal LO;
1670 typedef GlobalOrdinal GO;
1676 if (colMap_.is_null ()) {
1678 return Teuchos::OrdinalTraits<LO>::invalid ();
1680 else if (newVals.dimension_0 () != inds.dimension_0 ()) {
1682 return Teuchos::OrdinalTraits<LO>::invalid ();
1685 const size_t STINV = Teuchos::OrdinalTraits<size_t>::invalid ();
1693 if (isLocallyIndexed ()) {
1696 auto colInds = this->getLocalKokkosRowView (rowInfo);
1698 const LO numElts =
static_cast<LO
> (inds.dimension_0 ());
1699 for (LO j = 0; j < numElts; ++j) {
1700 const size_t k = this->findLocalIndex (rowInfo, inds(j), colInds, hint);
1703 Kokkos::atomic_add (&rowVals(k), newVals(j));
1706 rowVals(k) += newVals(j);
1713 else if (isGloballyIndexed ()) {
1716 auto colInds = this->getGlobalKokkosRowView (rowInfo);
1718 const LO numElts =
static_cast<LO
> (inds.dimension_0 ());
1719 for (LO j = 0; j < numElts; ++j) {
1720 const GO gblColInd = this->colMap_->getGlobalElement (inds(j));
1721 if (gblColInd != Teuchos::OrdinalTraits<GO>::invalid ()) {
1723 this->findGlobalIndex (rowInfo, gblColInd, colInds, hint);
1726 Kokkos::atomic_add (&rowVals(k), newVals(j));
1729 rowVals(k) += newVals(j);
1768 template<
class OutputScalarViewType,
1769 class LocalIndicesViewType,
1770 class InputScalarViewType>
1771 typename std::enable_if<Kokkos::is_view<OutputScalarViewType>::value &&
1772 Kokkos::is_view<LocalIndicesViewType>::value &&
1773 Kokkos::is_view<InputScalarViewType>::value &&
1774 std::is_same<
typename OutputScalarViewType::non_const_value_type,
1775 typename InputScalarViewType::non_const_value_type>::value &&
1776 std::is_same<
typename LocalIndicesViewType::non_const_value_type,
1777 local_ordinal_type>::value,
1780 const typename UnmanagedView<OutputScalarViewType>::type& rowVals,
1781 const typename UnmanagedView<LocalIndicesViewType>::type& inds,
1782 const typename UnmanagedView<InputScalarViewType>::type& newVals)
const 1784 typedef LocalOrdinal LO;
1785 typedef GlobalOrdinal GO;
1791 if (colMap_.is_null ()) {
1793 return Teuchos::OrdinalTraits<LO>::invalid ();
1795 else if (newVals.dimension_0 () != inds.dimension_0 ()) {
1797 return Teuchos::OrdinalTraits<LO>::invalid ();
1800 const size_t STINV = Teuchos::OrdinalTraits<size_t>::invalid ();
1808 if (isLocallyIndexed ()) {
1811 auto colInds = this->getLocalKokkosRowView (rowInfo);
1813 const LO numElts =
static_cast<LO
> (inds.dimension_0 ());
1814 for (LO j = 0; j < numElts; ++j) {
1815 const size_t k = this->findLocalIndex (rowInfo, inds(j), colInds, hint);
1817 rowVals(k) = newVals(j);
1823 else if (isGloballyIndexed ()) {
1826 auto colInds = this->getGlobalKokkosRowView (rowInfo);
1828 const LO numElts =
static_cast<LO
> (inds.dimension_0 ());
1829 for (LO j = 0; j < numElts; ++j) {
1830 const GO gblColInd = this->colMap_->getGlobalElement (inds(j));
1831 if (gblColInd != Teuchos::OrdinalTraits<GO>::invalid ()) {
1833 this->findGlobalIndex (rowInfo, gblColInd, colInds, hint);
1835 rowVals(k) = newVals(j);
1877 template<
class Scalar,
class InputMemorySpace,
class ValsMemorySpace>
1880 const Kokkos::View<Scalar*, ValsMemorySpace,
1881 Kokkos::MemoryUnmanaged>& rowVals,
1882 const Kokkos::View<
const GlobalOrdinal*, InputMemorySpace,
1883 Kokkos::MemoryUnmanaged>& inds,
1884 const Kokkos::View<
const Scalar*, InputMemorySpace,
1885 Kokkos::MemoryUnmanaged>& newVals,
1886 const bool atomic = useAtomicUpdatesByDefault)
const 1888 typedef LocalOrdinal LO;
1890 if (newVals.dimension_0 () != inds.dimension_0 ()) {
1892 return Teuchos::OrdinalTraits<LO>::invalid ();
1895 const size_t STINV = Teuchos::OrdinalTraits<size_t>::invalid ();
1903 if (isLocallyIndexed ()) {
1907 if (colMap_.is_null ()) {
1915 auto colInds = this->getLocalKokkosRowView (rowInfo);
1916 const LO LINV = Teuchos::OrdinalTraits<LO>::invalid ();
1918 const LO numElts =
static_cast<LO
> (inds.dimension_0 ());
1919 for (LO j = 0; j < numElts; ++j) {
1920 const LO lclColInd = this->colMap_->getLocalElement (inds(j));
1921 if (lclColInd != LINV) {
1923 this->findLocalIndex (rowInfo, lclColInd, colInds, hint);
1926 Kokkos::atomic_add (&rowVals(k), newVals(j));
1929 rowVals(k) += newVals(j);
1937 else if (isGloballyIndexed ()) {
1940 auto colInds = this->getGlobalKokkosRowView (rowInfo);
1942 const LO numElts =
static_cast<LO
> (inds.dimension_0 ());
1943 for (LO j = 0; j < numElts; ++j) {
1945 this->findGlobalIndex (rowInfo, inds(j), colInds, hint);
1948 Kokkos::atomic_add (&rowVals(k), newVals(j));
1951 rowVals(k) += newVals(j);
1991 template<
class Scalar,
1992 class BinaryFunction,
1993 class InputMemorySpace,
1994 class ValsMemorySpace>
1997 const Kokkos::View<Scalar*, ValsMemorySpace,
1998 Kokkos::MemoryUnmanaged>& rowVals,
1999 const Kokkos::View<
const GlobalOrdinal*,
2001 Kokkos::MemoryUnmanaged>& inds,
2002 const Kokkos::View<
const Scalar*,
2004 Kokkos::MemoryUnmanaged>& newVals,
2006 const bool atomic = useAtomicUpdatesByDefault)
const 2008 typedef LocalOrdinal LO;
2009 if (newVals.dimension_0 () != inds.dimension_0 ()) {
2011 return Teuchos::OrdinalTraits<LO>::invalid ();
2013 const size_t STINV = Teuchos::OrdinalTraits<size_t>::invalid ();
2014 const LO numElts =
static_cast<LO
> (inds.dimension_0 ());
2018 if (isLocallyIndexed ()) {
2022 if (colMap_.is_null ()) {
2028 const map_type& colMap = *colMap_;
2031 auto colInds = this->getLocalKokkosRowView (rowInfo);
2033 const LO LINV = Teuchos::OrdinalTraits<LO>::invalid ();
2034 for (LO j = 0; j < numElts; ++j) {
2036 if (lclColInd != LINV) {
2038 this->findLocalIndex (rowInfo, lclColInd, colInds, hint);
2048 volatile Scalar*
const dest = &rowVals(k);
2049 (void) atomic_binary_function_update (dest, newVals(j), f);
2052 rowVals(k) = f (rowVals(k), newVals(j));
2060 else if (isGloballyIndexed ()) {
2063 auto colInds = this->getGlobalKokkosRowView (rowInfo);
2065 for (LO j = 0; j < numElts; ++j) {
2067 this->findGlobalIndex (rowInfo, inds(j), colInds, hint);
2077 volatile Scalar*
const dest = &rowVals(k);
2078 (void) atomic_binary_function_update (dest, newVals(j), f);
2081 rowVals(k) = f (rowVals(k), newVals(j));
2100 bool isMerged ()
const;
2107 void setLocallyModified ();
2110 void sortAllIndices ();
2113 void sortRowIndices (
const RowInfo rowinfo);
2129 template <
class Scalar>
2130 void sortRowIndicesAndValues (
const RowInfo rowinfo,
2131 const Teuchos::ArrayView<Scalar>& values);
2141 void mergeAllIndices ();
2147 void mergeRowIndices (
RowInfo rowinfo);
2159 template<
class Scalar>
2161 mergeRowIndicesAndValues (
RowInfo rowinfo,
2162 const Teuchos::ArrayView<Scalar>& rowValues);
2175 setDomainRangeMaps (
const Teuchos::RCP<const map_type>& domainMap,
2176 const Teuchos::RCP<const map_type>& rangeMap);
2178 void staticAssertions()
const;
2179 void clearGlobalConstants();
2180 void computeGlobalConstants();
2184 RowInfo getRowInfo (
const LocalOrdinal myRow)
const;
2198 RowInfo getRowInfoFromGlobalRowIndex (
const GlobalOrdinal gblRow)
const;
2203 Teuchos::ArrayView<const LocalOrdinal>
2204 getLocalView (
const RowInfo rowinfo)
const;
2209 Teuchos::ArrayView<LocalOrdinal>
2210 getLocalViewNonConst (
const RowInfo rowinfo);
2220 Kokkos::View<const LocalOrdinal*, execution_space, Kokkos::MemoryUnmanaged>
2221 getLocalKokkosRowView (
const RowInfo& rowinfo)
const;
2229 Kokkos::View<LocalOrdinal*, execution_space, Kokkos::MemoryUnmanaged>
2230 getLocalKokkosRowViewNonConst (
const RowInfo& rowinfo);
2238 Kokkos::View<const GlobalOrdinal*, execution_space, Kokkos::MemoryUnmanaged>
2239 getGlobalKokkosRowView (
const RowInfo& rowinfo)
const;
2246 Teuchos::ArrayView<const GlobalOrdinal>
2247 getGlobalView (
const RowInfo rowinfo)
const;
2252 Teuchos::ArrayView<GlobalOrdinal>
2253 getGlobalViewNonConst (
const RowInfo rowinfo);
2290 findLocalIndex (
const RowInfo& rowinfo,
2291 const LocalOrdinal ind,
2292 const size_t hint = 0)
const;
2324 findLocalIndex (
const RowInfo& rowinfo,
2325 const LocalOrdinal ind,
2326 const Kokkos::View<
const LocalOrdinal*, device_type,
2327 Kokkos::MemoryUnmanaged>& colInds,
2328 const size_t hint)
const;
2339 findGlobalIndex (
const RowInfo& rowinfo,
2340 const GlobalOrdinal ind,
2341 const size_t hint = 0)
const;
2352 findGlobalIndex (
const RowInfo& rowinfo,
2353 const GlobalOrdinal ind,
2354 const Kokkos::View<
const GlobalOrdinal*,
2355 device_type, Kokkos::MemoryUnmanaged>& colInds,
2356 const size_t hint = 0)
const;
2366 local_graph_type getLocalGraph ()
const;
2370 TPETRA_DEPRECATED local_graph_type getLocalGraph_Kokkos ()
const;
2372 void fillLocalGraph (
const Teuchos::RCP<Teuchos::ParameterList>& params);
2375 bool hasRowInfo ()
const;
2378 void checkInternalState ()
const;
2410 global_size_t globalNumEntries_, globalNumDiags_, globalMaxNumRowEntries_;
2411 size_t nodeNumEntries_, nodeNumDiags_, nodeMaxNumRowEntries_, nodeNumAllocated_;
2539 typedef Kokkos::DualView<size_t*, Kokkos::LayoutLeft, execution_space> t_numRowEntries_;
2562 bool indicesAreAllocated_;
2563 bool indicesAreLocal_;
2564 bool indicesAreGlobal_;
2608 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node, const
bool classic = Node::
classic>
2609 Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node, classic> >
2611 size_t maxNumEntriesPerRow = 0,
2612 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2616 return rcp (
new graph_type (map, maxNumEntriesPerRow,
DynamicProfile, params));
2621 template<
class LocalOrdinal,
2622 class GlobalOrdinal,
2623 class OutputNodeType,
2624 class InputNodeType>
2625 class CrsGraphCopier<CrsGraph<LocalOrdinal, GlobalOrdinal, OutputNodeType>,
2626 CrsGraph<LocalOrdinal, GlobalOrdinal, InputNodeType> > {
2631 static Teuchos::RCP<output_crs_graph_type>
2632 clone (
const input_crs_graph_type& graphIn,
2633 const Teuchos::RCP<OutputNodeType> &nodeOut,
2634 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2636 using Teuchos::arcp;
2637 using Teuchos::ArrayRCP;
2638 using Teuchos::ArrayView;
2639 using Teuchos::null;
2640 using Teuchos::outArg;
2641 using Teuchos::ParameterList;
2642 using Teuchos::parameterList;
2645 using Teuchos::REDUCE_MIN;
2646 using Teuchos::reduceAll;
2647 using Teuchos::sublist;
2650 typedef LocalOrdinal LO;
2651 typedef GlobalOrdinal GO;
2652 typedef typename ArrayView<const GO>::size_type size_type;
2653 typedef ::Tpetra::Map<LO, GO, InputNodeType> input_map_type;
2654 typedef ::Tpetra::Map<LO, GO, OutputNodeType> output_map_type;
2655 const char prefix[] =
"Tpetra::Details::CrsGraphCopier::clone: ";
2659 bool fillCompleteClone =
true;
2660 bool useLocalIndices = graphIn.hasColMap ();
2663 if (! params.is_null ()) {
2664 fillCompleteClone = params->get (
"fillComplete clone", fillCompleteClone);
2665 useLocalIndices = params->get (
"Locally indexed clone", useLocalIndices);
2666 if (params->get (
"Static profile clone",
true) ==
false) {
2669 debug = params->get (
"Debug", debug);
2672 const Teuchos::Comm<int>& comm = * (graphIn.getRowMap ()->getComm ());
2673 const int myRank = comm.getRank ();
2675 TEUCHOS_TEST_FOR_EXCEPTION(
2676 ! graphIn.hasColMap () && useLocalIndices, std::runtime_error,
2677 prefix <<
"You asked clone() to use local indices (by setting the " 2678 "\"Locally indexed clone\" parameter to true), but the source graph " 2679 "does not yet have a column Map, so this is impossible.");
2682 std::ostringstream os;
2683 os <<
"Process " << myRank <<
": Cloning row Map" << endl;
2687 RCP<const output_map_type> clonedRowMap =
2688 graphIn.getRowMap ()->template clone<OutputNodeType> (nodeOut);
2692 RCP<output_crs_graph_type> clonedGraph;
2694 ArrayRCP<const size_t> numEntriesPerRow;
2695 size_t numEntriesForAll = 0;
2696 bool boundSameForAllLocalRows =
true;
2699 std::ostringstream os;
2700 os <<
"Process " << myRank <<
": Getting per-row bounds" << endl;
2703 graphIn.getNumEntriesPerLocalRowUpperBound (numEntriesPerRow,
2705 boundSameForAllLocalRows);
2707 std::ostringstream os;
2708 os <<
"Process " << myRank <<
": numEntriesForAll = " 2709 << numEntriesForAll << endl;
2714 std::ostringstream os;
2715 os <<
"Process " << myRank <<
": graphIn.getNodeMaxNumRowEntries() = " 2716 << graphIn.getNodeMaxNumRowEntries () << endl;
2720 RCP<ParameterList> graphparams;
2721 if (params.is_null ()) {
2722 graphparams = parameterList (
"CrsGraph");
2724 graphparams = sublist (params,
"CrsGraph");
2726 if (useLocalIndices) {
2727 RCP<const output_map_type> clonedColMap =
2728 graphIn.getColMap ()->template clone<OutputNodeType> (nodeOut);
2729 if (boundSameForAllLocalRows) {
2730 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap, clonedColMap,
2731 numEntriesForAll, pftype,
2734 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap, clonedColMap,
2735 numEntriesPerRow, pftype,
2739 if (boundSameForAllLocalRows) {
2740 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap,
2741 numEntriesForAll, pftype,
2744 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap,
2746 pftype, graphparams));
2751 std::ostringstream os;
2752 os <<
"Process " << myRank <<
": Invoked output graph's constructor" << endl;
2757 numEntriesPerRow = null;
2758 numEntriesForAll = 0;
2761 const input_map_type& inputRowMap = * (graphIn.getRowMap ());
2762 const size_type numRows =
2763 static_cast<size_type
> (inputRowMap.getNodeNumElements ());
2765 bool failed =
false;
2767 if (useLocalIndices) {
2768 const LO localMinLID = inputRowMap.getMinLocalIndex ();
2769 const LO localMaxLID = inputRowMap.getMaxLocalIndex ();
2771 if (graphIn.isLocallyIndexed ()) {
2774 ArrayView<const LO> linds;
2775 for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
2776 graphIn.getLocalRowView (lrow, linds);
2777 if (linds.size () != 0) {
2778 clonedGraph->insertLocalIndices (lrow, linds);
2782 catch (std::exception& e) {
2783 std::ostringstream os;
2784 os <<
"Process " << myRank <<
": copying (reading local by view, " 2785 "writing local) indices into the output graph threw an " 2786 "exception: " << e.what () << endl;
2793 TEUCHOS_TEST_FOR_EXCEPTION(
2794 ! graphIn.hasColMap () && useLocalIndices, std::invalid_argument,
2795 prefix <<
"You asked clone() to use local indices (by setting the " 2796 "\"Locally indexed clone\" parameter to true), but the source graph " 2797 "does not yet have a column Map, so this is impossible.");
2812 size_t myMaxNumRowEntries =
2813 graphIn.isFillActive () ?
static_cast<size_t> (0) :
2814 graphIn.getNodeMaxNumRowEntries ();
2816 Array<LO> linds (myMaxNumRowEntries);
2819 for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
2820 size_t theNumEntries = graphIn.getNumEntriesInLocalRow (lrow);
2821 if (theNumEntries > myMaxNumRowEntries) {
2822 myMaxNumRowEntries = theNumEntries;
2823 linds.resize (myMaxNumRowEntries);
2825 graphIn.getLocalRowCopy (lrow, linds (), theNumEntries);
2826 if (theNumEntries != 0) {
2827 clonedGraph->insertLocalIndices (lrow, linds (0, theNumEntries));
2831 catch (std::exception& e) {
2832 std::ostringstream os;
2833 os <<
"Process " << myRank <<
": copying (reading local by copy, " 2834 "writing local) indices into the output graph threw an exception: " 2835 << e.what () << endl;
2843 const GlobalOrdinal localMinGID = inputRowMap.getMinGlobalIndex ();
2844 const GlobalOrdinal localMaxGID = inputRowMap.getMaxGlobalIndex ();
2845 const bool inputRowMapIsContiguous = inputRowMap.isContiguous ();
2847 if (graphIn.isGloballyIndexed ()) {
2848 ArrayView<const GlobalOrdinal> ginds;
2850 if (inputRowMapIsContiguous) {
2852 for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
2853 graphIn.getGlobalRowView (grow, ginds);
2854 if (ginds.size () != 0) {
2855 clonedGraph->insertGlobalIndices (grow, ginds);
2859 catch (std::exception& e) {
2860 std::ostringstream os;
2861 os <<
"Process " << myRank <<
": copying (reading global by view, " 2862 "writing global) indices into the output graph threw an " 2863 "exception: " << e.what () << endl;
2870 ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
2871 for (size_type k = 0; k < numRows; ++k) {
2872 const GO grow = inputRowMapGIDs[k];
2873 graphIn.getGlobalRowView (grow, ginds);
2874 if (ginds.size () != 0) {
2875 clonedGraph->insertGlobalIndices (grow, ginds);
2879 catch (std::exception& e) {
2880 std::ostringstream os;
2881 os <<
"Process " << myRank <<
": copying (reading global by view, " 2882 "writing global) indices into the output graph threw an " 2883 "exception: " << e.what () << endl;
2896 size_t myMaxNumRowEntries =
2897 graphIn.isFillActive () ?
static_cast<size_t> (0) :
2898 graphIn.getNodeMaxNumRowEntries ();
2900 Array<GO> ginds (myMaxNumRowEntries);
2902 if (inputRowMapIsContiguous) {
2904 for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
2905 size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
2906 if (theNumEntries > myMaxNumRowEntries) {
2907 myMaxNumRowEntries = theNumEntries;
2908 ginds.resize (myMaxNumRowEntries);
2910 graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
2911 if (theNumEntries != 0) {
2912 clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
2916 catch (std::exception& e) {
2917 std::ostringstream os;
2918 os <<
"Process " << myRank <<
": copying (reading global by copy, " 2919 "writing global) indices into the output graph threw an " 2920 "exception: " << e.what () << endl;
2927 ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
2928 for (size_type k = 0; k < numRows; ++k) {
2929 const GO grow = inputRowMapGIDs[k];
2931 size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
2932 if (theNumEntries > myMaxNumRowEntries) {
2933 myMaxNumRowEntries = theNumEntries;
2934 ginds.resize (myMaxNumRowEntries);
2936 graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
2937 if (theNumEntries != 0) {
2938 clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
2942 catch (std::exception& e) {
2943 std::ostringstream os;
2944 os <<
"Process " << myRank <<
": copying (reading global by copy, " 2945 "writing global) indices into the output graph threw an " 2946 "exception: " << e.what () << endl;
2956 std::ostringstream os;
2957 os <<
"Process " << myRank <<
": copied entries" << endl;
2961 if (fillCompleteClone) {
2962 RCP<ParameterList> fillparams = params.is_null () ?
2963 parameterList (
"fillComplete") :
2964 sublist (params,
"fillComplete");
2966 RCP<const output_map_type> clonedRangeMap;
2967 RCP<const output_map_type> clonedDomainMap;
2968 if (! graphIn.getRangeMap ().is_null () &&
2969 graphIn.getRangeMap () != graphIn.getRowMap ()) {
2971 graphIn.getRangeMap ()->template clone<OutputNodeType> (nodeOut);
2974 clonedRangeMap = clonedRowMap;
2976 if (! graphIn.getDomainMap ().is_null ()
2977 && graphIn.getDomainMap () != graphIn.getRowMap ()) {
2979 graphIn.getDomainMap ()->template clone<OutputNodeType> (nodeOut);
2982 clonedDomainMap = clonedRowMap;
2986 std::ostringstream os;
2987 os <<
"Process " << myRank <<
": About to call fillComplete on " 2988 "cloned graph" << endl;
2991 clonedGraph->fillComplete (clonedDomainMap, clonedRangeMap, fillparams);
2993 catch (std::exception &e) {
2995 std::ostringstream os;
2996 os << prefix <<
"Process " << myRank <<
": Caught the following " 2997 "exception while calling fillComplete() on clone of type" 2998 << endl << Teuchos::typeName (*clonedGraph) << endl;
3003 int lclSuccess = failed ? 0 : 1;
3005 reduceAll<int, int> (comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
3006 TEUCHOS_TEST_FOR_EXCEPTION(
3007 gblSuccess != 1, std::logic_error, prefix <<
3008 "Clone failed on at least one process.");
3011 std::ostringstream os;
3012 os <<
"Process " << myRank <<
": Done with CrsGraph::clone" << endl;
3022 #endif // TPETRA_CRSGRAPH_DECL_HPP Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
Namespace Tpetra contains the class and methods constituting the Tpetra library.
std::enable_if< Kokkos::is_view< OutputScalarViewType >::value &&Kokkos::is_view< LocalIndicesViewType >::value &&Kokkos::is_view< InputScalarViewType >::value &&std::is_same< typename OutputScalarViewType::non_const_value_type, typename InputScalarViewType::non_const_value_type >::value &&std::is_same< typename LocalIndicesViewType::non_const_value_type, local_ordinal_type >::value, LocalOrdinal >::type transformLocalValues(const RowInfo &rowInfo, const typename UnmanagedView< OutputScalarViewType >::type &rowVals, const typename UnmanagedView< LocalIndicesViewType >::type &inds, const typename UnmanagedView< InputScalarViewType >::type &newVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault) const
Transform the given values using local indices.
bool haveGlobalConstants_
Whether all processes have computed global constants.
Teuchos::RCP< CrsGraph< LocalOrdinal, GlobalOrdinal, Node2, Node2::classic > > clone(const Teuchos::RCP< Node2 > &node2, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) const
Create a cloned CrsGraph for a different Node type.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
An abstract interface for graphs accessed by rows.
bool isNodeGlobalElement(GlobalOrdinal globalIndex) const
Whether the given global index is owned by this Map on the calling process.
bool indicesAreSorted_
Whether the graph's indices are sorted in each row, on this process.
GlobalOrdinal global_ordinal_type
This class' second template parameter; the type of global indices.
bool noRedundancies_
Whether the graph's indices are non-redundant (merged) in each row, on this process.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
local_graph_type LocalStaticCrsGraphType TPETRA_DEPRECATED
DEPRECATED; use local_graph_type (above) instead.
bool sortGhostsAssociatedWithEachProcessor_
Whether to require makeColMap() (and therefore fillComplete()) to order column Map GIDs associated wi...
Node::device_type device_type
This class' Kokkos device type.
Teuchos::RCP< const map_type > rangeMap_
The Map describing the range of the (matrix corresponding to the) graph.
ProfileType pftype_
Whether the graph was allocated with static or dynamic profile.
t_numRowEntries_ k_numRowEntries_
The number of local entries in each locally owned row.
local_graph_type::entries_type::non_const_type k_lclInds1D_
Local column indices for all rows.
Teuchos::ArrayRCP< Teuchos::Array< GlobalOrdinal > > gblInds2D_
Global column indices for all rows.
LocalOrdinal local_ordinal_type
This class' first template parameter; the type of local indices.
Teuchos::RCP< CrsGraph< LocalOrdinal, GlobalOrdinal, Node, classic > > 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 ...
void removeEmptyProcessesInPlace(Teuchos::RCP< DistObjectType > &input, const Teuchos::RCP< const Map< typename DistObjectType::local_ordinal_type, typename DistObjectType::global_ordinal_type, typename DistObjectType::node_type > > &newMap)
Remove processes which contain no elements in this object's Map.
bool upperTriangular_
Whether the graph is locally upper triangular.
Teuchos::RCP< const map_type > domainMap_
The Map describing the domain of the (matrix corresponding to the) graph.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
int local_ordinal_type
Default value of LocalOrdinal template parameter.
bool isNodeLocalElement(LocalOrdinal localIndex) const
Whether the given local index is valid for this Map on the calling process.
Teuchos::RCP< const map_type > colMap_
The Map describing the distribution of columns of the graph.
Implementation details of Tpetra.
size_t numAllocForAllRows_
The maximum number of entries to allow in each locally owned row.
size_t global_size_t
Global size_t object.
Kokkos::StaticCrsGraph< LocalOrdinal, Kokkos::LayoutLeft, execution_space > local_graph_type
The type of the part of the sparse graph on each MPI process.
bool haveLocalConstants_
Whether this process has computed local constants.
t_GlobalOrdinal_1D k_gblInds1D_
Global column indices for all rows.
local_graph_type lclGraph_
Local graph; only initialized after first fillComplete() call.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Sets up and executes a communication plan for a Tpetra DistObject.
GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const
The global index corresponding to the given local index.
CombineMode
Rule for combining data in an Import or Export.
Kokkos::DualView< const size_t *, Kokkos::LayoutLeft, execution_space > k_numAllocPerRow_
The maximum number of entries to allow in each locally owned row, per row.
Abstract base class for objects that can be the source of an Import or Export operation.
Teuchos::RCP< const import_type > importer_
The Import from the domain Map to the column Map.
Node node_type
This class' Kokkos Node type.
Teuchos::RCP< const map_type > rowMap_
The Map describing the distribution of rows of the graph.
Teuchos::ArrayRCP< Teuchos::Array< LocalOrdinal > > lclInds2D_
Local column indices for all rows.
LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const
The local index corresponding to the given global index.
Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The Map specialization used by this class.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Describes a parallel distribution of objects over processes.
Details::EStorageStatus storageStatus_
Status of the graph's storage, when not in a fill-complete state.
std::enable_if< Kokkos::is_view< OutputScalarViewType >::value &&Kokkos::is_view< LocalIndicesViewType >::value &&Kokkos::is_view< InputScalarViewType >::value &&std::is_same< typename OutputScalarViewType::non_const_value_type, typename InputScalarViewType::non_const_value_type >::value &&std::is_same< typename LocalIndicesViewType::non_const_value_type, local_ordinal_type >::value, LocalOrdinal >::type replaceLocalValues(const RowInfo &rowInfo, const typename UnmanagedView< OutputScalarViewType >::type &rowVals, const typename UnmanagedView< LocalIndicesViewType >::type &inds, const typename UnmanagedView< InputScalarViewType >::type &newVals) const
Implementation detail of CrsMatrix::replaceLocalValues.
device_type::execution_space execution_space
This class' Kokkos execution space.
local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D TPETRA_DEPRECATED
DEPRECATED; use local_graph_type::entries_type::non_const_type instead.
std::enable_if< Kokkos::is_view< OutputScalarViewType >::value &&Kokkos::is_view< LocalIndicesViewType >::value &&Kokkos::is_view< InputScalarViewType >::value &&std::is_same< typename OutputScalarViewType::non_const_value_type, typename InputScalarViewType::non_const_value_type >::value &&std::is_same< typename LocalIndicesViewType::non_const_value_type, local_ordinal_type >::value, LocalOrdinal >::type sumIntoLocalValues(const RowInfo &rowInfo, const typename UnmanagedView< OutputScalarViewType >::type &rowVals, const typename UnmanagedView< LocalIndicesViewType >::type &inds, const typename UnmanagedView< InputScalarViewType >::type &newVals, const bool atomic=useAtomicUpdatesByDefault) const
Implementation detail of CrsMatrix::sumIntoLocalValues.
local_graph_type::row_map_type::const_type k_rowPtrs_
Row offsets for "1-D" storage.
std::map< GlobalOrdinal, std::vector< GlobalOrdinal > > nonlocals_
Nonlocal data given to insertGlobalValues or sumIntoGlobalValues.
local_graph_type::row_map_type t_RowPtrs TPETRA_DEPRECATED
DEPRECATED; use local_graph_type::row_map_type instead.
local_graph_type::row_map_type::non_const_type t_RowPtrsNC TPETRA_DEPRECATED
DEPRECATED; use local_graph_type::row_map_type::non_const_type instead.
Kokkos::View< GlobalOrdinal *, execution_space > t_GlobalOrdinal_1D
Type of the k_gblInds1D_ array of global column indices.
Base class for distributed Tpetra objects that support data redistribution.
Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization used by this class.
LocalOrdinal sumIntoGlobalValues(const RowInfo &rowInfo, const Kokkos::View< Scalar *, ValsMemorySpace, Kokkos::MemoryUnmanaged > &rowVals, const Kokkos::View< const GlobalOrdinal *, InputMemorySpace, Kokkos::MemoryUnmanaged > &inds, const Kokkos::View< const Scalar *, InputMemorySpace, Kokkos::MemoryUnmanaged > &newVals, const bool atomic=useAtomicUpdatesByDefault) const
Implementation detail of CrsMatrix::sumIntoGlobalValues.
LocalOrdinal transformGlobalValues(const RowInfo &rowInfo, const Kokkos::View< Scalar *, ValsMemorySpace, Kokkos::MemoryUnmanaged > &rowVals, const Kokkos::View< const GlobalOrdinal *, InputMemorySpace, Kokkos::MemoryUnmanaged > &inds, const Kokkos::View< const Scalar *, InputMemorySpace, Kokkos::MemoryUnmanaged > &newVals, BinaryFunction f, const bool atomic=useAtomicUpdatesByDefault) const
Transform the given values using global indices.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
Teuchos::RCP< const export_type > exporter_
The Export from the row Map to the range Map.
bool lowerTriangular_
Whether the graph is locally lower triangular.
Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization used by this class.