hardware-counters
physics.py
"""
Is there a simple physical law connecting rank-0 counters to wall time?
CrayPat reports counters for rank 0 only. For a perfectly load-balanced job
every rank does the same work, so rank-0 cycles / clock should approximate
wall time regardless of rank count -- unless the rank spends time waiting
(MPI, imbalance) or the clock is not at peak.
"""
import pandas as pd, numpy as np
pd.set_option("display.width", 250)
D = "/work/project/project/user"
df = pd.read_csv(f"{D}/data/runs.csv")
df = df[(df.app != "cp2k") & df.runtime_s.notna()].reset_index(drop=True)
w = [c for c in ["wall_B","wall_C","wall_D","wall_E"] if c in df]
y = df[w].median(axis=1).fillna(df.runtime_s)
cyc = df.PAPI_TOT_CYC
ins = df.PAPI_TOT_INS
print("=== candidate predictors vs actual runtime (log-log correlation) ===")
cands = {
"cycles": cyc,
"cycles/2.25GHz": cyc / 2.25e9,
"instructions": ins,
"cycles*ncore": cyc * df.ncore,
"cycles/ncore": cyc / df.ncore,
"energy(PACKAGE)": df.PACKAGE_ENERGY,
"energy*ncore": df.PACKAGE_ENERGY * df.ncore,
}
for k, v in cands.items():
v = pd.to_numeric(v, errors="coerce")
ok = v.notna() & (v > 0)
r = np.corrcoef(np.log10(v[ok]), np.log10(y[ok]))[0, 1]
print(f" {k:22s} log-log r = {r:+.3f} (n={ok.sum()})")
print("\n=== effective clock rate implied by cycles/runtime ===")
eff = (cyc / y / 1e9)
print(pd.DataFrame({"app": df.app, "ncore": df.ncore,
"GHz_implied": eff.round(2)})
.pivot(index="ncore", columns="app", values="GHz_implied").to_string())
print("\nNominal peak = 2.25 GHz. Values far below peak mean rank 0 was")
print("stalled/waiting; values are stable per app but vary strongly with")
print("core count for the memory-bound codes.")