for i in xrange(np):
testsys.cpu[i].max_insts_any_thread = offset
- m5.instantiate(root)
+ m5.instantiate()
if options.checkpoint_restore != None:
from os.path import isdir, exists
fatal("Unable to find checkpoint directory %s", checkpoint_dir)
print "Restoring checkpoint ..."
- m5.restoreCheckpoint(root, checkpoint_dir)
+ m5.restoreCheckpoint(checkpoint_dir)
print "Done."
elif options.simpoint:
# assume workload 0 has the simpoint
options.bench, options.checkpoint_restore)
print "Restoring checkpoint ..."
- m5.restoreCheckpoint(root,checkpoint_dir)
+ m5.restoreCheckpoint(checkpoint_dir)
print "Done."
else:
dirs = listdir(cptdir)
maxtick = maxtick - int(cpts[cpt_num - 1])
## Restore the checkpoint
- m5.restoreCheckpoint(root,
- joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1]))
+ m5.restoreCheckpoint(joinpath(cptdir,
+ "cpt.%s" % cpts[cpt_num - 1]))
if options.standard_switch or cpu_class:
if options.standard_switch:
if exit_event.getCause() == \
"a thread reached the max instruction count":
- m5.checkpoint(root, joinpath(cptdir, "cpt.%s.%d" % \
+ m5.checkpoint(joinpath(cptdir, "cpt.%s.%d" % \
(options.bench, checkpoint_inst)))
print "Checkpoint written."
num_checkpoints += 1
exit_event = m5.simulate(when - m5.curTick())
if exit_event.getCause() == "simulate() limit reached":
- m5.checkpoint(root, joinpath(cptdir, "cpt.%d"))
+ m5.checkpoint(joinpath(cptdir, "cpt.%d"))
num_checkpoints += 1
sim_ticks = when
while exit_event.getCause() == "checkpoint":
exit_event = m5.simulate(sim_ticks - m5.curTick())
if exit_event.getCause() == "simulate() limit reached":
- m5.checkpoint(root, joinpath(cptdir, "cpt.%d"))
+ m5.checkpoint(joinpath(cptdir, "cpt.%d"))
num_checkpoints += 1
if exit_event.getCause() != "simulate() limit reached":
exit_event = m5.simulate(maxtick)
while exit_event.getCause() == "checkpoint":
- m5.checkpoint(root, joinpath(cptdir, "cpt.%d"))
+ m5.checkpoint(joinpath(cptdir, "cpt.%d"))
num_checkpoints += 1
if num_checkpoints == max_checkpoints:
exit_cause = "maximum %d checkpoints dropped" % max_checkpoints
print 'Exiting @ cycle %i because %s' % (m5.curTick(), exit_cause)
if options.checkpoint_at_end:
- m5.checkpoint(root, joinpath(cptdir, "cpt.%d"))
+ m5.checkpoint(joinpath(cptdir, "cpt.%d"))
import SimObject
import ticks
import objects
+from util import fatal
# define a MaxTick parameter
MaxTick = 2**63 - 1
# The final hook to generate .ini files. Called from the user script
# once the config is built.
-def instantiate(root):
+def instantiate():
+ root = objects.Root.getInstance()
+
+ if not root:
+ fatal("Need to instantiate Root() before calling instantiate()")
+
# we need to fix the global frequency
ticks.fixGlobalFrequency()
def resume(root):
root.resume()
-def checkpoint(root, dir):
+def checkpoint(dir):
+ root = objects.Root.getInstance()
if not isinstance(root, objects.Root):
raise TypeError, "Checkpoint must be called on a root object."
doDrain(root)
internal.core.serializeAll(dir)
resume(root)
-def restoreCheckpoint(root, dir):
+def restoreCheckpoint(dir):
+ root = objects.Root.getInstance()
print "Restoring from checkpoint"
internal.core.unserializeAll(dir)
need_resume.append(root)
from m5.SimObject import SimObject
from m5.params import *
+from m5.util import fatal
class Root(SimObject):
+
+ _the_instance = None
+
+ def __new__(cls, **kwargs):
+ if Root._the_instance:
+ fatal("Attempt to allocate multiple instances of Root.")
+ return None
+
+ # first call: allocate the unique instance
+ #
+ # If SimObject ever implements __new__, we may want to pass
+ # kwargs here, but for now this goes straight to
+ # object.__new__ which prints an ugly warning if you pass it
+ # args. Seems like a bad design but that's the way it is.
+ Root._the_instance = SimObject.__new__(cls)
+ return Root._the_instance
+
+ @classmethod
+ def getInstance(cls):
+ return Root._the_instance
+
+ def path(self):
+ return 'root'
+
type = 'Root'
dummy = Param.Int(0, "We don't support objects without params")