gem5-stat ported

This commit is contained in:
Ciro Santilli
2018-08-31 08:34:19 +01:00
parent 78a7eeaed8
commit 17b3e10bab
2 changed files with 21 additions and 25 deletions

View File

@@ -236,6 +236,7 @@ def setup(parser, **extra_args):
this.target_dir = os.path.join(this.buildroot_out_dir, 'target') this.target_dir = os.path.join(this.buildroot_out_dir, 'target')
this.gem5_run_dir = os.path.join(this.out_arch_dir, 'gem5', str(args.run_id)) this.gem5_run_dir = os.path.join(this.out_arch_dir, 'gem5', str(args.run_id))
this.m5out_dir = os.path.join(this.gem5_run_dir, 'm5out') this.m5out_dir = os.path.join(this.gem5_run_dir, 'm5out')
this.stats_file = os.path.join(this.m5out_dir, 'stats.txt')
this.trace_txt_file = os.path.join(this.m5out_dir, 'trace.txt') this.trace_txt_file = os.path.join(this.m5out_dir, 'trace.txt')
this.gem5_termout_file = os.path.join(this.gem5_run_dir, 'termout.txt') this.gem5_termout_file = os.path.join(this.gem5_run_dir, 'termout.txt')
this.qemu_run_dir = os.path.join(this.out_arch_dir, 'qemu', str(args.run_id)) this.qemu_run_dir = os.path.join(this.out_arch_dir, 'qemu', str(args.run_id))

View File

@@ -1,25 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env python3
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common" import re
common_gem5=true import common
while getopts "h${common_getopts_flags}" OPT; do parser = common.get_argparse(
case "$OPT" in argparse_args={'description':'Get the value of a gem5 stat from the stats.txt file.'}
h) )
printf "\ parser.add_argument(
usage: $0 [-a arch] [stat=system.cpu.numCycles] 'stat',
Get the value for a gem5 stat from the stats.txt file. default='^system.cpu[0-9]*.numCycles$',
" 1>&2 help='Python regexp matching the full stat name of interest',
exit nargs='?',
;; )
?) args = common.setup(parser)
common_getopts_case "$OPT" stat_re = re.compile(args.stat)
;; with open(common.stats_file, 'r') as statfile:
esac for line in statfile:
done if line[0] != '-':
shift "$(($OPTIND - 1))" cols = line.split()
if [ $# -gt 0 ]; then if len(cols) > 1 and stat_re.search(cols[0]):
stat="$1" print(cols[1])
else
stat=system.cpu[0-9]*.numCycles
fi
common_setup
awk "/^$stat /{ print \$2 }" "${common_m5out_dir}/stats.txt"