Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 7c2400a

Browse files
authored
wave equation: print timings for each iteration block (#31)
The block timing includes n iterations plus the subsequent reductions for the diagnostic outputs.
1 parent a9e570b commit 7c2400a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

examples/wave_equation.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,26 @@ def step(u, v, e, u1, v1, e1, u2, v2, e2):
220220
u_max = float(np.max(u, all_axes))
221221

222222
total_v = float(np.sum(e + h, all_axes)) * dx * dy
223-
if initial_v is None:
223+
if i_export == 0:
224224
initial_v = total_v
225+
tcpu_str = ""
226+
else:
227+
block_duration = time_mod.perf_counter() - block_tic
228+
tcpu_str = f"Tcpu={block_duration:.3} s"
229+
225230
diff_v = total_v - initial_v
226231

227232
info(
228233
f"{i_export:2d} {i:4d} {t:.3f} elev={elev_max:7.5f} "
229-
f"u={u_max:7.5f} dV={diff_v: 6.3e}"
234+
f"u={u_max:7.5f} dV={diff_v: 6.3e} " + tcpu_str
230235
)
231236
if elev_max > 1e3 or not math.isfinite(elev_max):
232237
info(f"Invalid elevation value: {elev_max}")
233238
break
234239
i_export += 1
235240
next_t_export = i_export * t_export
236241
sync()
242+
block_tic = time_mod.perf_counter()
237243

238244
step(u, v, e, u1, v1, e1, u2, v2, e2)
239245

0 commit comments

Comments
 (0)