#!/usr/bin/env bash
# experiments/fattree-all-to-all/sequential_512conns/run.sh: 512-host sequential all-to-all on a
# 1024-node fat tree with NDP and per-packet spraying (seed 13). The plotting step needs gnuplot and
# is skipped; metrics are parsed from the simulator output and the overlap file plot_overlap.py writes.
set -o pipefail
cd experiments/fattree-all-to-all/sequential_512conns || exit 1
echo "KVERITAS_INPUT src=seed:13"
echo "KVERITAS_PHASE name=simulate"
bash run.sh 2>&1 | grep -v "gnuplot: command not found"
python - <<'PY'
import re
rows = [l.split() for l in open("incast_1024_512_perm_50iw_1par.tmp") if l.strip()]
peak = max(float(r[2]) for r in rows)
out = open("out_1024_512_perm_50iw_1par.tmp").read()
done = [int(x) for x in re.findall(r"finished at (\d+)", out)]
m = re.search(r"New: (\d+) Rtx: (\d+)", out)
print(f"KVERITAS_METRIC name=flows_finished value={len(done)}")
print(f"KVERITAS_METRIC name=packets_new value={m.group(1)}")
print(f"KVERITAS_METRIC name=packets_retransmitted value={m.group(2)}")
print(f"KVERITAS_CLAIM metric=max_senders_per_receiver value={peak:g}")
print(f"KVERITAS_CLAIM metric=last_flow_finish_us value={max(done)}")
PY
