Tpetra parallel linear algebra Version of the Day
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#ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
47 makeTimers();
48#endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
49 }
50
51 DistributorActor::DistributorActor(const DistributorActor& otherActor)
52 : requests_(otherActor.requests_)
53 {
54#ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
55 makeTimers();
56#endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
57 }
58
59 void DistributorActor::doWaits(const DistributorPlan& plan) {
60#ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
61 Teuchos::TimeMonitor timeMon (*timer_doWaits_);
62#endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
63
64 if (requests_.size() > 0) {
65 Teuchos::waitAll(*plan.getComm(), requests_());
66
67 // Restore the invariant that requests_.size() is the number of
68 // outstanding nonblocking communication requests.
69 requests_.resize(0);
70 }
71 }
72
73#ifdef HAVE_TPETRA_DISTRIBUTOR_TIMINGS
74 void DistributorActor::makeTimers () {
75 timer_doWaits_ = Teuchos::TimeMonitor::getNewTimer (
76 "Tpetra::Distributor: doWaits");
77
78 timer_doPosts3KV_ = Teuchos::TimeMonitor::getNewTimer (
79 "Tpetra::Distributor: doPosts(3) KV");
80 timer_doPosts4KV_ = Teuchos::TimeMonitor::getNewTimer (
81 "Tpetra::Distributor: doPosts(4) KV");
82
83 timer_doPosts3KV_recvs_ = Teuchos::TimeMonitor::getNewTimer (
84 "Tpetra::Distributor: doPosts(3): recvs KV");
85 timer_doPosts4KV_recvs_ = Teuchos::TimeMonitor::getNewTimer (
86 "Tpetra::Distributor: doPosts(4): recvs KV");
87
88 timer_doPosts3KV_barrier_ = Teuchos::TimeMonitor::getNewTimer (
89 "Tpetra::Distributor: doPosts(3): barrier KV");
90 timer_doPosts4KV_barrier_ = Teuchos::TimeMonitor::getNewTimer (
91 "Tpetra::Distributor: doPosts(4): barrier KV");
92
93 timer_doPosts3KV_sends_ = Teuchos::TimeMonitor::getNewTimer (
94 "Tpetra::Distributor: doPosts(3): sends KV");
95 timer_doPosts4KV_sends_ = Teuchos::TimeMonitor::getNewTimer (
96 "Tpetra::Distributor: doPosts(4): sends KV");
97 timer_doPosts3KV_sends_slow_ = Teuchos::TimeMonitor::getNewTimer (
98 "Tpetra::Distributor: doPosts(3): sends KV SLOW");
99 timer_doPosts4KV_sends_slow_ = Teuchos::TimeMonitor::getNewTimer (
100 "Tpetra::Distributor: doPosts(4): sends KV SLOW");
101 timer_doPosts3KV_sends_fast_ = Teuchos::TimeMonitor::getNewTimer (
102 "Tpetra::Distributor: doPosts(3): sends KV FAST");
103 timer_doPosts4KV_sends_fast_ = Teuchos::TimeMonitor::getNewTimer (
104 "Tpetra::Distributor: doPosts(4): sends KV FAST");
105 }
106#endif // HAVE_TPETRA_DISTRIBUTOR_TIMINGS
107}
108}
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.