#!/usr/bin/env bash set -euo pipefail # Sweep Ultra Tiny (SLL-only) with debug counters and output CSV # Usage: scripts/run_ultra_debug_sweep.sh [cycles] [batch] ROOT_DIR=$(cd "$(dirname "$0")/.." && pwd) cd "$ROOT_DIR" cycles=${1:-60000} batch=${2:-200} make -s bench_fast >/dev/null TS=$(date +%Y%m%d_%H%M%S) OUTDIR="bench_results/ultra_debug_${TS}" mkdir -p "$OUTDIR" CSV="$OUTDIR/results.csv" echo "size,batch,cycles,throughput_mops,class,pop_hits,refills,resets,sll_count" > "$CSV" sizes=(16 32 64) size_to_class() { case "$1" in 16) echo 1;; 32) echo 2;; 64) echo 3;; 8) echo 0;; 128) echo 4;; *) echo -1;; esac } for s in "${sizes[@]}"; do cls=$(size_to_class "$s") log="$OUTDIR/ultra_${s}_b=${batch}_c=${cycles}.log" # Run with Ultra + debug; capture stdout+stderr in one file HAKMEM_TINY_ULTRA=1 HAKMEM_TINY_ULTRA_DEBUG=1 HAKMEM_TINY_MAG_CAP=128 \ ./bench_tiny_hot_hakmem "$s" "$batch" "$cycles" >"$log" 2>&1 || true thr=$(sed -n 's/^Throughput: \([0-9.][0-9.]*\) M ops.*/\1/p' "$log" | tail -n1) # Extract Ultra debug block start=$(grep -n '^\[Ultra Tiny Debug\]' "$log" | tail -n1 | cut -d: -f1) if [[ -n "$start" ]]; then # header is the next line; data follows data_start=$((start+2)) # take next 8 lines (classes 0..7) sed -n "${data_start},$((data_start+7))p" "$log" > "$OUTDIR/tmp_ultra.txt" || true # pick the line for target class line=$(awk -F',' -v k="$cls" '($1==k){print $0}' "$OUTDIR/tmp_ultra.txt" | tail -n1) if [[ -n "$line" ]]; then # line format: class,pop_hits,refills,resets,sll_count IFS=',' read -r c ph rf rs sc <<<"$line" echo "$s,$batch,$cycles,${thr:-},$c,$ph,$rf,$rs,$sc" >> "$CSV" fi fi done echo "[done] CSV: $CSV" sed -n '1,20p' "$CSV" || true