10#include "Tpetra_Distributor.hpp" 
   14#include "Tpetra_Details_makeValidVerboseStream.hpp" 
   15#include "Teuchos_StandardParameterEntryValidators.hpp" 
   16#include "Teuchos_VerboseObjectParameterListHelpers.hpp" 
   26const bool tpetraDistributorDebugDefault = 
false;
 
   29#if defined(TPETRA_ENABLE_DEPRECATED_CODE) 
   30Teuchos::Array<std::string>
 
   37    Distributor(
const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
 
   38                const Teuchos::RCP<Teuchos::FancyOStream>& ,
 
   39                const Teuchos::RCP<Teuchos::ParameterList>& 
plist)
 
 
   45    Distributor(
const Teuchos::RCP<
const Teuchos::Comm<int> >& comm)
 
 
   49    Distributor(
const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
 
   50                const Teuchos::RCP<Teuchos::FancyOStream>& 
out)
 
 
   54    Distributor(
const Teuchos::RCP<
const Teuchos::Comm<int> >& comm,
 
   55                const Teuchos::RCP<Teuchos::ParameterList>& 
plist)
 
 
   63  , reverseDistributor_(
distributor.reverseDistributor_) {
 
   64  using Teuchos::ParameterList;
 
 
   74  using Teuchos::ParameterList;
 
   75  using Teuchos::parameterList;
 
   78  std::swap(plan_, 
rhs.plan_);
 
   79  std::swap(actor_, 
rhs.actor_);
 
   80  std::swap(verbose_, 
rhs.verbose_);
 
   81  std::swap(reverseDistributor_, 
rhs.reverseDistributor_);
 
 
  101bool Distributor::getVerbose() {
 
  106std::unique_ptr<std::string>
 
  108    createPrefix(
const char methodName[])
 const {
 
  110      plan_.getComm().getRawPtr(), 
"Distributor", methodName);
 
  116  using Teuchos::FancyOStream;
 
  117  using Teuchos::getIntegralValue;
 
  118  using Teuchos::includesVerbLevel;
 
  119  using Teuchos::ParameterList;
 
  120  using Teuchos::parameterList;
 
  122  using ::Tpetra::Details::Behavior;
 
  124  if (!
plist.is_null()) {
 
 
  139Teuchos::RCP<const Teuchos::ParameterList>
 
  141  using Teuchos::Array;
 
  142  using Teuchos::ParameterList;
 
  143  using Teuchos::parameterList;
 
  145  using Teuchos::setStringToIntegralParameter;
 
  156                                                              "When using MPI, the variant of send to use in " 
  157                                                              "do[Reverse]Posts()",
 
  159  plist->set(
"Debug", debug,
 
  160             "Whether to print copious debugging output on " 
  162  plist->set(
"Timer Label", 
"", 
"Label for Time Monitor output");
 
  170  Teuchos::setupVerboseObjectSublist(&*
plist);
 
  171  return Teuchos::rcp_const_cast<const ParameterList>(
plist);
 
 
  192Teuchos::RCP<Distributor>
 
  194  if (reverseDistributor_.is_null() && 
create) {
 
  195    createReverseDistributor();
 
  199                             "Distributor is null after createReverseDistributor returned.  " 
  200                             "Please report this bug to the Tpetra developers.");
 
  201  return reverseDistributor_;
 
 
  204void Distributor::createReverseDistributor()
 const {
 
  205  reverseDistributor_           = Teuchos::rcp(
new Distributor(plan_.getComm()));
 
  206  reverseDistributor_->plan_    = *plan_.getReversePlan();
 
  207  reverseDistributor_->verbose_ = verbose_;
 
  223  reverseDistributor_->reverseDistributor_ = Teuchos::null;
 
  227  actor_.doWaits(plan_);
 
 
  232  if (!reverseDistributor_.is_null()) {
 
  233    reverseDistributor_->doWaits();
 
 
  238  std::ostringstream 
out;
 
  240  out << 
"\"Tpetra::Distributor\": {";
 
  243    out << 
"Label: " << label << 
", ";
 
  245  out << 
"How initialized: " 
  249      << DistributorSendTypeEnumToString(plan_.getSendType())
 
  250      << 
", Debug: " << (verbose_ ? 
"true" : 
"false")
 
 
  257    localDescribeToString(
const Teuchos::EVerbosityLevel 
vl)
 const {
 
  259  using Teuchos::toString;
 
  260  using Teuchos::VERB_EXTREME;
 
  261  using Teuchos::VERB_HIGH;
 
  264  if (
vl <= Teuchos::VERB_LOW || plan_.getComm().is_null()) {
 
  265    return std::string();
 
  268  auto outStringP            = Teuchos::rcp(
new std::ostringstream());
 
  269  auto outp                  = Teuchos::getFancyOStream(outStringP);  
 
  270  Teuchos::FancyOStream& out = *outp;
 
  272  const int myRank   = plan_.getComm()->getRank();
 
  273  const int numProcs = plan_.getComm()->getSize();
 
  274  out << 
"Process " << myRank << 
" of " << numProcs << 
":" << endl;
 
  275  Teuchos::OSTab tab1(out);
 
  279  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
 
  280    out << 
"procsTo: " << toString(plan_.getProcsTo()) << endl;
 
  281    out << 
"lengthsTo: " << toString(plan_.getLengthsTo()) << endl;
 
  284  if (vl == VERB_EXTREME) {
 
  285    out << 
"startsTo: " << toString(plan_.getStartsTo()) << endl;
 
  286    out << 
"indicesTo: " << toString(plan_.getIndicesTo()) << endl;
 
  288  if (vl == VERB_HIGH || vl == VERB_EXTREME) {
 
  291    out << 
"lengthsFrom: " << toString(plan_.getLengthsFrom()) << endl;
 
  292    out << 
"procsFrom: " << toString(plan_.getProcsFrom()) << endl;
 
  296  return outStringP->str();
 
  301             const Teuchos::EVerbosityLevel 
verbLevel)
 const {
 
  303  using Teuchos::VERB_DEFAULT;
 
  304  using Teuchos::VERB_EXTREME;
 
  305  using Teuchos::VERB_HIGH;
 
  306  using Teuchos::VERB_LOW;
 
  307  using Teuchos::VERB_MEDIUM;
 
  308  using Teuchos::VERB_NONE;
 
  309  const Teuchos::EVerbosityLevel 
vl =
 
  320  if (plan_.getComm().is_null()) {
 
  323  const int myRank   = plan_.getComm()->getRank();
 
  324  const int numProcs = plan_.getComm()->getSize();
 
  333  Teuchos::RCP<Teuchos::OSTab> 
tab0, 
tab1;
 
  339    tab0 = Teuchos::rcp(
new Teuchos::OSTab(
out));
 
  342    out << 
"\"Tpetra::Distributor\":" << 
endl;
 
  343    tab1 = Teuchos::rcp(
new Teuchos::OSTab(
out));
 
  347      out << 
"Label: " << label << 
endl;
 
  350        << 
"How initialized: " 
  356      out << 
"\"Send type\": " 
  357          << DistributorSendTypeEnumToString(plan_.getSendType()) << 
endl 
  358          << 
"\"Debug\": " << (verbose_ ? 
"true" : 
"false") << 
endl;
 
  364    const std::string 
lclStr = this->localDescribeToString(
vl);
 
  368  out << 
"Reverse Distributor:";
 
  369  if (reverseDistributor_.is_null()) {
 
  373    reverseDistributor_->describe(
out, 
vl);
 
 
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
 
Declaration of a function that prints strings from each process.
 
Stand-alone utility functions and macros.
 
Struct that holds views of the contents of a CrsMatrix.
 
static bool verbose()
Whether Tpetra is in verbose mode.
 
static std::string defaultSendType()
Default send type.
 
Sets up and executes a communication plan for a Tpetra DistObject.
 
size_t getMaxSendLength() const
Maximum number of values this process will send to another single process.
 
Teuchos::RCP< Distributor > getReverse(bool create=true) const
A reverse communication plan Distributor.
 
Teuchos::ArrayView< const int > getProcsTo() const
Ranks of the processes to which this process will send values.
 
size_t getNumReceives() const
The number of processes from which we will receive data.
 
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Set Distributor parameters.
 
size_t getTotalReceiveLength() const
Total number of values this process will receive from other processes.
 
bool hasSelfMessage() const
Whether the calling process will send or receive messages to itself.
 
void swap(Distributor &rhs)
Swap the contents of rhs with those of *this.
 
Teuchos::ArrayView< const size_t > getLengthsTo() const
Number of values this process will send to each process.
 
Teuchos::ArrayView< const int > getProcsFrom() const
Ranks of the processes sending values to this process.
 
Distributor(const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
Construct using the specified communicator and default parameters.
 
std::string description() const
Return a one-line description of this object.
 
size_t createFromSends(const Teuchos::ArrayView< const int > &exportProcIDs)
Set up Distributor using list of process ranks to which this process will send.
 
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...
 
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
List of valid Distributor parameters.
 
Teuchos::ArrayView< const size_t > getLengthsFrom() const
Number of values this process will receive from each process.
 
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.
 
Teuchos::Array< EDistributorSendType > distributorSendTypeEnums()
Valid enum values of distributor send types.
 
Teuchos::Array< std::string > distributorSendTypes()
Valid string values for Distributor's "Send type" parameter.
 
std::unique_ptr< std::string > createPrefix(const int myRank, const char prefix[])
Create string prefix for each line of verbose output.
 
const std::string & validSendTypeOrThrow(const std::string &s)
Valid enum values of distributor send types.
 
std::string DistributorHowInitializedEnumToString(EDistributorHowInitialized how)
Convert an EDistributorHowInitialized enum value to a string.
 
void gathervPrint(std::ostream &out, const std::string &s, const Teuchos::Comm< int > &comm)
On Process 0 in the given communicator, print strings from each process in that communicator,...
 
Namespace Tpetra contains the class and methods constituting the Tpetra library.