Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_Distributor.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TPETRA_DISTRIBUTOR_HPP
11 #define TPETRA_DISTRIBUTOR_HPP
12 
13 #include "Tpetra_Details_DistributorActor.hpp"
15 
16 #include "Tpetra_Util.hpp"
17 #include "Teuchos_as.hpp"
18 #include "Teuchos_Describable.hpp"
19 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
20 #include "Teuchos_VerboseObject.hpp"
22 
23 #include "KokkosCompat_View.hpp"
24 #include "Kokkos_Core.hpp"
25 #include "Kokkos_TeuchosCommAdapters.hpp"
26 #include "Kokkos_StdAlgorithms.hpp"
27 #include <memory>
28 #include <sstream>
29 #include <type_traits>
30 
31 namespace Tpetra {
32 
39  Teuchos::Array<std::string> distributorSendTypes ();
40 
103  class Distributor :
104  public Teuchos::Describable,
105  public Teuchos::ParameterListAcceptorDefaultBase {
106  public:
108 
109 
118  explicit Distributor (const Teuchos::RCP<const Teuchos::Comm<int> >& comm);
119 
131  Distributor (const Teuchos::RCP<const Teuchos::Comm<int> >& comm,
132  const Teuchos::RCP<Teuchos::FancyOStream>& out);
133 
147  Distributor (const Teuchos::RCP<const Teuchos::Comm<int> >& comm,
148  const Teuchos::RCP<Teuchos::ParameterList>& plist);
149 
166  Distributor (const Teuchos::RCP<const Teuchos::Comm<int> >& comm,
167  const Teuchos::RCP<Teuchos::FancyOStream>& out,
168  const Teuchos::RCP<Teuchos::ParameterList>& plist);
169 
171  Distributor (const Distributor& distributor);
172 
177  virtual ~Distributor () = default;
178 
184  void swap (Distributor& rhs);
185 
187 
189 
194  void setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& plist);
195 
200  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters () const;
201 
203 
205 
225  size_t createFromSends (const Teuchos::ArrayView<const int>& exportProcIDs);
226 
260  template <class Ordinal>
261  void
262  createFromRecvs (const Teuchos::ArrayView<const Ordinal>& remoteIDs,
263  const Teuchos::ArrayView<const int>& remoteProcIDs,
264  Teuchos::Array<Ordinal>& exportIDs,
265  Teuchos::Array<int>& exportProcIDs);
266 
274  void
275  createFromSendsAndRecvs (const Teuchos::ArrayView<const int>& exportProcIDs,
276  const Teuchos::ArrayView<const int>& remoteProcIDs);
277 
279 
281 
285  size_t getNumReceives() const;
286 
290  size_t getNumSends() const;
291 
293  bool hasSelfMessage() const;
294 
296  size_t getMaxSendLength() const;
297 
299  size_t getTotalReceiveLength() const;
300 
305  Teuchos::ArrayView<const int> getProcsFrom() const;
306 
311  Teuchos::ArrayView<const int> getProcsTo() const;
312 
320  Teuchos::ArrayView<const size_t> getLengthsFrom() const;
321 
329  Teuchos::ArrayView<const size_t> getLengthsTo() const;
330 
336  return plan_.howInitialized();
337  }
338 
340 
342 
353  Teuchos::RCP<Distributor> getReverse(bool create=true) const;
354 
356 
358 
365  void doWaits ();
366 
373  void doReverseWaits ();
374 
395  template <class ExpView, class ImpView>
396  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
398  const ExpView &exports,
399  size_t numPackets,
400  const ImpView &imports);
401 
423  template <class ExpView, class ImpView>
424  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
425  doPostsAndWaits (const ExpView &exports,
426  const Teuchos::ArrayView<const size_t>& numExportPacketsPerLID,
427  const ImpView &imports,
428  const Teuchos::ArrayView<const size_t>& numImportPacketsPerLID);
429 
430  template <class ExpView, class ExpPacketsView, class ImpView, class ImpPacketsView>
431  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
432  doPostsAndWaitsKokkos (const ExpView &exports,
433  const ExpPacketsView &numExportPacketsPerLID,
434  const ImpView &imports,
435  const ImpPacketsView &numImportPacketsPerLID);
436 
461  template <class ExpView, class ImpView>
462  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
463  doPosts (const ExpView &exports,
464  size_t numPackets,
465  const ImpView &imports);
466 
485  template <class ExpView, class ImpView>
486  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
487  doPosts (const ExpView &exports,
488  const Teuchos::ArrayView<const size_t>& numExportPacketsPerLID,
489  const ImpView &imports,
490  const Teuchos::ArrayView<const size_t>& numImportPacketsPerLID);
491 
492  template <class ExpView, class ExpPacketsView, class ImpView, class ImpPacketsView>
493  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
494  doPostsKokkos (const ExpView &exports,
495  const ExpPacketsView &numExportPacketsPerLID,
496  const ImpView &imports,
497  const ImpPacketsView &numImportPacketsPerLID);
498 
503  template <class ExpView, class ImpView>
504  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
505  doReversePostsAndWaits (const ExpView &exports,
506  size_t numPackets,
507  const ImpView &imports);
508 
513  template <class ExpView, class ImpView>
514  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
515  doReversePostsAndWaits (const ExpView &exports,
516  const Teuchos::ArrayView<const size_t>& numExportPacketsPerLID,
517  const ImpView &imports,
518  const Teuchos::ArrayView<const size_t>& numImportPacketsPerLID);
519 
520  template <class ExpView, class ExpPacketsView, class ImpView, class ImpPacketsView>
521  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
522  doReversePostsAndWaitsKokkos (const ExpView &exports,
523  const ExpPacketsView &numExportPacketsPerLID,
524  const ImpView &imports,
525  const ImpPacketsView &numImportPacketsPerLID);
526 
531  template <class ExpView, class ImpView>
532  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
533  doReversePosts (const ExpView &exports,
534  size_t numPackets,
535  const ImpView &imports);
536 
541  template <class ExpView, class ImpView>
542  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
543  doReversePosts (const ExpView &exports,
544  const Teuchos::ArrayView<const size_t>& numExportPacketsPerLID,
545  const ImpView &imports,
546  const Teuchos::ArrayView<const size_t>& numImportPacketsPerLID);
547 
548  template <class ExpView, class ExpPacketsView, class ImpView, class ImpPacketsView>
549  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
550  doReversePostsKokkos (const ExpView &exports,
551  const ExpPacketsView &numExportPacketsPerLID,
552  const ImpView &imports,
553  const ImpPacketsView &numImportPacketsPerLID);
554 
556 
558 
560  std::string description() const;
561 
583  void
584  describe (Teuchos::FancyOStream& out,
585  const Teuchos::EVerbosityLevel verbLevel =
586  Teuchos::Describable::verbLevel_default) const;
588 
593  const Details::DistributorPlan& getPlan() const { return plan_; }
594  private:
596  Details::DistributorActor actor_;
597 
599 
600 
602  static bool getVerbose();
603 
608  std::unique_ptr<std::string>
609  createPrefix(const char methodName[]) const;
610 
612  bool verbose_ = getVerbose();
614 
619  mutable Teuchos::RCP<Distributor> reverseDistributor_;
620 
633  template <class Ordinal>
634  void computeSends (const Teuchos::ArrayView<const Ordinal> &remoteGIDs,
635  const Teuchos::ArrayView<const int> &remoteProcIDs,
636  Teuchos::Array<Ordinal> &exportGIDs,
637  Teuchos::Array<int> &exportProcIDs);
638 
640  void createReverseDistributor() const;
641 
642 
647  std::string
648  localDescribeToString (const Teuchos::EVerbosityLevel vl) const;
649  }; // class Distributor
650 
651  template <class ExpView, class ImpView>
652  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
653  Distributor::
654  doPostsAndWaits (const ExpView& exports,
655  size_t numPackets,
656  const ImpView& imports)
657  {
658  actor_.doPostsAndWaits(plan_, exports, numPackets, imports);
659  }
660 
661  template <class ExpView, class ImpView>
662  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
663  Distributor::
664  doPostsAndWaits(const ExpView& exports,
665  const Teuchos::ArrayView<const size_t>& numExportPacketsPerLID,
666  const ImpView& imports,
667  const Teuchos::ArrayView<const size_t>& numImportPacketsPerLID)
668  {
669  actor_.doPostsAndWaits(plan_, exports, numExportPacketsPerLID, imports, numImportPacketsPerLID);
670  }
671 
672  template <class ExpView, class ExpPacketsView, class ImpView, class ImpPacketsView>
673  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
674  Distributor::
675  doPostsAndWaitsKokkos (const ExpView &exports,
676  const ExpPacketsView &numExportPacketsPerLID,
677  const ImpView &imports,
678  const ImpPacketsView &numImportPacketsPerLID)
679  {
680  actor_.doPostsAndWaitsKokkos(plan_, exports, numExportPacketsPerLID, imports, numImportPacketsPerLID);
681  }
682 
683  template <class ExpView, class ImpView>
684  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
685  Distributor::
686  doPosts (const ExpView &exports,
687  size_t numPackets,
688  const ImpView &imports)
689  {
690  actor_.doPosts(plan_, exports, numPackets, imports);
691  }
692 
693  template <class ExpView, class ImpView>
694  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
695  Distributor::
696  doPosts (const ExpView &exports,
697  const Teuchos::ArrayView<const size_t>& numExportPacketsPerLID,
698  const ImpView &imports,
699  const Teuchos::ArrayView<const size_t>& numImportPacketsPerLID)
700  {
701  actor_.doPosts(plan_, exports, numExportPacketsPerLID, imports, numImportPacketsPerLID);
702  }
703 
704  template <class ExpView, class ExpPacketsView, class ImpView, class ImpPacketsView>
705  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
706  Distributor::
707  doPostsKokkos (const ExpView &exports,
708  const ExpPacketsView &numExportPacketsPerLID,
709  const ImpView &imports,
710  const ImpPacketsView &numImportPacketsPerLID)
711  {
712  actor_.doPostsKokkos(plan_, exports, numExportPacketsPerLID, imports, numImportPacketsPerLID);
713  }
714 
715  template <class ExpView, class ImpView>
716  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
717  Distributor::
718  doReversePostsAndWaits (const ExpView& exports,
719  size_t numPackets,
720  const ImpView& imports)
721  {
722  doReversePosts (exports, numPackets, imports);
723  doReverseWaits ();
724  }
725 
726  template <class ExpView, class ImpView>
727  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
728  Distributor::
729  doReversePostsAndWaits (const ExpView& exports,
730  const Teuchos::ArrayView<const size_t>& numExportPacketsPerLID,
731  const ImpView& imports,
732  const Teuchos::ArrayView<const size_t>& numImportPacketsPerLID)
733  {
734  doReversePosts (exports, numExportPacketsPerLID, imports,
735  numImportPacketsPerLID);
736  doReverseWaits ();
737  }
738 
739  template <class ExpView, class ExpPacketsView, class ImpView, class ImpPacketsView>
740  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
741  Distributor::
742  doReversePostsAndWaitsKokkos (const ExpView& exports,
743  const ExpPacketsView &numExportPacketsPerLID,
744  const ImpView& imports,
745  const ImpPacketsView &numImportPacketsPerLID)
746  {
747  doReversePostsKokkos (exports, numExportPacketsPerLID, imports,
748  numImportPacketsPerLID);
749  doReverseWaits ();
750  }
751 
752  template <class ExpView, class ImpView>
753  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
754  Distributor::
755  doReversePosts (const ExpView &exports,
756  size_t numPackets,
757  const ImpView &imports)
758  {
759  // FIXME (mfh 29 Mar 2012) WHY?
760  TEUCHOS_TEST_FOR_EXCEPTION(
761  ! plan_.getIndicesTo().is_null(), std::runtime_error,
762  "Tpetra::Distributor::doReversePosts(3 args): Can only do "
763  "reverse communication when original data are blocked by process.");
764  if (reverseDistributor_.is_null ()) {
765  createReverseDistributor ();
766  }
767  reverseDistributor_->doPosts (exports, numPackets, imports);
768  }
769 
770  template <class ExpView, class ImpView>
771  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
772  Distributor::
773  doReversePosts (const ExpView &exports,
774  const Teuchos::ArrayView<const size_t>& numExportPacketsPerLID,
775  const ImpView &imports,
776  const Teuchos::ArrayView<const size_t>& numImportPacketsPerLID)
777  {
778  // FIXME (mfh 29 Mar 2012) WHY?
779  TEUCHOS_TEST_FOR_EXCEPTION(
780  ! plan_.getIndicesTo().is_null(), std::runtime_error,
781  "Tpetra::Distributor::doReversePosts(3 args): Can only do "
782  "reverse communication when original data are blocked by process.");
783  if (reverseDistributor_.is_null ()) {
784  createReverseDistributor ();
785  }
786  reverseDistributor_->doPosts (exports, numExportPacketsPerLID,
787  imports, numImportPacketsPerLID);
788  }
789 
790  template <class ExpView, class ExpPacketsView, class ImpView, class ImpPacketsView>
791  typename std::enable_if<(Kokkos::is_view<ExpView>::value && Kokkos::is_view<ImpView>::value)>::type
792  Distributor::
793  doReversePostsKokkos (const ExpView &exports,
794  const ExpPacketsView &numExportPacketsPerLID,
795  const ImpView &imports,
796  const ImpPacketsView &numImportPacketsPerLID)
797  {
798  // FIXME (mfh 29 Mar 2012) WHY?
799  TEUCHOS_TEST_FOR_EXCEPTION(
800  ! plan_.getIndicesTo().is_null(), std::runtime_error,
801  "Tpetra::Distributor::doReversePosts(3 args): Can only do "
802  "reverse communication when original data are blocked by process.");
803  if (reverseDistributor_.is_null ()) {
804  createReverseDistributor ();
805  }
806  reverseDistributor_->doPostsKokkos (exports, numExportPacketsPerLID,
807  imports, numImportPacketsPerLID);
808  }
809 
810  template <class OrdinalType>
811  void Distributor::
812  computeSends(const Teuchos::ArrayView<const OrdinalType>& importGIDs,
813  const Teuchos::ArrayView<const int>& importProcIDs,
814  Teuchos::Array<OrdinalType>& exportGIDs,
815  Teuchos::Array<int>& exportProcIDs)
816  {
817  // NOTE (mfh 19 Apr 2012): There was a note on this code saying:
818  // "assumes that size_t >= Ordinal". The code certainly does
819  // assume that sizeof(size_t) >= sizeof(OrdinalType) as well as
820  // sizeof(size_t) >= sizeof(int). This is because it casts the
821  // OrdinalType elements of importGIDs (along with their
822  // corresponding process IDs, as int) to size_t, and does a
823  // doPostsAndWaits<size_t>() to send the packed data.
824  using Teuchos::ArrayView;
825  using std::endl;
826  using size_type = typename ArrayView<const OrdinalType>::size_type;
827  const char errPrefix[] = "Tpetra::Distributor::computeSends: ";
828  const char suffix[] =
829  " Please report this bug to the Tpetra developers.";
830 
831  const int myRank = plan_.getComm()->getRank ();
832 
833  TEUCHOS_TEST_FOR_EXCEPTION
834  (importGIDs.size () != importProcIDs.size (),
835  std::invalid_argument, errPrefix << "On Process " << myRank
836  << ": importProcIDs.size()=" << importProcIDs.size()
837  << " != importGIDs.size()=" << importGIDs.size() << ".");
838 
839  const size_type numImports = importProcIDs.size();
840  Kokkos::View<size_t*, Kokkos::HostSpace> importObjs("importObjs", 2*numImports);
841  // Pack pairs (importGIDs[i], my process ID) to send into importObjs.
842  for (size_type i = 0; i < numImports; ++i) {
843  importObjs[2*i] = static_cast<size_t>(importGIDs[i]);
844  importObjs[2*i+1] = static_cast<size_t>(myRank);
845  }
846  //
847  // Use a temporary Distributor to send the (importGIDs[i], myRank)
848  // pairs to importProcIDs[i].
849  //
850  Distributor tempPlan(plan_.getComm());
851  // mfh 20 Mar 2014: An extra-cautious cast from unsigned to
852  // signed, in order to forestall any possible causes for Bug 6069.
853  const size_t numExportsAsSizeT =
854  tempPlan.createFromSends(importProcIDs);
855  const size_type numExports =
856  static_cast<size_type>(numExportsAsSizeT);
857  TEUCHOS_TEST_FOR_EXCEPTION
858  (numExports < 0, std::logic_error, errPrefix <<
859  "tempPlan.createFromSends() returned numExports="
860  << numExportsAsSizeT << " as a size_t, which overflows to "
861  << numExports << " when cast to " <<
862  Teuchos::TypeNameTraits<size_type>::name () << "." << suffix);
863  TEUCHOS_TEST_FOR_EXCEPTION
864  (size_type(tempPlan.getTotalReceiveLength()) != numExports,
865  std::logic_error, errPrefix << "tempPlan.getTotalReceiveLength()="
866  << tempPlan.getTotalReceiveLength () << " != numExports="
867  << numExports << "." << suffix);
868 
869  if (numExports > 0) {
870  exportGIDs.resize(numExports);
871  exportProcIDs.resize(numExports);
872  }
873 
874  // exportObjs: Packed receive buffer. (exportObjs[2*i],
875  // exportObjs[2*i+1]) will give the (GID, PID) pair for export i,
876  // after tempPlan.doPostsAndWaits(...) finishes below.
877  //
878  // FIXME (mfh 19 Mar 2014) This only works if OrdinalType fits in
879  // size_t. This issue might come up, for example, on a 32-bit
880  // machine using 64-bit global indices. I will add a check here
881  // for that case.
882  static_assert(sizeof(size_t) >= sizeof(OrdinalType),
883  "Tpetra::Distributor::computeSends: "
884  "sizeof(size_t) < sizeof(OrdinalType).");
885 
886  TEUCHOS_TEST_FOR_EXCEPTION
887  (tempPlan.getTotalReceiveLength () < size_t(numExports),
888  std::logic_error,
889  errPrefix << "tempPlan.getTotalReceiveLength()="
890  << tempPlan.getTotalReceiveLength() << " < numExports="
891  << numExports << "." << suffix);
892 
893  Kokkos::View<size_t*, Kokkos::HostSpace> exportObjs("exportObjs", tempPlan.getTotalReceiveLength() * 2);
894  tempPlan.doPostsAndWaits(importObjs, 2, exportObjs);
895 
896  // Unpack received (GID, PID) pairs into exportIDs resp. exportProcIDs.
897  for (size_type i = 0; i < numExports; ++i) {
898  exportGIDs[i] = static_cast<OrdinalType> (exportObjs[2*i]);
899  exportProcIDs[i] = static_cast<int> (exportObjs[2*i+1]);
900  }
901  }
902 
903  template <class OrdinalType>
904  void Distributor::
905  createFromRecvs (const Teuchos::ArrayView<const OrdinalType> &remoteGIDs,
906  const Teuchos::ArrayView<const int> &remoteProcIDs,
907  Teuchos::Array<OrdinalType> &exportGIDs,
908  Teuchos::Array<int> &exportProcIDs)
909  {
910  using std::endl;
911  const char errPrefix[] = "Tpetra::Distributor::createFromRecvs: ";
912  const int myRank = plan_.getComm()->getRank();
913 
914  std::unique_ptr<std::string> prefix;
915  if (verbose_) {
916  prefix = createPrefix("createFromRecvs");
917  std::ostringstream os;
918  os << *prefix << "Start" << endl;
919  std::cerr << os.str();
920  }
921 
922  const bool debug = Details::Behavior::debug("Distributor");
923  if (debug) {
924  using Teuchos::outArg;
925  using Teuchos::REDUCE_MAX;
926  using Teuchos::reduceAll;
927  // In debug mode, first test locally, then do an all-reduce to
928  // make sure that all processes passed.
929  const int errProc =
930  (remoteGIDs.size () != remoteProcIDs.size ()) ? myRank : -1;
931  int maxErrProc = -1;
932  reduceAll(*plan_.getComm(), REDUCE_MAX, errProc, outArg(maxErrProc));
933  TEUCHOS_TEST_FOR_EXCEPTION
934  (maxErrProc != -1, std::runtime_error, errPrefix << "Lists "
935  "of remote IDs and remote process IDs must have the same "
936  "size on all participating processes. Maximum process ID "
937  "with error: " << maxErrProc << ".");
938  }
939  else { // in non-debug mode, just test locally
940  // NOTE (mfh 13 Feb 2020) This needs to throw std::runtime_error
941  // in order to make an existing Distributor unit test pass.
942  TEUCHOS_TEST_FOR_EXCEPTION
943  (remoteGIDs.size() != remoteProcIDs.size(), std::runtime_error,
944  errPrefix << "On Process " << myRank << ": "
945  "remoteGIDs.size()=" << remoteGIDs.size() <<
946  " != remoteProcIDs.size()=" << remoteProcIDs.size() << ".");
947  }
948 
949  computeSends(remoteGIDs, remoteProcIDs, exportGIDs, exportProcIDs);
950 
951  plan_.createFromRecvs(remoteProcIDs);
952 
953  if (verbose_) {
954  std::ostringstream os;
955  os << *prefix << "Done" << endl;
956  std::cerr << os.str();
957  }
958  }
959 
960 } // namespace Tpetra
961 
962 #endif // TPETRA_DISTRIBUTOR_HPP
const Details::DistributorPlan & getPlan() const
Get this Distributor&#39;s DistributorPlan.
size_t getNumReceives() const
The number of processes from which we will receive data.
std::string description() const
Return a one-line description of this object.
std::enable_if<(Kokkos::is_view< ExpView >::value &&Kokkos::is_view< ImpView >::value)>::type doReversePostsAndWaits(const ExpView &exports, size_t numPackets, const ImpView &imports)
Execute the reverse communication plan.
Teuchos::RCP< Distributor > getReverse(bool create=true) const
A reverse communication plan Distributor.
EDistributorHowInitialized
Enum indicating how and whether a Distributor was initialized.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
List of valid Distributor parameters.
virtual ~Distributor()=default
Destructor (virtual for memory safety).
static bool debug()
Whether Tpetra is in debug mode.
std::enable_if<(Kokkos::is_view< ExpView >::value &&Kokkos::is_view< ImpView >::value)>::type doPosts(const ExpView &exports, size_t numPackets, const ImpView &imports)
Post the data for a forward plan, but do not execute the waits yet.
void swap(Distributor &rhs)
Swap the contents of rhs with those of *this.
Teuchos::ArrayView< const size_t > getLengthsFrom() const
Number of values this process will receive from each process.
Teuchos::ArrayView< const int > getProcsFrom() const
Ranks of the processes sending values to this process.
size_t createFromSends(const Teuchos::ArrayView< const int > &exportProcIDs)
Set up Distributor using list of process ranks to which this process will send.
Details::EDistributorHowInitialized howInitialized() const
Return an enum indicating whether and how a Distributor was initialized.
Teuchos::ArrayView< const int > getProcsTo() const
Ranks of the processes to which this process will send values.
void createFromSendsAndRecvs(const Teuchos::ArrayView< const int > &exportProcIDs, const Teuchos::ArrayView< const int > &remoteProcIDs)
Set up Distributor using list of process ranks to which to send, and list of process ranks from which...
bool hasSelfMessage() const
Whether the calling process will send or receive messages to itself.
std::enable_if<(Kokkos::is_view< ExpView >::value &&Kokkos::is_view< ImpView >::value)>::type doReversePosts(const ExpView &exports, size_t numPackets, const ImpView &imports)
Post the data for a reverse plan, but do not execute the waits yet.
Sets up and executes a communication plan for a Tpetra DistObject.
size_t getTotalReceiveLength() const
Total number of values this process will receive from other processes.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Set Distributor parameters.
Teuchos::ArrayView< const size_t > getLengthsTo() const
Number of values this process will send to each process.
Teuchos::Array< std::string > distributorSendTypes()
Valid values for Distributor&#39;s &quot;Send type&quot; parameter.
std::enable_if<(Kokkos::is_view< ExpView >::value &&Kokkos::is_view< ImpView >::value)>::type doPostsAndWaits(const ExpView &exports, size_t numPackets, const ImpView &imports)
Execute the (forward) communication plan.
Stand-alone utility functions and macros.
size_t getNumSends() const
The number of processes to which we will send data.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Describe this object in a human-readable way to the given output stream.
size_t getMaxSendLength() const
Maximum number of values this process will send to another single process.
void createFromRecvs(const Teuchos::ArrayView< const Ordinal > &remoteIDs, const Teuchos::ArrayView< const int > &remoteProcIDs, Teuchos::Array< Ordinal > &exportIDs, Teuchos::Array< int > &exportProcIDs)
Set up Distributor using list of process ranks from which to receive.
Distributor(const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Construct using the specified communicator and default parameters.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra&#39;s behavior.