interplane.Get Omega
Read in your language

omega-gpu-driver

aien-dev/omega-gpu-driver

Brought by drakestapleton

branch main Branches Tags History

omega-gpu-driver / qemu / bench / run.sh

28 lines · 1550 bytes Raw Blame History
1#!/bin/sh
2# usage: run.sh W0BIN CMDSFILE LOG -- boots QEMU virt+SMMUv3 with 2x edu, runs /cmds, writes serial log to LOG
3set -eu
4[ $# -eq 3 ] || { echo "usage: $0 W0BIN CMDSFILE LOG" >&2; exit 2; }
5B=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
6# Guest kernel: the host's own Ubuntu image, extracted without root:
7# apt-get download linux-image-7.0.0-1019-nvidia && dpkg-deb -x linux-image-*.deb img
8# /tmp is wiped at boot on the Spark, so there is no default path: KERNEL must name the image.
9K=${KERNEL:?set KERNEL to the extracted vmlinuz-7.0.0-1019-nvidia}
10[ -f "$K" ] || { echo "KERNEL=$K: no such file" >&2; exit 2; }
11[ -f $B/initramfs.cpio.gz ] || sh $B/mkinit.sh
12T=$(mktemp -d "$B/run.XXXXXX")
13trap 'rm -rf "$T"' EXIT
14mkdir "$T/x"; cp "$1" "$T/x/w0"; chmod +x "$T/x/w0"; cp "$2" "$T/x/cmds"
15cp $B/initramfs.cpio.gz "$T/initrd"
16(cd "$T/x" && printf 'w0\ncmds\n' | cpio -o -H newc --quiet) | gzip >> "$T/initrd"
17boot() { # $1 = accel args
18 nice -n 19 taskset -c "${AIEN_TEST_CPUS:-0-9,15-19}" timeout ${TIMEOUT:-180} qemu-system-aarch64 \
19 -M virt,iommu=smmuv3 $1 -smp 2 -m 1G -nographic -no-reboot \
20 -kernel $K -initrd "$T/initrd" -append 'console=ttyAMA0 rdinit=/init panic=-1' \
21 ${DEVICES:--device edu -device edu}
22}
23{ echo "### accel: KVM (-cpu host -enable-kvm)"; boot "-cpu host -enable-kvm"; } > "$3" 2>&1 && rc=0 || rc=$?
24if [ $rc -ne 0 ] || ! grep -q 'bench done' "$3"; then
25 mv "$3" "$3.kvmfail"
26 { echo "### accel: TCG (-cpu max) after KVM rc=$rc"; boot "-cpu max"; } > "$3" 2>&1 || true
27fi
28grep -q 'bench done' "$3"