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 
25 }
26 
27 ProfilingRegion::ProfilingRegion (const char name[]) {
28  kokkos_region_active_ = false;
30  kokkos_region_active_ = true;
31  ::Kokkos::Profiling::pushRegion(name);
32  }
34  tm = Teuchos::rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name)));
35 
36 }
37 
38 ProfilingRegion::ProfilingRegion (const char name[], const char group[]) {
39  kokkos_region_active_ = false;
40  const bool timeit = Behavior::timing(group);
41  if (timeit)
42  {
44  kokkos_region_active_ = true;
45  ::Kokkos::Profiling::pushRegion(name);
46  }
48  tm = Teuchos::rcp(new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer(name)));
49  }
50 }
51 
53  if(Behavior::profilingRegionUseKokkosProfiling() && kokkos_region_active_){
54  ::Kokkos::Profiling::popRegion();
55  }
56 }
57 
58 } // namespace Details
59 } // namespace Tpetra
60 
61 
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.