32 lines
2.3 KiB
Bash
32 lines
2.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Attack-pass F9 pod job: build the pack kernels and the F9 variants on the pod, run the checks and the timed rounds
|
|
# with nvidia-smi 1-s power samples, write everything to the log directory. Run on the pod from the job directory that
|
|
# holds: pack/ (the pack files), f9-host.cu, f9-variants.cu (generated here), make-variants.py, join-power.py,
|
|
# ref.txt, table-random.bin, table-k10.bin, table-k14.bin.
|
|
# bash run.sh <rounds> <seconds> [arch]
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
ROUNDS="${1:-5}"; SECS="${2:-8}"; ARCH="${3:-sm_120}"; BATCH="${4:-24}"
|
|
export PATH=/usr/local/cuda/bin:$PATH
|
|
LOG=log; mkdir -p "$LOG"
|
|
echo "f9 pod job start $(date -u +%Y-%m-%dT%H:%M:%SZ) rounds $ROUNDS seconds $SECS arch $ARCH" | tee "$LOG/run.log"
|
|
nvidia-smi --query-gpu=name,driver_version,power.limit,memory.total --format=csv | tee -a "$LOG/run.log"
|
|
python3 make-variants.py pack/kernel_bound.cu f9-variants.cu --force 7,8,9,10,31 | tee -a "$LOG/run.log"
|
|
sha256sum pack/kernel_bound.cu pack/kernel.cu pack/program.h pack/vectors.h f9-variants.cu f9-host.cu table-*.bin ref.txt | tee "$LOG/sha256.txt"
|
|
t0=$(date +%s)
|
|
nvcc -O3 -std=c++17 -arch="$ARCH" -I pack -o f9-host f9-host.cu pack/kernel.cu pack/kernel_bound.cu f9-variants.cu 2>&1 | tee "$LOG/nvcc.log"
|
|
echo "nvcc done in $(( $(date +%s) - t0 )) s" | tee -a "$LOG/run.log"
|
|
# power sampler: epoch ms prefixed by the shell, one line a second
|
|
# the sampler runs in its own session (setsid) so the whole group can be killed and no orphan holds the ssh open
|
|
setsid bash -c 'stdbuf -oL nvidia-smi --query-gpu=power.draw,clocks.sm,clocks.mem,temperature.gpu,utilization.gpu --format=csv,noheader,nounits -lms 1000 | while IFS= read -r l; do echo "$(date +%s%3N) $l"; done' > "$LOG/power.csv" 2>&1 < /dev/null &
|
|
PW=$!
|
|
sleep 2
|
|
set +e
|
|
./f9-host --prehash "$(cat prehash.txt)" --ref ref.txt --table-random table-random.bin --table-k10 table-k10.bin --table-k14 table-k14.bin --rounds "$ROUNDS" --seconds "$SECS" --batch-log2 "$BATCH" 2>&1 | tee "$LOG/host.log"
|
|
rc=${PIPESTATUS[0]}
|
|
set -e
|
|
sleep 2
|
|
kill -- -$PW 2>/dev/null || kill $PW 2>/dev/null || true; pkill -x nvidia-smi 2>/dev/null || true
|
|
python3 join-power.py "$LOG/host.log" "$LOG/power.csv" | tee "$LOG/power-by-variant.txt"
|
|
echo "f9 pod job end $(date -u +%Y-%m-%dT%H:%M:%SZ) host rc $rc" | tee -a "$LOG/run.log"
|
|
exit $rc
|