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 #include "Teuchos_TimeMonitor.hpp"
12 
13 namespace Tpetra {
14 namespace Details {
15 
16  DistributorActor::DistributorActor()
17  : mpiTag_(DEFAULT_MPI_TAG)
18  {
19 #ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
20  makeTimers();
21 #endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
22  }
23 
24  DistributorActor::DistributorActor(const DistributorActor& otherActor)
25  : mpiTag_(otherActor.mpiTag_),
26  requests_(otherActor.requests_)
27  {
28 #ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
29  makeTimers();
30 #endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
31  }
32 
33  void DistributorActor::doWaits(const DistributorPlan& plan) {
34 #ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
35  Teuchos::TimeMonitor timeMon (*timer_doWaits_);
36 #endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
37 
38  if (requests_.size() > 0) {
39  Teuchos::waitAll(*plan.getComm(), requests_());
40 
41  // Restore the invariant that requests_.size() is the number of
42  // outstanding nonblocking communication requests.
43  requests_.resize(0);
44  }
45  }
46 
47  bool DistributorActor::isReady() const {
48  bool result = true;
49  for (auto& request : requests_) {
50  result &= request->isReady();
51  }
52  return result;
53  }
54 
55 #ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
56  void DistributorActor::makeTimers () {
57  timer_doWaits_ = Teuchos::TimeMonitor::getNewTimer (
58  "Tpetra::Distributor: doWaits");
59 
60  timer_doPosts3KV_ = Teuchos::TimeMonitor::getNewTimer (
61  "Tpetra::Distributor: doPosts(3) KV");
62  timer_doPosts4KV_ = Teuchos::TimeMonitor::getNewTimer (
63  "Tpetra::Distributor: doPosts(4) KV");
64 
65  timer_doPosts3KV_recvs_ = Teuchos::TimeMonitor::getNewTimer (
66  "Tpetra::Distributor: doPosts(3): recvs KV");
67  timer_doPosts4KV_recvs_ = Teuchos::TimeMonitor::getNewTimer (
68  "Tpetra::Distributor: doPosts(4): recvs KV");
69 
70  timer_doPosts3KV_barrier_ = Teuchos::TimeMonitor::getNewTimer (
71  "Tpetra::Distributor: doPosts(3): barrier KV");
72  timer_doPosts4KV_barrier_ = Teuchos::TimeMonitor::getNewTimer (
73  "Tpetra::Distributor: doPosts(4): barrier KV");
74 
75  timer_doPosts3KV_sends_ = Teuchos::TimeMonitor::getNewTimer (
76  "Tpetra::Distributor: doPosts(3): sends KV");
77  timer_doPosts4KV_sends_ = Teuchos::TimeMonitor::getNewTimer (
78  "Tpetra::Distributor: doPosts(4): sends KV");
79  timer_doPosts3KV_sends_slow_ = Teuchos::TimeMonitor::getNewTimer (
80  "Tpetra::Distributor: doPosts(3): sends KV SLOW");
81  timer_doPosts4KV_sends_slow_ = Teuchos::TimeMonitor::getNewTimer (
82  "Tpetra::Distributor: doPosts(4): sends KV SLOW");
83  timer_doPosts3KV_sends_fast_ = Teuchos::TimeMonitor::getNewTimer (
84  "Tpetra::Distributor: doPosts(3): sends KV FAST");
85  timer_doPosts4KV_sends_fast_ = Teuchos::TimeMonitor::getNewTimer (
86  "Tpetra::Distributor: doPosts(4): sends KV FAST");
87  }
88 #endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
89 }
90 }