This commit is contained in:
Carlos Gutierrez
2025-10-04 23:48:44 -04:00
parent 74bb5d9dba
commit 23364fa1f1
5 changed files with 134 additions and 14 deletions

View File

@@ -2,8 +2,40 @@
This repo holds **all scripts, commands, and logs** for Phase 3.
## Prerequisites
### Install gem5
Before running any simulations, you need to install and build gem5:
```bash
# Clone gem5 repository
git clone https://github.com/gem5/gem5.git /home/carlos/projects/gem5/gem5src/gem5
# Build gem5 for ARM
cd /home/carlos/projects/gem5/gem5src/gem5
scons build/ARM/gem5.opt -j$(nproc)
# Verify installation
sh scripts/check_gem5.sh
```
### Install ARM Cross-Compiler
```bash
# Ubuntu/Debian
sudo apt-get install gcc-arm-linux-gnueabihf
# macOS (if using Homebrew)
brew install gcc-arm-linux-gnueabihf
```
## Order of operations
### 0. Check Prerequisites
```bash
sh scripts/check_gem5.sh
```
**Check logs**: Should show "✓ All checks passed!" or installation instructions
### 1. Setup Environment
```bash
sh scripts/env.sh
@@ -94,8 +126,35 @@ head -5 results/phase3_drowsy_deltas.csv
- **Logs**: `/home/carlos/projects/gem5/gem5-data/SmartEdgeAI/logs/` (mirrored to `logs/`)
## Troubleshooting
- **Empty stats.txt**: Check gem5 simulation logs for errors
- **Missing binaries**: Re-run `scripts/build_workloads.sh`
- **Permission errors**: Ensure scripts are executable: `chmod +x scripts/*.sh`
- **Path issues**: Verify `ROOT` variable in `scripts/env.sh` points to correct gem5 installation
### Common Issues
**Empty stats.txt files (0 bytes)**
- **Cause**: gem5 binary doesn't exist or simulation failed
- **Solution**: Run `sh scripts/check_gem5.sh` and install gem5 if needed
- **Check**: `ls -la /home/carlos/projects/gem5/build/ARM/gem5.opt`
**CSV extraction shows empty values**
- **Cause**: Simulation didn't run, so no statistics were generated
- **Solution**: Fix gem5 installation first, then re-run simulations
**"ModuleNotFoundError: No module named 'matplotlib'"**
- **Solution**: Install matplotlib: `pip install matplotlib` or `sudo apt-get install python3-matplotlib`
**"ValueError: could not convert string to float: ''"**
- **Cause**: Empty CSV values from failed simulations
- **Solution**: Fixed in updated scripts - they now handle empty values gracefully
**Permission errors**
- **Solution**: Make scripts executable: `chmod +x scripts/*.sh`
**Path issues**
- **Solution**: Verify `ROOT` variable in `scripts/env.sh` points to correct gem5 installation
### Debugging Steps
1. **Check gem5 installation**: `sh scripts/check_gem5.sh`
2. **Verify workload binaries**: `ls -la /home/carlos/projects/gem5/gem5-run/`
3. **Test single simulation**: `sh scripts/run_one.sh tinyml_kws big high 0 1MB`
4. **Check simulation logs**: `cat logs/tinyml_kws_big_high_l21MB_d0.stdout.log`
5. **Verify stats output**: `ls -l /home/carlos/projects/gem5/gem5-data/SmartEdgeAI/results/tinyml_kws_big_high_l21MB_d0/stats.txt`

47
scripts/check_gem5.sh Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
set -eu
. "$(dirname "$0")/env.sh"
echo "[check_gem5] Checking gem5 installation..."
# Check if gem5 binary exists
if [ ! -x "$GEM5_BIN" ]; then
echo "[check_gem5] ERROR: gem5 binary not found at $GEM5_BIN"
echo "[check_gem5] You need to install and build gem5 first."
echo ""
echo "To install gem5:"
echo "1. Clone gem5 repository:"
echo " git clone https://github.com/gem5/gem5.git $ROOT/gem5src/gem5"
echo ""
echo "2. Build gem5 for ARM:"
echo " cd $ROOT/gem5src/gem5"
echo " scons build/ARM/gem5.opt -j\$(nproc)"
echo ""
echo "3. Verify the binary exists:"
echo " ls -la $GEM5_BIN"
echo ""
echo "Alternative: Install gem5 via package manager:"
echo " sudo apt-get install gem5 # Ubuntu/Debian"
echo " brew install gem5 # macOS"
exit 1
fi
echo "[check_gem5] ✓ gem5 binary found at $GEM5_BIN"
# Check if gem5 runs
if ! "$GEM5_BIN" --version >/dev/null 2>&1; then
echo "[check_gem5] ERROR: gem5 binary exists but cannot run"
echo "[check_gem5] Try running: $GEM5_BIN --version"
exit 1
fi
echo "[check_gem5] ✓ gem5 binary is executable"
# Check if ARM cross-compiler exists
if ! command -v arm-linux-gnueabihf-gcc >/dev/null 2>&1; then
echo "[check_gem5] WARNING: ARM cross-compiler not found"
echo "[check_gem5] Install with: sudo apt-get install gcc-arm-linux-gnueabihf"
echo "[check_gem5] This is needed to compile workloads for ARM simulation"
fi
echo "[check_gem5] ✓ All checks passed!"

View File

@@ -3,7 +3,7 @@ import csv
import os
root = os.path.dirname(os.path.dirname(__file__))
src = os.path.join(root, "results", "phase3_summary_energy.csv")
src = os.path.join(root, "results", "summary_energy.csv")
dst = os.path.join(root, "results", "phase3_drowsy_deltas.csv")
# group by key without drowsy; compare d0 vs d1

View File

@@ -23,12 +23,20 @@ if not os.path.exists(src):
with open(src) as f:
r = csv.DictReader(f)
for row in r:
insts = float(row["insts"])
secs = float(row["sim_seconds"])
# Handle empty or invalid values
try:
insts = float(row["insts"]) if row["insts"] else 0.0
secs = float(row["sim_seconds"]) if row["sim_seconds"] else 0.0
mr = float(row["l2_miss_rate"]) if row["l2_miss_rate"] else 0.0
except (ValueError, TypeError):
print(f"[energy] WARNING: Invalid data in row: {row}")
insts = 0.0
secs = 0.0
mr = 0.0
core = row["core"]
drowsy = int(row["drowsy"])
drowsy = int(row["drowsy"]) if row["drowsy"] else 0
epi = EPI_PJ.get(core, EPI_PJ["little"])
mr = float(row["l2_miss_rate"]) if row["l2_miss_rate"] else 0.0
l2_misses = mr * insts
energy = (epi * 1e-12) * insts + (E_MEM_PJ * 1e-12) * l2_misses

View File

@@ -16,11 +16,17 @@ for d in "$OUT_DATA"/*; do
DROW=$(echo "$base" | sed -E 's/.*_d([01]).*/\1/')
S="$d/stats.txt"
SIMS=$(awk '/^sim_seconds/ {print $2}' "$S")
IPC=$(awk '/^system\.cpu\.ipc|^system\.cpu0\.ipc/ {print $2}' "$S" | head -n1)
CYC=$(awk '/^system\.cpu\.numCycles|^system\.cpu0\.numCycles/ {print $2}' "$S" | head -n1)
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")
SIMS=$(awk '/^sim_seconds/ {print $2}' "$S" || echo "")
IPC=$(awk '/^system\.cpu\.ipc|^system\.cpu0\.ipc/ {print $2}' "$S" | head -n1 || echo "")
CYC=$(awk '/^system\.cpu\.numCycles|^system\.cpu0\.numCycles/ {print $2}' "$S" | head -n1 || echo "")
INST=$(awk '/^system\.cpu\.commit\.committedInsts|^system\.cpu0\.commit\.committedInsts/ {print $2}' "$S" | head -n1 || echo "")
L2MR=$(awk '/^system\.l2\.overall_miss_rate::total/ {print $2}' "$S" || echo "")
# Check if stats.txt is empty or has no data
if [ ! -s "$S" ] || [ -z "$SIMS" ]; then
echo "[extract] WARNING: Empty or invalid stats.txt in $d"
SIMS="0"; IPC="0"; CYC="0"; INST="0"; L2MR="0"
fi
echo "$W,$CORE,$DVFS,$L2,$DROW,$SIMS,$IPC,$CYC,$INST,$L2MR" >> "$CSV_DATA"
done