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 353548 : PerfGraphInterface::validParams() 17 : { 18 353548 : InputParameters params = emptyInputParameters(); 19 353548 : return params; 20 : } 21 : 22 866494 : PerfGraphInterface::PerfGraphInterface(const MooseObject * moose_object) 23 866494 : : _pg_moose_app(*moose_object->parameters().getCheckedPointerParam<MooseApp *>( 24 : MooseBase::app_param, "PerfGraphInterface is unable to retrieve the MooseApp pointer!")), 25 1732988 : _prefix(moose_object->type()) 26 : { 27 866494 : } 28 : 29 24389 : PerfGraphInterface::PerfGraphInterface(const MooseObject * moose_object, const std::string prefix) 30 24389 : : _pg_moose_app(*moose_object->parameters().getCheckedPointerParam<MooseApp *>( 31 : MooseBase::app_param, "PerfGraphInterface is unable to retrieve the MooseApp pointer!")), 32 48778 : _prefix(prefix) 33 : { 34 24389 : } 35 : 36 135336 : PerfGraphInterface::PerfGraphInterface(MooseApp & moose_app, const std::string prefix) 37 135336 : : _pg_moose_app(moose_app), _prefix(prefix) 38 : { 39 135336 : } 40 : 41 3807392 : PerfGraphInterface::PerfGraphInterface(PerfGraph & perf_graph, const std::string prefix) 42 3807392 : : _pg_moose_app(perf_graph.mooseApp()), _prefix(prefix) 43 : { 44 3807392 : } 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 86739466 : PerfGraphInterface::timedSectionName(const std::string & section_name) const 56 : { 57 86739466 : return _prefix.empty() ? "" : (_prefix + "::") + section_name; 58 : } 59 : 60 : PerfID 61 60430983 : PerfGraphInterface::registerTimedSection(const std::string & section_name, 62 : const unsigned int level) const 63 : { 64 60430983 : const auto timed_section_name = timedSectionName(section_name); 65 60430983 : if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name)) 66 4095217 : return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level); 67 : else 68 56335766 : return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name); 69 60430983 : } 70 : 71 : PerfID 72 23352467 : 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 23352467 : const auto timed_section_name = timedSectionName(section_name); 78 23352467 : if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name)) 79 5912032 : return moose::internal::getPerfGraphRegistry().registerSection( 80 5912032 : timedSectionName(section_name), level, live_message, print_dots); 81 : else 82 20396451 : return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name); 83 23352467 : } 84 : 85 : PerfGraph & 86 232492 : PerfGraphInterface::perfGraph() 87 : { 88 232492 : return _pg_moose_app.perfGraph(); 89 : }