Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Details_DistributorActor.cpp
1// ***********************************************************************
2//
3// Tpetra: Templated Linear Algebra Services Package
4// Copyright (2008) Sandia Corporation
5//
6// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7// the U.S. Government retains certain rights in this software.
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12//
13// 1. Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15//
16// 2. Redistributions in binary form must reproduce the above copyright
17// notice, this list of conditions and the following disclaimer in the
18// documentation and/or other materials provided with the distribution.
19//
20// 3. Neither the name of the Corporation nor the names of the
21// contributors may be used to endorse or promote products derived from
22// this software without specific prior written permission.
23//
24// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
25// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
28// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35//
36// ************************************************************************
37// @HEADER
38
39#include "Tpetra_Details_DistributorActor.hpp"
40#include "Teuchos_TimeMonitor.hpp"
41
42namespace Tpetra {
43namespace Details {
44
45 DistributorActor::DistributorActor()
46 : mpiTag_(DEFAULT_MPI_TAG)
47 {
48#ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
49 makeTimers();
50#endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
51 }
52
53 DistributorActor::DistributorActor(const DistributorActor& otherActor)
54 : mpiTag_(otherActor.mpiTag_),
55 requests_(otherActor.requests_)
56 {
57#ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
58 makeTimers();
59#endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
60 }
61
62 void DistributorActor::doWaits(const DistributorPlan& plan) {
63#ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
64 Teuchos::TimeMonitor timeMon (*timer_doWaits_);
65#endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
66
67 if (requests_.size() > 0) {
68 Teuchos::waitAll(*plan.getComm(), requests_());
69
70 // Restore the invariant that requests_.size() is the number of
71 // outstanding nonblocking communication requests.
72 requests_.resize(0);
73 }
74 }
75
76 bool DistributorActor::isReady() const {
77 bool result = true;
78 for (auto& request : requests_) {
79 result &= request->isReady();
80 }
81 return result;
82 }
83
84#ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
85 void DistributorActor::makeTimers () {
86 timer_doWaits_ = Teuchos::TimeMonitor::getNewTimer (
87 "Tpetra::Distributor: doWaits");
88
89 timer_doPosts3KV_ = Teuchos::TimeMonitor::getNewTimer (
90 "Tpetra::Distributor: doPosts(3) KV");
91 timer_doPosts4KV_ = Teuchos::TimeMonitor::getNewTimer (
92 "Tpetra::Distributor: doPosts(4) KV");
93
94 timer_doPosts3KV_recvs_ = Teuchos::TimeMonitor::getNewTimer (
95 "Tpetra::Distributor: doPosts(3): recvs KV");
96 timer_doPosts4KV_recvs_ = Teuchos::TimeMonitor::getNewTimer (
97 "Tpetra::Distributor: doPosts(4): recvs KV");
98
99 timer_doPosts3KV_barrier_ = Teuchos::TimeMonitor::getNewTimer (
100 "Tpetra::Distributor: doPosts(3): barrier KV");
101 timer_doPosts4KV_barrier_ = Teuchos::TimeMonitor::getNewTimer (
102 "Tpetra::Distributor: doPosts(4): barrier KV");
103
104 timer_doPosts3KV_sends_ = Teuchos::TimeMonitor::getNewTimer (
105 "Tpetra::Distributor: doPosts(3): sends KV");
106 timer_doPosts4KV_sends_ = Teuchos::TimeMonitor::getNewTimer (
107 "Tpetra::Distributor: doPosts(4): sends KV");
108 timer_doPosts3KV_sends_slow_ = Teuchos::TimeMonitor::getNewTimer (
109 "Tpetra::Distributor: doPosts(3): sends KV SLOW");
110 timer_doPosts4KV_sends_slow_ = Teuchos::TimeMonitor::getNewTimer (
111 "Tpetra::Distributor: doPosts(4): sends KV SLOW");
112 timer_doPosts3KV_sends_fast_ = Teuchos::TimeMonitor::getNewTimer (
113 "Tpetra::Distributor: doPosts(3): sends KV FAST");
114 timer_doPosts4KV_sends_fast_ = Teuchos::TimeMonitor::getNewTimer (
115 "Tpetra::Distributor: doPosts(4): sends KV FAST");
116 }
117#endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
118}
119}
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.