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 using const_lo_dv_type =
593 Kokkos::DualView<const local_ordinal_type*, buffer_device_type>;
594 const_lo_dv_type permToLIDs = (revOp == DoForward) ?
595 transfer.getPermuteToLIDs_dv () :
596 transfer.getPermuteFromLIDs_dv ();
597 const_lo_dv_type permFromLIDs = (revOp == DoForward) ?
598 transfer.getPermuteFromLIDs_dv () :
599 transfer.getPermuteToLIDs_dv ();
600 const_lo_dv_type remoteLIDs = (revOp == DoForward) ?
601 transfer.getRemoteLIDs_dv () :
602 transfer.getExportLIDs_dv ();
603 const_lo_dv_type exportLIDs = (revOp == DoForward) ?
604 transfer.getExportLIDs_dv () :
605 transfer.getRemoteLIDs_dv ();
606 doTransferNew (src, CM, numSameIDs, permToLIDs, permFromLIDs,
607 remoteLIDs, exportLIDs, distor, revOp, commOnHost,restrictedMode);
610 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
611 if (! useTheNewInterface) {
613 std::ostringstream os;
614 os << *prefix <<
"doTransfer: Use old interface" << endl;
615 std::cerr << os.str ();
617 const auto permToLIDs = (revOp == DoForward) ?
618 transfer.getPermuteToLIDs () : transfer.getPermuteFromLIDs ();
619 const auto permFromLIDs = (revOp == DoForward) ?
620 transfer.getPermuteFromLIDs () : transfer.getPermuteToLIDs ();
621 const auto exportLIDs = (revOp == DoForward) ?
622 transfer.getExportLIDs () : transfer.getRemoteLIDs ();
623 const auto remoteLIDs = (revOp == DoForward) ?
624 transfer.getRemoteLIDs () : transfer.getExportLIDs ();
625 doTransferOld (src, CM, numSameIDs, permToLIDs, permFromLIDs,
626 remoteLIDs, exportLIDs, distor, revOp, restrictedMode);
628 #endif // TPETRA_ENABLE_DEPRECATED_CODE
631 std::ostringstream os;
632 os << *prefix <<
"Tpetra::DistObject::doTransfer: Done!" << endl;
633 std::cerr << os.str ();
637 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
642 const std::string* prefix)
645 std::ostringstream os;
646 os << *prefix <<
"Realloc (if needed) imports_ from "
647 << imports_.extent (0) <<
" to " << newSize << std::endl;
648 std::cerr << os.str ();
651 const bool reallocated =
654 std::ostringstream os;
655 os << *prefix <<
"Finished realloc'ing imports_" << std::endl;
656 std::cerr << os.str ();
661 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
665 const size_t numImportLIDs)
674 constexpr
size_t tooBigFactor = 10;
677 std::unique_ptr<std::string> prefix;
679 const int myRank = [&] () {
680 auto map = this->getMap ();
681 if (map.get () ==
nullptr) {
684 auto comm = map->getComm ();
685 if (comm.get () ==
nullptr) {
688 return comm->getRank ();
690 std::ostringstream os;
691 os <<
"Proc " << myRank <<
": reallocArraysForNumPacketsPerLid("
692 << numExportLIDs <<
", " << numImportLIDs <<
"): ";
693 prefix = std::unique_ptr<std::string> (
new std::string (os.str ()));
697 std::ostringstream os;
698 os << *prefix <<
"before:" << endl
700 "numExportPacketsPerLID_")
703 "numImportPacketsPerLID_")
705 std::cerr << os.str ();
709 const bool firstReallocated =
712 "numExportPacketsPerLID",
719 const bool needFenceBeforeNextAlloc = ! firstReallocated;
720 const bool secondReallocated =
723 "numImportPacketsPerLID",
725 needFenceBeforeNextAlloc);
728 std::ostringstream os;
729 os << *prefix <<
"after:" << endl
731 "numExportPacketsPerLID_")
734 "numImportPacketsPerLID_")
736 std::cerr << os.str ();
739 return firstReallocated || secondReallocated;
742 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
747 const size_t numSameIDs,
758 const bool commOnHost,
759 const bool restrictedMode)
763 using ::Tpetra::Details::ProfilingRegion;
764 using Kokkos::Compat::getArrayView;
765 using Kokkos::Compat::getConstArrayView;
766 using Kokkos::Compat::getKokkosViewDeepCopy;
767 using Kokkos::Compat::create_const_view;
770 using DES =
typename DT::execution_space;
772 ProfilingRegion region_dTN (
"Tpetra::DistObject::doTransferNew");
773 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
776 Teuchos::TimeMonitor doXferMon (*doXferTimer_);
777 #endif // HAVE_TPETRA_TRANSFER_TIMERS
782 std::unique_ptr<std::string> prefix;
784 auto map = this->getMap ();
785 auto comm = map.is_null () ? Teuchos::null : map->getComm ();
786 const int myRank = comm.is_null () ? 0 : comm->getRank ();
787 std::ostringstream os;
788 os <<
"Proc " << myRank <<
": Tpetra::CrsMatrix::doTransferNew: ";
789 prefix = std::unique_ptr<std::string> (
new std::string (os.str ()));
793 std::ostringstream os;
794 os << *prefix <<
"Input arguments:" << endl
796 << *prefix <<
" numSameIDs: " << numSameIDs << endl
805 << *prefix <<
" revOp: Do" << (revOp == DoReverse ?
"Reverse" :
"Forward") << endl
806 << *prefix <<
" commOnHost: " << (commOnHost ?
"true" :
"false") << endl;
807 std::cerr << os.str ();
811 ProfilingRegion region_cs (
"Tpetra::DistObject::doTransferNew::checkSizes");
813 std::ostringstream os;
814 os << *prefix <<
"1. checkSizes" << endl;
815 std::cerr << os.str ();
817 const bool checkSizesResult = this->checkSizes (src);
818 TEUCHOS_TEST_FOR_EXCEPTION
819 (! checkSizesResult, std::invalid_argument,
820 "Tpetra::DistObject::doTransfer: checkSizes() indicates that the "
821 "destination object is not a legal target for redistribution from the "
822 "source object. This probably means that they do not have the same "
823 "dimensions. For example, MultiVectors must have the same number of "
824 "rows and columns.");
831 if (!restrictedMode && numSameIDs + permuteToLIDs.extent (0) != 0) {
834 std::ostringstream os;
835 os << *prefix <<
"2. copyAndPermute" << endl;
836 std::cerr << os.str ();
838 ProfilingRegion region_cp
839 (
"Tpetra::DistObject::doTransferNew::copyAndPermute");
840 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
843 Teuchos::TimeMonitor copyAndPermuteMon (*copyAndPermuteTimer_);
844 #endif // HAVE_TPETRA_TRANSFER_TIMERS
846 if (numSameIDs + permuteToLIDs.extent (0) != 0) {
849 std::ostringstream os;
850 os << *prefix <<
"2. copyAndPermute" << endl;
851 std::cerr << os.str ();
853 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
854 this->copyAndPermuteNew (src, numSameIDs, permuteToLIDs,
856 #else // TPETRA_ENABLE_DEPRECATED_CODE
857 this->copyAndPermute (src, numSameIDs, permuteToLIDs,
859 #endif // TPETRA_ENABLE_DEPRECATED_CODE
861 std::ostringstream os;
862 os << *prefix <<
"After copyAndPermute:" << endl
869 std::cerr << os.str ();
882 size_t constantNumPackets = this->constantNumberOfPackets ();
884 std::ostringstream os;
885 os << *prefix <<
"constantNumPackets=" << constantNumPackets << endl;
886 std::cerr << os.str ();
894 if (constantNumPackets == 0) {
896 std::ostringstream os;
897 os << *prefix <<
"3. (Re)allocate num{Ex,Im}portPacketsPerLID"
899 std::cerr << os.str ();
903 this->reallocArraysForNumPacketsPerLid (exportLIDs.extent (0),
904 remoteLIDs.extent (0));
908 std::ostringstream os;
909 os << *prefix <<
"4. packAndPrepare: before, "
912 std::cerr << os.str ();
915 ProfilingRegion region_pp
916 (
"Tpetra::DistObject::doTransferNew::packAndPrepare");
917 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
920 Teuchos::TimeMonitor packAndPrepareMon (*packAndPrepareTimer_);
921 #endif // HAVE_TPETRA_TRANSFER_TIMERS
939 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
940 this->packAndPrepareNew (src, exportLIDs, this->exports_,
941 this->numExportPacketsPerLID_,
942 constantNumPackets, distor);
943 #else // TPETRA_ENABLE_DEPRECATED_CODE
944 this->packAndPrepare (src, exportLIDs, this->exports_,
945 this->numExportPacketsPerLID_,
946 constantNumPackets, distor);
947 #endif // TPETRA_ENABLE_DEPRECATED_CODE
949 if (this->exports_.need_sync_host ()) {
950 this->exports_.sync_host ();
954 if (this->exports_.need_sync_device ()) {
955 this->exports_.sync_device ();
960 std::ostringstream os;
961 os << *prefix <<
"5.1. After packAndPrepare, "
964 std::cerr << os.str ();
970 if (constantNumPackets != 0) {
975 const size_t rbufLen = remoteLIDs.extent (0) * constantNumPackets;
976 reallocImportsIfNeeded (rbufLen, verbose, prefix.get ());
980 bool needCommunication =
true;
985 if (revOp == DoReverse && ! this->isDistributed ()) {
986 needCommunication =
false;
995 else if (revOp == DoForward && srcDistObj != NULL &&
997 needCommunication =
false;
1000 if (! needCommunication) {
1002 std::ostringstream os;
1003 os << *prefix <<
"Comm not needed; skipping" << endl;
1004 std::cerr << os.str ();
1008 ProfilingRegion region_dpw
1009 (
"Tpetra::DistObject::doTransferNew::doPostsAndWaits");
1010 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1013 Teuchos::TimeMonitor doPostsAndWaitsMon (*doPostsAndWaitsTimer_);
1014 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1017 std::ostringstream os;
1018 os << *prefix <<
"7.0. "
1019 << (revOp == DoReverse ?
"Reverse" :
"Forward")
1021 std::cerr << os.str ();
1024 if (constantNumPackets == 0) {
1026 std::ostringstream os;
1027 os << *prefix <<
"7.1. Variable # packets / LID: first comm "
1028 <<
"(commOnHost = " << (commOnHost ?
"true" :
"false") <<
")"
1030 std::cerr << os.str ();
1032 size_t totalImportPackets = 0;
1034 if (this->numExportPacketsPerLID_.need_sync_host ()) {
1035 this->numExportPacketsPerLID_.sync_host ();
1037 if (this->numImportPacketsPerLID_.need_sync_host ()) {
1038 this->numImportPacketsPerLID_.sync_host ();
1040 this->numImportPacketsPerLID_.modify_host ();
1042 create_const_view (this->numExportPacketsPerLID_.view_host ());
1043 auto numImp_h = this->numImportPacketsPerLID_.view_host ();
1047 std::ostringstream os;
1048 os << *prefix <<
"Call do"
1049 << (revOp == DoReverse ?
"Reverse" :
"") <<
"PostsAndWaits"
1051 std::cerr << os.str ();
1053 if (revOp == DoReverse) {
1062 std::ostringstream os;
1063 os << *prefix <<
"Count totalImportPackets" << std::endl;
1064 std::cerr << os.str ();
1066 using the_dev_type =
typename decltype (numImp_h)::
device_type;
1067 totalImportPackets = countTotalImportPackets<the_dev_type> (numImp_h);
1070 if (this->numExportPacketsPerLID_.need_sync_device ()) {
1071 this->numExportPacketsPerLID_.sync_device ();
1073 if (this->numImportPacketsPerLID_.need_sync_device ()) {
1074 this->numImportPacketsPerLID_.sync_device ();
1076 this->numImportPacketsPerLID_.modify_device ();
1077 auto numExp_d = create_const_view
1078 (this->numExportPacketsPerLID_.view_device ());
1079 auto numImp_d = this->numImportPacketsPerLID_.view_device ();
1083 std::ostringstream os;
1084 os << *prefix <<
"Call do"
1085 << (revOp == DoReverse ?
"Reverse" :
"") <<
"PostsAndWaits"
1087 std::cerr << os.str ();
1089 if (revOp == DoReverse) {
1098 std::ostringstream os;
1099 os << *prefix <<
"Count totalImportPackets" << std::endl;
1100 std::cerr << os.str ();
1102 using the_dev_type =
typename decltype (numImp_d)::
device_type;
1103 totalImportPackets = countTotalImportPackets<the_dev_type> (numImp_d);
1107 std::ostringstream os;
1108 os << *prefix <<
"totalImportPackets=" << totalImportPackets << endl;
1109 std::cerr << os.str ();
1111 this->reallocImportsIfNeeded (totalImportPackets, verbose,
1114 std::ostringstream os;
1115 os << *prefix <<
"7.3. Second comm" << std::endl;
1116 std::cerr << os.str ();
1122 if (this->numExportPacketsPerLID_.need_sync_host ()) {
1123 this->numExportPacketsPerLID_.sync_host ();
1125 if (this->numImportPacketsPerLID_.need_sync_host ()) {
1126 this->numImportPacketsPerLID_.sync_host ();
1136 auto numExportPacketsPerLID_av =
1138 auto numImportPacketsPerLID_av =
1146 this->imports_.clear_sync_state ();
1149 std::ostringstream os;
1150 os << *prefix <<
"Comm on "
1151 << (commOnHost ?
"host" :
"device")
1152 <<
"; call do" << (revOp == DoReverse ?
"Reverse" :
"")
1153 <<
"PostsAndWaits" << endl;
1154 std::cerr << os.str ();
1158 this->imports_.modify_host ();
1159 if (revOp == DoReverse) {
1161 (create_const_view (this->exports_.view_host ()),
1162 numExportPacketsPerLID_av,
1163 this->imports_.view_host (),
1164 numImportPacketsPerLID_av);
1168 (create_const_view (this->exports_.view_host ()),
1169 numExportPacketsPerLID_av,
1170 this->imports_.view_host (),
1171 numImportPacketsPerLID_av);
1175 this->imports_.modify_device ();
1176 if (revOp == DoReverse) {
1178 (create_const_view (this->exports_.view_device ()),
1179 numExportPacketsPerLID_av,
1180 this->imports_.view_device (),
1181 numImportPacketsPerLID_av);
1185 (create_const_view (this->exports_.view_device ()),
1186 numExportPacketsPerLID_av,
1187 this->imports_.view_device (),
1188 numImportPacketsPerLID_av);
1194 std::ostringstream os;
1195 os << *prefix <<
"7.1. Const # packets per LID: " << endl
1202 std::cerr << os.str ();
1209 this->imports_.clear_sync_state ();
1212 std::ostringstream os;
1213 os << *prefix <<
"7.2. Comm on "
1214 << (commOnHost ?
"host" :
"device")
1215 <<
"; call do" << (revOp == DoReverse ?
"Reverse" :
"")
1216 <<
"PostsAndWaits" << endl;
1217 std::cerr << os.str ();
1220 this->imports_.modify_host ();
1221 if (revOp == DoReverse) {
1223 (create_const_view (this->exports_.view_host ()),
1225 this->imports_.view_host ());
1229 (create_const_view (this->exports_.view_host ()),
1231 this->imports_.view_host ());
1235 this->imports_.modify_device ();
1236 if (revOp == DoReverse) {
1238 (create_const_view (this->exports_.view_device ()),
1240 this->imports_.view_device ());
1244 (create_const_view (this->exports_.view_device ()),
1246 this->imports_.view_device ());
1252 std::ostringstream os;
1253 os << *prefix <<
"8. unpackAndCombine" << endl;
1254 std::cerr << os.str ();
1256 ProfilingRegion region_uc
1257 (
"Tpetra::DistObject::doTransferNew::unpackAndCombine");
1258 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1261 Teuchos::TimeMonitor unpackAndCombineMon (*unpackAndCombineTimer_);
1262 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1271 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1272 this->unpackAndCombineNew (remoteLIDs, this->imports_,
1273 this->numImportPacketsPerLID_,
1274 constantNumPackets, distor, CM);
1275 #else // TPETRA_ENABLE_DEPRECATED_CODE
1276 this->unpackAndCombine (remoteLIDs, this->imports_,
1277 this->numImportPacketsPerLID_,
1278 constantNumPackets, distor, CM);
1279 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1284 std::ostringstream os;
1285 os << *prefix <<
"9. Done!" << endl;
1286 std::cerr << os.str ();
1290 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1291 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1292 void TPETRA_DEPRECATED
1297 const Teuchos::ArrayView<const LocalOrdinal>& permuteToLIDs,
1298 const Teuchos::ArrayView<const LocalOrdinal>& permuteFromLIDs,
1299 const Teuchos::ArrayView<const LocalOrdinal>& remoteLIDs,
1300 const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
1302 ReverseOption revOp,
1303 const bool restrictedMode)
1306 using ::Tpetra::Details::ProfilingRegion;
1309 const char prefixRaw[] =
"Tpetra::DistObject::doTransferOld: ";
1311 ProfilingRegion region_doTransferOld (
"Tpetra::DistObject::doTransferOld");
1312 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1315 Teuchos::TimeMonitor doXferMon (*doXferTimer_);
1316 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1319 std::unique_ptr<std::string> prefix;
1321 auto map = this->getMap ();
1322 auto comm = map.is_null () ? Teuchos::null : map->getComm ();
1323 const int myRank = comm.is_null () ? -1 : comm->getRank ();
1324 std::ostringstream os;
1325 os <<
"Proc " << myRank <<
": " << prefixRaw;
1326 prefix = std::unique_ptr<std::string> (
new std::string (os.str ()));
1329 TEUCHOS_TEST_FOR_EXCEPTION(
1330 ! checkSizes (src), std::invalid_argument,
1331 prefixRaw <<
"checkSizes() indicates that the "
1332 "destination object is not a legal target for redistribution from the "
1333 "source object. This probably means that they do not have the same "
1334 "dimensions. For example, MultiVectors must have the same number of "
1335 "rows and columns.");
1336 KokkosClassic::ReadWriteOption rwo = KokkosClassic::ReadWrite;
1338 const size_t numIDsToWrite = numSameIDs +
1339 static_cast<size_t> (permuteToLIDs.size ()) +
1340 static_cast<size_t> (remoteLIDs.size ());
1341 if (numIDsToWrite == this->getMap ()->getNodeNumElements ()) {
1349 rwo = KokkosClassic::WriteOnly;
1354 std::ostringstream os;
1355 os << *prefix <<
"ReadWriteOption: ";
1356 if (rwo == KokkosClassic::ReadWrite) {
1359 else if (rwo == KokkosClassic::WriteOnly) {
1363 os <<
"Something else; weird!";
1366 std::cerr << os.str ();
1377 const this_type* srcDistObj =
dynamic_cast<const this_type*
> (&src);
1378 if (srcDistObj != NULL) {
1380 std::ostringstream os;
1381 os << *prefix <<
"Call srcDistObject->createViews()" << endl;
1382 std::cerr << os.str ();
1384 srcDistObj->createViews ();
1388 std::ostringstream os;
1389 os << *prefix <<
"Source object has a different type than target object"
1391 std::cerr << os.str ();
1408 std::ostringstream os;
1409 os << *prefix <<
"Call createViewsNonConst" << endl;
1410 std::cerr << os.str ();
1412 this->createViewsNonConst (rwo);
1414 if (!restrictedMode && numSameIDs + permuteToLIDs.size()) {
1415 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1416 Teuchos::TimeMonitor copyAndPermuteMon (*copyAndPermuteTimer_);
1417 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1419 std::ostringstream os;
1420 os << *prefix <<
"Call copyAndPermute" << endl;
1421 std::cerr << os.str ();
1424 copyAndPermute (src, numSameIDs, permuteToLIDs, permuteFromLIDs);
1428 std::ostringstream os;
1429 os << *prefix <<
"Skipping copyAndPermute" << endl;
1430 std::cerr << os.str ();
1442 size_t constantNumPackets = this->constantNumberOfPackets ();
1444 std::ostringstream os;
1445 os << *prefix <<
"constantNumPackets=" << constantNumPackets << endl;
1446 std::cerr << os.str ();
1454 if (constantNumPackets == 0) {
1455 this->reallocArraysForNumPacketsPerLid (exportLIDs.size (),
1456 remoteLIDs.size ());
1460 std::ostringstream os;
1461 os << *prefix <<
"Preparing for packAndPrepare" << endl;
1462 std::cerr << os.str ();
1465 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1466 Teuchos::TimeMonitor packAndPrepareMon (*packAndPrepareTimer_);
1467 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1473 numExportPacketsPerLID_.modify_host ();
1474 Teuchos::ArrayView<size_t> numExportPacketsPerLID =
1482 Teuchos::Array<packet_type> exportsOld;
1484 std::ostringstream os;
1485 os << *prefix <<
"Call packAndPrepare" << endl;
1486 std::cerr << os.str ();
1488 packAndPrepare (src, exportLIDs, exportsOld, numExportPacketsPerLID,
1489 constantNumPackets, distor);
1490 const size_t exportsLen =
static_cast<size_t> (exportsOld.size ());
1492 Kokkos::View<
const packet_type*, Kokkos::HostSpace,
1493 Kokkos::MemoryUnmanaged> exportsOldK (exportsOld.getRawPtr (),
1495 exports_.modify_host ();
1505 if (srcDistObj !=
nullptr) {
1507 std::ostringstream os;
1508 os << *prefix <<
"Call srcDistObj->releaseViews()" << endl;
1509 std::cerr << os.str ();
1511 srcDistObj->releaseViews ();
1515 std::ostringstream os;
1516 os << *prefix <<
"Skipping srcDistObj->releaseViews()" << endl;
1517 std::cerr << os.str ();
1523 if (constantNumPackets != 0) {
1528 const size_t rbufLen = remoteLIDs.size() * constantNumPackets;
1530 std::ostringstream os;
1531 os << *prefix <<
"Const # packets: imports_.extent(0)="
1532 << imports_.extent (0) <<
", ; calling reallocImportsIfNeeded("
1533 "rbufLen=" << rbufLen <<
", verbose=true)" << endl;
1534 std::cerr << os.str ();
1536 reallocImportsIfNeeded (rbufLen, verbose, prefix.get ());
1540 bool needCommunication =
true;
1541 if (revOp == DoReverse && ! isDistributed ()) {
1542 needCommunication =
false;
1551 else if (revOp == DoForward && srcDistObj != NULL &&
1552 ! srcDistObj->isDistributed ()) {
1553 needCommunication =
false;
1557 std::ostringstream os;
1558 os << *prefix <<
"needCommunication="
1559 << (needCommunication ?
"true" :
"false")
1561 << (revOp == DoReverse ?
"DoReverse" :
"DoForward") << endl;
1562 std::cerr << os.str ();
1565 if (needCommunication) {
1566 if (revOp == DoReverse) {
1567 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1568 Teuchos::TimeMonitor doPostsAndWaitsMon (*doPostsAndWaitsTimer_);
1569 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1570 if (constantNumPackets == 0) {
1576 numExportPacketsPerLID_.sync_host ();
1577 Teuchos::ArrayView<const size_t> numExportPacketsPerLID =
1584 numImportPacketsPerLID_.modify_host ();
1585 Teuchos::ArrayView<size_t> numImportPacketsPerLID =
1589 std::ostringstream os;
1590 os << *prefix <<
"Call doReversePostsAndWaits (3-arg)" << endl;
1591 std::cerr << os.str ();
1594 numImportPacketsPerLID);
1597 std::ostringstream os;
1598 os << *prefix <<
"Compute totalImportPackets" << endl;
1599 std::cerr << os.str ();
1601 size_t totalImportPackets = 0;
1603 typedef typename Kokkos::DualView<
size_t*,
1604 device_type>::t_host::execution_space host_exec_space;
1605 typedef Kokkos::RangePolicy<host_exec_space, Array_size_type> range_type;
1606 const size_t*
const arrayToSum = numImportPacketsPerLID.getRawPtr ();
1607 Kokkos::parallel_reduce (
"Count import packets",
1608 range_type (0, numImportPacketsPerLID.size ()),
1610 lclSum += arrayToSum[i];
1611 }, totalImportPackets);
1615 std::ostringstream os;
1616 os << *prefix <<
"totalImportPackets=" << totalImportPackets
1617 <<
"; calling reallocImportsIfNeeded" << endl;
1618 std::cerr << os.str ();
1620 reallocImportsIfNeeded (totalImportPackets, verbose, prefix.get ());
1626 imports_.modify_host ();
1627 Teuchos::ArrayView<packet_type> hostImports =
1629 exports_.sync_host ();
1630 Teuchos::ArrayView<const packet_type> hostExports =
1634 std::ostringstream os;
1635 os << *prefix <<
"Call doReversePostsAndWaits (4-arg)"
1637 std::cerr << os.str ();
1640 numExportPacketsPerLID,
1642 numImportPacketsPerLID);
1649 imports_.modify_host ();
1650 Teuchos::ArrayView<packet_type> hostImports =
1652 exports_.sync_host ();
1653 Teuchos::ArrayView<const packet_type> hostExports =
1657 std::ostringstream os;
1658 os << *prefix <<
"Call doReversePostsAndWaits (3-arg)"
1660 std::cerr << os.str ();
1668 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1669 Teuchos::TimeMonitor doPostsAndWaitsMon (*doPostsAndWaitsTimer_);
1670 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1671 if (constantNumPackets == 0) {
1677 numExportPacketsPerLID_.sync_host ();
1678 Teuchos::ArrayView<const size_t> numExportPacketsPerLID =
1685 numImportPacketsPerLID_.modify_host ();
1686 Teuchos::ArrayView<size_t> numImportPacketsPerLID =
1690 std::ostringstream os;
1691 os << *prefix <<
"Call doPostsAndWaits (3-arg)" << endl;
1692 std::cerr << os.str ();
1695 numImportPacketsPerLID);
1698 std::ostringstream os;
1699 os << *prefix <<
"Compute totalImportPackets" << endl;
1700 std::cerr << os.str ();
1702 size_t totalImportPackets = 0;
1704 typedef typename Kokkos::DualView<
size_t*,
1705 device_type>::t_host::execution_space host_exec_space;
1706 typedef Kokkos::RangePolicy<host_exec_space, Array_size_type> range_type;
1707 const size_t*
const arrayToSum = numImportPacketsPerLID.getRawPtr ();
1708 Kokkos::parallel_reduce (
"Count import packets",
1709 range_type (0, numImportPacketsPerLID.size ()),
1711 lclSum += arrayToSum[i];
1712 }, totalImportPackets);
1716 std::ostringstream os;
1717 os << *prefix <<
"totalImportPackets=" << totalImportPackets
1718 <<
"; calling reallocImportsIfNeeded" << endl;
1719 std::cerr << os.str ();
1721 reallocImportsIfNeeded (totalImportPackets, verbose, prefix.get ());
1727 imports_.modify_host ();
1728 Teuchos::ArrayView<packet_type> hostImports =
1730 exports_.sync_host ();
1731 Teuchos::ArrayView<const packet_type> hostExports =
1735 std::ostringstream os;
1736 os << *prefix <<
"Call doPostsAndWaits (4-arg)" << endl;
1737 std::cerr << os.str ();
1740 numExportPacketsPerLID,
1742 numImportPacketsPerLID);
1749 imports_.modify_host ();
1750 Teuchos::ArrayView<packet_type> hostImports =
1752 exports_.sync_host ();
1753 Teuchos::ArrayView<const packet_type> hostExports =
1757 std::ostringstream os;
1758 os << *prefix <<
"Call doPostsAndWaits (3-arg)" << endl;
1759 std::cerr << os.str ();
1768 std::ostringstream os;
1769 os << *prefix <<
"Preparing for unpackAndCombine" << endl;
1770 std::cerr << os.str ();
1773 #ifdef HAVE_TPETRA_TRANSFER_TIMERS
1774 Teuchos::TimeMonitor unpackAndCombineMon (*unpackAndCombineTimer_);
1775 #endif // HAVE_TPETRA_TRANSFER_TIMERS
1780 imports_.modify_host ();
1781 Teuchos::ArrayView<packet_type> hostImports =
1786 numImportPacketsPerLID_.sync_host ();
1790 Teuchos::ArrayView<size_t> numImportPacketsPerLID =
1794 std::ostringstream os;
1795 os << *prefix <<
"Call unpackAndCombine" << endl;
1796 std::cerr << os.str ();
1798 unpackAndCombine (remoteLIDs, hostImports, numImportPacketsPerLID,
1799 constantNumPackets, distor, CM);
1805 std::ostringstream os;
1806 os << *prefix <<
"Call releaseViews()" << endl;
1807 std::cerr << os.str ();
1809 this->releaseViews ();
1812 std::ostringstream os;
1813 os << *prefix <<
"Done!" << endl;
1814 std::cerr << os.str ();
1817 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1819 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1821 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1822 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1824 #else // TPETRA_ENABLE_DEPRECATED_CODE
1826 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1827 (
const SrcDistObject&,
1829 const Kokkos::DualView<
1831 buffer_device_type>&,
1832 const Kokkos::DualView<
1834 buffer_device_type>&)
1837 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1839 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1840 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1842 #else // TPETRA_ENABLE_DEPRECATED_CODE
1844 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1845 (
const SrcDistObject&,
1846 const Kokkos::DualView<
1848 buffer_device_type>&,
1851 buffer_device_type>&,
1854 buffer_device_type>,
1859 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1861 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1862 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1864 #else // TPETRA_ENABLE_DEPRECATED_CODE
1866 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1867 (
const Kokkos::DualView<
1869 buffer_device_type>& ,
1872 buffer_device_type> ,
1875 buffer_device_type> ,
1881 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1882 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1883 void TPETRA_DEPRECATED
1887 const Teuchos::ArrayView<const local_ordinal_type>& ,
1888 const Teuchos::ArrayView<const local_ordinal_type>& )
1891 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1892 void TPETRA_DEPRECATED
1895 const Teuchos::ArrayView<const local_ordinal_type>& ,
1896 Teuchos::Array<packet_type>& ,
1897 const Teuchos::ArrayView<size_t>& ,
1902 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1903 void TPETRA_DEPRECATED
1906 const Teuchos::ArrayView<const packet_type>& ,
1907 const Teuchos::ArrayView<size_t>& ,
1913 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1914 void TPETRA_DEPRECATED
1915 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1916 createViews ()
const
1919 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1920 void TPETRA_DEPRECATED
1921 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1922 createViewsNonConst (KokkosClassic::ReadWriteOption )
1925 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1926 void TPETRA_DEPRECATED
1927 DistObject<Packet, LocalOrdinal, GlobalOrdinal, Node>::
1928 releaseViews ()
const
1930 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1932 template <
class Packet,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
1937 using Teuchos::FancyOStream;
1938 using Teuchos::getFancyOStream;
1940 using Teuchos::rcpFromRef;
1943 RCP<FancyOStream> out = getFancyOStream (rcpFromRef (os));
1944 this->describe (*out, Teuchos::VERB_DEFAULT);
1947 template<
class DistObjectType>
1950 const Teuchos::RCP<
const Map<
typename DistObjectType::local_ordinal_type,
1951 typename DistObjectType::global_ordinal_type,
1952 typename DistObjectType::node_type> >& newMap)
1954 input->removeEmptyProcessesInPlace (newMap);
1955 if (newMap.is_null ()) {
1956 input = Teuchos::null;
1960 template<
class DistObjectType>
1964 auto newMap = input->getMap ()->removeEmptyProcesses ();
1965 removeEmptyProcessesInPlace<DistObjectType> (input, newMap);
1969 #define TPETRA_DISTOBJECT_INSTANT(SCALAR, LO, GO, NODE) \
1970 template class DistObject< SCALAR , LO , GO , NODE >;
1974 #define TPETRA_DISTOBJECT_INSTANT_CHAR(LO, GO, NODE) \
1975 template class DistObject< char , LO , GO , NODE >;
1979 #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.
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.
int local_ordinal_type
Default value of Scalar template parameter.
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.