PERF-2 P0: intra-step profiler — StepTimers on the overset solver (RTX_PROFILE; overlap build / predictors / patch BiCGSTAB / background Poisson with its setup-vs-iterate split / round exchange / apply / end exchange), PoissonSolution carries setup_ns and iterate_ns, the harness times advance / restore / snapshot / load sampling / force / FEA predictor and prints the wall split of the coupled phase; no clock is read when profiling is off; the reclassified/step progress denominator fixed (was ×4)
CI / Build (macos-latest) (push) Waiting to run
CI / Test (macos-latest) (push) Blocked by required conditions
CI / Test (ubuntu-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (macos-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (ubuntu-latest) (push) Blocked by required conditions
CI / WASM Build + Size Check (push) Blocked by required conditions
CI / Distributed Training Tests (push) Blocked by required conditions
CI / CI Success (push) Blocked by required conditions
CI / Format Check (push) Failing after 6s
CI / Build (ubuntu-latest) (push) Failing after 5s
CI / Clippy Check (push) Failing after 5s
Documentation / Build User Guide (push) Successful in 6s
Performance Benchmarks / Run Benchmarks (push) Failing after 27s
CI / Build CPU-Only (Explicit) (push) Failing after 1m24s
Documentation / Build API Documentation (push) Failing after 1m34s
CI / Build (macos-latest) (push) Waiting to run
CI / Test (macos-latest) (push) Blocked by required conditions
CI / Test (ubuntu-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (macos-latest) (push) Blocked by required conditions
CI / Python Bindings (maturin) (ubuntu-latest) (push) Blocked by required conditions
CI / WASM Build + Size Check (push) Blocked by required conditions
CI / Distributed Training Tests (push) Blocked by required conditions
CI / CI Success (push) Blocked by required conditions
CI / Format Check (push) Failing after 6s
CI / Build (ubuntu-latest) (push) Failing after 5s
CI / Clippy Check (push) Failing after 5s
Documentation / Build User Guide (push) Successful in 6s
Performance Benchmarks / Run Benchmarks (push) Failing after 27s
CI / Build CPU-Only (Explicit) (push) Failing after 1m24s
Documentation / Build API Documentation (push) Failing after 1m34s
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YJPeT6WA2e7YvAnS875AHL
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
2d2fed7181
commit
172a26dee4
@@ -218,6 +218,14 @@ pub struct OversetFluid {
|
||||
/// Patch regenerations and their wall time.
|
||||
pub regen_count: Cell<usize>,
|
||||
pub regen_seconds: Cell<f64>,
|
||||
/// PERF-2 P0 wall-time buckets [s]: the composite step (`advance`), the
|
||||
/// per-pass restore, the per-step snapshot, the load sampling and the
|
||||
/// force measurement (`docs/perf2_campaign.md`).
|
||||
pub t_advance: Cell<f64>,
|
||||
pub t_restore: Cell<f64>,
|
||||
pub t_snapshot: Cell<f64>,
|
||||
pub t_sample: Cell<f64>,
|
||||
pub t_force: Cell<f64>,
|
||||
/// Background cells reclassified, summed over every fluid step.
|
||||
pub reclassified_total: Cell<usize>,
|
||||
pub fresh_total: Cell<usize>,
|
||||
@@ -441,6 +449,11 @@ impl OversetFluid {
|
||||
sweeps,
|
||||
regen_count: Cell::new(0),
|
||||
regen_seconds: Cell::new(0.0),
|
||||
t_advance: Cell::new(0.0),
|
||||
t_restore: Cell::new(0.0),
|
||||
t_snapshot: Cell::new(0.0),
|
||||
t_sample: Cell::new(0.0),
|
||||
t_force: Cell::new(0.0),
|
||||
reclassified_total: Cell::new(0),
|
||||
fresh_total: Cell::new(0),
|
||||
rounds_total: Cell::new(0),
|
||||
@@ -895,6 +908,7 @@ impl OversetFluid {
|
||||
|
||||
/// One fluid step at the current wall.
|
||||
pub fn step(&mut self) -> CfdResult<OversetResult> {
|
||||
let t0 = std::time::Instant::now();
|
||||
let r = match futures::executor::block_on(
|
||||
self.solver.advance(&mut self.field, self.dt_fluid),
|
||||
) {
|
||||
@@ -919,6 +933,8 @@ impl OversetFluid {
|
||||
.set(self.rounds_total.get() + r.rounds.iter().sum::<usize>());
|
||||
self.correctors_total
|
||||
.set(self.correctors_total.get() + r.rounds.len());
|
||||
self.t_advance
|
||||
.set(self.t_advance.get() + t0.elapsed().as_secs_f64());
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
@@ -987,11 +1003,14 @@ impl OversetFluid {
|
||||
|
||||
/// Drag and lift on cylinder + flag from the patch's wall stress.
|
||||
pub fn measure_force(&self) -> (f64, f64) {
|
||||
let t0 = std::time::Instant::now();
|
||||
let f = self
|
||||
.solver
|
||||
.patch()
|
||||
.surface_force(&self.field.patch, PatchSide::Inner, self.solver.time())
|
||||
.total();
|
||||
self.t_force
|
||||
.set(self.t_force.get() + t0.elapsed().as_secs_f64());
|
||||
(f[0], f[1])
|
||||
}
|
||||
|
||||
@@ -1000,6 +1019,14 @@ impl OversetFluid {
|
||||
/// Faces on the cylinder proper are skipped; the fillets' load goes
|
||||
/// to the nearest (clamped) root nodes.
|
||||
pub fn sample_load(&self, d: &[f64]) -> (Vec<(NodeId, Vector3<f64>)>, f64, usize) {
|
||||
let t0 = std::time::Instant::now();
|
||||
let out = self.sample_load_inner(d);
|
||||
self.t_sample
|
||||
.set(self.t_sample.get() + t0.elapsed().as_secs_f64());
|
||||
out
|
||||
}
|
||||
|
||||
fn sample_load_inner(&self, d: &[f64]) -> (Vec<(NodeId, Vector3<f64>)>, f64, usize) {
|
||||
let mut faces = Vec::new();
|
||||
let mut tractions: Vec<Vector3<f64>> = Vec::new();
|
||||
for (centre, normal, len, traction) in self.solver.patch().wall_tractions(
|
||||
@@ -1117,12 +1144,63 @@ impl OversetFluid {
|
||||
}
|
||||
|
||||
pub fn snapshot(&self) -> (OversetSolverState, OversetField) {
|
||||
(self.solver.snapshot(), self.field.clone())
|
||||
let t0 = std::time::Instant::now();
|
||||
let out = (self.solver.snapshot(), self.field.clone());
|
||||
self.t_snapshot
|
||||
.set(self.t_snapshot.get() + t0.elapsed().as_secs_f64());
|
||||
out
|
||||
}
|
||||
|
||||
pub fn restore(&mut self, saved: &(OversetSolverState, OversetField)) {
|
||||
let t0 = std::time::Instant::now();
|
||||
self.solver.restore(&saved.0);
|
||||
self.field = saved.1.clone();
|
||||
self.t_restore
|
||||
.set(self.t_restore.get() + t0.elapsed().as_secs_f64());
|
||||
}
|
||||
|
||||
/// PERF-2 P0: the solver's own split of `advance` (when `RTX_PROFILE`
|
||||
/// is set) as one printable line, with the background Poisson's
|
||||
/// setup / iterate split.
|
||||
pub fn profile_line(&self) -> Option<String> {
|
||||
let t = self.solver.timers()?;
|
||||
let (ps, pi, pc) = self.solver.background().poisson_profile();
|
||||
let s = |ns: u64| ns as f64 * 1e-9;
|
||||
let adv = s(t.advance_ns).max(1e-300);
|
||||
let pct = |ns: u64| 100.0 * s(ns) / adv;
|
||||
Some(format!(
|
||||
" advance split over {} steps ({} rounds), {:.0} s: overlap build {:.0} s ({:.1}%), predictor bg {:.0} s ({:.1}%), predictor patch {:.0} s ({:.1}%), bg Poisson {:.0} s ({:.1}%) [setup {:.0} s, iterate {:.0} s, {} solves], patch BiCGSTAB {:.0} s ({:.1}%), round exchange {:.0} s ({:.1}%), apply {:.0} s ({:.1}%), end exchange {:.0} s ({:.1}%), other {:.0} s",
|
||||
t.steps,
|
||||
t.rounds,
|
||||
adv,
|
||||
s(t.overlap_build_ns),
|
||||
pct(t.overlap_build_ns),
|
||||
s(t.predictor_bg_ns),
|
||||
pct(t.predictor_bg_ns),
|
||||
s(t.predictor_patch_ns),
|
||||
pct(t.predictor_patch_ns),
|
||||
s(t.bg_solve_ns),
|
||||
pct(t.bg_solve_ns),
|
||||
s(ps),
|
||||
s(pi),
|
||||
pc,
|
||||
s(t.patch_solve_ns),
|
||||
pct(t.patch_solve_ns),
|
||||
s(t.round_exchange_ns),
|
||||
pct(t.round_exchange_ns),
|
||||
s(t.apply_ns),
|
||||
pct(t.apply_ns),
|
||||
s(t.end_exchange_ns),
|
||||
pct(t.end_exchange_ns),
|
||||
adv - s(t.overlap_build_ns
|
||||
+ t.predictor_bg_ns
|
||||
+ t.predictor_patch_ns
|
||||
+ t.bg_solve_ns
|
||||
+ t.patch_solve_ns
|
||||
+ t.round_exchange_ns
|
||||
+ t.apply_ns
|
||||
+ t.end_exchange_ns),
|
||||
))
|
||||
}
|
||||
|
||||
pub fn time(&self) -> f64 {
|
||||
|
||||
@@ -377,6 +377,8 @@ pub fn run_march_overset(case: BenchmarkCase, config: &OversetMarchConfig) -> Ov
|
||||
f
|
||||
});
|
||||
let (t_fluid, t_structure) = (std::cell::Cell::new(0.0_f64), std::cell::Cell::new(0.0_f64));
|
||||
// PERF-2 P0: the FEA predictor step (outside both buckets before).
|
||||
let t_predictor = std::cell::Cell::new(0.0_f64);
|
||||
let prev_area = std::cell::Cell::new(fluid.borrow().shared.read().unwrap().area());
|
||||
let save_from: f64 = std::env::var("RTX_FSI2O_SAVE_FROM")
|
||||
.ok()
|
||||
@@ -395,9 +397,11 @@ pub fn run_march_overset(case: BenchmarkCase, config: &OversetMarchConfig) -> Ov
|
||||
let v = extract_velocity(&flag_state);
|
||||
d_n.iter().zip(&v).map(|(d, v)| d + dt * v).collect()
|
||||
} else {
|
||||
let ps = std::time::Instant::now();
|
||||
flag.borrow_mut()
|
||||
.set_nodal_forces(&with_fict(&committed_nodal, &extract_accel(&flag_state)));
|
||||
let (predicted, _) = flag.borrow_mut().step(&flag_state).unwrap();
|
||||
t_predictor.set(t_predictor.get() + ps.elapsed().as_secs_f64());
|
||||
extract(&predicted)
|
||||
};
|
||||
if robin_alpha > 0.0 {
|
||||
@@ -582,7 +586,7 @@ pub fn run_march_overset(case: BenchmarkCase, config: &OversetMarchConfig) -> Ov
|
||||
total_subiterations as f64 / (step + 1) as f64,
|
||||
fl.rounds_total.get() as f64 / fl.correctors_total.get().max(1) as f64,
|
||||
fl.reclassified_total.get() as f64
|
||||
/ (rigid_steps + (step + 1) * cfg.subcycle * 4).max(1) as f64,
|
||||
/ (rigid_steps + (step + 1) * cfg.subcycle).max(1) as f64,
|
||||
fl.regen_seconds.get(),
|
||||
t_fluid.get(),
|
||||
phase_start.elapsed().as_secs_f64()
|
||||
@@ -590,6 +594,37 @@ pub fn run_march_overset(case: BenchmarkCase, config: &OversetMarchConfig) -> Ov
|
||||
}
|
||||
}
|
||||
let fl = fluid.borrow();
|
||||
// PERF-2 P0: the wall split of the coupled phase (every bucket the
|
||||
// harness can see; `other` is what none of them caught).
|
||||
{
|
||||
let wall = phase_start.elapsed().as_secs_f64().max(1e-300);
|
||||
let pct = |x: f64| 100.0 * x / wall;
|
||||
let (adv, res, snap, samp, force, regen) = (
|
||||
fl.t_advance.get(),
|
||||
fl.t_restore.get(),
|
||||
fl.t_snapshot.get(),
|
||||
fl.t_sample.get(),
|
||||
fl.t_force.get(),
|
||||
fl.regen_seconds.get(),
|
||||
);
|
||||
let (st, pr) = (t_structure.get(), t_predictor.get());
|
||||
let other = wall - (adv + res + snap + samp + force + regen + st + pr);
|
||||
println!(
|
||||
" wall split over the coupled phase ({wall:.0} s): fluid advance {adv:.0} s ({:.1}%), patch regeneration {regen:.0} s ({:.1}%), restore {res:.0} s ({:.1}%), snapshot {snap:.0} s ({:.1}%), load sampling {samp:.0} s ({:.1}%), force {force:.0} s ({:.1}%), structure {st:.0} s ({:.1}%), FEA predictor {pr:.0} s ({:.1}%), other {other:.0} s ({:.1}%)",
|
||||
pct(adv),
|
||||
pct(regen),
|
||||
pct(res),
|
||||
pct(snap),
|
||||
pct(samp),
|
||||
pct(force),
|
||||
pct(st),
|
||||
pct(pr),
|
||||
pct(other)
|
||||
);
|
||||
if let Some(line) = fl.profile_line() {
|
||||
println!("{line}");
|
||||
}
|
||||
}
|
||||
let final_state_finite = flag_state.displacement.iter().all(|v| v.is_finite());
|
||||
let steps_done = times.len();
|
||||
OversetMarchResult {
|
||||
|
||||
Reference in New Issue
Block a user