def instantiate(root): # we need to fix the global frequency ticks.fixGlobalFrequency() root.unproxy_all() if options.dump_config: ini_file = file(os.path.join(options.outdir, options.dump_config), 'w') root.print_ini(ini_file) ini_file.close() # Initialize the global statistics stats.initSimStats() # Create the C++ sim objects and connect ports root.createCCObject() root.connectPorts() # Do a second pass to finish initializing the sim objects core.initAll() # Do a third pass to initialize statistics core.regAllStats() # We're done registering statistics. Enable the stats package now. stats.enable() # Reset to put the stats in a consistent state. stats.reset()
def instantiate(ckpt_dir=None): from m5 import options root = objects.Root.getInstance() if not root: fatal("Need to instantiate Root() before calling instantiate()") # we need to fix the global frequency ticks.fixGlobalFrequency() # Make sure SimObject-valued params are in the configuration # hierarchy so we catch them with future descendants() walks for obj in root.descendants(): obj.adoptOrphanParams() # Unproxy in sorted order for determinism for obj in root.descendants(): obj.unproxyParams() if options.dump_config: ini_file = file(os.path.join(options.outdir, options.dump_config), 'w') # Print ini sections in sorted order for easier diffing for obj in sorted(root.descendants(), key=lambda o: o.path()): obj.print_ini(ini_file) ini_file.close() # Initialize the global statistics stats.initSimStats() # Create the C++ sim objects and connect ports for obj in root.descendants(): obj.createCCObject() for obj in root.descendants(): obj.connectPorts() # Do a second pass to finish initializing the sim objects for obj in root.descendants(): obj.init() # Do a third pass to initialize statistics for obj in root.descendants(): obj.regStats() for obj in root.descendants(): obj.regFormulas() # We're done registering statistics. Enable the stats package now. stats.enable() # Restore checkpoint (if any) if ckpt_dir: ckpt = internal.core.getCheckpoint(ckpt_dir) internal.core.unserializeGlobals(ckpt); for obj in root.descendants(): obj.loadState(ckpt) need_resume.append(root) else: for obj in root.descendants(): obj.initState() # Reset to put the stats in a consistent state. stats.reset()
def simulate(*args, **kwargs): global need_startup if need_startup: root = objects.Root.getInstance() for obj in root.descendants(): obj.startup() need_startup = False # Python exit handlers happen in reverse order. # We want to dump stats last. atexit.register(stats.dump) # register our C++ exit callback function with Python atexit.register(internal.core.doExitCleanup) # Reset to put the stats in a consistent state. stats.reset() if _drain_manager.isDrained(): _drain_manager.resume() return internal.event.simulate(*args, **kwargs)
def simulate(*args, **kwargs): global need_startup if need_startup: root = objects.Root.getInstance() for obj in root.descendants(): obj.startup() need_startup = False # Python exit handlers happen in reverse order. # We want to dump stats last. atexit.register(stats.dump) # register our C++ exit callback function with Python atexit.register(_m5.core.doExitCleanup) # Reset to put the stats in a consistent state. stats.reset() if _drain_manager.isDrained(): _drain_manager.resume() return _m5.event.simulate(*args, **kwargs)
def instantiate(ckpt_dir=None): from m5 import options root = objects.Root.getInstance() if not root: fatal("Need to instantiate Root() before calling instantiate()") # we need to fix the global frequency ticks.fixGlobalFrequency() # Make sure SimObject-valued params are in the configuration # hierarchy so we catch them with future descendants() walks for obj in root.descendants(): obj.adoptOrphanParams() # Unproxy in sorted order for determinism for obj in root.descendants(): obj.unproxyParams() if options.dump_config: ini_file = file(os.path.join(options.outdir, options.dump_config), 'w') # Print ini sections in sorted order for easier diffing for obj in sorted(root.descendants(), key=lambda o: o.path()): obj.print_ini(ini_file) ini_file.close() if options.json_config: try: import json json_file = file(os.path.join(options.outdir, options.json_config), 'w') d = root.get_config_as_dict() json.dump(d, json_file, indent=4) json_file.close() except ImportError: pass do_dot(root, options.outdir, options.dot_config) # Initialize the global statistics stats.initSimStats() # Create the C++ sim objects and connect ports for obj in root.descendants(): obj.createCCObject() for obj in root.descendants(): obj.connectPorts() # Do a second pass to finish initializing the sim objects for obj in root.descendants(): obj.init() # Do a third pass to initialize statistics for obj in root.descendants(): obj.regStats() # We're done registering statistics. Enable the stats package now. stats.enable() # Restore checkpoint (if any) if ckpt_dir: ckpt = internal.core.getCheckpoint(ckpt_dir) internal.core.unserializeGlobals(ckpt) for obj in root.descendants(): obj.loadState(ckpt) need_resume.append(root) else: for obj in root.descendants(): obj.initState() # Check to see if any of the stat events are in the past after resuming from # a checkpoint, If so, this call will shift them to be at a valid time. updateStatEvents() # Reset to put the stats in a consistent state. stats.reset()
def restoreCheckpoint(root, dir): print "Restoring from checkpoint" internal.core.unserializeAll(dir) need_resume.append(root) stats.reset()