Line data Source code
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 : 15 : InputParameters 16 351520 : PerfGraphInterface::validParams() 17 : { 18 351520 : InputParameters params = emptyInputParameters(); 19 351520 : return params; 20 : } 21 : 22 860555 : PerfGraphInterface::PerfGraphInterface(const MooseObject * moose_object) 23 860555 : : _pg_moose_app(*moose_object->parameters().getCheckedPointerParam<MooseApp *>( 24 : MooseBase::app_param, "PerfGraphInterface is unable to retrieve the MooseApp pointer!")), 25 1721110 : _prefix(moose_object->type()) 26 : { 27 860555 : } 28 : 29 24326 : PerfGraphInterface::PerfGraphInterface(const MooseObject * moose_object, const std::string prefix) 30 24326 : : _pg_moose_app(*moose_object->parameters().getCheckedPointerParam<MooseApp *>( 31 : MooseBase::app_param, "PerfGraphInterface is unable to retrieve the MooseApp pointer!")), 32 48652 : _prefix(prefix) 33 : { 34 24326 : } 35 : 36 134464 : PerfGraphInterface::PerfGraphInterface(MooseApp & moose_app, const std::string prefix) 37 134464 : : _pg_moose_app(moose_app), _prefix(prefix) 38 : { 39 134464 : } 40 : 41 3781258 : PerfGraphInterface::PerfGraphInterface(PerfGraph & perf_graph, const std::string prefix) 42 3781258 : : _pg_moose_app(perf_graph.mooseApp()), _prefix(prefix) 43 : { 44 3781258 : } 45 : 46 : #ifdef MOOSE_KOKKOS_ENABLED 47 7931 : PerfGraphInterface::PerfGraphInterface(const PerfGraphInterface & object, 48 7931 : const Moose::Kokkos::FunctorCopy &) 49 7931 : : _pg_moose_app(object._pg_moose_app), _prefix(object._prefix) 50 : { 51 7931 : } 52 : #endif 53 : 54 : std::string 55 86736175 : PerfGraphInterface::timedSectionName(const std::string & section_name) const 56 : { 57 86736175 : return _prefix.empty() ? "" : (_prefix + "::") + section_name; 58 : } 59 : 60 : PerfID 61 60361293 : PerfGraphInterface::registerTimedSection(const std::string & section_name, 62 : const unsigned int level) const 63 : { 64 60361293 : const auto timed_section_name = timedSectionName(section_name); 65 60361293 : if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name)) 66 4066770 : return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level); 67 : else 68 56294523 : return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name); 69 60361293 : } 70 : 71 : PerfID 72 23391375 : PerfGraphInterface::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 23391375 : const auto timed_section_name = timedSectionName(section_name); 78 23391375 : if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name)) 79 5967014 : return moose::internal::getPerfGraphRegistry().registerSection( 80 5967014 : timedSectionName(section_name), level, live_message, print_dots); 81 : else 82 20407868 : return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name); 83 23391375 : } 84 : 85 : PerfGraph & 86 231238 : PerfGraphInterface::perfGraph() 87 : { 88 231238 : return _pg_moose_app.perfGraph(); 89 : }