bench-boot: start convert to cli function

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-01-22 00:00:00 +00:00
parent 9acbcaaa5b
commit c2983e0e1f
4 changed files with 121 additions and 88 deletions

View File

@@ -1,95 +1,125 @@
#!/usr/bin/env bash #!/usr/bin/env python3
set -eu
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
test_size=1
while [ $# -gt 0 ]; do
case "$1" in
--size)
# 1: a few seconds and important
# 2: < 5 minutes and important or a few seconds and not too important
# 3: all
test_size="$2"
shift 2
;;
esac
done
if [ $# -gt 1 ]; then import common
extra_args=" $*" from shell_helpers import LF
else
extra_args=
fi
getvar="${root_dir}/getvar"
common_bench_boot="$("$getvar" bench_boot)"
caches='--caches --l2cache --l1d_size=1024kB --l1i_size=1024kB --l2_size=1024kB --l3_size=1024kB'
bench() ( class Main(common.LkmcCliFunction):
"${root_dir}/bench-cmd" "./run --arch ${1}${extra_args}" "$common_bench_boot" def __init__(self):
) super().__init__(
defaults={
'print_time': False,
},
description='''\
Run Linux kernel boot tests and benchmarks.
'''
)
self.add_argument(
'--size',
default=1,
type=int,
help='''\
Size of the tests to run. Scale:
newline() ( * 1: a few seconds and important
echo >> "$common_bench_boot" * 2: < 5 minutes and important or a few seconds and not too important
) * 3: all
'''
)
gem5_insts() ( def _bench(self, **kwargs):
printf "instructions $(./gem5-stat --arch "$1" sim_insts)\n" >> "$common_bench_boot" self.run(**kwargs)
newline
)
qemu_insts() ( def timed_main(self):
common_arch="$1" #bench() (
./qemu-trace2txt --arch "$common_arch" # "${root_dir}/bench-cmd" "./run --arch ${1}${extra_args}" "$self.env['bench_boot']"
common_qemu_trace_txt_file="$("$getvar" --arch "$common_arch" qemu_trace_txt_file)" #)
printf "instructions $(wc -l "${common_qemu_trace_txt_file}" | cut -d' ' -f1)\n" >> "$common_bench_boot" #
newline #newline() (
) # echo >> "$self.env['bench_boot']"
#)
#
#gem5_insts() (
# printf "instructions $(./gem5-stat --arch "$1" sim_insts)\n" >> "$self.env['bench_boot']"
# newline
#)
#
#qemu_insts() (
# common_arch="$1"
# ./qemu-trace2txt --arch "$common_arch"
# common_qemu_trace_txt_file="$("$getvar" --arch "$common_arch" qemu_trace_txt_file)"
# printf "instructions $(wc -l "${common_qemu_trace_txt_file}" | cut -d' ' -f1)\n" >> "$self.env['bench_boot']"
# newline
#)
#
#rm -f "${self.env['bench_boot']}"
rm -f "${common_bench_boot}" self.run = self.import_path_main('run')
run_args = self.get_common_args()
if self.env['emulator'] == 'gem5':
run_args['eval'] = 'm5 exit'
elif self.env['emulator'] == 'qemu':
run_args['eval'] = '/poweroff.out'
if (self.env['emulator'] == 'qemu' or
(self.env['emulator'] == 'gem5' and self.env['size'] >= 2)):
self._bench(**run_args)
if self.env['host_arch'] == self.env['arch']:
# TODO: find out why it fails.
if self.env['emulator'] != 'gem5':
self._bench(kvm=True, **run_args)
# newline
if self.env['emulator'] == 'qemu' and self.env['size'] >= 2:
self._bench(trace='exec_tb', **run_args)
# qemu_insts "$arch"
if self.env['emulator'] == 'gem5' and self.env['size'] >= 3:
self._bench(
extra_emulator_args=[
'--cpu-type',
'DerivO3CPU',
'--caches',
'--l2cache',
'--l1d_size=1024kB',
'--l1i_size=1024kB',
'--l2_size=1024kB',
'--l3_size=1024kB',
],
**run_args
)
# gem5_insts "$arch"
arch=x86_64 #arch=arm
bench "${arch} --eval '/poweroff.out'" #bench "$arch --eval '/poweroff.out'"
newline #newline
bench "${arch} --eval '/poweroff.out' --kvm" #if [ self.env['size'] -ge 2 ]; then
newline # bench "$arch --eval '/poweroff.out' --trace exec_tb"
if [ "$test_size" -ge 2 ]; then # qemu_insts "$arch"
bench "${arch} --eval '/poweroff.out' --trace exec_tb" # bench "$arch --eval 'm5 exit' --emulator gem5"
qemu_insts "$arch" # gem5_insts "$arch"
bench "$arch --eval 'm5 exit' --emulator gem5" #fi
gem5_insts "$arch" #if [ self.env['size'] -ge 3 ]; then
fi # bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=HPI ${caches}"
#bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=DerivO3CPU ${caches}" # gem5_insts "$arch"
#gem5_insts "$arch" #fi
arch=arm #arch=aarch64
bench "$arch --eval '/poweroff.out'" #bench "$arch --eval '/poweroff.out'"
newline #newline
if [ "$test_size" -ge 2 ]; then #if [ self.env['size'] -ge 2 ]; then
bench "$arch --eval '/poweroff.out' --trace exec_tb" # bench "$arch --eval '/poweroff.out' --trace exec_tb"
qemu_insts "$arch" # qemu_insts "$arch"
bench "$arch --eval 'm5 exit' --emulator gem5" # bench "$arch --eval 'm5 exit' --emulator gem5"
gem5_insts "$arch" # gem5_insts "$arch"
fi #fi
if [ "$test_size" -ge 3 ]; then #if [ self.env['size'] -ge 3 ]; then
bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=HPI ${caches}" # bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=HPI ${caches}"
gem5_insts "$arch" # gem5_insts "$arch"
fi # #bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-script biglittle"
# #gem5_insts "$arch"
# bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-build-type fast"
# gem5_insts "$arch"
# bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-build-type debug"
# gem5_insts "$arch"
#fi
if __name__ == '__main__':
Main().cli_exit()
arch=aarch64
bench "$arch --eval '/poweroff.out'"
newline
if [ "$test_size" -ge 2 ]; then
bench "$arch --eval '/poweroff.out' --trace exec_tb"
qemu_insts "$arch"
bench "$arch --eval 'm5 exit' --emulator gem5"
gem5_insts "$arch"
fi
if [ "$test_size" -ge 3 ]; then
bench "$arch --eval 'm5 exit' --emulator gem5 -- --cpu-type=HPI ${caches}"
gem5_insts "$arch"
#bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-script biglittle"
#gem5_insts "$arch"
bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-build-type fast"
gem5_insts "$arch"
bench "$arch --eval 'm5 exit' --emulator gem5 --gem5-build-type debug"
gem5_insts "$arch"
fi

3
build
View File

@@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import platform
import re import re
import os import os
@@ -368,7 +367,7 @@ Which components to build. Default: qemu-buildroot
} }
# E.g. on an ARM host, the package gcc-arm-linux-gnueabihf # E.g. on an ARM host, the package gcc-arm-linux-gnueabihf
# is called just gcc. # is called just gcc.
processor = platform.processor() processor = self.env['host_arch']
if processor != 'arm': if processor != 'arm':
apt_get_pkgs.update({ apt_get_pkgs.update({
'gcc-arm-linux-gnueabihf', 'gcc-arm-linux-gnueabihf',

View File

@@ -431,6 +431,8 @@ amazing function!
assert one_cli_function.get_cli(pos_mandatory=1, bool=False) == [('--bool',), ('--bool-cli',), ('1',)] assert one_cli_function.get_cli(pos_mandatory=1, bool=False) == [('--bool',), ('--bool-cli',), ('1',)]
assert one_cli_function.get_cli(pos_mandatory=1, pos_optional=2, args_star=['3', '4']) == [('--bool-cli',), ('1',), ('2',), ('3',), ('4',)] assert one_cli_function.get_cli(pos_mandatory=1, pos_optional=2, args_star=['3', '4']) == [('--bool-cli',), ('1',), ('2',), ('3',), ('4',)]
assert one_cli_function.get_cli(pos_mandatory=1, append=['2', '3']) == [('--append', '2'), ('--append', '3',), ('--bool-cli',), ('1',)] assert one_cli_function.get_cli(pos_mandatory=1, append=['2', '3']) == [('--append', '2'), ('--append', '3',), ('--bool-cli',), ('1',)]
print(one_cli_function.get_cli(pos_mandatory=1, args_star=['asdf', 'qwer']))
assert one_cli_function.get_cli(pos_mandatory=1, args_star=['asdf', 'qwer']) == [('--bool-cli',), ('1',), ('asdf',), ('qwer',),]
if len(sys.argv) > 1: if len(sys.argv) > 1:
# CLI call with argv command line arguments. # CLI call with argv command line arguments.

View File

@@ -12,6 +12,7 @@ import json
import math import math
import multiprocessing import multiprocessing
import os import os
import platform
import re import re
import shutil import shutil
import signal import signal
@@ -105,6 +106,7 @@ consts['emulator_choices'] = set()
for key in consts['emulator_short_to_long_dict']: for key in consts['emulator_short_to_long_dict']:
consts['emulator_choices'].add(key) consts['emulator_choices'].add(key)
consts['emulator_choices'].add(consts['emulator_short_to_long_dict'][key]) consts['emulator_choices'].add(consts['emulator_short_to_long_dict'][key])
consts['host_arch'] = platform.processor()
class LkmcCliFunction(cli_function.CliFunction): class LkmcCliFunction(cli_function.CliFunction):
''' '''