summaryrefslogtreecommitdiff
path: root/configs/common
diff options
context:
space:
mode:
authorJoel Hestness <jthestness@gmail.com>2013-07-18 14:46:54 -0500
committerJoel Hestness <jthestness@gmail.com>2013-07-18 14:46:54 -0500
commit7aa67f42cb02be0e47d1395fa5377af4730471dc (patch)
tree97510e849a33fd9e64e7531aaeb5c6adb6bdc5a2 /configs/common
parentc20105c2ff2b8300fa18a5c3f1afb806d6ae9458 (diff)
downloadgem5-7aa67f42cb02be0e47d1395fa5377af4730471dc.tar.xz
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 (limited to 'configs/common')
-rw-r--r--configs/common/Options.py13
-rw-r--r--configs/common/Simulation.py52
2 files changed, 45 insertions, 20 deletions
diff --git a/configs/common/Options.py b/configs/common/Options.py
index ce270fcd4..2fe77aef3 100644
--- a/configs/common/Options.py
+++ b/configs/common/Options.py
@@ -109,9 +109,16 @@ def addCommonOptions(parser):
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 --git a/configs/common/Simulation.py b/configs/common/Simulation.py
index deccdad5c..f88888dc4 100644
--- a/configs/common/Simulation.py
+++ b/configs/common/Simulation.py
@@ -106,7 +106,7 @@ def setWorkCountOptions(system, options):
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 @@ def findCptDir(options, maxtick, cptdir, testsys):
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 @@ def findCptDir(options, maxtick, cptdir, testsys):
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 @@ def repeatSwitch(testsys, repeat_switch_cpu_list, maxtick, switch_freq):
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 @@ def run(options, root, testsys, cpu_class):
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" % \