Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_Details_Profiling.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 
12 // I don't like including everything, but currently (as of 19 Apr
13 // 2017), Kokkos does not provide a public header file to get just the
14 // Profiling hooks. Users are just supposed to include
15 // Kokkos_Core.hpp.
16 #include "Kokkos_Core.hpp"
17 
18 namespace Tpetra {
19 namespace Details {
20 
22  : kokkos_region_active_(false) {
23 }
24 
26  kokkos_region_active_ = false;
28  kokkos_region_active_ = true;
29  ::Kokkos::Profiling::pushRegion(name);
30  }
32  tm = Teuchos::rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name)));
33 }
34 
35 ProfilingRegion::ProfilingRegion(const char name[], const char group[]) {
36  kokkos_region_active_ = false;
37  const bool timeit = Behavior::timing(group);
38  if (timeit) {
40  kokkos_region_active_ = true;
41  ::Kokkos::Profiling::pushRegion(name);
42  }
44  tm = Teuchos::rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name)));
45  }
46 }
47 
49  if (Behavior::profilingRegionUseKokkosProfiling() && kokkos_region_active_) {
50  ::Kokkos::Profiling::popRegion();
51  }
52 }
53 
54 } // namespace Details
55 } // namespace Tpetra
static bool timing()
Whether Tpetra is in timing mode.
Declaration of Tpetra::Details::Profiling, a scope guard for Kokkos Profiling.
ProfilingRegion()
Default constructor does not construct a region.
static bool profilingRegionUseTeuchosTimers()
Use Teuchos::Timer in Tpetra::ProfilingRegion.
static bool profilingRegionUseKokkosProfiling()
Use Kokkos::Profiling in Tpetra::ProfilingRegion.
~ProfilingRegion()
Close region to profile.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.