Skip to content

Commit

Permalink
Test PerfGraphLivePrint refs idaholab#15444
Browse files Browse the repository at this point in the history
  • Loading branch information
friedmud committed Aug 17, 2021
1 parent 3c02f17 commit 7d7265d
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 8 deletions.
1 change: 0 additions & 1 deletion framework/src/actions/Action.C
Expand Up @@ -89,7 +89,6 @@ Action::Action(InputParameters parameters)
void
Action::timedAct()
{
_console << "act_timer: " << _act_timer << std::endl;
TIME_SECTION(_act_timer);
act();
}
Expand Down
5 changes: 2 additions & 3 deletions framework/src/outputs/ConsoleUtils.C
Expand Up @@ -45,8 +45,7 @@ outputFrameworkInformation(const MooseApp & app)
<< std::setw(console_field_width)
<< " Num Processors: " << static_cast<std::size_t>(app.n_processors()) << '\n'
<< std::setw(console_field_width)
<< " Num Threads: " << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
<< std::endl;
<< " Num Threads: " << static_cast<std::size_t>(libMesh::n_threads()) << std::endl;

return oss.str();
}
Expand All @@ -66,7 +65,7 @@ outputMeshInformation(FEProblemBase & problem, bool verbose)
bool pre_split = problem.getMooseApp().isUseSplit();

// clang-format off
oss << "\n\nMesh: " << '\n'
oss << "\nMesh: " << '\n'
<< std::setw(console_field_width)
<< " Parallel Type: " << (moose_mesh.isDistributedMesh() ? "distributed" : "replicated")
<< (forced || pre_split ? " (" : "")
Expand Down
3 changes: 0 additions & 3 deletions framework/src/utils/PerfGraphRegistry.C
Expand Up @@ -58,9 +58,6 @@ PerfGraphRegistry::actuallyRegisterSection(const std::string & section_name,
_section_name_to_id.emplace(section_name, id);
}

if (id == 4)
libMesh::out << "ID4: " << section_name << std::endl;

{
std::lock_guard<std::mutex> lock(_id_to_section_info_mutex);

Expand Down
2 changes: 1 addition & 1 deletion framework/src/utils/SystemInfo.C
Expand Up @@ -26,7 +26,7 @@ std::string
SystemInfo::getInfo() const
{
std::stringstream oss;
oss << std::left << "\n\nFramework Information:\n"
oss << std::left << "Framework Information:\n"
<< std::setw(25) << "MOOSE Version: " << MOOSE_REVISION << '\n'
<< std::setw(25) << "LibMesh Version: " << LIBMESH_BUILD_VERSION << '\n';
#ifdef LIBMESH_DETECTED_PETSC_VERSION_MAJOR
Expand Down
27 changes: 27 additions & 0 deletions test/include/problems/SlowProblem.h
@@ -0,0 +1,27 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "FEProblem.h"

/**
* FEProblemBase derived class for testing out PerfGraph
*/
class SlowProblem : public FEProblem
{
public:
static InputParameters validParams();

SlowProblem(const InputParameters & params);
virtual void solve();

protected:
unsigned int _seconds_to_sleep;
};
41 changes: 41 additions & 0 deletions test/src/problems/SlowProblem.C
@@ -0,0 +1,41 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "SlowProblem.h"

#include "MooseApp.h"

#include <thread>
#include <chrono>

registerMooseObject("MooseTestApp", SlowProblem);

InputParameters
SlowProblem::validParams()
{
InputParameters params = FEProblem::validParams();
params.addRequiredParam<unsigned int>("seconds_to_sleep", "The number of seconds to sleep");
return params;
}

SlowProblem::SlowProblem(const InputParameters & params)
: FEProblem(params), _seconds_to_sleep(getParam<unsigned int>("seconds_to_sleep"))
{
}

void
SlowProblem::solve()
{
{
TIME_SECTION("slow", 1, "Testing Slowness");
std::this_thread::sleep_for(std::chrono::seconds(_seconds_to_sleep));
}

FEProblem::solve();
}
49 changes: 49 additions & 0 deletions test/tests/utils/perf_graph_live_print/perf_graph_live_print.i
@@ -0,0 +1,49 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[Variables]
[u]
[]
[]

[Kernels]
[diff]
type = Diffusion
variable = u
[]
[]

[BCs]
[left]
type = DirichletBC
variable = u
boundary = left
value = 0
[]
[right]
type = DirichletBC
variable = u
boundary = right
value = 1
[]
[]

[Problem]
type = SlowProblem
seconds_to_sleep = 4
[]

[Executioner]
type = Steady
solve_type = 'PJFNK'
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]

[Outputs]
exodus = true
[]
11 changes: 11 additions & 0 deletions test/tests/utils/perf_graph_live_print/tests
@@ -0,0 +1,11 @@
[Tests]
[./test]
type = RunApp
input = perf_graph_live_print.i
expect_out = "Testing Slowness"

issues = '#15444'
design = 'utils/PerfGraph.md'
requirement = 'The system shall allow for timing sections of code and having automated print-outs when they take too long or use too much memory'
[../]
[]

0 comments on commit 7d7265d

Please sign in to comment.