https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PerfGraphInterface.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 "PerfGraphInterface.h"
11#include "PerfGraphRegistry.h"
12
13#include "MooseApp.h"
14
17{
19 return params;
20}
21
23 : _pg_moose_app(*moose_object->parameters().getCheckedPointerParam<MooseApp *>(
24 MooseBase::app_param, "PerfGraphInterface is unable to retrieve the MooseApp pointer!")),
25 _prefix(moose_object->type())
26{
27}
28
29PerfGraphInterface::PerfGraphInterface(const MooseObject * moose_object, const std::string prefix)
30 : _pg_moose_app(*moose_object->parameters().getCheckedPointerParam<MooseApp *>(
31 MooseBase::app_param, "PerfGraphInterface is unable to retrieve the MooseApp pointer!")),
32 _prefix(prefix)
33{
34}
35
36PerfGraphInterface::PerfGraphInterface(MooseApp & moose_app, const std::string prefix)
37 : _pg_moose_app(moose_app), _prefix(prefix)
38{
39}
40
41PerfGraphInterface::PerfGraphInterface(PerfGraph & perf_graph, const std::string prefix)
42 : _pg_moose_app(perf_graph.mooseApp()), _prefix(prefix)
43{
44}
45
46#ifdef MOOSE_KOKKOS_ENABLED
49 : _pg_moose_app(object._pg_moose_app), _prefix(object._prefix)
50{
51}
52#endif
53
54std::string
55PerfGraphInterface::timedSectionName(const std::string & section_name) const
56{
57 return _prefix.empty() ? "" : (_prefix + "::") + section_name;
58}
59
61PerfGraphInterface::registerTimedSection(const std::string & section_name,
62 const unsigned int level) const
63{
64 const auto timed_section_name = timedSectionName(section_name);
65 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
66 return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level);
67 else
68 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
69}
70
72PerfGraphInterface::registerTimedSection(const std::string & section_name,
73 const unsigned int level,
74 const std::string & live_message,
75 const bool print_dots) const
76{
77 const auto timed_section_name = timedSectionName(section_name);
78 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
80 timedSectionName(section_name), level, live_message, print_dots);
81 else
82 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
83}
84
InputParameters emptyInputParameters()
unsigned int PerfID
Definition MooseTypes.h:240
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Base class for MOOSE-based applications.
Definition MooseApp.h:110
PerfGraph & perfGraph()
Get the PerfGraph for this app.
Definition MooseApp.h:179
Base class for everything in MOOSE with a name and a type.
Definition MooseBase.h:50
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
Interface for objects interacting with the PerfGraph.
PerfID registerTimedSection(const std::string &section_name, const unsigned int level) const
Call to register a named section for timing.
std::string timedSectionName(const std::string &section_name) const
const std::string _prefix
A prefix to use for all sections.
PerfGraphInterface(const MooseObject *moose_object)
For objects that are MooseObjects with a default prefix of type()
PerfGraph & perfGraph()
Get the PerfGraph.
static InputParameters validParams()
MooseApp & _pg_moose_app
The MooseApp that owns the PerfGraph.
The PerfGraph will hold the master list of all registered performance segments and the head PerfNode.
Definition PerfGraph.h:44
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID @section_name The name of the section.
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.