perf: grind uses minimum wall-clock per-stage time, not running-mean cpu_time#1650
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the simulation “grind” performance metric to use the minimum wall-clock time of a full TVD-RK stage (compute + comms + RK update + optional IBM correction), instead of a running mean of cpu_time measured only around s_compute_rhs. This better reflects end-to-end stage cost and is less sensitive to MPI host spin-wait and run-to-run jitter.
Changes:
- Move perf timing from
s_compute_rhsto the RK stage loop ins_tvd_rk, bracketing the full stage. - Switch from
cpu_timerunning mean tosystem_clockwall-clock timing and take the minimum over steady-state stages. - Simplify
s_compute_rhsby removing thetime_avgin/out timing parameter and internal timing logic.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/simulation/m_time_steppers.fpp |
Adds per-stage wall-clock timing in s_tvd_rk and updates time_avg as the timing floor after warmup. |
src/simulation/m_rhs.fpp |
Removes RHS-local cpu_time timing and the time_avg argument from s_compute_rhs. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1650 +/- ##
==========================================
- Coverage 60.95% 59.56% -1.39%
==========================================
Files 83 83
Lines 20003 21115 +1112
Branches 2983 3129 +146
==========================================
+ Hits 12193 12578 +385
- Misses 5782 6434 +652
- Partials 2028 2103 +75 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Brings up/mega up to date with MFlowCode/MFC master (9 commits), clearing the PR's merge-conflict state so CI can run. Conflicts resolved (all preserve both branches' intent): - m_rhs.fpp / m_time_steppers.fpp (master MFlowCode#1650, grind timing): master moved per-stage timing from a cpu_time running-mean in s_compute_rhs to a system_clock minimum in the stepper, and dropped time_avg from the s_compute_rhs signature. Kept up/mega's active_box + rank-timing; adopted master's timing. Reconciled the AMR advance chain: the fine advance runs inside the stepper's new per-stage bracket, so the now-dead time_avg pass-through (s_amr_fine_stage_advance / subtree / children / subcycle -> s_compute_rhs) is removed rather than threaded to the old signature. - m_mpi_common.fpp / post/m_start_up.fpp (master #597f3c5c4, chemistry temperature seam-ghost exchange): kept up/mega's chem_T_comm rename and the AMR condition (chem_params%diffusion .or. amr); master's broadening of the post_process branch to all chemistry was already present in up/mega, so the resolution is a superset of both. Verified on macOS/arm64 GNU+MPI (--test-all): AMR 54/54, restart-roundtrip 2/2, MPI-consistency 3/3, chemistry 13/13, and the restart-header fix (476AA3A4) all pass.
What
Change the
grindperformance metric (ns/gp/eq/rhs, printed asPerformance:and written totime_data.dat) from a running mean ofcpu_timeto the minimum wall-clock time of a full RK stage.The timer also moves from
s_compute_rhsto the stage loop ins_tvd_rk, so it now brackets the whole per-stage compute+communication — RHS + halo H2D/D2H copies + RK update + source terms + the IBM ghost-point correction — while still excluding file I/O.Why
The old metric was noisy and incomplete on multi-rank GPU runs:
cpu_timeis per-process CPU time. An MPI wait that busy-spins the host accumulates CPU time, so idle ranks look busy. At 8 ranks the reduction (maxval(proc_time)) then picks the rank that spun most, not the one that computed most. →system_clock(wall) measures real elapsed time.s == 1stage that carries any run-time-info/probe I/O.s_compute_rhs, so per-stage work outside it — most notably the IBM correction (s_ibm_correct_state) — was never counted. Theibmbenchmark's per-step cost was invisible togrind.Validation (amdflang 23.1.0, MI250X,
-n 8MPI, gbpp 2)Same binary, repeated runs:
cpu_time(igr)igr's run-to-run CV drops ~38%. (Residual spread is contention on a shared dev node; a dedicated CI node will be tighter.)
ibmnow produces a grind that includes the IBM correction.Notes for reviewers
grindvalues shift versus historical numbers by design.wall_time_avg) is intentionally left oncpu_time; it is cosmetic and separate from the perf gate.