Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_Details_DistributorActor.cpp
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 #include "Tpetra_Details_DistributorActor.hpp"
11 
12 namespace Tpetra::Details {
13 
14  DistributorActor::DistributorActor()
15  : mpiTag_(DEFAULT_MPI_TAG) {}
16 
17  void DistributorActor::doWaits(const DistributorPlan& plan) {
18  doWaitsRecv(plan);
19  doWaitsSend(plan);
20  }
21 
22  void DistributorActor::doWaitsRecv(const DistributorPlan& plan) {
23  if (requestsRecv_.size() > 0) {
24  ProfilingRegion wr("Tpetra::Distributor::doWaitsRecv");
25 
26  Teuchos::waitAll(*plan.getComm(), requestsRecv_());
27 
28  // Restore the invariant that requests_.size() is the number of
29  // outstanding nonblocking communication requests.
30  requestsRecv_.resize(0);
31  }
32  }
33 
34  void DistributorActor::doWaitsSend(const DistributorPlan& plan) {
35  if (requestsSend_.size() > 0) {
36  ProfilingRegion ws("Tpetra::Distributor::doWaitsSend");
37 
38  Teuchos::waitAll(*plan.getComm(), requestsSend_());
39 
40  // Restore the invariant that requests_.size() is the number of
41  // outstanding nonblocking communication requests.
42  requestsSend_.resize(0);
43  }
44  }
45 
46  bool DistributorActor::isReady() const {
47  bool result = true;
48  for (auto& request : requestsRecv_) {
49  result &= request->isReady();
50  }
51  for (auto& request : requestsSend_) {
52  result &= request->isReady();
53  }
54  return result;
55  }
56 }