Adding scripts, commands, and logging scaffolding
This commit is contained in:
51
scripts/00_env.sh
Normal file → Executable file
51
scripts/00_env.sh
Normal file → Executable file
@@ -1,21 +1,48 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
# source this from anywhere inside /home/carlos/projects/gem5
|
||||
|
||||
ROOT="/home/carlos/projects/gem5"
|
||||
export GEM5="$ROOT/build/ARM/gem5.opt"
|
||||
export CFG="$ROOT/scripts/hetero_big_little.py"
|
||||
export RUN="$ROOT/gem5-run"
|
||||
export OUTROOT="$ROOT/iot/results"
|
||||
export LOGROOT="$ROOT/iot/logs"
|
||||
IOT="$ROOT/iot"
|
||||
DATA="$ROOT/gem5-data" # persistent store (your symlink)
|
||||
RUN="$ROOT/gem5-run" # workloads
|
||||
CFG="$ROOT/scripts/hetero_big_little.py" # gem5 config script
|
||||
|
||||
mkdir -p "$OUTROOT" "$LOGROOT"
|
||||
# auto-detect gem5.opt (ARM or ARM64)
|
||||
if [ -x "$ROOT/build/ARM/gem5.opt" ]; then
|
||||
GEM5="$ROOT/build/ARM/gem5.opt"
|
||||
elif [ -x "$ROOT/gem5-build/ARM/gem5.opt" ]; then
|
||||
GEM5="$ROOT/gem5-build/ARM/gem5.opt"
|
||||
elif [ -x "$ROOT/gem5-build/ARM64/gem5.opt" ]; then
|
||||
GEM5="$ROOT/gem5-build/ARM64/gem5.opt"
|
||||
else
|
||||
echo "[env] gem5.opt not found. Build it with:"
|
||||
echo " scons build/ARM/gem5.opt -j\$(nproc)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# record environment (append-only)
|
||||
# primary outputs in gem5-data, mirrored into iot/
|
||||
OUT_DATA="$DATA/SmartEdgeAI/results"
|
||||
LOG_DATA="$DATA/SmartEdgeAI/logs"
|
||||
OUT_IOT="$IOT/results"
|
||||
LOG_IOT="$IOT/logs"
|
||||
|
||||
# ensure directories
|
||||
mkdir -p "$OUT_DATA" "$LOG_DATA" "$OUT_IOT" "$LOG_IOT"
|
||||
|
||||
# export for child scripts
|
||||
export ROOT IOT DATA RUN CFG GEM5 OUT_DATA LOG_DATA OUT_IOT LOG_IOT
|
||||
|
||||
# minimal env log
|
||||
{
|
||||
echo "==== uname ===="; uname -a
|
||||
echo; echo "==== date ===="; date
|
||||
echo; echo "==== gem5 git ===="; (git -C "$ROOT/gem5src" rev-parse --short HEAD 2>/dev/null || echo n/a)
|
||||
} >> "$LOGROOT/env.txt"
|
||||
echo "==== env ===="
|
||||
echo "ROOT=$ROOT"
|
||||
echo "GEM5=$GEM5"
|
||||
echo "CFG=$CFG"
|
||||
echo "RUN=$RUN"
|
||||
echo "OUT_DATA=$OUT_DATA"
|
||||
echo "LOG_DATA=$LOG_DATA"
|
||||
date
|
||||
} >> "$LOG_IOT/env.txt"
|
||||
|
||||
echo "[env] READY"
|
||||
|
||||
|
||||
4
scripts/01_build_gem5.sh
Executable file
4
scripts/01_build_gem5.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
cd /home/carlos/projects/gem5
|
||||
scons build/ARM/gem5.opt -j"$(nproc)"
|
||||
21
scripts/10_run_one.sh
Normal file → Executable file
21
scripts/10_run_one.sh
Normal file → Executable file
@@ -1,17 +1,18 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
source "$(dirname "$0")/00_env.sh"
|
||||
. "$(dirname "$0")/env.sh"
|
||||
|
||||
if [[ $# -lt 5 ]]; then
|
||||
if [ $# -lt 5 ]; then
|
||||
echo "Usage: $0 <workload:{tinyml_kws|sensor_fusion|aes_ccm|attention_kernel}> <core:{big|little|hybrid}> <dvfs:{high|low}> <drowsy:{0|1}> <l2:{512kB|1MB}> [mem=16GB]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
W=$1; CORE=$2; DV=$3; DROWSY=$4; L2=$5; MEM=${6:-16GB}
|
||||
OUT="$OUTROOT/${W}_${CORE}_${DV}_l2${L2}_d${DROWSY}"
|
||||
TAG="${W}_${CORE}_${DV}_l2${L2}_d${DROWSY}"
|
||||
OUTDIR="$OUT_DATA/$TAG"
|
||||
|
||||
mkdir -p "$OUT"
|
||||
echo "[run_one] $W $CORE $DV L2=$L2 drowsy=$DROWSY mem=$MEM -> $OUT"
|
||||
mkdir -p "$OUTDIR"
|
||||
echo "[run_one] $TAG mem=$MEM -> $OUTDIR"
|
||||
|
||||
"$GEM5" "$CFG" \
|
||||
--cmd="$RUN/$W" \
|
||||
@@ -19,9 +20,13 @@ echo "[run_one] $W $CORE $DV L2=$L2 drowsy=$DROWSY mem=$MEM -> $OUT"
|
||||
--dvfs="$DV" \
|
||||
--drowsy="$DROWSY" \
|
||||
--l2="$L2" \
|
||||
--outdir="$OUT" \
|
||||
> "$LOGROOT/${W}_${CORE}_${DV}_l2${L2}_d${DROWSY}.stdout.log" \
|
||||
2> "$LOGROOT/${W}_${CORE}_${DV}_l2${L2}_d${DROWSY}.stderr.log"
|
||||
--outdir="$OUTDIR" \
|
||||
> "$LOG_DATA/${TAG}.stdout.log" \
|
||||
2> "$LOG_DATA/${TAG}.stderr.log"
|
||||
|
||||
# mirror to repo (iot/)
|
||||
rsync -a --delete "$OUTDIR/" "$OUT_IOT/$TAG/"
|
||||
rsync -a "$LOG_DATA/${TAG}."* "$LOG_IOT/" 2>/dev/null || true
|
||||
|
||||
echo "[run_one] DONE"
|
||||
|
||||
|
||||
23
scripts/11_run_all.sh
Executable file
23
scripts/11_run_all.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
. "$(dirname "$0")/env.sh"
|
||||
|
||||
run_case () {
|
||||
W=$1; CORE=$2; DV=$3; D=$4; L2=$5
|
||||
sh "$(dirname "$0")/run_one.sh" "$W" "$CORE" "$DV" "$D" "$L2" 16GB
|
||||
}
|
||||
|
||||
for W in tinyml_kws sensor_fusion aes_ccm attention_kernel; do
|
||||
for DV in high low; do
|
||||
for D in 0 1; do
|
||||
for L2 in 512kB 1MB; do
|
||||
run_case "$W" big "$DV" "$D" "$L2"
|
||||
run_case "$W" little "$DV" "$D" "$L2"
|
||||
run_case "$W" hybrid "$DV" "$D" "$L2"
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
echo "[run_all] ALL DONE"
|
||||
|
||||
0
scripts/20_sweep.sh
Normal file → Executable file
0
scripts/20_sweep.sh
Normal file → Executable file
16
scripts/30_extract_csv.sh
Normal file → Executable file
16
scripts/30_extract_csv.sh
Normal file → Executable file
@@ -1,12 +1,13 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
source "$(dirname "$0")/00_env.sh"
|
||||
. "$(dirname "$0")/env.sh"
|
||||
|
||||
CSV="$OUTROOT/phase3_summary.csv"
|
||||
echo "workload,core,dvfs,l2,drowsy,sim_seconds,ipc,cycles,insts,l2_miss_rate" > "$CSV"
|
||||
CSV_DATA="$OUT_DATA/summary.csv"
|
||||
CSV_IOT="$OUT_IOT/summary.csv"
|
||||
echo "workload,core,dvfs,l2,drowsy,sim_seconds,ipc,cycles,insts,l2_miss_rate" > "$CSV_DATA"
|
||||
|
||||
for d in "$OUTROOT"/*; do
|
||||
[[ -d "$d" ]] || continue
|
||||
for d in "$OUT_DATA"/*; do
|
||||
[ -d "$d" ] || continue
|
||||
base=$(basename "$d")
|
||||
W=$(echo "$base" | cut -d'_' -f1)
|
||||
CORE=$(echo "$base" | cut -d'_' -f2)
|
||||
@@ -21,8 +22,9 @@ for d in "$OUTROOT"/*; do
|
||||
INST=$(awk '/^system\.cpu\.commit\.committedInsts|^system\.cpu0\.commit\.committedInsts/ {print $2}' "$S" | head -n1)
|
||||
L2MR=$(awk '/^system\.l2\.overall_miss_rate::total/ {print $2}' "$S")
|
||||
|
||||
echo "$W,$CORE,$DVFS,$L2,$DROW,$SIMS,$IPC,$CYC,$INST,$L2MR" >> "$CSV"
|
||||
echo "$W,$CORE,$DVFS,$L2,$DROW,$SIMS,$IPC,$CYC,$INST,$L2MR" >> "$CSV_DATA"
|
||||
done
|
||||
|
||||
echo "[extract] wrote $CSV"
|
||||
cp "$CSV_DATA" "$CSV_IOT"
|
||||
echo "[extract] wrote $CSV_DATA and mirrored to $CSV_IOT"
|
||||
|
||||
|
||||
60
scripts/40_energy_post.py
Normal file → Executable file
60
scripts/40_energy_post.py
Normal file → Executable 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}")
|
||||
|
||||
|
||||
20
scripts/50_plot_epi.py
Normal file → Executable file
20
scripts/50_plot_epi.py
Normal file → Executable file
@@ -1,13 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
import csv, os
|
||||
import os, csv
|
||||
import matplotlib.pyplot as plt
|
||||
from collections import defaultdict
|
||||
|
||||
root = os.path.dirname(os.path.dirname(__file__))
|
||||
src = os.path.join(root, "results", "phase3_summary_energy.csv")
|
||||
out = os.path.join(root, "results", "fig_epi_across_workloads.png")
|
||||
ROOT="/home/carlos/projects/gem5"
|
||||
OUT_DATA=os.path.join(ROOT,"gem5-data","SmartEdgeAI","results")
|
||||
OUT_IOT =os.path.join(ROOT,"iot","results")
|
||||
src=os.path.join(OUT_DATA,"summary_energy.csv")
|
||||
out_data=os.path.join(OUT_DATA,"fig_epi_across_workloads.png")
|
||||
out_iot =os.path.join(OUT_IOT ,"fig_epi_across_workloads.png")
|
||||
|
||||
epi_by_core = defaultdict(list)
|
||||
epi_by_core=defaultdict(list)
|
||||
with open(src) as f:
|
||||
r=csv.DictReader(f)
|
||||
for row in r:
|
||||
@@ -21,8 +24,7 @@ vals=[sum(epi_by_core[c])/max(1,len(epi_by_core[c])) for c in cores]
|
||||
plt.figure()
|
||||
plt.bar(cores, vals)
|
||||
plt.ylabel('EPI (pJ/inst)')
|
||||
plt.title('Energy per Instruction across Workloads (avg by core mode)')
|
||||
plt.tight_layout()
|
||||
plt.savefig(out)
|
||||
print(f"[plot] wrote {out}")
|
||||
plt.title('Energy per Instruction across workloads (avg by core mode)')
|
||||
plt.tight_layout(); plt.savefig(out_data); plt.savefig(out_iot)
|
||||
print(f"[plot] wrote {out_data} and mirrored to {out_iot}")
|
||||
|
||||
|
||||
16
scripts/51_plot_edp_tinyml.py
Normal file → Executable file
16
scripts/51_plot_edp_tinyml.py
Normal file → Executable file
@@ -1,10 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
import csv, os
|
||||
import os, csv
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
root = os.path.dirname(os.path.dirname(__file__))
|
||||
src = os.path.join(root, "results", "phase3_summary_energy.csv")
|
||||
out = os.path.join(root, "results", "fig_tinyml_edp.png")
|
||||
ROOT="/home/carlos/projects/gem5"
|
||||
OUT_DATA=os.path.join(ROOT,"gem5-data","SmartEdgeAI","results")
|
||||
OUT_IOT =os.path.join(ROOT,"iot","results")
|
||||
src=os.path.join(OUT_DATA,"summary_energy.csv")
|
||||
out_data=os.path.join(OUT_DATA,"fig_tinyml_edp.png")
|
||||
out_iot =os.path.join(OUT_IOT ,"fig_tinyml_edp.png")
|
||||
|
||||
labels=[]; edps=[]
|
||||
with open(src) as f:
|
||||
@@ -19,7 +22,6 @@ plt.bar(labels, edps)
|
||||
plt.ylabel('EDP (J·s)')
|
||||
plt.title('TinyML: EDP by configuration')
|
||||
plt.xticks(rotation=60, ha='right')
|
||||
plt.tight_layout()
|
||||
plt.savefig(out)
|
||||
print(f"[plot] wrote {out}")
|
||||
plt.tight_layout(); plt.savefig(out_data); plt.savefig(out_iot)
|
||||
print(f"[plot] wrote {out_data} and mirrored to {out_iot}")
|
||||
|
||||
|
||||
38
scripts/60_bundle_logs.sh
Normal file → Executable file
38
scripts/60_bundle_logs.sh
Normal file → Executable file
@@ -1,23 +1,29 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
source "$(dirname "$0")/00_env.sh"
|
||||
. "$(dirname "$0")/env.sh"
|
||||
|
||||
# terminal excerpts
|
||||
: > "$LOGROOT/TERMINAL_EXCERPTS.txt"
|
||||
for f in "$LOGROOT"/*.stdout.log; do
|
||||
echo "===== $(basename "$f") =====" >> "$LOGROOT/TERMINAL_EXCERPTS.txt"
|
||||
(head -n 20 "$f"; echo "..."; tail -n 20 "$f") >> "$LOGROOT/TERMINAL_EXCERPTS.txt"
|
||||
echo >> "$LOGROOT/TERMINAL_EXCERPTS.txt"
|
||||
TE="$LOG_DATA/TERMINAL_EXCERPTS.txt"
|
||||
SE="$LOG_DATA/STATS_EXCERPTS.txt"
|
||||
: > "$TE"; : > "$SE"
|
||||
|
||||
for f in "$LOG_DATA"/*.stdout.log; do
|
||||
[ -f "$f" ] || continue
|
||||
echo "===== $(basename "$f") =====" >> "$TE"
|
||||
(head -n 20 "$f"; echo "..."; tail -n 20 "$f") >> "$TE"
|
||||
echo >> "$TE"
|
||||
done
|
||||
echo "[bundle] wrote $LOGROOT/TERMINAL_EXCERPTS.txt"
|
||||
|
||||
# stats excerpts
|
||||
: > "$LOGROOT/STATS_EXCERPTS.txt"
|
||||
for d in "$OUTROOT"/*; do
|
||||
[[ -d "$d" ]] || continue
|
||||
echo "===== $(basename "$d") =====" >> "$LOGROOT/STATS_EXCERPTS.txt"
|
||||
awk '/^sim_seconds|^system\.cpu\.ipc|^system\.cpu0\.ipc|^system\.cpu\.numCycles|^system\.cpu0\.numCycles|^system\.cpu\.commit\.committedInsts|^system\.cpu0\.commit\.committedInsts|^system\.l2\.overall_miss_rate::total/' "$d/stats.txt" >> "$LOGROOT/STATS_EXCERPTS.txt"
|
||||
echo >> "$LOGROOT/STATS_EXCERPTS.txt"
|
||||
for d in "$OUT_DATA"/*; do
|
||||
[ -d "$d" ] || continue
|
||||
S="$d/stats.txt"
|
||||
[ -f "$S" ] || continue
|
||||
echo "===== $(basename "$d") =====" >> "$SE"
|
||||
awk '/^sim_seconds|^system\.cpu\.ipc|^system\.cpu0\.ipc|^system\.cpu\.numCycles|^system\.cpu0\.numCycles|^system\.cpu\.commit\.committedInsts|^system\.cpu0\.commit\.committedInsts|^system\.l2\.overall_miss_rate::total/' "$S" >> "$SE"
|
||||
echo >> "$SE"
|
||||
done
|
||||
echo "[bundle] wrote $LOGROOT/STATS_EXCERPTS.txt"
|
||||
|
||||
# mirror to repo
|
||||
cp "$TE" "$LOG_IOT/TERMINAL_EXCERPTS.txt"
|
||||
cp "$SE" "$LOG_IOT/STATS_EXCERPTS.txt"
|
||||
echo "[bundle] wrote $TE and $SE (mirrored into iot/logs)"
|
||||
|
||||
|
||||
8
scripts/61_tinyml_kws.sh
Executable file
8
scripts/61_tinyml_kws.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
cat > /home/carlos/projects/gem5/gem5-run/tinyml_kws << 'SH'
|
||||
#!/bin/bash
|
||||
# placeholder workload; swap later for your real binary
|
||||
for i in $(seq 1 2000000); do :; done
|
||||
echo "tinyml_kws: done"
|
||||
SH
|
||||
chmod +x /home/carlos/projects/gem5/gem5-run/tinyml_kws
|
||||
|
||||
0
scripts/70_diff_table.py
Normal file → Executable file
0
scripts/70_diff_table.py
Normal file → Executable file
Reference in New Issue
Block a user