Adding scripts, commands, and logging scaffolding

This commit is contained in:
Carlos Gutierrez
2025-10-05 01:59:00 +00:00
parent f1debadbb3
commit 1d39c0cbd7
15 changed files with 193 additions and 89 deletions

60
scripts/40_energy_post.py Normal file → Executable file
View File

@@ -1,48 +1,48 @@
#!/usr/bin/env python3
import csv, sys, os
import csv, os, sys
root = os.path.dirname(os.path.dirname(__file__))
src = os.path.join(root, "results", "phase3_summary.csv")
dst = os.path.join(root, "results", "phase3_summary_energy.csv")
ROOT = "/home/carlos/projects/gem5"
OUT_DATA = os.path.join(ROOT, "gem5-data", "SmartEdgeAI", "results")
OUT_IOT = os.path.join(ROOT, "iot", "results")
# === your modeling constants (document in Methods) ===
EPI_PJ = {'big': 200.0, 'little': 80.0, 'hybrid': 104.0} # pJ/inst
E_MEM_PJ = 600.0 # pJ per L2 miss
DROWSY_SCALE = 0.85 # 15% energy reduction when drowsy=1
src = os.path.join(OUT_DATA, "summary.csv")
dst_data = os.path.join(OUT_DATA, "summary_energy.csv")
dst_iot = os.path.join(OUT_IOT, "summary_energy.csv")
# modeling constants (document in your Methods)
EPI_PJ = {'big':200.0,'little':80.0,'hybrid':104.0} # pJ/inst
E_MEM_PJ = 600.0 # pJ per L2 miss
DROWSY_SCALE = 0.85 # 15% energy drop when drowsy=1
rows=[]
with open(src) as f:
r=csv.DictReader(f)
for row in r:
insts = float(row['insts'])
secs = float(row['sim_seconds'])
core = row['core']
drowsy= int(row['drowsy'])
epi_pJ= EPI_PJ.get(core, EPI_PJ['little'])
insts=float(row['insts'])
secs=float(row['sim_seconds'])
core=row['core']; drowsy=int(row['drowsy'])
epi=EPI_PJ.get(core, EPI_PJ['little'])
mr=float(row['l2_miss_rate']) if row['l2_miss_rate'] else 0.0
mr = float(row['l2_miss_rate']) if row['l2_miss_rate'] else 0.0
l2_misses = mr * insts # proxy; replace with MPKI-based calc if available
energy_instr = (epi_pJ * 1e-12) * insts
energy_mem = (E_MEM_PJ * 1e-12) * l2_misses
energy_J = energy_instr + energy_mem
if drowsy == 1:
l2_misses = mr * insts
energy_J = (epi*1e-12)*insts + (E_MEM_PJ*1e-12)*l2_misses
if drowsy==1:
energy_J *= DROWSY_SCALE
power_W = energy_J / secs if secs > 0 else 0.0
edp = energy_J * secs # CORRECT EDP
power_W = energy_J/secs if secs>0 else 0.0
edp = energy_J * secs # J*s
row.update({
'energy_J': f"{energy_J:.6f}",
'power_W': f"{power_W:.6f}",
'edp': f"{edp:.6e}",
'epi_model_pJ': f"{epi_pJ:.1f}",
'power_W': f"{power_W:.6f}",
'edp': f"{edp:.6e}",
'epi_model_pJ': f"{epi:.1f}",
})
rows.append(row)
with open(dst, 'w', newline='') as f:
w=csv.DictWriter(f, fieldnames=list(rows[0].keys()))
w.writeheader(); w.writerows(rows)
print(f"[energy] wrote {dst}")
for path in (dst_data, dst_iot):
with open(path, 'w', newline='') as f:
w=csv.DictWriter(f, fieldnames=list(rows[0].keys()))
w.writeheader(); w.writerows(rows)
print(f"[energy] wrote {dst_data} and mirrored to {dst_iot}")