changeset 971507cbbe65 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=971507cbbe65
description:
Configs: Fix up maxtick and maxtime
This patch contains three fixes to max tick options handling in
Options.py and
Simulation.py:
1) Since the global simulator frequency isn't bound until
m5.instantiate()
is called, the maxtick resolution needs to happen after this call, since
changes to the global frequency will cause m5.simulate() to
misinterpret the
maxtick value. Shuffling this also requires tweaking the checkpoint
directory
handling to signal the checkpoint restore tick back to run(). Fixing
this
completely and correctly will require storing the simulation frequency
into
checkpoints, which is beyond the scope of this patch.
2) The maxtick option in Options.py was defaulted to MaxTicks, so the
old code
would always skip over the maxtime part of the conditionals at the
beginning
of run(). Change the maxtick default to None, and set the maxtick local
variable in run() appropriately.
3) To clarify whether max ticks settings are relative or absolute,
split the
maxtick option into separate options, for relative and absolute. Ensure
that
these two options and the maxtime option are handled appropriately to
set the
maxtick variable in Simulation.py.
diffstat:
configs/common/Options.py | 13 ++++++++--
configs/common/Simulation.py | 52 +++++++++++++++++++++++++++++--------------
2 files changed, 45 insertions(+), 20 deletions(-)
diffs (117 lines):
diff -r 3b3b94536547 -r 971507cbbe65 configs/common/Options.py
--- a/configs/common/Options.py Thu Jul 18 08:31:19 2013 -0400
+++ b/configs/common/Options.py Thu Jul 18 14:46:54 2013 -0500
@@ -109,9 +109,16 @@
parser.add_option("--ruby", action="store_true")
# Run duration options
- parser.add_option("-m", "--maxtick", type="int", default=m5.MaxTick,
- metavar="T", help="Stop after T ticks")
- parser.add_option("--maxtime", type="float")
+ parser.add_option("-m", "--abs-max-tick", type="int", default=None,
+ metavar="TICKS", help="Run to absolute simulated tick " \
+ "specified including ticks from a restored checkpoint")
+ parser.add_option("--rel-max-tick", type="int", default=None,
+ metavar="TICKS", help="Simulate for specified number of"
\
+ " ticks relative to the simulation start tick (e.g. if "
\
+ "restoring a checkpoint)")
+ parser.add_option("--maxtime", type="float", default=None,
+ help="Run to the specified absolute simulated time in " \
+ "seconds")
parser.add_option("-I", "--maxinsts", action="store", type="int",
default=None, help="""Total number of instructions to
simulate (default: run forever)""")
diff -r 3b3b94536547 -r 971507cbbe65 configs/common/Simulation.py
--- a/configs/common/Simulation.py Thu Jul 18 08:31:19 2013 -0400
+++ b/configs/common/Simulation.py Thu Jul 18 14:46:54 2013 -0500
@@ -106,7 +106,7 @@
if options.work_cpus_checkpoint_count != None:
system.work_cpus_ckpt_count = options.work_cpus_checkpoint_count
-def findCptDir(options, maxtick, cptdir, testsys):
+def findCptDir(options, cptdir, testsys):
"""Figures out the directory from which the checkpointed state is read.
There are two different ways in which the directories holding checkpoints
@@ -117,9 +117,6 @@
This function parses through the options to figure out which one of the
above should be used for selecting the checkpoint, and then figures out
the appropriate directory.
-
- It also sets the value of the maximum tick value till which the simulation
- will run.
"""
from os.path import isdir, exists
@@ -155,10 +152,10 @@
if cpt_num > len(cpts):
fatal('Checkpoint %d not found', cpt_num)
- maxtick = maxtick - int(cpts[cpt_num - 1])
+ cpt_starttick = int(cpts[cpt_num - 1])
checkpoint_dir = joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1])
- return maxtick, checkpoint_dir
+ return cpt_starttick, checkpoint_dir
def scriptCheckpoints(options, maxtick, cptdir):
if options.at_instruction or options.simpoint:
@@ -260,15 +257,6 @@
return exit_event
def run(options, root, testsys, cpu_class):
- if options.maxtick:
- maxtick = options.maxtick
- elif options.maxtime:
- simtime = m5.ticks.seconds(simtime)
- print "simulating for: ", simtime
- maxtick = simtime
- else:
- maxtick = m5.MaxTick
-
if options.checkpoint_dir:
cptdir = options.checkpoint_dir
elif m5.options.outdir:
@@ -421,10 +409,40 @@
testsys.cpu[i].max_insts_any_thread = offset
checkpoint_dir = None
- if options.checkpoint_restore != None:
- maxtick, checkpoint_dir = findCptDir(options, maxtick, cptdir, testsys)
+ if options.checkpoint_restore:
+ cpt_starttick, checkpoint_dir = findCptDir(options, cptdir, testsys)
m5.instantiate(checkpoint_dir)
+ # Handle the max tick settings now that tick frequency was resolved
+ # during system instantiation
+ # NOTE: the maxtick variable here is in absolute ticks, so it must
+ # include any simulated ticks before a checkpoint
+ explicit_maxticks = 0
+ maxtick_from_abs = m5.MaxTick
+ maxtick_from_rel = m5.MaxTick
+ maxtick_from_maxtime = m5.MaxTick
+ if options.abs_max_tick:
+ maxtick_from_abs = options.abs_max_tick
+ explicit_maxticks += 1
+ if options.rel_max_tick:
+ maxtick_from_rel = options.rel_max_tick
+ if options.checkpoint_restore:
+ # NOTE: this may need to be updated if checkpoints ever store
+ # the ticks per simulated second
+ maxtick_from_rel += cpt_starttick
+ explicit_maxticks += 1
+ if options.maxtime:
+ maxtick_from_maxtime = m5.ticks.fromSeconds(options.maxtime)
+ explicit_maxticks += 1
+ if explicit_maxticks > 1:
+ warn("Specified multiple of --abs-max-tick, --rel-max-tick,
--maxtime."\
+ " Using least")
+ maxtick = min([maxtick_from_abs, maxtick_from_rel, maxtick_from_maxtime])
+
+ if options.checkpoint_restore != None and maxtick < cpt_starttick:
+ fatal("Bad maxtick (%d) specified: " \
+ "Checkpoint starts starts from tick: %d", maxtick, cpt_starttick)
+
if options.standard_switch or cpu_class:
if options.standard_switch:
print "Switch at instruction count:%s" % \
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev