#!/bin/bash
set -euo pipefail
cd /srv/home/gc-sdk/ipu-stack
while test -e /proc/70978; do sleep 10; done
cargo build --release -p ipu-tests --bin ipu-trivial-test --bin ipu-exchange-schedule-bench > artifacts/exchange-frontier-20260911/build.log 2>&1
cargo test -p ipu-tests --bin ipu-trivial-test > artifacts/exchange-frontier-20260911/tests.log 2>&1
python3 - <<'PY'
import json
from pathlib import Path
source=Path('artifacts/baseline-local-planner/pairwise-resident-full27/transfers.json')
s=json.loads(source.read_text())
phases={0,3,7,9,11,12,14,16,17,32,42,47,49}
s['phases']=[p for p in s['phases'] if p['phase'] in phases]
Path('artifacts/exchange-frontier-20260911/ordinary.json').write_text(json.dumps(s,separators=(',',':')))
PY
RAYON_NUM_THREADS=1 target/release/ipu-exchange-schedule-bench artifacts/exchange-frontier-20260911/ordinary.json --select-widths --write-selected-snapshot artifacts/exchange-frontier-20260911/selected.json > artifacts/exchange-frontier-20260911/width-selection.log 2>&1
python3 scripts/exchange-frontier.py artifacts/exchange-frontier-20260911/selected.json --output artifacts/exchange-frontier-20260911/plots > artifacts/exchange-frontier-20260911/sweep.log 2>&1
