mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
scripts: factor out benchmarks and run further with ./eeval and common_bench_cmd
This commit is contained in:
12
bench-boot
12
bench-boot
@@ -2,9 +2,9 @@
|
|||||||
set -eu
|
set -eu
|
||||||
. common
|
. common
|
||||||
results_file="${out_dir}/bench-boot.txt"
|
results_file="${out_dir}/bench-boot.txt"
|
||||||
|
caches='--caches --l2cache --l1d_size=1024kB --l1i_size=1024kB --l2_size=1024kB --l3_size=1024kB'
|
||||||
bench() (
|
bench() (
|
||||||
printf 'cmd ' >> "$results_file"
|
common_bench_cmd "./run -a ${1}" "$results_file"
|
||||||
env time --append -f 'time %e' --output="$results_file" ./eeval "./run -a $1" "$results_file"
|
|
||||||
)
|
)
|
||||||
gem5_insts() (
|
gem5_insts() (
|
||||||
printf "instructions $(./gem5-stat -a "$1" sim_insts)\n" >> "$results_file"
|
printf "instructions $(./gem5-stat -a "$1" sim_insts)\n" >> "$results_file"
|
||||||
@@ -19,11 +19,14 @@ rm -f "${results_file}"
|
|||||||
|
|
||||||
arch=x86_64
|
arch=x86_64
|
||||||
bench "$arch -E '/poweroff.out'"
|
bench "$arch -E '/poweroff.out'"
|
||||||
bench "$arch -E '/poweroff.out' -- -enable-kvm"
|
bench "$arch -E '/poweroff.out' -K"
|
||||||
bench "$arch -E '/poweroff.out' -T exec_tb"
|
bench "$arch -E '/poweroff.out' -T exec_tb"
|
||||||
qemu_insts "$arch"
|
qemu_insts "$arch"
|
||||||
bench "$arch -E 'm5 exit' -g"
|
bench "$arch -E 'm5 exit' -g"
|
||||||
gem5_insts "$arch"
|
gem5_insts "$arch"
|
||||||
|
# Was taking more than one hour.
|
||||||
|
#bench "$arch -E 'm5 exit' -g -- --cpu-type=DerivO3CPU ${caches}"
|
||||||
|
#gem5_insts "$arch"
|
||||||
|
|
||||||
arch=arm
|
arch=arm
|
||||||
# Manual Ctrl+C required.
|
# Manual Ctrl+C required.
|
||||||
@@ -32,6 +35,7 @@ arch=arm
|
|||||||
#qemu_insts "$arch"
|
#qemu_insts "$arch"
|
||||||
bench "$arch -E 'm5 exit' -g"
|
bench "$arch -E 'm5 exit' -g"
|
||||||
gem5_insts "$arch"
|
gem5_insts "$arch"
|
||||||
|
# Was taking more than one hour.
|
||||||
#bench "$arch -E 'm5 exit' -g -- --caches --cpu-type=HPI"
|
#bench "$arch -E 'm5 exit' -g -- --caches --cpu-type=HPI"
|
||||||
#gem5_insts "$arch"
|
#gem5_insts "$arch"
|
||||||
|
|
||||||
@@ -41,5 +45,5 @@ bench "$arch -E '/poweroff.out' -T exec_tb"
|
|||||||
qemu_insts "$arch"
|
qemu_insts "$arch"
|
||||||
bench "$arch -E 'm5 exit' -g"
|
bench "$arch -E 'm5 exit' -g"
|
||||||
gem5_insts "$arch"
|
gem5_insts "$arch"
|
||||||
bench "$arch -E 'm5 exit' -g -- --caches --cpu-type=HPI"
|
bench "$arch -E 'm5 exit' -g -- --cpu-type=HPI ${caches}"
|
||||||
gem5_insts "$arch"
|
gem5_insts "$arch"
|
||||||
|
|||||||
3
build
3
build
@@ -187,5 +187,4 @@ V='${v}' \\
|
|||||||
${extra_make_args} \
|
${extra_make_args} \
|
||||||
all \\
|
all \\
|
||||||
"
|
"
|
||||||
echo "$cmd" | tee "${out_arch_dir}/build.sh"
|
./eeval "$cmd" "${out_arch_dir}/build.sh"
|
||||||
eval "$cmd"
|
|
||||||
|
|||||||
17
common
17
common
@@ -1,4 +1,21 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
common_bench_cmd() (
|
||||||
|
# Benchmark a command.
|
||||||
|
#
|
||||||
|
# $1: command to benchmark
|
||||||
|
# $2: where to write results to
|
||||||
|
#
|
||||||
|
# Result format:
|
||||||
|
#
|
||||||
|
# cmd <command run>
|
||||||
|
# time <time in seconds to finish>
|
||||||
|
# status <exit status>
|
||||||
|
cmd="$1"
|
||||||
|
results_file="$2"
|
||||||
|
printf 'cmd ' >> "$results_file"
|
||||||
|
env time --append -f 'time %e' --output="$results_file" ./eeval -a "$cmd" "$results_file"
|
||||||
|
printf "status $?\n" >> "$results_file"
|
||||||
|
)
|
||||||
set_common_vars() {
|
set_common_vars() {
|
||||||
arch="$1"
|
arch="$1"
|
||||||
gem5="${2:-false}"
|
gem5="${2:-false}"
|
||||||
|
|||||||
18
eeval
18
eeval
@@ -1,4 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# echo and eval
|
||||||
|
a=
|
||||||
|
while getopts a OPT; do
|
||||||
|
case "$OPT" in
|
||||||
|
a)
|
||||||
|
# Append to file instead of overwriting.
|
||||||
|
a=-a
|
||||||
|
;;
|
||||||
|
?)
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift "$(($OPTIND - 1))"
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
echo "$cmd" | tee -a "${2:-/dev/null}"
|
outfile="${2:-/dev/null}"
|
||||||
|
echo "$cmd" | tee $a "$outfile"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
|
exit "$?"
|
||||||
|
|||||||
@@ -19,12 +19,10 @@ set_common_vars "$arch" true
|
|||||||
cmd="./run -a $arch -g"
|
cmd="./run -a $arch -g"
|
||||||
cache_small='--caches --l2cache --l1d_size=1024 --l1i_size=1024 --l2_size=1024 --l3_size=1024 '
|
cache_small='--caches --l2cache --l1d_size=1024 --l1i_size=1024 --l2_size=1024 --l3_size=1024 '
|
||||||
cache_large='--caches --l2cache --l1d_size=1024kB --l1i_size=1024kB --l2_size=1024kB --l3_size=1024kB'
|
cache_large='--caches --l2cache --l1d_size=1024kB --l1i_size=1024kB --l2_size=1024kB --l3_size=1024kB'
|
||||||
result_file="${gem5_out_dir}/bench-cache.txt"
|
results_file="${gem5_out_dir}/bench-cache.txt"
|
||||||
|
|
||||||
bench() (
|
bench() (
|
||||||
cmd="$1"
|
common_bench_cmd "$1" "$results_file"
|
||||||
printf 'cmd ' >> "$result_file"
|
|
||||||
./eeval "$cmd" "$result_file"
|
|
||||||
{
|
{
|
||||||
printf 'cycles '
|
printf 'cycles '
|
||||||
./gem5-stat -a "$arch"
|
./gem5-stat -a "$arch"
|
||||||
@@ -33,7 +31,7 @@ bench() (
|
|||||||
#if [ -n "$cycles_switch" ]; then
|
#if [ -n "$cycles_switch" ]; then
|
||||||
# printf "cycles_switch ${cycles_switch}\n"
|
# printf "cycles_switch ${cycles_switch}\n"
|
||||||
#fi
|
#fi
|
||||||
} >> "$result_file"
|
} >> "$results_file"
|
||||||
)
|
)
|
||||||
|
|
||||||
bench-all() (
|
bench-all() (
|
||||||
@@ -67,7 +65,7 @@ bench-all() (
|
|||||||
if "$generate_checkpoints"; then
|
if "$generate_checkpoints"; then
|
||||||
# Create the checkpoints after the kernel boot.
|
# Create the checkpoints after the kernel boot.
|
||||||
rm -rf "${m5out_dir}"/cpt.*;
|
rm -rf "${m5out_dir}"/cpt.*;
|
||||||
printf 'm5 exit' >"${readfile_file}"
|
printf 'm5 exit' > "${readfile_file}"
|
||||||
cpt_cmd="-E 'm5 checkpoint;m5 readfile > a.sh;sh a.sh'"
|
cpt_cmd="-E 'm5 checkpoint;m5 readfile > a.sh;sh a.sh'"
|
||||||
# 1
|
# 1
|
||||||
./eeval "$cmd $cpt_cmd"
|
./eeval "$cmd $cpt_cmd"
|
||||||
@@ -83,14 +81,15 @@ if "$generate_checkpoints"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore and run benchmarks.
|
# Restore and run benchmarks.
|
||||||
rm -f "$result_file"
|
rm -f "$results_file"
|
||||||
printf '#!/bin/sh
|
printf '#!/bin/sh
|
||||||
m5 resetstats
|
m5 resetstats
|
||||||
dhrystone XXX
|
dhrystone XXX
|
||||||
m5 exit
|
m5 exit
|
||||||
' >"${readfile_file}"
|
' >"${readfile_file}"
|
||||||
for n in 1000 10000 100000; do
|
for n in 1000 10000 100000; do
|
||||||
printf "n ${n}\n" >> "$result_file"
|
printf "n ${n}\n" >> "$results_file"
|
||||||
sed -Ei "s/^dhrystone .*/dhrystone ${n}/" "${readfile_file}"
|
sed -Ei "s/^dhrystone .*/dhrystone ${n}/" "${readfile_file}"
|
||||||
bench-all
|
bench-all
|
||||||
|
printf "\n" >> "$results_file"
|
||||||
done
|
done
|
||||||
|
|||||||
3
run
3
run
@@ -296,5 +296,4 @@ if "$tmux"; then
|
|||||||
eval "./tmu 'sleep 2;./gem5-shell'"
|
eval "./tmu 'sleep 2;./gem5-shell'"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "$cmd" | tee "${out_arch_dir}/run.sh"
|
./eeval "$cmd" "${out_arch_dir}/run.sh"
|
||||||
eval "$cmd"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user