#!/bin/sh # SPDX-License-Identifier: Apache-2.0 # Everything a builder runs on their own board, in order: load the engine, the conformance set, the # worked examples against the CPU reference, the joint statistics against exact enumeration, the # processor-to-logic latency, throughput, then the power campaign. On the board, as root, from a # directory holding wai-quantum-landscape-fpga, landscape.bit.bin, this script and power_campaign.sh: # sudo setsid nohup sh run_all.sh > /dev/null 2>&1 & # and leave the board alone until results-*/power/DONE appears (about three hours). It refuses to # start, and stops between steps, if another session is flashing or measuring, and it stops if a # check fails: a power figure on a design that failed its checks is not worth the three hours. On a # shared board, name the other sessions' tools in WAI_QUANTUM_LANDSCAPE_FPGA_FOREIGN. cd "$(dirname "$0")" OUT=results-$(date -u +%Y%m%dT%H%M%SZ) mkdir -p "$OUT" B=./wai-quantum-landscape-fpga BIT=${ENGINE_BITSTREAM:-landscape.bit.bin} log() { echo "$(date -u +%FT%TZ) $*" >> "$OUT/log.txt"; } FOREIGN=$($B foreign) || { echo "another session is on the board: $FOREIGN" > "$OUT/STOPPED"; exit 3; } { echo "fpga manager flags: $(cat /sys/class/fpga_manager/fpga0/flags)" echo "last FPGA write: $(dmesg | grep 'writing.*FPGA' | tail -1)" sha256sum "$BIT" "$B" } > "$OUT/board_before.txt" # A non-zero flags word makes the manager treat a plain bitstream as something else; it is put back. FLAGS=$(cat /sys/class/fpga_manager/fpga0/flags) echo 0 > /sys/class/fpga_manager/fpga0/flags # The flock is not held here across the steps: each step takes it itself, and would wait on this # script for ever. Between steps the board is free, which is why the session check runs at each. $B load "$BIT" > "$OUT/load.txt" 2>&1 || { log "load failed"; echo "$FLAGS" > /sys/class/fpga_manager/fpga0/flags; exit 2; } $B status > "$OUT/status.txt" 2>&1 step() { name=$1; shift f=$($B foreign) || { log "STOP: another session is on the board: $f"; echo "$FLAGS" > /sys/class/fpga_manager/fpga0/flags; exit 3; } $B "$@" > "$OUT/$name.txt" 2>&1; rc=$? log "$name exit=$rc" [ "$rc" -eq 0 ] || { echo "$FLAGS" > /sys/class/fpga_manager/fpga0/flags; exit 4; } } step conform conform step agree agree --seeds 200 step joint joint --seed 2027 step latency latency step throughput throughput sh power_campaign.sh "$OUT" $B release >> "$OUT/status.txt" 2>&1 echo "$FLAGS" > /sys/class/fpga_manager/fpga0/flags