Commit 98ae1d1c authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

experiments: add some gem5 examples

parent e7c6e658
...@@ -3,10 +3,15 @@ MQNICMOD := $(abspath ../images/mqnic/mqnic.ko) ...@@ -3,10 +3,15 @@ MQNICMOD := $(abspath ../images/mqnic/mqnic.ko)
GUESTS := \ GUESTS := \
qemu-pair-client \ qemu-pair-client \
qemu-pair-server \ qemu-pair-server \
gem5-pair-client \
gem5-pair-server-cp \
gem5-pair-client-cp \
EXPERIMENTS := \ EXPERIMENTS := \
qemu-corundum-bm-pair \ qemu-corundum-bm-pair \
qemu-corundum-verilator-pair \ qemu-corundum-verilator-pair \
gem5-kvm-corundum-bm-pair \
gem5-timing-corundum-verilator-pair \
BUILDDIR := build BUILDDIR := build
OUTDIR := out OUTDIR := out
......
...@@ -7,19 +7,26 @@ fi ...@@ -7,19 +7,26 @@ fi
source local-config.sh source local-config.sh
if [ -z "$EHSIM_BASE" ] ; then if [ ! -d "$EHSIM_BASE" ] ; then
echo "\$EHSIM_BASE should be set to the absolute path of the root"\ echo "\$EHSIM_BASE should be set to the absolute path of the root"\
"of this repo (local-config.sh)" "of this repo (local-config.sh)"
exit 1 exit 1
fi fi
if [ -z "$QEMU_CMD" ] ; then if [ ! -f "$QEMU_CMD" ] ; then
echo "\$QEMU_CMD should be set to the absolute path to a QEMU instance"\ echo "\$QEMU_CMD should be set to the absolute path to a QEMU instance"\
"with cosim support (local-config.sh)" "with cosim support (local-config.sh)"
exit 1 exit 1
fi fi
if [ ! -d "$GEM5_BASE" ] ; then
echo "\$GEM5_BASE should be set to the absolute path to a built gem5 repo"\
"(local-config.sh)"
exit 1
fi
QEMU_BASE_IMAGE=$EHSIM_BASE/images/output-ubuntu1804/ubuntu1804 QEMU_IMAGE=$EHSIM_BASE/images/output-ubuntu1804/ubuntu1804
QEMU_KERNEL=$EHSIM_BASE/images/bzImage QEMU_KERNEL=$EHSIM_BASE/images/bzImage
GEM5_IMAGE=$EHSIM_BASE/images/output-ubuntu1804/ubuntu1804.raw
GEM5_KERNEL=$EHSIM_BASE/images/vmlinux
# Args: # Args:
# - experiment name # - experiment name
...@@ -39,7 +46,7 @@ run_qemu() { ...@@ -39,7 +46,7 @@ run_qemu() {
pcisock="$OUTDIR/pci.$2" pcisock="$OUTDIR/pci.$2"
rm -f $img_a $img_b rm -f $img_a $img_b
echo Creating disk for qemu $1 echo Creating disk for qemu $1
qemu-img create -f qcow2 -o backing_file=$QEMU_BASE_IMAGE $img_a qemu-img create -f qcow2 -o backing_file=$QEMU_IMAGE $img_a
cp $3 $img_b cp $3 $img_b
echo Starting qemu $1 echo Starting qemu $1
$QEMU_CMD -machine q35 -cpu host \ $QEMU_CMD -machine q35 -cpu host \
...@@ -56,6 +63,31 @@ run_qemu() { ...@@ -56,6 +63,31 @@ run_qemu() {
return $pid return $pid
} }
# Args:
# - Instance name
# - Cosim instance
# - secondary hard drive
# - cpu type
# - checkpoint dir
# - extra flags
run_gem5() {
echo Starting gem5 $1
pcisock="$OUTDIR/pci.$2"
shm="$OUTDIR/shm.$2"
cpdir="$OUTDIR/checkpoints.$5"
mkdir -p $cpdir
$GEM5_BASE/build/X86/gem5.opt \
--outdir=$OUTDIR/gem5.out.$1 \
$GEM5_BASE/configs/cosim/cosim.py \
--kernel=$GEM5_KERNEL --disk-image=$GEM5_IMAGE --disk-image=$3 \
--cpu-type=$4 --mem-size=4GB --cosim-pci=$pcisock --cosim-shm=$shm \
--checkpoint-dir="$cpdir" $6 \
&>$OUTDIR/gem5.$1.log &
pid=$!
ALL_PIDS="$ALL_PIDS $pid"
return $pid
}
# Args: # Args:
# - Instance name # - Instance name
run_corundum_verilator() { run_corundum_verilator() {
...@@ -95,8 +127,13 @@ run_wire() { ...@@ -95,8 +127,13 @@ run_wire() {
cleanup() { cleanup() {
echo Cleaning up echo Cleaning up
for p in $ALL_PIDS ; do
kill $p &>/dev/null
done
sleep 1
for p in $ALL_PIDS ; do for p in $ALL_PIDS ; do
kill -KILL $p &>/dev/null kill -KILL $p &>/dev/null
done done
rm -f $OUTDIR/{qemu.hd.*,shm.*,pci.*,eth.*} rm -f $OUTDIR/{qemu.hd.*,shm.*,pci.*,eth.*}
} }
#!/bin/bash
source common-functions.sh
init_out gem5-kvm-corundum-bm-pair
run_corundum_bm a
run_corundum_bm b
sleep 0.5
run_wire ab a b
run_gem5 a a build/qemu-pair-server.tar X86KvmCPU a
run_gem5 b b build/gem5-pair-client.tar X86KvmCPU b
client_pid=$!
wait $client_pid
cleanup
#!/bin/bash
source common-functions.sh
init_out gem5-timing-corundum-verilator-pair
# first run to checkpoint with fast CPU
run_corundum_verilator a
run_corundum_verilator b
sleep 0.5
run_wire ab a b
run_gem5 a a build/gem5-pair-server-cp.tar X86KvmCPU server
run_gem5 b b build/gem5-pair-client-cp.tar X86KvmCPU client
client_pid=$!
wait $client_pid
cleanup
echo "Took checkpoint successfully"
# then run with timing CPU
run_corundum_verilator a_cp
run_corundum_verilator b_cp
sleep 0.5
run_wire ab_cp a_cp b_cp
run_gem5 a_cp a_cp build/gem5-pair-server-cp.tar TimingSimpleCPU server "-r 0 --cosim-sync"
run_gem5 b_cp b_cp build/gem5-pair-client-cp.tar TimingSimpleCPU client "-r 0 --cosim-sync"
client_pid=$!
wait $client_pid
cleanup
#!/bin/bash
m5 checkpoint
insmod mqnic.ko
ip link set dev eth0 up
ip addr add 192.168.64.2/24 dev eth0
sleep 2
iperf -c 192.168.64.1
m5 exit
#!/bin/bash
insmod mqnic.ko
ip link set dev eth0 up
ip addr add 192.168.64.2/24 dev eth0
sleep 2
iperf -c 192.168.64.1
m5 exit
#!/bin/bash
m5 checkpoint
insmod mqnic.ko
ip link set dev eth0 up
ip addr add 192.168.64.1/24 dev eth0
iperf -s
m5 exit
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment