run: -l latest checkpoint restore

Run is in theory done now, but all edge functionality needs double testing.
This commit is contained in:
Ciro Santilli
2018-08-30 09:54:28 +01:00
parent ddfb34cdd4
commit 12d5794547
3 changed files with 27 additions and 15 deletions

View File

@@ -8535,7 +8535,7 @@ The out of build tree is required, because otherwise Buildroot would copy the ou
By default, we use `configs/example/fs.py` script.
The `-X-b` option enables the alternative `configs/example/arm/fs_bigLITTLE.py` script instead.
The `--gem5-biglittle` option enables the alternative `configs/example/arm/fs_bigLITTLE.py` script instead.
First apply:
@@ -8546,7 +8546,7 @@ patch -d gem5/gem5 -p1 < patches/manual/gem5-biglittle.patch
then:
....
./run -a A -g -X-b
./run -a A -g --gem5-biglittle
....
Advantages over `fs.py`:

View File

@@ -3,6 +3,7 @@
import argparse
import base64
import imp
import re
import subprocess
import os
import shlex
@@ -33,6 +34,20 @@ this = sys.modules[__name__]
def base64_encode(string):
return base64.b64encode(string.encode()).decode()
def error(msg):
print('error: {}'.format(msg), file=sys.stderr)
sys.exit(1)
def gem_list_checkpoint_dirs():
"""
List checkpoint directory, oldest first.
"""
global this
prefix_re = re.compile(this.gem5_cpt_prefix)
files = list(filter(lambda x: os.path.isdir(os.path.join(this.m5out_dir, x)) and prefix_re.search(x), os.listdir(this.m5out_dir)))
files.sort(key=lambda x: os.path.getmtime(os.path.join(this.m5out_dir, x)))
return files
def get_argparse(default_args=None, argparse_args=None):
"""
Return an argument parser with common arguments set.
@@ -245,7 +260,7 @@ arch_map = {
'A': 'aarch64',
'x': 'x86_64',
}
gem5_cpt_pref = '^cpt\.'
gem5_cpt_prefix = '^cpt\.'
sha = subprocess.check_output(['git', '-C', root_dir, 'log', '-1', '--format=%H']).decode().rstrip()
# Config file. TODO move to decent python setup.

21
run
View File

@@ -224,11 +224,9 @@ if args.gem5:
]
)
if args.gem5_biglittle:
# TODO port
# if args.gem5_restore_last_checkpoint is not None:
# cmd += [
# '--restore-from='${common.m5out_dir}/$(ls -crt "common.m5out_dir" | grep -E "common.gem5_cpt_pref" | tail -n "$gem5_restore_last_checkpoint" | head -n 1
# ]
if args.gem5_restore_last_checkpoint is not None:
cpt_dir = common.gem_list_checkpoint_dirs()[-args.gem5_restore_last_checkpoint]
extra_emulator_args.extend(['--restore-from', os.path.join(common.m5out_dir, cpt_dir)])
cmd += [
os.path.join(common.gem5_src_dir, 'configs', 'example', 'arm', 'fs_bigLITTLE.py'),
'--big-cpus', '2',
@@ -240,10 +238,10 @@ if args.gem5:
]
else:
# TODO port
#if [ -n "$gem5_restore_last_checkpoint" ]; then
# latest_cpt_basename="$(ls -crt "common.m5out_dir" | grep -E "common.gem5_cpt_pref" | tail -n "$gem5_restore_last_checkpoint" | head -n 1)"
# n="$(ls -1 "common.m5out_dir" | grep -E "common.gem5_cpt_pref" | sort -k 2 -n -t . | grep -n "$latest_cpt_basename" | cut -d : -f 1)"
# cmd += -r ${n} \\
if args.gem5_restore_last_checkpoint is not None:
cpt_dirs = common.gem_list_checkpoint_dirs()
cpt_dir = cpt_dirs[-args.gem5_restore_last_checkpoint]
extra_emulator_args.extend(['-r', str(sorted(cpt_dirs).index(cpt_dir) + 1)])
cmd += [
os.path.join(common.gem5_src_dir, 'configs', 'example', 'fs.py'),
'--disk-image', common.ext2_file,
@@ -401,7 +399,7 @@ with subprocess.Popen(cmd, stdout=stdout, stderr=stderr, env=env) as proc:
break
signal.signal(signal.SIGINT, signal.SIG_DFL)
if proc.returncode != 0:
sys.exit(proc.returncode)
common.error('simulator exited with status != 0')
# Check if guest panicked.
if args.gem5:
# We have to do some parsing here because gem5 exits with status 0 even when panic happens.
@@ -413,5 +411,4 @@ panic_re = re.compile(panic_msg)
with open(common.termout_file, 'r') as logfile:
for line in logfile:
if panic_re.search(line):
print('Simulation error detected by parsing logs. Exiting with status 1.', file=sys.stderr)
sys.exit(1)
common.error('simulation error detected by parsing logs')