From 0e5f621c87fe6db40466850a8891225953f72138 Mon Sep 17 00:00:00 2001 From: Daniel Schwen Date: Fri, 7 Sep 2018 10:22:17 -0400 Subject: [PATCH] Use PerfGraph for profiling (#353) --- include/userobjects/MyTRIMDiracRun.h | 5 +++++ include/userobjects/MyTRIMElementRun.h | 5 +++++ include/userobjects/MyTRIMRasterizer.h | 3 +++ src/userobjects/MyTRIMDiracRun.C | 17 +++++++++++++---- src/userobjects/MyTRIMElementRun.C | 15 ++++++++++----- src/userobjects/MyTRIMRasterizer.C | 5 ++++- 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/include/userobjects/MyTRIMDiracRun.h b/include/userobjects/MyTRIMDiracRun.h index eeb25087..42c7cd9b 100644 --- a/include/userobjects/MyTRIMDiracRun.h +++ b/include/userobjects/MyTRIMDiracRun.h @@ -46,6 +46,11 @@ class MyTRIMDiracRun : public MyTRIMRunBase /// data such as interstitials and vacancies produced will be stored here MyTRIMResultList _result_list; + + ///@{ timers + PerfID _perf_trim; + PerfID _perf_finalize; + ///@} }; #endif // MYTRIMDIRACRUN_H diff --git a/include/userobjects/MyTRIMElementRun.h b/include/userobjects/MyTRIMElementRun.h index 3ed6a6f0..c8e88a8a 100644 --- a/include/userobjects/MyTRIMElementRun.h +++ b/include/userobjects/MyTRIMElementRun.h @@ -46,6 +46,11 @@ class MyTRIMElementRun : public MyTRIMRunBase /// data such as interstitials and vacancies produced will be stored here MyTRIMResultMap _result_map; + ///@{ timers + PerfID _perf_trim; + PerfID _perf_finalize; + ///@} + private: /// zero result to return for elements that have not been touched by the cascades MyTRIMResult _zero; diff --git a/include/userobjects/MyTRIMRasterizer.h b/include/userobjects/MyTRIMRasterizer.h index 727af017..a13987d8 100644 --- a/include/userobjects/MyTRIMRasterizer.h +++ b/include/userobjects/MyTRIMRasterizer.h @@ -198,6 +198,9 @@ class MyTRIMRasterizer : public ElementUserObject private: bool _execute_this_timestep; + + /// timers + PerfID _perf_finalize; }; #endif // MYTRIMRASTERIZER_H diff --git a/src/userobjects/MyTRIMDiracRun.C b/src/userobjects/MyTRIMDiracRun.C index a7094976..946764a9 100644 --- a/src/userobjects/MyTRIMDiracRun.C +++ b/src/userobjects/MyTRIMDiracRun.C @@ -27,7 +27,10 @@ validParams() return params; } -MyTRIMDiracRun::MyTRIMDiracRun(const InputParameters & parameters) : MyTRIMRunBase(parameters) +MyTRIMDiracRun::MyTRIMDiracRun(const InputParameters & parameters) + : MyTRIMRunBase(parameters), + _perf_trim(registerTimedSection("trim", 2)), + _perf_finalize(registerTimedSection("finalize", 2)) { if (_trim_parameters.desired_npka != 0) mooseError("Result scaling not supported in MyTRIMDiracRun"); @@ -52,9 +55,10 @@ MyTRIMDiracRun::execute() _console << "\nMyTRIM: Running " << _trim_parameters.original_npka << " recoils." << std::endl; // run threads - Moose::perf_log.push("MyTRIMRecoilLoop", "Solve"); - Threads::parallel_reduce(PKARange(_pka_list.begin(), _pka_list.end()), rl); - Moose::perf_log.pop("MyTRIMRecoilLoop", "Solve"); + { + TIME_SECTION(_perf_trim); + Threads::parallel_reduce(PKARange(_pka_list.begin(), _pka_list.end()), rl); + } // fetch the joined data from thread 0 _result_list = rl.getResultList(); @@ -63,6 +67,11 @@ MyTRIMDiracRun::execute() void MyTRIMDiracRun::finalize() { + TIME_SECTION(_perf_finalize); + + if (!_rasterizer.executeThisTimestep()) + return; + // for single processor runs we do not need to do anything here if (_app.n_processors() == 1) return; diff --git a/src/userobjects/MyTRIMElementRun.C b/src/userobjects/MyTRIMElementRun.C index e8917604..93121cd3 100644 --- a/src/userobjects/MyTRIMElementRun.C +++ b/src/userobjects/MyTRIMElementRun.C @@ -29,7 +29,10 @@ validParams() } MyTRIMElementRun::MyTRIMElementRun(const InputParameters & parameters) - : MyTRIMRunBase(parameters), _zero(_nvars) + : MyTRIMRunBase(parameters), + _perf_trim(registerTimedSection("trim", 2)), + _perf_finalize(registerTimedSection("finalize", 2)), + _zero(_nvars) { } @@ -55,10 +58,10 @@ MyTRIMElementRun::execute() << "Result scaling factor: " << _trim_parameters.result_scaling_factor << std::endl; // run threads - Moose::perf_log.push("MyTRIMRecoilLoop", "Solve"); - Threads::parallel_reduce(PKARange(_pka_list.begin(), _pka_list.end()), rl); - - Moose::perf_log.pop("MyTRIMRecoilLoop", "Solve"); + { + TIME_SECTION(_perf_trim); + Threads::parallel_reduce(PKARange(_pka_list.begin(), _pka_list.end()), rl); + } // fetch the joined data from thread 0 _result_map = rl.getResultMap(); @@ -67,6 +70,8 @@ MyTRIMElementRun::execute() void MyTRIMElementRun::finalize() { + TIME_SECTION(_perf_finalize); + if (!_rasterizer.executeThisTimestep()) return; diff --git a/src/userobjects/MyTRIMRasterizer.C b/src/userobjects/MyTRIMRasterizer.C index 552cb4d2..96c6a288 100644 --- a/src/userobjects/MyTRIMRasterizer.C +++ b/src/userobjects/MyTRIMRasterizer.C @@ -144,7 +144,8 @@ MyTRIMRasterizer::MyTRIMRasterizer(const InputParameters & parameters) _periodic(isCoupled("periodic_var") ? coupled("periodic_var", 0) : coupled("var", 0)), _accumulated_time(0.0), _accumulated_time_old(0.0), - _interval(getParam("interval")) + _interval(getParam("interval")), + _perf_finalize(registerTimedSection("finalize", 2)) { if (_nvars == 0) mooseError("Must couple variables to MyTRIMRasterizer."); @@ -370,6 +371,8 @@ MyTRIMRasterizer::threadJoin(const UserObject & y) void MyTRIMRasterizer::finalize() { + TIME_SECTION(_perf_finalize); + // save the accumulated time so that we can properly roll back if the step does not converge _accumulated_time_old = _accumulated_time;