Add benchmark awareness to pipeline.

This commit is contained in:
Dylan Bautista 2025-02-17 13:29:19 +01:00
parent 6185599b70
commit 7cce64c10f
2 changed files with 71 additions and 18 deletions

72
boot.sh
View File

@ -1,6 +1,40 @@
#!/usr/bin/env bash
set -ex
set -e
show_help () {
echo "Usage: $0 [QEMU options]"
echo "Options:"
echo " -h Show this help message."
echo " --kernelp {bench2|debug2} Kernel parameter:"
echo " bench2: to execute benchmark suite at boot stage 2."
echo " debug2: to get an interactive shell at boot stage 2."
}
QEMU_KERNEL_PARAMS=""
OPTIONS=$(getopt -o h -l help,kernelp: -n "$0" -- "$@")
eval set -- "$OPTIONS"
while true
do
case "$1" in
--kernelp)
QEMU_KERNEL_PARAMS="$2"
shift 2
;;
-h|--help)
show_help
exit 0
;;
--)
shift
break
;;
esac
done
set -x
#export PATH=/nix/store/c5xwy0rllg4lcw61mh20glairjz7ibv4-qemu-8.0.4/bin/:$PATH
@ -22,8 +56,6 @@ if [ -z "$TMPDIR" ] || [ -z "$USE_TMPDIR" ]; then
TMPDIR=$(mktemp -d nix-vm.XXXXXXXXXX --tmpdir)
fi
# Create a directory for exchanging data with the VM.
mkdir -p "$TMPDIR/xchg"
@ -31,17 +63,15 @@ system="$TOPLEVEL"
echo "Booting $system"
cd "$TMPDIR"
#QEMU_KERNEL_PARAMS="boot.debug1devices"
eARAMS="boot.debug1devices"
#QEMU_KERNEL_PARAMS="boot.trace boot.debug1"
QEMU_KERNEL_PARAMS=bench2
#QEMU_KERNEL_PARAMS=bench2
#QEMU_KERNEL_PARAMS=debug2
# Trap the CPU on compressed instructions?
#TRAP_COMPRESSED="-cpu rv64,c=false"
CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_payload.bin"
#CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_payload.bin"
#CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_jump.elf"
#CUSTOM_BIOS="-bios $CDIR/bios-nc.bin"
#CUSTOM_BIOS="-bios $CDIR/bios.bin"
@ -50,8 +80,8 @@ CUSTOM_BIOS="-bios $OPENSBI/share/opensbi/lp64/generic/firmware/fw_payload.bin"
#DEBUG_CPU="-d cpu_reset"
#DEBUG_CPU="-d in_asm,cpu,cpu_reset"
exec qemu-system-riscv64 \
run_qemu () {
qemu-system-riscv64 \
$DEBUG_GDB \
$DEBUG_CPU \
-name nixos-riscv \
@ -70,22 +100,30 @@ exec qemu-system-riscv64 \
-device virtio-blk-device,drive=hd0 \
-kernel $system/kernel \
-initrd $system/initrd \
-append "$(cat $system/kernel-params) init=$system/init console=ttyS0,115200n8 loglevel=7 $QEMU_KERNEL_PARAMS" \
$QEMU_OPTS \
"$@"
-device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=123 \
-serial mon:stdio \
-append "$(cat $system/kernel-params) init=$system/init console=ttyS0 loglevel=7 $QEMU_KERNEL_PARAMS" \
$QEMU_OPTS
"$@" 2>&1
}
if [ $QEMU_KERNEL_PARAMS == "bench2" ]; then
run_qemu | awk -f $CDIR/verify_rvb.awk
echo "The exit status value is $?"
else
run_qemu
fi
# QEMU OPTIONS GRAVEYARD
# -kernel $system/kernel \
# -initrd $system/initrd \
# -append "$(cat $system/kernel-params) init=$system/init regInfo=/nix/store/x3zpwfbk2wkiisxhgi7zwsfwbdfxk0w1-closure-info-riscv64-unknown-linux-gnu/registration console=ttyS0,115200n8 loglevel=7 $QEMU_KERNEL_PARAMS"
# -kernel ${NIXPKGS_QEMU_KERNEL_visionfive_nix:-/nix/store/8n5fakqq44nsmbcn0vdm3mzsvcq9ihbi-nixos-system-visionfive-nix-24.05.20240115.c3e128f/kernel} \
# -initrd /nix/store/96058frp51dn0xxfci4kyvzz0rvd5ngy-initrd-linux-riscv64-unknown-linux-gnu-6.1.72/initrd \
# -append "$(cat /nix/store/8n5fakqq44nsmbcn0vdm3mzsvcq9ihbi-nixos-system-visionfive-nix-24.05.20240115.c3e128f/kernel-params) init=/nix/store/8n5fakqq44nsmbcn0vdm3mzsvcq9ihbi-nixos-system-visionfive-nix-24.05.20240115.c3e128f/init regInfo=/nix/store/bgqa92gznhcr9aryx6ac4ycx4s2385cr-closure-info-riscv64-unknown-linux-gnu/registration console=ttyS0,115200n8 console=tty0 $QEMU_KERNEL_PARAMS" \
# -drive "file=$NIX_DISK_IMAGE,if=virtio,id=hd0" \
# -hda "$NIX_DISK_IMAGE" \
#-net nic,model=virtio,macaddr=16:da:11:b4:44:c9 -net user \

15
verify_rvb.awk Normal file
View File

@ -0,0 +1,15 @@
BEGIN {
bench_success_flag = 0
}
/^BENCHMARK-SUCESS-STATE/ { bench_success_flag = 1; system("pkill -f -SIGTERM qemu-system-riscv64")}
{print $0}
END {
printf "Benchmark execution has finished.\n";
if (bench_success_flag)
exit 0;
else
exit 1;
}