https://mooseframework.inl.gov
PerfGuard.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "PerfGuard.h"
11 #include "PerfGraph.h"
12 #ifdef LIBMESH_HAVE_NVTX_API
13 #include "nvtx3/nvtx3.hpp"
14 #endif
15 
16 PerfGuard::PerfGuard(PerfGraph & graph, const PerfID id) : _graph(graph)
17 {
18  _graph.push(id);
19 #ifdef LIBMESH_HAVE_NVTX_API
20  nvtxRangePushA(moose::internal::getPerfGraphRegistry().sectionInfo(id)._name.c_str());
21 #endif
22 }
23 
25 {
26  _graph.pop();
27 #ifdef LIBMESH_HAVE_NVTX_API
28  nvtxRangePop();
29 #endif
30 }
PerfGuard(PerfGraph &graph, const PerfID id)
Start timing for the given ID.
Definition: PerfGuard.C:16
unsigned int PerfID
Definition: MooseTypes.h:240
~PerfGuard()
Stop timing.
Definition: PerfGuard.C:24
void pop()
Remove a Node from the end of the current scope.
Definition: PerfGraph.C:236
PerfGraph & _graph
The graph we're working on.
Definition: PerfGuard.h:43
void push(const PerfID id)
Add a Node onto the end of the end of the current callstack.
Definition: PerfGraph.C:186
The PerfGraph will hold the master list of all registered performance segments and the head PerfNode...
Definition: PerfGraph.h:43
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.