Files
hakmem/archive/experimental_scripts/sweep_tiny_params.sh

53 lines
1.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
# Sweep Tiny parameters via env for 1664B and capture throughput.
# This keeps code unchanged and only toggles env knobs:
# - HAKMEM_TINY_TLS_SLL: 0/1
# - HAKMEM_TINY_MAG_CAP: e.g. 128/256/512/1024
#
# Usage: scripts/sweep_tiny_params.sh [cycles]
ROOT_DIR=$(cd "$(dirname "$0")/.." && pwd)
cd "$ROOT_DIR"
cycles=${1:-150000}
make -s bench_fast >/dev/null
TS=$(date +%Y%m%d_%H%M%S)
OUTDIR="bench_results/sweep_tiny_${TS}"
mkdir -p "$OUTDIR"
CSV="$OUTDIR/results.csv"
echo "size,sll,mag_cap,throughput_mops" > "$CSV"
sizes=(16 32 64)
slls=(1 0)
mags=(128 256 512 1024 2048)
run_case() {
local size="$1"; shift
local sll="$1"; shift
local cap="$1"; shift
local out
HAKMEM_TINY_TLS_SLL="$sll" HAKMEM_TINY_MAG_CAP="$cap" ./bench_tiny_hot_hakmem "$size" 100 "$cycles" \
| sed -n 's/^Throughput: \([0-9.][0-9.]*\) M ops.*/\1/p' >"$OUTDIR/tmp.txt" || true
out=$(cat "$OUTDIR/tmp.txt" || true)
if [[ -n "$out" ]]; then
echo "$size,$sll,$cap,$out" >> "$CSV"
fi
}
for sz in "${sizes[@]}"; do
for sll in "${slls[@]}"; do
for cap in "${mags[@]}"; do
echo "[sweep] size=$sz sll=$sll cap=$cap cycles=$cycles"
run_case "$sz" "$sll" "$cap"
done
done
done
echo "[done] CSV: $CSV"
grep -E '^(size|16|32|64),' "$CSV" | sed -n '1,30p' || true