42 #ifndef TPETRA_DISTOBJECT_DEF_HPP
43 #define TPETRA_DISTOBJECT_DEF_HPP
53 #include "Tpetra_Distributor.hpp"
64 template<
class DeviceType,
class IndexType =
size_t>
66 SumFunctor (
const Kokkos::View<const size_t*, DeviceType>& viewToSum) :
67 viewToSum_ (viewToSum) {}
68 KOKKOS_INLINE_FUNCTION
void operator() (
const IndexType i,
size_t& lclSum)
const {
69 lclSum += viewToSum_(i);
71 Kokkos::View<const size_t*, DeviceType> viewToSum_;
74 template<
class DeviceType,
class IndexType =
size_t>
76 countTotalImportPackets (
const Kokkos::View<const size_t*, DeviceType>& numImportPacketsPerLID)
78 using Kokkos::parallel_reduce;
79 typedef DeviceType DT;
80 typedef typename DT::execution_space DES;
81 typedef Kokkos::RangePolicy<DES, IndexType> range_type;
83 const IndexType numOut = numImportPacketsPerLID.extent (0);
84 size_t totalImportPackets = 0;
85 parallel_reduce (
"Count import packets",
86 range_type (0, numOut),
87 SumFunctor<DeviceType, IndexType> (numImportPacketsPerLID),
89 return totalImportPackets;
94 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
99 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
102 using Teuchos::TimeMonitor;
104 RCP<Time> doXferTimer =
105 TimeMonitor::lookupCounter (
"Tpetra::DistObject::doTransfer");
106 if (doXferTimer.is_null ()) {
108 TimeMonitor::getNewCounter (
"Tpetra::DistObject::doTransfer");
110 doXferTimer_ = doXferTimer;
112 RCP<Time> copyAndPermuteTimer =
113 TimeMonitor::lookupCounter (
"Tpetra::DistObject::copyAndPermute");
114 if (copyAndPermuteTimer.is_null ()) {
115 copyAndPermuteTimer =
116 TimeMonitor::getNewCounter (
"Tpetra::DistObject::copyAndPermute");
118 copyAndPermuteTimer_ = copyAndPermuteTimer;
120 RCP<Time> packAndPrepareTimer =
121 TimeMonitor::lookupCounter (
"Tpetra::DistObject::packAndPrepare");
122 if (packAndPrepareTimer.is_null ()) {
123 packAndPrepareTimer =
124 TimeMonitor::getNewCounter (
"Tpetra::DistObject::packAndPrepare");
126 packAndPrepareTimer_ = packAndPrepareTimer;
128 RCP<Time> doPostsAndWaitsTimer =
129 TimeMonitor::lookupCounter (
"Tpetra::DistObject::doPostsAndWaits");
130 if (doPostsAndWaitsTimer.is_null ()) {
131 doPostsAndWaitsTimer =
132 TimeMonitor::getNewCounter (
"Tpetra::DistObject::doPostsAndWaits");
134 doPostsAndWaitsTimer_ = doPostsAndWaitsTimer;
136 RCP<Time> unpackAndCombineTimer =
137 TimeMonitor::lookupCounter (
"Tpetra::DistObject::unpackAndCombine");
138 if (unpackAndCombineTimer.is_null ()) {
139 unpackAndCombineTimer =
140 TimeMonitor::getNewCounter (
"Tpetra::DistObject::unpackAndCombine");
142 unpackAndCombineTimer_ = unpackAndCombineTimer;
143 #endif // HAVE_TPETRA_TRANSFER_TIMERS
146 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
151 using Teuchos::TypeNameTraits;
153 std::ostringstream os;
154 os <<
"\"Tpetra::DistObject\": {"
155 <<
"Packet: " << TypeNameTraits<packet_type>::name ()
156 <<
", LocalOrdinal: " << TypeNameTraits<local_ordinal_type>::name ()
157 <<
", GlobalOrdinal: " << TypeNameTraits<global_ordinal_type>::name ()
158 <<
", Node: " << TypeNameTraits<Node>::name ();
159 if (this->getObjectLabel () !=
"") {
160 os <<
"Label: \"" << this->getObjectLabel () <<
"\"";
166 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
170 const Teuchos::EVerbosityLevel verbLevel)
const
172 using Teuchos::rcpFromRef;
173 using Teuchos::TypeNameTraits;
175 const Teuchos::EVerbosityLevel vl = (verbLevel == Teuchos::VERB_DEFAULT) ?
176 Teuchos::VERB_LOW : verbLevel;
177 Teuchos::RCP<const Teuchos::Comm<int> > comm = this->getMap ()->getComm ();
178 const int myRank = comm.is_null () ? 0 : comm->getRank ();
179 const int numProcs = comm.is_null () ? 1 : comm->getSize ();
181 if (vl != Teuchos::VERB_NONE) {
182 Teuchos::OSTab tab0 (out);
184 out <<
"\"Tpetra::DistObject\":" << endl;
186 Teuchos::OSTab tab1 (out);
188 out <<
"Template parameters:" << endl;
190 Teuchos::OSTab tab2 (out);
191 out <<
"Packet: " << TypeNameTraits<packet_type>::name () << endl
192 <<
"LocalOrdinal: " << TypeNameTraits<local_ordinal_type>::name () << endl
193 <<
"GlobalOrdinal: " << TypeNameTraits<global_ordinal_type>::name () << endl
194 <<
"Node: " << TypeNameTraits<node_type>::name () << endl;
196 if (this->getObjectLabel () !=
"") {
197 out <<
"Label: \"" << this->getObjectLabel () <<
"\"" << endl;
204 out <<
"Map:" << endl;
206 Teuchos::OSTab tab2 (out);
207 map_->describe (out, vl);
211 if (vl > Teuchos::VERB_LOW) {
212 for (
int p = 0; p < numProcs; ++p) {
214 out <<
"Process " << myRank <<
":" << endl;
215 Teuchos::OSTab tab2 (out);
216 out <<
"Export buffer size (in packets): "
217 << exports_.extent (0)
219 <<
"Import buffer size (in packets): "
220 << imports_.extent (0)
223 if (! comm.is_null ()) {
233 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
238 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
239 "Tpetra::DistObject::removeEmptyProcessesInPlace: Not implemented");
271 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
277 const bool restrictedMode)
280 const char modeString[] =
"doImport (forward mode)";
286 std::unique_ptr<std::string> prefix;
289 auto map = this->getMap ();
290 if (! map.is_null ()) {
291 auto comm = map->getComm ();
292 if (! comm.is_null ()) {
293 myRank = comm->getRank ();
296 prefix = [myRank] () {
297 std::ostringstream os;
298 os <<
"Proc " << myRank <<
": Tpetra::DistObject::doTransfer: ";
299 return std::unique_ptr<std::string> (
new std::string (os.str ()));
301 std::ostringstream os;
302 os << *prefix <<
"Start" << endl;
303 std::cerr << os.str ();
305 this->doTransfer (source, importer, modeString, DoForward, CM, restrictedMode);
307 std::ostringstream os;
308 os << *prefix <<
"Done!" << endl;
309 std::cerr << os.str ();
313 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
319 const bool restrictedMode)
322 const char modeString[] =
"doExport (forward mode)";
328 std::unique_ptr<std::string> prefix;
331 auto map = this->getMap ();
332 if (! map.is_null ()) {
333 auto comm = map->getComm ();
334 if (! comm.is_null ()) {
335 myRank = comm->getRank ();
338 prefix = [myRank] () {
339 std::ostringstream os;
340 os <<
"(Proc " << myRank <<
") ";
341 return std::unique_ptr<std::string> (
new std::string (os.str ()));
343 std::ostringstream os;
344 os << *prefix <<
"Tpetra::DistObject::" << modeString <<
":" << endl;
345 std::cerr << os.str ();
347 this->doTransfer (source, exporter, modeString, DoForward, CM, restrictedMode);
349 std::ostringstream os;
350 os << *prefix <<
"Tpetra::DistObject::" << modeString <<
": Done!"
352 std::cerr << os.str ();
356 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
362 const bool restrictedMode)
365 const char modeString[] =
"doImport (reverse mode)";
371 std::unique_ptr<std::string> prefix;
374 auto map = this->getMap ();
375 if (! map.is_null ()) {
376 auto comm = map->getComm ();
377 if (! comm.is_null ()) {
378 myRank = comm->getRank ();
381 prefix = [myRank] () {
382 std::ostringstream os;
383 os <<
"(Proc " << myRank <<
") ";
384 return std::unique_ptr<std::string> (
new std::string (os.str ()));
386 std::ostringstream os;
387 os << *prefix <<
"Tpetra::DistObject::" << modeString <<
":" << endl;
388 std::cerr << os.str ();
390 this->doTransfer (source, exporter, modeString, DoReverse, CM, restrictedMode);
392 std::ostringstream os;
393 os << *prefix <<
"Tpetra::DistObject::" << modeString <<
": Done!"
395 std::cerr << os.str ();
399 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
405 const bool restrictedMode)
408 const char modeString[] =
"doExport (reverse mode)";
414 std::unique_ptr<std::string> prefix;
417 auto map = this->getMap ();
418 if (! map.is_null ()) {
419 auto comm = map->getComm ();
420 if (! comm.is_null ()) {
421 myRank = comm->getRank ();
424 prefix = [myRank] () {
425 std::ostringstream os;
426 os <<
"(Proc " << myRank <<
") ";
427 return std::unique_ptr<std::string> (
new std::string (os.str ()));
429 std::ostringstream os;
430 os << *prefix <<
"Tpetra::DistObject::" << modeString <<
":" << endl;
431 std::cerr << os.str ();
433 this->doTransfer (source, importer, modeString, DoReverse, CM, restrictedMode);
435 std::ostringstream os;
436 os << *prefix <<
"Tpetra::DistObject::" << modeString <<
": Done!"
438 std::cerr << os.str ();
442 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
446 return map_->isDistributed ();
449 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
456 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
460 const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, node_type>& transfer,
461 const char modeString[],
467 using ::Tpetra::Details::ProfilingRegion;
470 ProfilingRegion region_doTransfer (
"Tpetra::DistObject::doTransfer");
472 std::unique_ptr<std::string> prefix;
474 auto map = this->getMap ();
475 auto comm = map.is_null () ? Teuchos::null : map->getComm ();
476 const int myRank = comm.is_null () ? -1 : comm->getRank ();
477 std::ostringstream os;
478 os <<
"Proc " << myRank <<
": Tpetra::DistObject::doTransfer: ";
479 prefix = std::unique_ptr<std::string> (
new std::string (os.str ()));
480 os << *prefix <<
"Source type: " <<
typeid (src).name ()
481 <<
", Target type: " <<
typeid (*this).name () << endl;
482 std::cerr << os.str ();
497 if (!restrictedMode && revOp == DoForward) {
498 const bool myMapSameAsTransferTgtMap =
499 this->getMap ()->isSameAs (* (transfer.getTargetMap ()));
500 TEUCHOS_TEST_FOR_EXCEPTION
501 (! myMapSameAsTransferTgtMap, std::invalid_argument,
502 "Tpetra::DistObject::" << modeString <<
": For forward-mode "
503 "communication, the target DistObject's Map must be the same "
504 "(in the sense of Tpetra::Map::isSameAs) as the input "
505 "Export/Import object's target Map.");
507 else if (!restrictedMode && revOp == DoReverse) {
508 const bool myMapSameAsTransferSrcMap =
509 this->getMap ()->isSameAs (* (transfer.getSourceMap ()));
510 TEUCHOS_TEST_FOR_EXCEPTION
511 (! myMapSameAsTransferSrcMap, std::invalid_argument,
512 "Tpetra::DistObject::" << modeString <<
": For reverse-mode "
513 "communication, the target DistObject's Map must be the same "
514 "(in the sense of Tpetra::Map::isSameAs) as the input "
515 "Export/Import object's source Map.");
517 else if (restrictedMode && revOp == DoForward) {
518 const bool myMapLocallyFittedTransferTgtMap =
519 this->getMap ()->isLocallyFitted (* (transfer.getTargetMap ()));
520 TEUCHOS_TEST_FOR_EXCEPTION
521 (! myMapLocallyFittedTransferTgtMap , std::invalid_argument,
522 "Tpetra::DistObject::" << modeString <<
": For forward-mode "
523 "communication using restricted mode, Export/Import object's "
524 "target Map must be locally fitted (in the sense of "
525 "Tpetra::Map::isLocallyFitted) to target DistObject's Map.");
528 const bool myMapLocallyFittedTransferSrcMap =
529 this->getMap ()->isLocallyFitted (* (transfer.getSourceMap ()));
530 TEUCHOS_TEST_FOR_EXCEPTION
531 (! myMapLocallyFittedTransferSrcMap, std::invalid_argument,
532 "Tpetra::DistObject::" << modeString <<
": For reverse-mode "
533 "communication using restricted mode, Export/Import object's "
534 "source Map must be locally fitted (in the sense of "
535 "Tpetra::Map::isLocallyFitted) to target DistObject's Map.");
542 if (srcDistObj !=
nullptr) {
543 if (revOp == DoForward) {
544 const bool srcMapSameAsImportSrcMap =
545 srcDistObj->
getMap ()->isSameAs (* (transfer.getSourceMap ()));
546 TEUCHOS_TEST_FOR_EXCEPTION
547 (! srcMapSameAsImportSrcMap, std::invalid_argument,
548 "Tpetra::DistObject::" << modeString <<
": For forward-mode "
549 "communication, the source DistObject's Map must be the same "
550 "as the input Export/Import object's source Map.");
553 const bool srcMapSameAsImportTgtMap =
554 srcDistObj->
getMap ()->isSameAs (* (transfer.getTargetMap ()));
555 TEUCHOS_TEST_FOR_EXCEPTION
556 (! srcMapSameAsImportTgtMap, std::invalid_argument,
557 "Tpetra::DistObject::" << modeString <<
": For reverse-mode "
558 "communication, the source DistObject's Map must be the same "
559 "as the input Export/Import object's target Map.");
564 const size_t numSameIDs = transfer.getNumSameIDs ();
567 TEUCHOS_TEST_FOR_EXCEPTION
568 (debug && restrictedMode &&
569 (transfer.getPermuteToLIDs_dv().extent(0) != 0 ||
570 transfer.getPermuteFromLIDs_dv().extent(0) != 0),
571 std::invalid_argument,
572 "Tpetra::DistObject::" << modeString <<
": Transfer object "
573 "cannot have permutes in restricted mode.");
575 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
576 const bool useTheNewInterface = this->useNewInterface ();
578 const bool useTheNewInterface =
true;
579 #endif // TPETRA_ENABLE_DEPRECATED_CODE
581 if (useTheNewInterface) {
582 using ::Tpetra::Details::Behavior;
584 const bool commOnHost = ! Behavior::assumeMpiIsCudaAware ();
586 std::ostringstream os;
587 os << *prefix <<
"doTransfer: Use new interface; "
588 "commOnHost=" << (commOnHost ?
"true" :
"false") << endl;
589 std::cerr << os.str ();
592 auto permToLIDs = (revOp == DoForward) ?
593 transfer.getPermuteToLIDs_dv () :
594 transfer.getPermuteFromLIDs_dv ();
595 auto permFromLIDs = (revOp == DoForward) ?
596 transfer.getPermuteFromLIDs_dv () :
597 transfer.getPermuteToLIDs_dv ();
598 auto remoteLIDs = (revOp == DoForward) ?
599 transfer.getRemoteLIDs_dv () :
600 transfer.getExportLIDs_dv ();
601 auto exportLIDs = (revOp == DoForward) ?
602 transfer.getExportLIDs_dv () :
603 transfer.getRemoteLIDs_dv ();
604 doTransferNew (src, CM, numSameIDs, permToLIDs, permFromLIDs,
605 remoteLIDs, exportLIDs, distor, revOp, commOnHost,restrictedMode);
608 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
609 if (! useTheNewInterface) {
611 std::ostringstream os;
612 os << *prefix <<
"doTransfer: Use old interface" << endl;
613 std::cerr << os.str ();
615 const auto permToLIDs = (revOp == DoForward) ?
616 transfer.getPermuteToLIDs () : transfer.getPermuteFromLIDs ();
617 const auto permFromLIDs = (revOp == DoForward) ?
618 transfer.getPermuteFromLIDs () : transfer.getPermuteToLIDs ();
619 const auto exportLIDs = (revOp == DoForward) ?
620 transfer.getExportLIDs () : transfer.getRemoteLIDs ();
621 const auto remoteLIDs = (revOp == DoForward) ?
622 transfer.getRemoteLIDs () : transfer.getExportLIDs ();
623 doTransferOld (src, CM, numSameIDs, permToLIDs, permFromLIDs,
624 remoteLIDs, exportLIDs, distor, revOp, restrictedMode);
626 #endif // TPETRA_ENABLE_DEPRECATED_CODE
629 std::ostringstream os;
630 os << *prefix <<
"Tpetra::DistObject::doTransfer: Done!" << endl;
631 std::cerr << os.str ();
635 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
640 const std::string* prefix)
643 std::ostringstream os;
644 os << *prefix <<
"Realloc (if needed) imports_ from "
645 << imports_.extent (0) <<
" to " << newSize << std::endl;
646 std::cerr << os.str ();
649 const bool reallocated =
652 std::ostringstream os;
653 os << *prefix <<
"Finished realloc'ing imports_" << std::endl;
654 std::cerr << os.str ();
659 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
663 const size_t numImportLIDs)
672 constexpr
size_t tooBigFactor = 10;
675 std::unique_ptr<std::string> prefix;
677 const int myRank = [&] () {
678 auto map = this->getMap ();
679 if (map.get () ==
nullptr) {
682 auto comm = map->getComm ();
683 if (comm.get () ==
nullptr) {
686 return comm->getRank ();
688 std::ostringstream os;
689 os <<
"Proc " << myRank <<
": reallocArraysForNumPacketsPerLid("
690 << numExportLIDs <<
", " << numImportLIDs <<
"): ";
691 prefix = std::unique_ptr<std::string> (
new std::string (os.str ()));
695 std::ostringstream os;
696 os << *prefix <<
"before:" << endl
698 "numExportPacketsPerLID_")
701 "numImportPacketsPerLID_")
703 std::cerr << os.str ();
707 const bool firstReallocated =
710 "numExportPacketsPerLID",
717 const bool needFenceBeforeNextAlloc = ! firstReallocated;
718 const bool secondReallocated =
721 "numImportPacketsPerLID",
723 needFenceBeforeNextAlloc);
726 std::ostringstream os;
727 os << *prefix <<
"after:" << endl
729 "numExportPacketsPerLID_")
732 "numImportPacketsPerLID_")
734 std::cerr << os.str ();
737 return firstReallocated || secondReallocated;
740 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
745 const size_t numSameIDs,
756 const bool commOnHost,
757 const bool restrictedMode)
761 using ::Tpetra::Details::ProfilingRegion;
762 using Kokkos::Compat::getArrayView;
763 using Kokkos::Compat::getConstArrayView;
764 using Kokkos::Compat::getKokkosViewDeepCopy;
765 using Kokkos::Compat::create_const_view;
768 using DES =
typename DT::execution_space;
770 ProfilingRegion region_dTN (
"Tpetra::DistObject::doTransferNew");
771 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
774 Teuchos::TimeMonitor doXferMon (*doXferTimer_);
775 #endif // HAVE_TPETRA_TRANSFER_TIMERS
780 std::unique_ptr<std::string> prefix;
782 auto map = this->getMap ();
783 auto comm = map.is_null () ? Teuchos::null : map->getComm ();
784 const int myRank = comm.is_null () ? 0 : comm->getRank ();
785 std::ostringstream os;
786 os <<
"Proc " << myRank <<
": Tpetra::CrsMatrix::doTransferNew: ";
787 prefix = std::unique_ptr<std::string> (
new std::string (os.str ()));
791 std::ostringstream os;
792 os << *prefix <<
"Input arguments:" << endl
794 << *prefix <<
" numSameIDs: " << numSameIDs << endl
803 << *prefix <<
" revOp: Do" << (revOp == DoReverse ?
"Reverse" :
"Forward") << endl
804 << *prefix <<
" commOnHost: " << (commOnHost ?
"true" :
"false") << endl;
805 std::cerr << os.str ();
809 ProfilingRegion region_cs (
"Tpetra::DistObject::doTransferNew::checkSizes");
811 std::ostringstream os;
812 os << *prefix <<
"1. checkSizes" << endl;
813 std::cerr << os.str ();
815 const bool checkSizesResult = this->checkSizes (src);
816 TEUCHOS_TEST_FOR_EXCEPTION
817 (! checkSizesResult, std::invalid_argument,
818 "Tpetra::DistObject::doTransfer: checkSizes() indicates that the "
819 "destination object is not a legal target for redistribution from the "
820 "source object. This probably means that they do not have the same "
821 "dimensions. For example, MultiVectors must have the same number of "
822 "rows and columns.");
829 if (!restrictedMode && numSameIDs + permuteToLIDs.extent (0) != 0) {
832 std::ostringstream os;
833 os << *prefix <<
"2. copyAndPermute" << endl;
834 std::cerr << os.str ();
836 ProfilingRegion region_cp
837 (
"Tpetra::DistObject::doTransferNew::copyAndPermute");
838 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
841 Teuchos::TimeMonitor copyAndPermuteMon (*copyAndPermuteTimer_);
842 #endif // HAVE_TPETRA_TRANSFER_TIMERS
844 if (numSameIDs + permuteToLIDs.extent (0) != 0) {
847 std::ostringstream os;
848 os << *prefix <<
"2. copyAndPermute" << endl;
849 std::cerr << os.str ();
851 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
852 this->copyAndPermuteNew (src, numSameIDs, permuteToLIDs,
854 #else // TPETRA_ENABLE_DEPRECATED_CODE
855 this->copyAndPermute (src, numSameIDs, permuteToLIDs,
857 #endif // TPETRA_ENABLE_DEPRECATED_CODE
859 std::ostringstream os;
860 os << *prefix <<
"After copyAndPermute:" << endl
867 std::cerr << os.str ();
880 size_t constantNumPackets = this->constantNumberOfPackets ();
882 std::ostringstream os;
883 os << *prefix <<
"constantNumPackets=" << constantNumPackets << endl;
884 std::cerr << os.str ();
892 if (constantNumPackets == 0) {
894 std::ostringstream os;
895 os << *prefix <<
"3. (Re)allocate num{Ex,Im}portPacketsPerLID"
897 std::cerr << os.str ();
901 this->reallocArraysForNumPacketsPerLid (exportLIDs.extent (0),
902 remoteLIDs.extent (0));
906 std::ostringstream os;
907 os << *prefix <<
"4. packAndPrepare: before, "
910 std::cerr << os.str ();
913 ProfilingRegion region_pp
914 (
"Tpetra::DistObject::doTransferNew::packAndPrepare");
915 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
918 Teuchos::TimeMonitor packAndPrepareMon (*packAndPrepareTimer_);
919 #endif // HAVE_TPETRA_TRANSFER_TIMERS
937 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
938 this->packAndPrepareNew (src, exportLIDs, this->exports_,
939 this->numExportPacketsPerLID_,
940 constantNumPackets, distor);
941 #else // TPETRA_ENABLE_DEPRECATED_CODE
942 this->packAndPrepare (src, exportLIDs, this->exports_,
943 this->numExportPacketsPerLID_,
944 constantNumPackets, distor);
945 #endif // TPETRA_ENABLE_DEPRECATED_CODE
947 if (this->exports_.need_sync_host ()) {
948 this->exports_.sync_host ();
952 if (this->exports_.need_sync_device ()) {
953 this->exports_.sync_device ();
958 std::ostringstream os;
959 os << *prefix <<
"5.1. After packAndPrepare, "
962 std::cerr << os.str ();
968 if (constantNumPackets != 0) {
973 const size_t rbufLen = remoteLIDs.extent (0) * constantNumPackets;
974 reallocImportsIfNeeded (rbufLen, verbose, prefix.get ());
978 bool needCommunication =
true;
983 if (revOp == DoReverse && ! this->isDistributed ()) {
984 needCommunication =
false;
993 else if (revOp == DoForward && srcDistObj != NULL &&
995 needCommunication =
false;
998 if (! needCommunication) {
1000 std::ostringstream os;
1001 os << *prefix <<
"Comm not needed; skipping" << endl;
1002 std::cerr << os.str ();
1006 ProfilingRegion region_dpw
1007 (
"Tpetra::DistObject::doTransferNew::doPostsAndWaits");
1008 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1011 Teuchos::TimeMonitor doPostsAndWaitsMon (*doPostsAndWaitsTimer_);
1012 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1015 std::ostringstream os;
1016 os << *prefix <<
"7.0. "
1017 << (revOp == DoReverse ?
"Reverse" :
"Forward")
1019 std::cerr << os.str ();
1022 if (constantNumPackets == 0) {
1024 std::ostringstream os;
1025 os << *prefix <<
"7.1. Variable # packets / LID: first comm "
1026 <<
"(commOnHost = " << (commOnHost ?
"true" :
"false") <<
")"
1028 std::cerr << os.str ();
1030 size_t totalImportPackets = 0;
1032 if (this->numExportPacketsPerLID_.need_sync_host ()) {
1033 this->numExportPacketsPerLID_.sync_host ();
1035 if (this->numImportPacketsPerLID_.need_sync_host ()) {
1036 this->numImportPacketsPerLID_.sync_host ();
1038 this->numImportPacketsPerLID_.modify_host ();
1040 create_const_view (this->numExportPacketsPerLID_.view_host ());
1041 auto numImp_h = this->numImportPacketsPerLID_.view_host ();
1045 std::ostringstream os;
1046 os << *prefix <<
"Call do"
1047 << (revOp == DoReverse ?
"Reverse" :
"") <<
"PostsAndWaits"
1049 std::cerr << os.str ();
1051 if (revOp == DoReverse) {
1060 std::ostringstream os;
1061 os << *prefix <<
"Count totalImportPackets" << std::endl;
1062 std::cerr << os.str ();
1064 using the_dev_type =
typename decltype (numImp_h)::
device_type;
1065 totalImportPackets = countTotalImportPackets<the_dev_type> (numImp_h);
1068 if (this->numExportPacketsPerLID_.need_sync_device ()) {
1069 this->numExportPacketsPerLID_.sync_device ();
1071 if (this->numImportPacketsPerLID_.need_sync_device ()) {
1072 this->numImportPacketsPerLID_.sync_device ();
1074 this->numImportPacketsPerLID_.modify_device ();
1075 auto numExp_d = create_const_view
1076 (this->numExportPacketsPerLID_.view_device ());
1077 auto numImp_d = this->numImportPacketsPerLID_.view_device ();
1081 std::ostringstream os;
1082 os << *prefix <<
"Call do"
1083 << (revOp == DoReverse ?
"Reverse" :
"") <<
"PostsAndWaits"
1085 std::cerr << os.str ();
1087 if (revOp == DoReverse) {
1096 std::ostringstream os;
1097 os << *prefix <<
"Count totalImportPackets" << std::endl;
1098 std::cerr << os.str ();
1100 using the_dev_type =
typename decltype (numImp_d)::
device_type;
1101 totalImportPackets = countTotalImportPackets<the_dev_type> (numImp_d);
1105 std::ostringstream os;
1106 os << *prefix <<
"totalImportPackets=" << totalImportPackets << endl;
1107 std::cerr << os.str ();
1109 this->reallocImportsIfNeeded (totalImportPackets, verbose,
1112 std::ostringstream os;
1113 os << *prefix <<
"7.3. Second comm" << std::endl;
1114 std::cerr << os.str ();
1120 if (this->numExportPacketsPerLID_.need_sync_host ()) {
1121 this->numExportPacketsPerLID_.sync_host ();
1123 if (this->numImportPacketsPerLID_.need_sync_host ()) {
1124 this->numImportPacketsPerLID_.sync_host ();
1134 auto numExportPacketsPerLID_av =
1136 auto numImportPacketsPerLID_av =
1144 this->imports_.clear_sync_state ();
1147 std::ostringstream os;
1148 os << *prefix <<
"Comm on "
1149 << (commOnHost ?
"host" :
"device")
1150 <<
"; call do" << (revOp == DoReverse ?
"Reverse" :
"")
1151 <<
"PostsAndWaits" << endl;
1152 std::cerr << os.str ();
1156 this->imports_.modify_host ();
1157 if (revOp == DoReverse) {
1159 (create_const_view (this->exports_.view_host ()),
1160 numExportPacketsPerLID_av,
1161 this->imports_.view_host (),
1162 numImportPacketsPerLID_av);
1166 (create_const_view (this->exports_.view_host ()),
1167 numExportPacketsPerLID_av,
1168 this->imports_.view_host (),
1169 numImportPacketsPerLID_av);
1173 this->imports_.modify_device ();
1174 if (revOp == DoReverse) {
1176 (create_const_view (this->exports_.view_device ()),
1177 numExportPacketsPerLID_av,
1178 this->imports_.view_device (),
1179 numImportPacketsPerLID_av);
1183 (create_const_view (this->exports_.view_device ()),
1184 numExportPacketsPerLID_av,
1185 this->imports_.view_device (),
1186 numImportPacketsPerLID_av);
1192 std::ostringstream os;
1193 os << *prefix <<
"7.1. Const # packets per LID: " << endl
1200 std::cerr << os.str ();
1207 this->imports_.clear_sync_state ();
1210 std::ostringstream os;
1211 os << *prefix <<
"7.2. Comm on "
1212 << (commOnHost ?
"host" :
"device")
1213 <<
"; call do" << (revOp == DoReverse ?
"Reverse" :
"")
1214 <<
"PostsAndWaits" << endl;
1215 std::cerr << os.str ();
1218 this->imports_.modify_host ();
1219 if (revOp == DoReverse) {
1221 (create_const_view (this->exports_.view_host ()),
1223 this->imports_.view_host ());
1227 (create_const_view (this->exports_.view_host ()),
1229 this->imports_.view_host ());
1233 this->imports_.modify_device ();
1234 if (revOp == DoReverse) {
1236 (create_const_view (this->exports_.view_device ()),
1238 this->imports_.view_device ());
1242 (create_const_view (this->exports_.view_device ()),
1244 this->imports_.view_device ());
1250 std::ostringstream os;
1251 os << *prefix <<
"8. unpackAndCombine" << endl;
1252 std::cerr << os.str ();
1254 ProfilingRegion region_uc
1255 (
"Tpetra::DistObject::doTransferNew::unpackAndCombine");
1256 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1259 Teuchos::TimeMonitor unpackAndCombineMon (*unpackAndCombineTimer_);
1260 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1269 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1270 this->unpackAndCombineNew (remoteLIDs, this->imports_,
1271 this->numImportPacketsPerLID_,
1272 constantNumPackets, distor, CM);
1273 #else // TPETRA_ENABLE_DEPRECATED_CODE
1274 this->unpackAndCombine (remoteLIDs, this->imports_,
1275 this->numImportPacketsPerLID_,
1276 constantNumPackets, distor, CM);
1277 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1282 std::ostringstream os;
1283 os << *prefix <<
"9. Done!" << endl;
1284 std::cerr << os.str ();
1288 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1289 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1290 void TPETRA_DEPRECATED
1295 const Teuchos::ArrayView<const LocalOrdinal>& permuteToLIDs,
1296 const Teuchos::ArrayView<const LocalOrdinal>& permuteFromLIDs,
1297 const Teuchos::ArrayView<const LocalOrdinal>& remoteLIDs,
1298 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
1300 ReverseOption revOp,
1301 const bool restrictedMode)
1304 using ::Tpetra::Details::ProfilingRegion;
1307 const char prefixRaw[] =
"Tpetra::DistObject::doTransferOld: ";
1309 ProfilingRegion region_doTransferOld (
"Tpetra::DistObject::doTransferOld");
1310 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1313 Teuchos::TimeMonitor doXferMon (*doXferTimer_);
1314 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1317 std::unique_ptr<std::string> prefix;
1319 auto map = this->getMap ();
1320 auto comm = map.is_null () ? Teuchos::null : map->getComm ();
1321 const int myRank = comm.is_null () ? -1 : comm->getRank ();
1322 std::ostringstream os;
1323 os <<
"Proc " << myRank <<
": " << prefixRaw;
1324 prefix = std::unique_ptr<std::string> (
new std::string (os.str ()));
1327 TEUCHOS_TEST_FOR_EXCEPTION(
1328 ! checkSizes (src), std::invalid_argument,
1329 prefixRaw <<
"checkSizes() indicates that the "
1330 "destination object is not a legal target for redistribution from the "
1331 "source object. This probably means that they do not have the same "
1332 "dimensions. For example, MultiVectors must have the same number of "
1333 "rows and columns.");
1334 KokkosClassic::ReadWriteOption rwo = KokkosClassic::ReadWrite;
1336 const size_t numIDsToWrite = numSameIDs +
1337 static_cast<size_t> (permuteToLIDs.size ()) +
1338 static_cast<size_t> (remoteLIDs.size ());
1339 if (numIDsToWrite == this->getMap ()->getNodeNumElements ()) {
1347 rwo = KokkosClassic::WriteOnly;
1352 std::ostringstream os;
1353 os << *prefix <<
"ReadWriteOption: ";
1354 if (rwo == KokkosClassic::ReadWrite) {
1357 else if (rwo == KokkosClassic::WriteOnly) {
1361 os <<
"Something else; weird!";
1364 std::cerr << os.str ();
1375 const this_type* srcDistObj =
dynamic_cast<const this_type*
> (&src);
1376 if (srcDistObj != NULL) {
1378 std::ostringstream os;
1379 os << *prefix <<
"Call srcDistObject->createViews()" << endl;
1380 std::cerr << os.str ();
1382 srcDistObj->createViews ();
1386 std::ostringstream os;
1387 os << *prefix <<
"Source object has a different type than target object"
1389 std::cerr << os.str ();
1406 std::ostringstream os;
1407 os << *prefix <<
"Call createViewsNonConst" << endl;
1408 std::cerr << os.str ();
1410 this->createViewsNonConst (rwo);
1412 if (!restrictedMode && numSameIDs + permuteToLIDs.size()) {
1413 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1414 Teuchos::TimeMonitor copyAndPermuteMon (*copyAndPermuteTimer_);
1415 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1417 std::ostringstream os;
1418 os << *prefix <<
"Call copyAndPermute" << endl;
1419 std::cerr << os.str ();
1422 copyAndPermute (src, numSameIDs, permuteToLIDs, permuteFromLIDs);
1426 std::ostringstream os;
1427 os << *prefix <<
"Skipping copyAndPermute" << endl;
1428 std::cerr << os.str ();
1440 size_t constantNumPackets = this->constantNumberOfPackets ();
1442 std::ostringstream os;
1443 os << *prefix <<
"constantNumPackets=" << constantNumPackets << endl;
1444 std::cerr << os.str ();
1452 if (constantNumPackets == 0) {
1453 this->reallocArraysForNumPacketsPerLid (exportLIDs.size (),
1454 remoteLIDs.size ());
1458 std::ostringstream os;
1459 os << *prefix <<
"Preparing for packAndPrepare" << endl;
1460 std::cerr << os.str ();
1463 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1464 Teuchos::TimeMonitor packAndPrepareMon (*packAndPrepareTimer_);
1465 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1471 numExportPacketsPerLID_.modify_host ();
1472 Teuchos::ArrayView<size_t> numExportPacketsPerLID =
1480 Teuchos::Array<packet_type> exportsOld;
1482 std::ostringstream os;
1483 os << *prefix <<
"Call packAndPrepare" << endl;
1484 std::cerr << os.str ();
1486 packAndPrepare (src, exportLIDs, exportsOld, numExportPacketsPerLID,
1487 constantNumPackets, distor);
1488 const size_t exportsLen =
static_cast<size_t> (exportsOld.size ());
1490 Kokkos::View<
const packet_type*, Kokkos::HostSpace,
1491 Kokkos::MemoryUnmanaged> exportsOldK (exportsOld.getRawPtr (),
1493 exports_.modify_host ();
1503 if (srcDistObj !=
nullptr) {
1505 std::ostringstream os;
1506 os << *prefix <<
"Call srcDistObj->releaseViews()" << endl;
1507 std::cerr << os.str ();
1509 srcDistObj->releaseViews ();
1513 std::ostringstream os;
1514 os << *prefix <<
"Skipping srcDistObj->releaseViews()" << endl;
1515 std::cerr << os.str ();
1521 if (constantNumPackets != 0) {
1526 const size_t rbufLen = remoteLIDs.size() * constantNumPackets;
1528 std::ostringstream os;
1529 os << *prefix <<
"Const # packets: imports_.extent(0)="
1530 << imports_.extent (0) <<
", ; calling reallocImportsIfNeeded("
1531 "rbufLen=" << rbufLen <<
", verbose=true)" << endl;
1532 std::cerr << os.str ();
1534 reallocImportsIfNeeded (rbufLen, verbose, prefix.get ());
1538 bool needCommunication =
true;
1539 if (revOp == DoReverse && ! isDistributed ()) {
1540 needCommunication =
false;
1549 else if (revOp == DoForward && srcDistObj != NULL &&
1550 ! srcDistObj->isDistributed ()) {
1551 needCommunication =
false;
1555 std::ostringstream os;
1556 os << *prefix <<
"needCommunication="
1557 << (needCommunication ?
"true" :
"false")
1559 << (revOp == DoReverse ?
"DoReverse" :
"DoForward") << endl;
1560 std::cerr << os.str ();
1563 if (needCommunication) {
1564 if (revOp == DoReverse) {
1565 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1566 Teuchos::TimeMonitor doPostsAndWaitsMon (*doPostsAndWaitsTimer_);
1567 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1568 if (constantNumPackets == 0) {
1574 numExportPacketsPerLID_.sync_host ();
1575 Teuchos::ArrayView<const size_t> numExportPacketsPerLID =
1582 numImportPacketsPerLID_.modify_host ();
1583 Teuchos::ArrayView<size_t> numImportPacketsPerLID =
1587 std::ostringstream os;
1588 os << *prefix <<
"Call doReversePostsAndWaits (3-arg)" << endl;
1589 std::cerr << os.str ();
1592 numImportPacketsPerLID);
1595 std::ostringstream os;
1596 os << *prefix <<
"Compute totalImportPackets" << endl;
1597 std::cerr << os.str ();
1599 size_t totalImportPackets = 0;
1601 typedef typename Kokkos::DualView<
size_t*,
1602 device_type>::t_host::execution_space host_exec_space;
1603 typedef Kokkos::RangePolicy<host_exec_space, Array_size_type> range_type;
1604 const size_t*
const arrayToSum = numImportPacketsPerLID.getRawPtr ();
1605 Kokkos::parallel_reduce (
"Count import packets",
1606 range_type (0, numImportPacketsPerLID.size ()),
1608 lclSum += arrayToSum[i];
1609 }, totalImportPackets);
1613 std::ostringstream os;
1614 os << *prefix <<
"totalImportPackets=" << totalImportPackets
1615 <<
"; calling reallocImportsIfNeeded" << endl;
1616 std::cerr << os.str ();
1618 reallocImportsIfNeeded (totalImportPackets, verbose, prefix.get ());
1624 imports_.modify_host ();
1625 Teuchos::ArrayView<packet_type> hostImports =
1627 exports_.sync_host ();
1628 Teuchos::ArrayView<const packet_type> hostExports =
1632 std::ostringstream os;
1633 os << *prefix <<
"Call doReversePostsAndWaits (4-arg)"
1635 std::cerr << os.str ();
1638 numExportPacketsPerLID,
1640 numImportPacketsPerLID);
1647 imports_.modify_host ();
1648 Teuchos::ArrayView<packet_type> hostImports =
1650 exports_.sync_host ();
1651 Teuchos::ArrayView<const packet_type> hostExports =
1655 std::ostringstream os;
1656 os << *prefix <<
"Call doReversePostsAndWaits (3-arg)"
1658 std::cerr << os.str ();
1666 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1667 Teuchos::TimeMonitor doPostsAndWaitsMon (*doPostsAndWaitsTimer_);
1668 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1669 if (constantNumPackets == 0) {
1675 numExportPacketsPerLID_.sync_host ();
1676 Teuchos::ArrayView<const size_t> numExportPacketsPerLID =
1683 numImportPacketsPerLID_.modify_host ();
1684 Teuchos::ArrayView<size_t> numImportPacketsPerLID =
1688 std::ostringstream os;
1689 os << *prefix <<
"Call doPostsAndWaits (3-arg)" << endl;
1690 std::cerr << os.str ();
1693 numImportPacketsPerLID);
1696 std::ostringstream os;
1697 os << *prefix <<
"Compute totalImportPackets" << endl;
1698 std::cerr << os.str ();
1700 size_t totalImportPackets = 0;
1702 typedef typename Kokkos::DualView<
size_t*,
1703 device_type>::t_host::execution_space host_exec_space;
1704 typedef Kokkos::RangePolicy<host_exec_space, Array_size_type> range_type;
1705 const size_t*
const arrayToSum = numImportPacketsPerLID.getRawPtr ();
1706 Kokkos::parallel_reduce (
"Count import packets",
1707 range_type (0, numImportPacketsPerLID.size ()),
1709 lclSum += arrayToSum[i];
1710 }, totalImportPackets);
1714 std::ostringstream os;
1715 os << *prefix <<
"totalImportPackets=" << totalImportPackets
1716 <<
"; calling reallocImportsIfNeeded" << endl;
1717 std::cerr << os.str ();
1719 reallocImportsIfNeeded (totalImportPackets, verbose, prefix.get ());
1725 imports_.modify_host ();
1726 Teuchos::ArrayView<packet_type> hostImports =
1728 exports_.sync_host ();
1729 Teuchos::ArrayView<const packet_type> hostExports =
1733 std::ostringstream os;
1734 os << *prefix <<
"Call doPostsAndWaits (4-arg)" << endl;
1735 std::cerr << os.str ();
1738 numExportPacketsPerLID,
1740 numImportPacketsPerLID);
1747 imports_.modify_host ();
1748 Teuchos::ArrayView<packet_type> hostImports =
1750 exports_.sync_host ();
1751 Teuchos::ArrayView<const packet_type> hostExports =
1755 std::ostringstream os;
1756 os << *prefix <<
"Call doPostsAndWaits (3-arg)" << endl;
1757 std::cerr << os.str ();
1766 std::ostringstream os;
1767 os << *prefix <<
"Preparing for unpackAndCombine" << endl;
1768 std::cerr << os.str ();
1771 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1772 Teuchos::TimeMonitor unpackAndCombineMon (*unpackAndCombineTimer_);
1773 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1778 imports_.modify_host ();
1779 Teuchos::ArrayView<packet_type> hostImports =
1784 numImportPacketsPerLID_.sync_host ();
1788 Teuchos::ArrayView<size_t> numImportPacketsPerLID =
1792 std::ostringstream os;
1793 os << *prefix <<
"Call unpackAndCombine" << endl;
1794 std::cerr << os.str ();
1796 unpackAndCombine (remoteLIDs, hostImports, numImportPacketsPerLID,
1797 constantNumPackets, distor, CM);
1803 std::ostringstream os;
1804 os << *prefix <<
"Call releaseViews()" << endl;
1805 std::cerr << os.str ();
1807 this->releaseViews ();
1810 std::ostringstream os;
1811 os << *prefix <<
"Done!" << endl;
1812 std::cerr << os.str ();
1815 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1817 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1819 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1820 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1822 #else // TPETRA_ENABLE_DEPRECATED_CODE
1824 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1825 (
const SrcDistObject&,
1827 const Kokkos::DualView<
1829 buffer_device_type>&,
1830 const Kokkos::DualView<
1832 buffer_device_type>&)
1835 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1837 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1838 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1840 #else // TPETRA_ENABLE_DEPRECATED_CODE
1842 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1843 (
const SrcDistObject&,
1844 const Kokkos::DualView<
1846 buffer_device_type>&,
1849 buffer_device_type>&,
1852 buffer_device_type>,
1857 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1859 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1860 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1862 #else // TPETRA_ENABLE_DEPRECATED_CODE
1864 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1865 (
const Kokkos::DualView<
1867 buffer_device_type>& ,
1870 buffer_device_type> ,
1873 buffer_device_type> ,
1879 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1880 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1881 void TPETRA_DEPRECATED
1885 const Teuchos::ArrayView<const local_ordinal_type>& ,
1886 const Teuchos::ArrayView<const local_ordinal_type>& )
1889 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1890 void TPETRA_DEPRECATED
1893 const Teuchos::ArrayView<const local_ordinal_type>& ,
1894 Teuchos::Array<packet_type>& ,
1895 const Teuchos::ArrayView<size_t>& ,
1900 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1901 void TPETRA_DEPRECATED
1904 const Teuchos::ArrayView<const packet_type>& ,
1905 const Teuchos::ArrayView<size_t>& ,
1911 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1912 void TPETRA_DEPRECATED
1913 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1914 createViews ()
const
1917 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1918 void TPETRA_DEPRECATED
1919 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1920 createViewsNonConst (KokkosClassic::ReadWriteOption )
1923 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1924 void TPETRA_DEPRECATED
1925 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1926 releaseViews ()
const
1928 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1930 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1935 using Teuchos::FancyOStream;
1936 using Teuchos::getFancyOStream;
1938 using Teuchos::rcpFromRef;
1941 RCP<FancyOStream> out = getFancyOStream (rcpFromRef (os));
1942 this->describe (*out, Teuchos::VERB_DEFAULT);
1945 template<
class DistObjectType>
1948 const Teuchos::RCP<
const Map<
typename DistObjectType::local_ordinal_type,
1949 typename DistObjectType::global_ordinal_type,
1950 typename DistObjectType::node_type> >& newMap)
1952 input->removeEmptyProcessesInPlace (newMap);
1953 if (newMap.is_null ()) {
1954 input = Teuchos::null;
1958 template<
class DistObjectType>
1962 auto newMap = input->getMap ()->removeEmptyProcesses ();
1963 removeEmptyProcessesInPlace<DistObjectType> (input, newMap);
1967 #define TPETRA_DISTOBJECT_INSTANT(SCALAR, LO, GO, NODE) \
1968 template class DistObject< SCALAR , LO , GO , NODE >;
1972 #define TPETRA_DISTOBJECT_INSTANT_CHAR(LO, GO, NODE) \
1973 template class DistObject< char , LO , GO , NODE >;
1977 #endif // TPETRA_DISTOBJECT_DEF_HPP
void doPostsAndWaits(const Teuchos::ArrayView< const Packet > &exports, size_t numPackets, const Teuchos::ArrayView< Packet > &imports)
Execute the (forward) communication plan.
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
Declaration of Tpetra::Details::Profiling, a scope guard for Kokkos Profiling.
void doImport(const SrcDistObject &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const CombineMode CM, const bool restrictedMode=false)
Import data into this object using an Import object ("forward mode").
virtual void packAndPrepare(const SrcDistObject &source, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Kokkos::DualView< packet_type *, buffer_device_type > &exports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, size_t &constantNumPackets, Distributor &distor)
Pack data and metadata for communication (sends).
virtual void doTransferNew(const SrcDistObject &src, const CombineMode CM, const size_t numSameIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteToLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteFromLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &remoteLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &exportLIDs, Distributor &distor, const ReverseOption revOp, const bool commOnHost, const bool restrictedMode)
Implementation detail of doTransfer.
void print(std::ostream &os) const
Print this object to the given output stream.
virtual bool reallocArraysForNumPacketsPerLid(const size_t numExportLIDs, const size_t numImportLIDs)
Reallocate numExportPacketsPerLID_ and/or numImportPacketsPerLID_, if necessary.
bool isDistributed() const
Whether this is a globally distributed object.
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.
static bool debug()
Whether Tpetra is in debug mode.
int local_ordinal_type
Default value of Scalar template parameter.
virtual void doTransfer(const SrcDistObject &src, const ::Tpetra::Details::Transfer< local_ordinal_type, global_ordinal_type, node_type > &transfer, const char modeString[], const ReverseOption revOp, const CombineMode CM, const bool restrictedMode)
Redistribute data across (MPI) processes.
typename Node::device_type device_type
The Kokkos Device type.
Teuchos_Ordinal Array_size_type
Size type for Teuchos Array objects.
void doReversePostsAndWaits(const Teuchos::ArrayView< const Packet > &exports, size_t numPackets, const Teuchos::ArrayView< Packet > &imports)
Execute the reverse communication plan.
void deep_copy(MultiVector< DS, DL, DG, DN > &dst, const MultiVector< SS, SL, SG, SN > &src)
Copy the contents of the MultiVector src into dst.
Insert new values that don't currently exist.
Kokkos::DualView< T *, DT > getDualViewCopyFromArrayView(const Teuchos::ArrayView< const T > &x_av, const char label[], const bool leaveOnHost)
Get a 1-D Kokkos::DualView which is a deep copy of the input Teuchos::ArrayView (which views host mem...
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.
static bool verbose()
Whether Tpetra is in verbose mode.
CombineMode
Rule for combining data in an Import or Export.
bool reallocDualViewIfNeeded(Kokkos::DualView< ValueType *, DeviceType > &dv, const size_t newSize, const char newLabel[], const size_t tooBigFactor=2, const bool needFenceBeforeRealloc=true)
Reallocate the DualView in/out argument, if needed.
Abstract base class for objects that can be the source of an Import or Export operation.
Declaration and definition of Tpetra::Details::reallocDualViewIfNeeded, an implementation detail of T...
bool reallocImportsIfNeeded(const size_t newSize, const bool verbose, const std::string *prefix)
Reallocate imports_ if needed.
Replace existing values with new values.
LocalOrdinal local_ordinal_type
The type of local indices.
Replace old values with zero.
std::string combineModeToString(const CombineMode combineMode)
Human-readable string representation of the given CombineMode.
ReverseOption
Whether the data transfer should be performed in forward or reverse mode.
DistObject(const Teuchos::RCP< const map_type > &map)
Constructor.
std::string dualViewStatusToString(const DualViewType &dv, const char name[])
Return the status of the given Kokkos::DualView, as a human-readable string.
virtual std::string description() const
One-line descriptiion of this object.
virtual size_t constantNumberOfPackets() const
Whether the implementation's instance promises always to have a constant number of packets per LID (l...
A parallel distribution of indices over processes.
void doExport(const SrcDistObject &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const CombineMode CM, const bool restrictedMode=false)
Export data into this object using an Export object ("forward mode").
Teuchos::ArrayView< typename DualViewType::t_dev::value_type > getArrayViewFromDualView(const DualViewType &x)
Get a Teuchos::ArrayView which views the host Kokkos::View of the input 1-D Kokkos::DualView.
virtual Teuchos::RCP< const map_type > getMap() const
The Map describing the parallel distribution of this object.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print a descriptiion of this object to the given output stream.
Kokkos::Device< typename device_type::execution_space, buffer_memory_space > buffer_device_type
Kokkos::Device specialization for communication buffers.
virtual void copyAndPermute(const SrcDistObject &source, const size_t numSameIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteToLIDs, const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &permuteFromLIDs)
Perform copies and permutations that are local to the calling (MPI) process.
Base class for distributed Tpetra objects that support data redistribution.
virtual void unpackAndCombine(const Kokkos::DualView< const local_ordinal_type *, buffer_device_type > &importLIDs, Kokkos::DualView< packet_type *, buffer_device_type > imports, Kokkos::DualView< size_t *, buffer_device_type > numPacketsPerLID, const size_t constantNumPackets, Distributor &distor, const CombineMode combineMode)
Perform any unpacking and combining after communication.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap)
Remove processes which contain no entries in this object's Map.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.