def _run_step(name, restore=None, interval=0.5): """ Instantiate (optionally from a checkpoint if restore is set to the checkpoitn name) the system and run for interval seconds of simulated time. At the end of the simulation interval, create a checkpoint and exit. As this function is intended to run in its own process using the multiprocessing framework, the exit is a true call to exit which terminates the process. Exit codes are used to pass information to the parent. """ if restore is not None: m5.instantiate(restore) else: m5.instantiate() e = m5.simulate(m5.ticks.fromSeconds(interval)) cause = e.getCause() if cause in _exit_limit: m5.checkpoint(name) sys.exit(_exitcode_checkpoint) elif cause in _exit_normal: sys.exit(_exitcode_done) else: print("Test failed: Unknown exit cause: %s" % cause) sys.exit(_exitcode_fail)
def benchCheckpoints_sync(options, maxreltick, cptdir): import socket quantum,port,host = options.sync.split(',') sync_quantum = long(quantum) TCP_IP = host TCP_PORT = int(port) BUFFER_SIZE = 1 pre_tick = m5.curTick() try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) exit_event = m5.simulate(sync_quantum) exit_cause = exit_event.getCause() total_tick_simulated = sync_quantum num_checkpoints = 0 max_checkpoints = options.max_checkpoints s.send("R") data = s.recv(BUFFER_SIZE) while total_tick_simulated <= maxreltick and\ (exit_cause == "simulate() limit reached" or\ exit_cause == "checkpoint"): if exit_cause == "checkpoint": m5.simulate(pre_tick + sync_quantum - m5.curTick()) # send "C" to barrier to notify that we should take a # checkpoint at the begining of next quantum s.send("C") else: s.send("R") data = s.recv(BUFFER_SIZE) pre_tick = m5.curTick() exit_event = m5.simulate(sync_quantum) total_tick_simulated += sync_quantum # if we receive a "C" from barrier, start to dump a checkpoint if data == "C" : m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 if num_checkpoints == max_checkpoints: exit_cause = "maximum %d checkpoints dropped"\ % max_checkpoints break exit_cause = exit_event.getCause() except KeyboardInterrupt: sys.exit() except Exception as ex: print "exception %s occured." %(ex.args[1]) sys.exit() return exit_event
def run(checkpoint_dir=m5.options.outdir): # start simulation (and drop checkpoints when requested) while True: event = m5.simulate() exit_msg = event.getCause() if exit_msg == "checkpoint": print("Dropping checkpoint at tick %d" % m5.curTick()) cpt_dir = os.path.join(checkpoint_dir, "cpt.%d" % m5.curTick()) m5.checkpoint(cpt_dir) print("Checkpoint done.") else: print(exit_msg, " @ ", m5.curTick()) break sys.exit(event.getCode())
def benchCheckpoints(options, maxtick, cptdir): exit_event = m5.simulate(maxtick - m5.curTick()) exit_cause = exit_event.getCause() num_checkpoints = 0 max_checkpoints = options.max_checkpoints while exit_cause == "checkpoint": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 if num_checkpoints == max_checkpoints: exit_cause = "maximum %d checkpoints dropped" % max_checkpoints break exit_event = m5.simulate(maxtick - m5.curTick()) exit_cause = exit_event.getCause() return exit_event
def run(args): cptdir = m5.options.outdir if args.checkpoint: print("Checkpoint directory: %s" % cptdir) while True: event = m5.simulate() exit_msg = event.getCause() if exit_msg == "checkpoint": print("Dropping checkpoint at tick %d" % m5.curTick()) cpt_dir = os.path.join(m5.options.outdir, "cpt.%d" % m5.curTick()) m5.checkpoint(os.path.join(cpt_dir)) print("Checkpoint done.") else: print(exit_msg, " @ ", m5.curTick()) break sys.exit(event.getCode())
def run(args): cptdir = m5.options.outdir if args.checkpoint: print "Checkpoint directory: %s" % cptdir while True: event = m5.simulate() exit_msg = event.getCause() if exit_msg == "checkpoint": print "Dropping checkpoint at tick %d" % m5.curTick() cpt_dir = os.path.join(m5.options.outdir, "cpt.%d" % m5.curTick()) m5.checkpoint(os.path.join(cpt_dir)) print "Checkpoint done." else: print exit_msg, " @ ", m5.curTick() break sys.exit(event.getCode())
def takeSimpointCheckpoints(simpoints, interval_length, cptdir): num_checkpoints = 0 index = 0 last_chkpnt_inst_count = -1 for simpoint in simpoints: interval, weight, starting_inst_count, actual_warmup_length = simpoint if starting_inst_count == last_chkpnt_inst_count: # checkpoint starting point same as last time # (when warmup period longer than starting point) exit_cause = "simpoint starting point found" code = 0 else: exit_event = m5.simulate() # skip checkpoint instructions should they exist while exit_event.getCause() == "checkpoint": print("Found 'checkpoint' exit event...ignoring...") exit_event = m5.simulate() exit_cause = exit_event.getCause() code = exit_event.getCode() if exit_cause == "simpoint starting point found": m5.checkpoint( joinpath( cptdir, "cpt.simpoint_%02d_inst_%d_weight_%f_interval_%d_warmup_%d" % (index, starting_inst_count, weight, interval_length, actual_warmup_length))) print("Checkpoint #%d written. start inst:%d weight:%f" % (num_checkpoints, starting_inst_count, weight)) num_checkpoints += 1 last_chkpnt_inst_count = starting_inst_count else: break index += 1 print('Exiting @ tick %i (takeSimpointCheckpoints) because %s' % (m5.curTick(), exit_cause)) print("%d checkpoints taken" % num_checkpoints) sys.exit(code)
def scriptCheckpoints(options, maxtick, cptdir): if options.at_instruction or options.simpoint: checkpoint_inst = options.take_checkpoints # maintain correct offset if we restored from some instruction if options.checkpoint_restore != None: checkpoint_inst += options.checkpoint_restore print "Creating checkpoint at inst:%d" % (checkpoint_inst) exit_event = m5.simulate() exit_cause = exit_event.getCause() print "exit cause = %s" % exit_cause # skip checkpoint instructions should they exist while exit_cause == "checkpoint": exit_event = m5.simulate() exit_cause = exit_event.getCause() if exit_cause == "a thread reached checkpoint inst number" or \ exit_cause == "sp simulation reached the interval size": m5.checkpoint(joinpath(cptdir, "cpt.%s.%d" % \ (options.bench, checkpoint_inst))) print "Checkpoint written." else: when, period = options.take_checkpoints.split(",", 1) when = int(when) period = int(period) num_checkpoints = 0 exit_event = m5.simulate(when - m5.curTick()) exit_cause = exit_event.getCause() while exit_cause == "checkpoint": exit_event = m5.simulate(when - m5.curTick()) exit_cause = exit_event.getCause() if exit_cause == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 sim_ticks = when max_checkpoints = options.max_checkpoints while num_checkpoints < max_checkpoints and \ exit_cause == "simulate() limit reached": if (sim_ticks + period) > maxtick: exit_event = m5.simulate(maxtick - sim_ticks) exit_cause = exit_event.getCause() break else: exit_event = m5.simulate(period) exit_cause = exit_event.getCause() sim_ticks += period while exit_event.getCause() == "checkpoint": exit_event = m5.simulate(sim_ticks - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 return exit_event
def scriptCheckpoints(options, maxtick, cptdir): if options.at_instruction or options.simpoint: checkpoint_inst = int(options.take_checkpoints) # maintain correct offset if we restored from some instruction if options.checkpoint_restore != None: checkpoint_inst += options.checkpoint_restore print "Creating checkpoint at inst:%d" % (checkpoint_inst) exit_event = m5.simulate() exit_cause = exit_event.getCause() print "exit cause = %s" % exit_cause # skip checkpoint instructions should they exist while exit_cause == "checkpoint": exit_event = m5.simulate() exit_cause = exit_event.getCause() if exit_cause == "a thread reached the max instruction count": m5.checkpoint(joinpath(cptdir, "cpt.%s.%d" % \ (options.bench, checkpoint_inst))) print "Checkpoint written." else: when, period = options.take_checkpoints.split(",", 1) when = int(when) period = int(period) num_checkpoints = 0 exit_event = m5.simulate(when - m5.curTick()) exit_cause = exit_event.getCause() while exit_cause == "checkpoint": exit_event = m5.simulate(when - m5.curTick()) exit_cause = exit_event.getCause() if exit_cause == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 sim_ticks = when max_checkpoints = options.max_checkpoints while num_checkpoints < max_checkpoints and \ exit_cause == "simulate() limit reached": if (sim_ticks + period) > maxtick: exit_event = m5.simulate(maxtick - sim_ticks) exit_cause = exit_event.getCause() break else: exit_event = m5.simulate(period) exit_cause = exit_event.getCause() sim_ticks += period while exit_event.getCause() == "checkpoint": exit_event = m5.simulate(sim_ticks - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 return exit_event
def takeSimpointCheckpoints(simpoints, interval_length, cptdir): num_checkpoints = 0 index = 0 last_chkpnt_inst_count = -1 for simpoint in simpoints: interval, weight, starting_inst_count, actual_warmup_length = simpoint if starting_inst_count == last_chkpnt_inst_count: # checkpoint starting point same as last time # (when warmup period longer than starting point) exit_cause = "simpoint starting point found" code = 0 else: exit_event = m5.simulate() # skip checkpoint instructions should they exist while exit_event.getCause() == "checkpoint": print "Found 'checkpoint' exit event...ignoring..." exit_event = m5.simulate() exit_cause = exit_event.getCause() code = exit_event.getCode() if exit_cause == "simpoint starting point found": m5.checkpoint(joinpath(cptdir, "cpt.simpoint_%02d_inst_%d_weight_%f_interval_%d_warmup_%d" % (index, starting_inst_count, weight, interval_length, actual_warmup_length))) print "Checkpoint #%d written. start inst:%d weight:%f" % \ (num_checkpoints, starting_inst_count, weight) num_checkpoints += 1 last_chkpnt_inst_count = starting_inst_count else: break index += 1 print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause) print "%d checkpoints taken" % num_checkpoints sys.exit(code)
def run(root, options, checkpoint_dir=m5.options.outdir): # start simulation (and drop checkpoints when requested) while True: event = m5.simulate() exit_msg = event.getCause() if exit_msg == "checkpoint": print("Dropping checkpoint at tick %d" % m5.curTick()) cpt_dir = os.path.join(checkpoint_dir, "cpt.%d" % m5.curTick()) m5.checkpoint(cpt_dir) print("Checkpoint done.") else: print(exit_msg, " @ ", m5.curTick()) break switch_cpu_list = [] if options.fast_forward: if options.big_cpus: sw_tmp_list = [(root.system.bigCluster.cpus[i], root.system.bigCluster.switch_cpus[i]) for i in range(options.big_cpus)] switch_cpu_list += sw_tmp_list if options.mid_cpus: sw_tmp_list = [(root.system.midCluster.cpus[i], root.system.midCluster.switch_cpus[i]) for i in range(options.mid_cpus)] switch_cpu_list += sw_tmp_list if options.little_cpus: sw_tmp_list = [(root.system.littleCluster.cpus[i], root.system.littleCluster.switch_cpus[i]) for i in range(options.little_cpus)] switch_cpu_list += sw_tmp_list print("Shift CPU at tick %d" % m5.curTick()) m5.switchCpus(root.system, switch_cpu_list) m5.stats.reset() event = m5.simulate() sys.exit(event.getCode())
def scriptCheckpoints(options, maxtick, cptdir): if options.at_instruction or options.simpoint: checkpoint_inst = int(options.take_checkpoints) # maintain correct offset if we restored from some instruction if options.checkpoint_restore != None: checkpoint_inst += options.checkpoint_restore print "Creating checkpoint at inst:%d" % (checkpoint_inst) exit_event = m5.simulate() exit_cause = exit_event.getCause() print "exit cause = %s" % exit_cause # skip checkpoint instructions should they exist while exit_cause == "checkpoint": exit_event = m5.simulate() exit_cause = exit_event.getCause() if exit_cause == "a thread reached the max instruction count": m5.checkpoint(joinpath(cptdir, "cpt.%s.%d" % \ (options.bench, checkpoint_inst))) print "Checkpoint written." else: when, period = options.take_checkpoints.split(",", 1) when = int(when) period = int(period) num_checkpoints = 0 exit_event = m5.simulate(when - m5.curTick()) exit_cause = exit_event.getCause() while exit_cause == "checkpoint": exit_event = m5.simulate(when - m5.curTick()) exit_cause = exit_event.getCause() if exit_cause == "simulate() limit reached": # cuiwl: dump and reset stats. print "Checkpoint %d." % (num_checkpoints) m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 sim_ticks = when max_checkpoints = options.max_checkpoints while num_checkpoints < max_checkpoints and \ exit_cause == "simulate() limit reached": if (sim_ticks + period) > maxtick: exit_event = m5.simulate(maxtick - sim_ticks) exit_cause = exit_event.getCause() break else: exit_event = m5.simulate(period) exit_cause = exit_event.getCause() sim_ticks += period while exit_event.getCause() == "checkpoint": exit_event = m5.simulate(sim_ticks - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": # dump and reset stats. print "Checkpoint %d." % (num_checkpoints) m5.stats.dump() m5.stats.reset() m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 if options.stat_prefix: shutil.copyfile("/usr/local/google/home/cuiwl/gem5/m5out/stats.txt", "/usr/local/google/home/cuiwl/gem5/m5out/stats/" + options.stat_prefix + "_" + time.strftime("%Y%m%d") + "_" + time.strftime("%H:%M:%S") + ".txt") else: shutil.copyfile("/usr/local/google/home/cuiwl/gem5/m5out/stats.txt", "/usr/local/google/home/cuiwl/gem5/m5out/stats/none" + "_" + time.strftime("%Y%m%d") + "_" + time.strftime("%H:%M:%S") + ".txt") 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: cptdir = m5.options.outdir else: cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: fatal("Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: fatal("Must specify --caches when using --standard-switch") np = options.num_cpus max_checkpoints = options.max_checkpoints switch_cpus = None if options.prog_interval: for i in xrange(np): testsys.cpu[i].progress_interval = options.prog_interval if options.maxinsts: for i in xrange(np): testsys.cpu[i].max_insts_any_thread = options.maxinsts if cpu_class: switch_cpus = [ cpu_class(defer_registration=True, cpu_id=(np + i)) for i in xrange(np) ] for i in xrange(np): if options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) switch_cpus[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[0].clock # simulation period if options.maxinsts: switch_cpus[i].max_insts_any_thread = options.maxinsts # Add checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() testsys.switch_cpus = switch_cpus switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] if options.standard_switch: if not options.caches: # O3 CPU must have a cache to work. print "O3 CPU must be used with caches" sys.exit(1) switch_cpus = [ TimingSimpleCPU(defer_registration=True, cpu_id=(np + i)) for i in xrange(np) ] switch_cpus_1 = [ DerivO3CPU(defer_registration=True, cpu_id=(2 * np + i)) for i in xrange(np) ] for i in xrange(np): switch_cpus[i].system = testsys switch_cpus_1[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus_1[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[0].clock switch_cpus_1[i].clock = testsys.cpu[0].clock # if restoring, make atomic cpu simulate only a few instructions if options.checkpoint_restore != None: testsys.cpu[i].max_insts_any_thread = 1 # Fast forward to specified location if we are not restoring elif options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if testsys.cpu[i].workload[0].simpoint == 0: fatal('simpoint not found') testsys.cpu[i].max_insts_any_thread = \ testsys.cpu[i].workload[0].simpoint # No distance specified, just switch else: testsys.cpu[i].max_insts_any_thread = 1 # warmup period if options.warmup_insts: switch_cpus[i].max_insts_any_thread = options.warmup_insts # simulation period if options.maxinsts: switch_cpus_1[i].max_insts_any_thread = options.maxinsts # attach the checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() switch_cpus_1[i].addCheckerCpu() testsys.switch_cpus = switch_cpus testsys.switch_cpus_1 = switch_cpus_1 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] switch_cpu_list1 = [(switch_cpus[i], switch_cpus_1[i]) for i in xrange(np)] # set the checkpoint in the cpu before m5.instantiate is called if options.take_checkpoints != None and \ (options.simpoint or options.at_instruction): offset = int(options.take_checkpoints) # Set an instruction break point if options.simpoint: for i in xrange(np): if testsys.cpu[i].workload[0].simpoint == 0: fatal('no simpoint for testsys.cpu[%d].workload[0]', i) checkpoint_inst = int( testsys.cpu[i].workload[0].simpoint) + offset testsys.cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: options.take_checkpoints = offset # Set all test cpus with the right number of instructions # for the upcoming simulation for i in xrange(np): testsys.cpu[i].max_insts_any_thread = offset checkpoint_dir = None if options.checkpoint_restore != None: from os.path import isdir, exists from os import listdir import re if not isdir(cptdir): fatal("checkpoint dir %s does not exist!", cptdir) if options.at_instruction or options.simpoint: inst = options.checkpoint_restore if options.simpoint: # assume workload 0 has the simpoint if testsys.cpu[0].workload[0].simpoint == 0: fatal('Unable to find simpoint') inst += int(testsys.cpu[0].workload[0].simpoint) checkpoint_dir = joinpath(cptdir, "cpt.%s.%s" % (options.bench, inst)) if not exists(checkpoint_dir): fatal("Unable to find checkpoint directory %s", checkpoint_dir) else: dirs = listdir(cptdir) expr = re.compile('cpt\.([0-9]*)') cpts = [] for dir in dirs: match = expr.match(dir) if match: cpts.append(match.group(1)) cpts.sort(lambda a, b: cmp(long(a), long(b))) cpt_num = options.checkpoint_restore if cpt_num > len(cpts): fatal('Checkpoint %d not found', cpt_num) ## Adjust max tick based on our starting tick maxtick = maxtick - int(cpts[cpt_num - 1]) checkpoint_dir = joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1]) m5.instantiate(checkpoint_dir) if options.standard_switch or cpu_class: if options.standard_switch: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() elif cpu_class and options.fast_forward: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() else: print "Switch at curTick count:%s" % str(10000) exit_event = m5.simulate(10000) print "Switched CPUS @ tick %s" % (m5.curTick()) # when you change to Timing (or Atomic), you halt the system # given as argument. When you are finished with the system # changes (including switchCpus), you must resume the system # manually. You DON'T need to resume after just switching # CPUs if you haven't changed anything on the system level. m5.changeToTiming(testsys) m5.switchCpus(switch_cpu_list) m5.resume(testsys) if options.standard_switch: print "Switch at instruction count:%d" % \ (testsys.switch_cpus[0].max_insts_any_thread) #warmup instruction count may have already been set if options.warmup_insts: exit_event = m5.simulate() else: exit_event = m5.simulate(options.warmup) print "Switching CPUS @ tick %s" % (m5.curTick()) print "Simulation ends instruction count:%d" % \ (testsys.switch_cpus_1[0].max_insts_any_thread) m5.drain(testsys) m5.switchCpus(switch_cpu_list1) m5.resume(testsys) num_checkpoints = 0 exit_cause = '' # If we're taking and restoring checkpoints, use checkpoint_dir # option only for finding the checkpoints to restore from. This # lets us test checkpointing by restoring from one set of # checkpoints, generating a second set, and then comparing them. if options.take_checkpoints and options.checkpoint_restore: if m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() # Checkpoints being taken via the command line at <when> and at # subsequent periods of <period>. Checkpoint instructions # received from the benchmark running are ignored and skipped in # favor of command line checkpoint instructions. if options.take_checkpoints != None: if options.at_instruction or options.simpoint: checkpoint_inst = int(options.take_checkpoints) # maintain correct offset if we restored from some instruction if options.checkpoint_restore != None: checkpoint_inst += options.checkpoint_restore print "Creating checkpoint at inst:%d" % (checkpoint_inst) exit_event = m5.simulate() print "exit cause = %s" % (exit_event.getCause()) # skip checkpoint instructions should they exist while exit_event.getCause() == "checkpoint": exit_event = m5.simulate() if exit_event.getCause() == \ "a thread reached the max instruction count": m5.checkpoint(joinpath(cptdir, "cpt.%s.%d" % \ (options.bench, checkpoint_inst))) print "Checkpoint written." num_checkpoints += 1 if exit_event.getCause() == "user interrupt received": exit_cause = exit_event.getCause() else: when, period = options.take_checkpoints.split(",", 1) when = int(when) period = int(period) exit_event = m5.simulate(when) while exit_event.getCause() == "checkpoint": exit_event = m5.simulate(when - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 sim_ticks = when exit_cause = "maximum %d checkpoints dropped" % max_checkpoints while num_checkpoints < max_checkpoints and \ exit_event.getCause() == "simulate() limit reached": if (sim_ticks + period) > maxtick: exit_event = m5.simulate(maxtick - sim_ticks) exit_cause = exit_event.getCause() break else: exit_event = m5.simulate(period) sim_ticks += period while exit_event.getCause() == "checkpoint": exit_event = m5.simulate(sim_ticks - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 if exit_event.getCause() != "simulate() limit reached": exit_cause = exit_event.getCause() else: # no checkpoints being taken via this script if options.fast_forward: m5.stats.reset() print "**** REAL SIMULATION ****" exit_event = m5.simulate(maxtick) while exit_event.getCause() == "checkpoint": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 if num_checkpoints == max_checkpoints: exit_cause = "maximum %d checkpoints dropped" % max_checkpoints break exit_event = m5.simulate(maxtick - m5.curTick()) exit_cause = exit_event.getCause() if exit_cause == '': exit_cause = exit_event.getCause() print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause) if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d"))
def run(options, root, testsys, cpu_class): # NOTE: this function is called from example from configs/example/ruby_fs.py # like this: "Simulation.run(options, root, system, FutureClass)" # so, "system" is "testsys" here; 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: cptdir = m5.options.outdir else: cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: fatal("Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: fatal("Must specify --caches when using --standard-switch") np = options.num_cpus max_checkpoints = options.max_checkpoints switch_cpus = None if options.prog_interval: for i in xrange(np): testsys.cpu[i].progress_interval = options.prog_interval if options.maxinsts: for i in xrange(np): testsys.cpu[i].max_insts_any_thread = options.maxinsts if cpu_class: switch_cpus = [cpu_class(defer_registration=True, cpu_id=(np+i)) for i in xrange(np)] for i in xrange(np): if options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) switch_cpus[i].system = testsys if not buildEnv['FULL_SYSTEM']: switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[0].clock # simulation period if options.maxinsts: switch_cpus[i].max_insts_any_thread = options.maxinsts testsys.switch_cpus = switch_cpus switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] if options.standard_switch: if not options.caches: # O3 CPU must have a cache to work. print "O3 CPU must be used with caches" sys.exit(1) switch_cpus = [TimingSimpleCPU(defer_registration=True, cpu_id=(np+i)) for i in xrange(np)] switch_cpus_1 = [DerivO3CPU(defer_registration=True, cpu_id=(2*np+i)) for i in xrange(np)] for i in xrange(np): switch_cpus[i].system = testsys switch_cpus_1[i].system = testsys if not buildEnv['FULL_SYSTEM']: switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus_1[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[0].clock switch_cpus_1[i].clock = testsys.cpu[0].clock # if restoring, make atomic cpu simulate only a few instructions if options.checkpoint_restore != None: testsys.cpu[i].max_insts_any_thread = 1 # Fast forward to specified location if we are not restoring elif options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if testsys.cpu[i].workload[0].simpoint == 0: fatal('simpoint not found') testsys.cpu[i].max_insts_any_thread = \ testsys.cpu[i].workload[0].simpoint # No distance specified, just switch else: testsys.cpu[i].max_insts_any_thread = 1 # warmup period if options.warmup_insts: switch_cpus[i].max_insts_any_thread = options.warmup_insts # simulation period if options.maxinsts: switch_cpus_1[i].max_insts_any_thread = options.maxinsts testsys.switch_cpus = switch_cpus testsys.switch_cpus_1 = switch_cpus_1 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] switch_cpu_list1 = [(switch_cpus[i], switch_cpus_1[i]) for i in xrange(np)] # set the checkpoint in the cpu before m5.instantiate is called if options.take_checkpoints != None and \ (options.simpoint or options.at_instruction): offset = int(options.take_checkpoints) # Set an instruction break point if options.simpoint: for i in xrange(np): if testsys.cpu[i].workload[0].simpoint == 0: fatal('no simpoint for testsys.cpu[%d].workload[0]', i) checkpoint_inst = int(testsys.cpu[i].workload[0].simpoint) + offset testsys.cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: options.take_checkpoints = offset # Set all test cpus with the right number of instructions # for the upcoming simulation for i in xrange(np): testsys.cpu[i].max_insts_any_thread = offset checkpoint_dir = None if options.checkpoint_restore != None: from os.path import isdir, exists from os import listdir import re if not isdir(cptdir): fatal("checkpoint dir %s does not exist!", cptdir) if options.at_instruction or options.simpoint: inst = options.checkpoint_restore if options.simpoint: # assume workload 0 has the simpoint if testsys.cpu[0].workload[0].simpoint == 0: fatal('Unable to find simpoint') inst += int(testsys.cpu[0].workload[0].simpoint) checkpoint_dir = joinpath(cptdir, "cpt.%s.%s" % (options.bench, inst)) if not exists(checkpoint_dir): fatal("Unable to find checkpoint directory %s", checkpoint_dir) else: dirs = listdir(cptdir) expr = re.compile('cpt\.([0-9]*)') cpts = [] for dir in dirs: match = expr.match(dir) if match: cpts.append(match.group(1)) cpts.sort(lambda a,b: cmp(long(a), long(b))) cpt_num = options.checkpoint_restore if cpt_num > len(cpts): fatal('Checkpoint %d not found', cpt_num) ## Adjust max tick based on our starting tick maxtick = maxtick - int(cpts[cpt_num - 1]) checkpoint_dir = joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1]) m5.instantiate(checkpoint_dir) if options.standard_switch or cpu_class: if options.standard_switch: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() elif cpu_class and options.fast_forward: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() else: print "Switch at curTick count:%s" % str(10000) exit_event = m5.simulate(10000) print "Switched CPUS @ tick %s" % (m5.curTick()) # when you change to Timing (or Atomic), you halt the system # given as argument. When you are finished with the system # changes (including switchCpus), you must resume the system # manually. You DON'T need to resume after just switching # CPUs if you haven't changed anything on the system level. m5.changeToTiming(testsys) m5.switchCpus(switch_cpu_list) m5.resume(testsys) if options.standard_switch: print "Switch at instruction count:%d" % \ (testsys.switch_cpus[0].max_insts_any_thread) #warmup instruction count may have already been set if options.warmup_insts: exit_event = m5.simulate() else: exit_event = m5.simulate(options.warmup) print "Switching CPUS @ tick %s" % (m5.curTick()) print "Simulation ends instruction count:%d" % \ (testsys.switch_cpus_1[0].max_insts_any_thread) m5.drain(testsys) m5.switchCpus(switch_cpu_list1) m5.resume(testsys) num_checkpoints = 0 exit_cause = '' # If we're taking and restoring checkpoints, use checkpoint_dir # option only for finding the checkpoints to restore from. This # lets us test checkpointing by restoring from one set of # checkpoints, generating a second set, and then comparing them. if options.take_checkpoints and options.checkpoint_restore: if m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() # Checkpoints being taken via the command line at <when> and at # subsequent periods of <period>. Checkpoint instructions # received from the benchmark running are ignored and skipped in # favor of command line checkpoint instructions. if options.take_checkpoints != None : if options.at_instruction or options.simpoint: checkpoint_inst = int(options.take_checkpoints) # maintain correct offset if we restored from some instruction if options.checkpoint_restore != None: checkpoint_inst += options.checkpoint_restore print "Creating checkpoint at inst:%d" % (checkpoint_inst) exit_event = m5.simulate() print "exit cause = %s" % (exit_event.getCause()) # skip checkpoint instructions should they exist while exit_event.getCause() == "checkpoint": exit_event = m5.simulate() if exit_event.getCause() == \ "a thread reached the max instruction count": m5.checkpoint(joinpath(cptdir, "cpt.%s.%d" % \ (options.bench, checkpoint_inst))) print "Checkpoint written." num_checkpoints += 1 if exit_event.getCause() == "user interrupt received": exit_cause = exit_event.getCause(); else: when, period = options.take_checkpoints.split(",", 1) when = int(when) period = int(period) exit_event = m5.simulate(when) while exit_event.getCause() == "checkpoint": exit_event = m5.simulate(when - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 sim_ticks = when exit_cause = "maximum %d checkpoints dropped" % max_checkpoints while num_checkpoints < max_checkpoints and \ exit_event.getCause() == "simulate() limit reached": if (sim_ticks + period) > maxtick: exit_event = m5.simulate(maxtick - sim_ticks) exit_cause = exit_event.getCause() break else: exit_event = m5.simulate(period) sim_ticks += period while exit_event.getCause() == "checkpoint": exit_event = m5.simulate(sim_ticks - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 if exit_event.getCause() != "simulate() limit reached": exit_cause = exit_event.getCause(); else: # no checkpoints being taken via this script if options.fast_forward: m5.stats.reset() print "**** REAL SIMULATION ****" #exit_event = m5.simulate(maxtick) # --Note1: Ruby is created in ruby_fs.py by # "Ruby.create_system(options, system, system.piobus, system._dma_devices)" # which assigned: "stats_filename = options.ruby_stats"; # definition of "create_system" is in configs/ruby/Ruby.py, which # instantiate the ctor of RubySystem: "system.ruby = RubySystem(...)"; #print testsys.ruby._cpu_ruby_ports #print testsys.ruby.network.ni_flit_size #print testsys.ruby.profiler.ruby_system # the ctor of RubySystem is defined in src/mem/ruby/system/RubySystem.py; # which sets some defaults: #print testsys.ruby.stats_filename # i.e., ruby.stats #print testsys.ruby.type #print testsys.ruby.random_seed #print testsys.ruby.clock #print testsys.ruby.block_size_bytes #print testsys.ruby.mem_size #print testsys.ruby.no_mem_vec # () cris: description of changes # --Note2: initially writing into ruby.stats was done with overwriting; # so, for each dump point the file was re-written; to fix that I # changed function "OutputDirectory::create(...)" from src/base/output.cc # which is called by "RubyExitCallback::process()" from src/mem/ruby/system/System.cc # function that is the one called at the end of the gem5 run # as a calback to dump all ruby stats (callback is "registered" in the # ctor of RubySystem::RubySystem() inside the same file...); # --Note3: using doExitCleanup inspired from src/python/m5/simulate.py # (inside which ini and json files are created; you need to rebuild each # time you change that Python file): #m5.internal.core.doExitCleanup( False) #clear callback queue? # --Note4: python/m5/internal/core.py describes "m5.internal.core"; # cris: here I want to dump stats every other delta ticks; # I need these to be able to generate reliability traces; NUM_OF_DUMPS = 100 num_i = 0 delta = maxtick/NUM_OF_DUMPS sim_ticks = m5.curTick() while (m5.curTick() < maxtick): sim_ticks += delta exit_event = m5.simulate(sim_ticks - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": #--Note5: "doExitCleanup()" is described in src/sim/core.cc; # I changed it to be able to call it multiple times; #--Note6: do not dump stats in ruby.stats for last iteration # because it will be repeated once more via the exit callbacks # in src/python/m5/simulate.py... # Note6: next call of doExitCleanup does actually also reset/clear # the stats of ruby system via the RubyExitCallback::process() in # src/mem/ruby/system/System.cc if num_i < (NUM_OF_DUMPS-1): print "Dumping also ruby stats at inst %d to file: ruby.stats" %(num_i) m5.internal.core.doExitCleanup( False) #clear callback queue? print "Dumping gem5 stats at inst %d to file: stats.txt" %(num_i) # --Note7: dump() wites into stats.txt; dump() is defined in # src/python/m5/stats/__init__.py and does its # thing via the functions described in base/stats/text.cc #atexit.register(stats.dump) <--- does not work (from simulate.py) m5.stats.dump() m5.stats.reset() # <--- what does it actually do? num_i += 1 # alex's changes: #while exit_event.getCause() != "m5_exit instruction encountered": # m5.stats.dump() # m5.stats.reset() # exit_event = m5.simulate(maxtick) #while exit_event.getCause() == "checkpoint": # m5.checkpoint(joinpath(cptdir, "cpt.%d")) # num_checkpoints += 1 # if num_checkpoints == max_checkpoints: # exit_cause = "maximum %d checkpoints dropped" % max_checkpoints # break # exit_event = m5.simulate(maxtick - m5.curTick()) # exit_cause = exit_event.getCause() if exit_cause == '': exit_cause = exit_event.getCause() print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause) if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d"))
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: cptdir = m5.options.outdir else: cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: fatal("Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: fatal("Must specify --caches when using --standard-switch") if options.standard_switch and options.repeat_switch: fatal("Can't specify both --standard-switch and --repeat-switch") if options.repeat_switch and options.take_checkpoints: fatal("Can't specify both --repeat-switch and --take-checkpoints") np = options.num_cpus switch_cpus = None if options.prog_interval: for i in xrange(np): testsys.cpu[i].progress_interval = options.prog_interval if options.maxinsts: for i in xrange(np): testsys.cpu[i].max_insts_any_thread = options.maxinsts if options.pred_type: for i in xrange(np): testsys.cpu[i].predType = options.pred_type if options.global_hist_size: for i in xrange(np): testsys.cpu[i].globalHistoryBits = options.global_hist_size if options.global_pred_size: for i in xrange(np): testsys.cpu[i].globalPredictorSize = options.global_pred_size if options.local_pred_size: for i in xrange(np): testsys.cpu[i].localPredictorSize = options.local_pred_size if cpu_class: switch_cpus = [ cpu_class(defer_registration=True, cpu_id=(i)) for i in xrange(np) ] for i in xrange(np): if options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) switch_cpus[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[i].clock # simulation period if options.maxinsts: switch_cpus[i].max_insts_any_thread = options.maxinsts # Add checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() testsys.switch_cpus = switch_cpus switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] if options.repeat_switch: if options.cpu_type == "arm_detailed": if not options.caches: print "O3 CPU must be used with caches" sys.exit(1) repeat_switch_cpus = [O3_ARM_v7a_3(defer_registration=True, \ cpu_id=(i)) for i in xrange(np)] elif options.cpu_type == "detailed": if not options.caches: print "O3 CPU must be used with caches" sys.exit(1) repeat_switch_cpus = [DerivO3CPU(defer_registration=True, \ cpu_id=(i)) for i in xrange(np)] elif options.cpu_type == "inorder": print "inorder CPU switching not supported" sys.exit(1) elif options.cpu_type == "timing": repeat_switch_cpus = [TimingSimpleCPU(defer_registration=True, \ cpu_id=(i)) for i in xrange(np)] else: repeat_switch_cpus = [AtomicSimpleCPU(defer_registration=True, \ cpu_id=(i)) for i in xrange(np)] for i in xrange(np): repeat_switch_cpus[i].system = testsys repeat_switch_cpus[i].workload = testsys.cpu[i].workload repeat_switch_cpus[i].clock = testsys.cpu[i].clock if options.maxinsts: repeat_switch_cpus[i].max_insts_any_thread = options.maxinsts if options.checker: repeat_switch_cpus[i].addCheckerCpu() testsys.repeat_switch_cpus = repeat_switch_cpus if cpu_class: repeat_switch_cpu_list = [(switch_cpus[i], repeat_switch_cpus[i]) for i in xrange(np)] else: repeat_switch_cpu_list = [(testsys.cpu[i], repeat_switch_cpus[i]) for i in xrange(np)] if options.standard_switch: switch_cpus = [ TimingSimpleCPU(defer_registration=True, cpu_id=(i)) for i in xrange(np) ] switch_cpus_1 = [ DerivO3CPU(defer_registration=True, cpu_id=(i)) for i in xrange(np) ] for i in xrange(np): switch_cpus[i].system = testsys switch_cpus_1[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus_1[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[i].clock switch_cpus_1[i].clock = testsys.cpu[i].clock # if restoring, make atomic cpu simulate only a few instructions if options.checkpoint_restore != None: testsys.cpu[i].max_insts_any_thread = 1 # Fast forward to specified location if we are not restoring elif options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if testsys.cpu[i].workload[0].simpoint == 0: fatal('simpoint not found') testsys.cpu[i].max_insts_any_thread = \ testsys.cpu[i].workload[0].simpoint # No distance specified, just switch else: testsys.cpu[i].max_insts_any_thread = 1 # warmup period if options.warmup_insts: switch_cpus[i].max_insts_any_thread = options.warmup_insts # simulation period if options.maxinsts: switch_cpus_1[i].max_insts_any_thread = options.maxinsts # attach the checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() switch_cpus_1[i].addCheckerCpu() testsys.switch_cpus = switch_cpus testsys.switch_cpus_1 = switch_cpus_1 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] switch_cpu_list1 = [(switch_cpus[i], switch_cpus_1[i]) for i in xrange(np)] # set the checkpoint in the cpu before m5.instantiate is called if options.take_checkpoints != None and \ (options.simpoint or options.at_instruction): offset = int(options.take_checkpoints) # Set an instruction break point if options.simpoint: for i in xrange(np): if testsys.cpu[i].workload[0].simpoint == 0: fatal('no simpoint for testsys.cpu[%d].workload[0]', i) checkpoint_inst = int( testsys.cpu[i].workload[0].simpoint) + offset testsys.cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: options.take_checkpoints = offset # Set all test cpus with the right number of instructions # for the upcoming simulation for i in xrange(np): testsys.cpu[i].max_insts_any_thread = offset checkpoint_dir = None if options.checkpoint_restore != None: maxtick, checkpoint_dir = findCptDir(options, maxtick, cptdir, testsys) m5.instantiate(checkpoint_dir) if options.standard_switch or cpu_class: if options.standard_switch: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() elif cpu_class and options.fast_forward: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() else: print "Switch at curTick count:%s" % str(10000) exit_event = m5.simulate(10000) print "Switched CPUS @ tick %s" % (m5.curTick()) # when you change to Timing (or Atomic), you halt the system # given as argument. When you are finished with the system # changes (including switchCpus), you must resume the system # manually. You DON'T need to resume after just switching # CPUs if you haven't changed anything on the system level. m5.doDrain(testsys) m5.changeToTiming(testsys) m5.switchCpus(switch_cpu_list) m5.resume(testsys) if options.standard_switch: print "Switch at instruction count:%d" % \ (testsys.switch_cpus[0].max_insts_any_thread) #warmup instruction count may have already been set if options.warmup_insts: exit_event = m5.simulate() else: exit_event = m5.simulate(options.standard_switch) print "Switching CPUS @ tick %s" % (m5.curTick()) print "Simulation ends instruction count:%d" % \ (testsys.switch_cpus_1[0].max_insts_any_thread) m5.doDrain(testsys) m5.switchCpus(switch_cpu_list1) m5.resume(testsys) # If we're taking and restoring checkpoints, use checkpoint_dir # option only for finding the checkpoints to restore from. This # lets us test checkpointing by restoring from one set of # checkpoints, generating a second set, and then comparing them. if options.take_checkpoints and options.checkpoint_restore: if m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() if options.take_checkpoints != None: # Checkpoints being taken via the command line at <when> and at # subsequent periods of <period>. Checkpoint instructions # received from the benchmark running are ignored and skipped in # favor of command line checkpoint instructions. exit_cause = scriptCheckpoints(options, maxtick, cptdir) else: if options.fast_forward: m5.stats.reset() print "**** REAL SIMULATION ****" # If checkpoints are being taken, then the checkpoint instruction # will occur in the benchmark code it self. if options.repeat_switch and maxtick > options.repeat_switch: exit_cause = repeatSwitch(testsys, repeat_switch_cpu_list, maxtick, options.repeat_switch) else: exit_cause = benchCheckpoints(options, maxtick, cptdir) print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause) if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d"))
tmp_cpu_list = [] for old_cpu, new_cpu in switch_cpu_list: tmp_cpu_list.append((new_cpu, old_cpu)) switch_cpu_list = tmp_cpu_list m5.stats.reset() exit_event = m5.simulate() exit_cause = exit_event.getCause() if switch_cpu_list[0][0].type == 'DerivO3CPU': m5.stats.dump() elif options.simpoint_mode == "checkpoint_gen": exit_event = m5.simulate() exit_cause = exit_event.getCause() checkpoint_points = simple_end_points[:] checkpoint_points.reverse() while exit_cause == "simpoint starting point found": point_inst = checkpoint_points.pop() m5.checkpoint(os.path.join(options.checkpoint_dir, "simpoint.ckpt.inst.%d" % point_inst)) if not checkpoint_points: exit_cause = "final simpoint checkpoint created" break; exit_event = m5.simulate() exit_cause = exit_event.getCause() print "Exiting @ tick %i because %s" % (m5.curTick(), exit_cause)
def main(): parser = argparse.ArgumentParser( description="Generic ARM big.LITTLE configuration") parser.add_argument("--restore-from", type=str, default=None, help="Restore from checkpoint") parser.add_argument("--dtb", type=str, default=default_dtb, help="DTB file to load") parser.add_argument("--kernel", type=str, default=default_kernel, help="Linux kernel") parser.add_argument("--disk", action="append", type=str, default=[], help="Disks to instantiate") parser.add_argument("--bootscript", type=str, default=default_rcs, help="Linux bootscript") parser.add_argument("--atomic", action="store_true", default=False, help="Use atomic CPUs") parser.add_argument("--kernel-init", type=str, default="/sbin/init", help="Override init") parser.add_argument("--big-cpus", type=int, default=1, help="Number of big CPUs to instantiate") parser.add_argument("--little-cpus", type=int, default=1, help="Number of little CPUs to instantiate") parser.add_argument("--caches", action="store_true", default=False, help="Instantiate caches") parser.add_argument("--last-cache-level", type=int, default=2, help="Last level of caches (e.g. 3 for L3)") parser.add_argument("--big-cpu-clock", type=str, default="2GHz", help="Big CPU clock frequency") parser.add_argument("--little-cpu-clock", type=str, default="1GHz", help="Little CPU clock frequency") m5.ticks.fixGlobalFrequency() options = parser.parse_args() if options.atomic: cpu_config = { 'cpu' : AtomicSimpleCPU } big_cpu_config, little_cpu_config = cpu_config, cpu_config else: big_cpu_config = { 'cpu' : CpuConfig.get("arm_detailed"), 'l1i' : devices.L1I, 'l1d' : devices.L1D, 'wcache' : devices.WalkCache, 'l2' : devices.L2 } little_cpu_config = { 'cpu' : MinorCPU, 'l1i' : devices.L1I, 'l1d' : devices.L1D, 'wcache' : devices.WalkCache, 'l2' : devices.L2 } big_cpu_class = big_cpu_config['cpu'] little_cpu_class = little_cpu_config['cpu'] kernel_cmd = [ "earlyprintk=pl011,0x1c090000", "console=ttyAMA0", "lpj=19988480", "norandmaps", "loglevel=8", "mem=%s" % default_mem_size, "root=/dev/vda1", "rw", "init=%s" % options.kernel_init, "vmalloc=768MB", ] root = Root(full_system=True) assert big_cpu_class.memory_mode() == little_cpu_class.memory_mode() disks = default_disk if len(options.disk) == 0 else options.disk system = createSystem(options.kernel, big_cpu_class.memory_mode(), options.bootscript, disks=disks) root.system = system system.boot_osflags = " ".join(kernel_cmd) # big cluster if options.big_cpus > 0: system.bigCluster = CpuCluster() system.bigCluster.addCPUs(big_cpu_config, options.big_cpus, options.big_cpu_clock) # LITTLE cluster if options.little_cpus > 0: system.littleCluster = CpuCluster() system.littleCluster.addCPUs(little_cpu_config, options.little_cpus, options.little_cpu_clock) # add caches if options.caches: cluster_mem_bus = addCaches(system, options.last_cache_level) else: if big_cpu_class.require_caches(): m5.util.panic("CPU model %s requires caches" % str(big_cpu_class)) if little_cpu_class.require_caches(): m5.util.panic("CPU model %s requires caches" % str(little_cpu_class)) cluster_mem_bus = system.membus # connect each cluster to the memory hierarchy for cluster in system._clusters: cluster.connectMemSide(cluster_mem_bus) # Linux device tree system.dtb_filename = SysPaths.binary(options.dtb) # Get and load from the chkpt or simpoint checkpoint if options.restore_from is not None: m5.instantiate(options.restore_from) else: m5.instantiate() # start simulation (and drop checkpoints when requested) while True: event = m5.simulate() exit_msg = event.getCause() if exit_msg == "checkpoint": print "Dropping checkpoint at tick %d" % m5.curTick() cpt_dir = os.path.join(m5.options.outdir, "cpt.%d" % m5.curTick()) m5.checkpoint(os.path.join(cpt_dir)) print "Checkpoint done." else: print exit_msg, " @ ", m5.curTick() break sys.exit(event.getCode())
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: cptdir = m5.options.outdir else: cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: fatal("Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: fatal("Must specify --caches when using --standard-switch") np = options.num_cpus max_checkpoints = options.max_checkpoints new = None if options.prog_interval: for i in xrange(np): testsys.cpu[i].progress_interval = options.prog_interval if options.maxinsts: for i in xrange(np): testsys.cpu[i].max_insts_any_thread = options.maxinsts if cpu_class: new = [cpu_class(defer_registration=True, cpu_id=(np + i)) for i in xrange(np)] for i in xrange(np): if options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) new[i].system = testsys if not buildEnv["FULL_SYSTEM"]: new[i].workload = testsys.cpu[i].workload new[i].clock = testsys.cpu[0].clock # simulation period if options.maxinsts: new[i].max_insts_any_thread = options.maxinsts testsys.new = new switch_cpu_list = [(testsys.cpu[i], new[i]) for i in xrange(np)] if options.standard_switch: if not options.caches: # O3 CPU must have a cache to work. print "O3 CPU must be used with caches" sys.exit(1) new = [TimingSimpleCPU(defer_registration=True, cpu_id=(np + i)) for i in xrange(np)] new_1 = [DerivO3CPU(defer_registration=True, cpu_id=(2 * np + i)) for i in xrange(np)] for i in xrange(np): new[i].system = testsys new_1[i].system = testsys if not buildEnv["FULL_SYSTEM"]: new[i].workload = testsys.cpu[i].workload new_1[i].workload = testsys.cpu[i].workload new[i].clock = testsys.cpu[0].clock new_1[i].clock = testsys.cpu[0].clock # if restoring, make atomic cpu simulate only a few instructions if options.checkpoint_restore != None: testsys.cpu[i].max_insts_any_thread = 1 # Fast forward to specified location if we are not restoring elif options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if testsys.cpu[i].workload[0].simpoint == 0: fatal("simpoint not found") testsys.cpu[i].max_insts_any_thread = testsys.cpu[i].workload[0].simpoint # No distance specified, just switch else: testsys.cpu[i].max_insts_any_thread = 1 # warmup period if options.warmup_insts: new[i].max_insts_any_thread = options.warmup_insts # simulation period if options.maxinsts: new_1[i].max_insts_any_thread = options.maxinsts testsys.new = new testsys.new_1 = new_1 switch_cpu_list = [(testsys.cpu[i], new[i]) for i in xrange(np)] switch_cpu_list1 = [(new[i], new_1[i]) for i in xrange(np)] # set the checkpoint in the cpu before m5.instantiate is called if options.take_checkpoints != None and (options.simpoint or options.at_instruction): offset = int(options.take_checkpoints) # Set an instruction break point if options.simpoint: for i in xrange(np): if testsys.cpu[i].workload[0].simpoint == 0: fatal("no simpoint for testsys.cpu[%d].workload[0]", i) checkpoint_inst = int(testsys.cpu[i].workload[0].simpoint) + offset testsys.cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: options.take_checkpoints = offset # Set all test cpus with the right number of instructions # for the upcoming simulation for i in xrange(np): testsys.cpu[i].max_insts_any_thread = offset checkpoint_dir = None if options.checkpoint_restore != None: from os.path import isdir, exists from os import listdir import re if not isdir(cptdir): fatal("checkpoint dir %s does not exist!", cptdir) if options.at_instruction or options.simpoint: inst = options.checkpoint_restore if options.simpoint: # assume workload 0 has the simpoint if testsys.cpu[0].workload[0].simpoint == 0: fatal("Unable to find simpoint") inst += int(testsys.cpu[0].workload[0].simpoint) checkpoint_dir = joinpath(cptdir, "cpt.%s.%s" % (options.bench, inst)) if not exists(checkpoint_dir): fatal("Unable to find checkpoint directory %s", checkpoint_dir) else: dirs = listdir(cptdir) expr = re.compile("cpt\.([0-9]*)") cpts = [] for dir in dirs: match = expr.match(dir) if match: cpts.append(match.group(1)) cpts.sort(lambda a, b: cmp(long(a), long(b))) cpt_num = options.checkpoint_restore if cpt_num > len(cpts): fatal("Checkpoint %d not found", cpt_num) ## Adjust max tick based on our starting tick maxtick = maxtick - int(cpts[cpt_num - 1]) checkpoint_dir = joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1]) m5.instantiate(checkpoint_dir) if options.standard_switch or cpu_class: if options.standard_switch: print "Switch at instruction count:%s" % str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() elif cpu_class and options.fast_forward: print "Switch at instruction count:%s" % str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() else: print "Switch at curTick count:%s" % str(10000) exit_event = m5.simulate(10000) print "Switched CPUS @ tick %s" % (m5.curTick()) # when you change to Timing (or Atomic), you halt the system # given as argument. When you are finished with the system # changes (including switchCpus), you must resume the system # manually. You DON'T need to resume after just switching # CPUs if you haven't changed anything on the system level. m5.changeToTiming(testsys) m5.switchCpus(switch_cpu_list) m5.resume(testsys) if options.standard_switch: print "Switch at instruction count:%d" % (testsys.new[0].max_insts_any_thread) # warmup instruction count may have already been set if options.warmup_insts: exit_event = m5.simulate() else: exit_event = m5.simulate(options.warmup) print "Switching CPUS @ tick %s" % (m5.curTick()) print "Simulation ends instruction count:%d" % (testsys.new_1[0].max_insts_any_thread) m5.drain(testsys) m5.switchCpus(switch_cpu_list1) m5.resume(testsys) num_checkpoints = 0 exit_cause = "" # If we're taking and restoring checkpoints, use checkpoint_dir # option only for finding the checkpoints to restore from. This # lets us test checkpointing by restoring from one set of # checkpoints, generating a second set, and then comparing them. if options.take_checkpoints and options.checkpoint_restore: if m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() # Checkpoints being taken via the command line at <when> and at # subsequent periods of <period>. Checkpoint instructions # received from the benchmark running are ignored and skipped in # favor of command line checkpoint instructions. if options.take_checkpoints != None: if options.at_instruction or options.simpoint: checkpoint_inst = int(options.take_checkpoints) # maintain correct offset if we restored from some instruction if options.checkpoint_restore != None: checkpoint_inst += options.checkpoint_restore print "Creating checkpoint at inst:%d" % (checkpoint_inst) exit_event = m5.simulate() print "exit cause = %s" % (exit_event.getCause()) # skip checkpoint instructions should they exist while exit_event.getCause() == "checkpoint": exit_event = m5.simulate() if exit_event.getCause() == "a thread reached the max instruction count": m5.checkpoint(joinpath(cptdir, "cpt.%s.%d" % (options.bench, checkpoint_inst))) print "Checkpoint written." num_checkpoints += 1 if exit_event.getCause() == "user interrupt received": exit_cause = exit_event.getCause() else: when, period = options.take_checkpoints.split(",", 1) when = int(when) period = int(period) exit_event = m5.simulate(when) while exit_event.getCause() == "checkpoint": exit_event = m5.simulate(when - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 sim_ticks = when exit_cause = "maximum %d checkpoints dropped" % max_checkpoints while num_checkpoints < max_checkpoints and exit_event.getCause() == "simulate() limit reached": if (sim_ticks + period) > maxtick: exit_event = m5.simulate(maxtick - sim_ticks) exit_cause = exit_event.getCause() break else: exit_event = m5.simulate(period) sim_ticks += period while exit_event.getCause() == "checkpoint": exit_event = m5.simulate(sim_ticks - m5.curTick()) if exit_event.getCause() == "simulate() limit reached": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 if exit_event.getCause() != "simulate() limit reached": exit_cause = exit_event.getCause() else: # no checkpoints being taken via this script if options.fast_forward: m5.stats.reset() print "**** REAL SIMULATION ****" exit_event = m5.simulate(maxtick) while exit_event.getCause() == "checkpoint": m5.checkpoint(joinpath(cptdir, "cpt.%d")) num_checkpoints += 1 if num_checkpoints == max_checkpoints: exit_cause = "maximum %d checkpoints dropped" % max_checkpoints break exit_event = m5.simulate(maxtick - m5.curTick()) exit_cause = exit_event.getCause() if exit_cause == "": exit_cause = exit_event.getCause() print "Exiting @ tick %i because %s" % (m5.curTick(), exit_cause) if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d"))
def run(options, root, testsys, cpu_class, numpids): 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: cptdir = m5.options.outdir else: cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: fatal("Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: fatal("Must specify --caches when using --standard-switch") if options.standard_switch and options.repeat_switch: fatal("Can't specify both --standard-switch and --repeat-switch") if options.repeat_switch and options.take_checkpoints: fatal("Can't specify both --repeat-switch and --take-checkpoints") np = options.num_cpus switch_cpus = None if options.prog_interval: for i in xrange(np): testsys.cpu[i].progress_interval = options.prog_interval if options.maxinsts: for i in xrange(np): testsys.cpu[i].max_insts_any_thread = options.maxinsts if cpu_class: switch_cpus = [cpu_class(defer_registration=True, cpu_id=(i)) for i in xrange(np)] for i in xrange(np): if options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) switch_cpus[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[i].clock # simulation period if options.maxinsts: switch_cpus[i].max_insts_any_thread = options.maxinsts # Add checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() testsys.switch_cpus = switch_cpus switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] if options.repeat_switch: if options.cpu_type == "arm_detailed": if not options.caches: print "O3 CPU must be used with caches" sys.exit(1) repeat_switch_cpus = [O3_ARM_v7a_3(defer_registration=True, cpu_id=(i)) for i in xrange(np)] elif options.cpu_type == "detailed": if not options.caches: print "O3 CPU must be used with caches" sys.exit(1) repeat_switch_cpus = [DerivO3CPU(defer_registration=True, cpu_id=(i)) for i in xrange(np)] elif options.cpu_type == "inorder": print "inorder CPU switching not supported" sys.exit(1) elif options.cpu_type == "timing": repeat_switch_cpus = [TimingSimpleCPU(defer_registration=True, cpu_id=(i)) for i in xrange(np)] else: repeat_switch_cpus = [AtomicSimpleCPU(defer_registration=True, cpu_id=(i)) for i in xrange(np)] for i in xrange(np): repeat_switch_cpus[i].system = testsys repeat_switch_cpus[i].workload = testsys.cpu[i].workload repeat_switch_cpus[i].clock = testsys.cpu[i].clock if options.maxinsts: repeat_switch_cpus[i].max_insts_any_thread = options.maxinsts if options.checker: repeat_switch_cpus[i].addCheckerCpu() testsys.repeat_switch_cpus = repeat_switch_cpus if cpu_class: repeat_switch_cpu_list = [(switch_cpus[i], repeat_switch_cpus[i]) for i in xrange(np)] else: repeat_switch_cpu_list = [(testsys.cpu[i], repeat_switch_cpus[i]) for i in xrange(np)] if options.standard_switch: switch_cpus = [TimingSimpleCPU(defer_registration=True, cpu_id=(i)) for i in xrange(np)] switch_cpus_1 = [DerivO3CPU(defer_registration=True, cpu_id=(i)) for i in xrange(np)] for i in xrange(np): switch_cpus[i].system = testsys switch_cpus_1[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus_1[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[i].clock switch_cpus_1[i].clock = testsys.cpu[i].clock # if restoring, make atomic cpu simulate only a few instructions if options.checkpoint_restore != None: testsys.cpu[i].max_insts_any_thread = 1 # Fast forward to specified location if we are not restoring elif options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if testsys.cpu[i].workload[0].simpoint == 0: fatal("simpoint not found") testsys.cpu[i].max_insts_any_thread = testsys.cpu[i].workload[0].simpoint # No distance specified, just switch else: testsys.cpu[i].max_insts_any_thread = 1 # warmup period if options.warmup_insts: switch_cpus[i].max_insts_any_thread = options.warmup_insts # simulation period if options.maxinsts: switch_cpus_1[i].max_insts_any_thread = options.maxinsts # attach the checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() switch_cpus_1[i].addCheckerCpu() testsys.switch_cpus = switch_cpus testsys.switch_cpus_1 = switch_cpus_1 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] switch_cpu_list1 = [(switch_cpus[i], switch_cpus_1[i]) for i in xrange(np)] # set the checkpoint in the cpu before m5.instantiate is called if options.take_checkpoints != None and (options.simpoint or options.at_instruction): offset = int(options.take_checkpoints) # Set an instruction break point if options.simpoint: for i in xrange(np): if testsys.cpu[i].workload[0].simpoint == 0: fatal("no simpoint for testsys.cpu[%d].workload[0]", i) checkpoint_inst = int(testsys.cpu[i].workload[0].simpoint) + offset testsys.cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: options.take_checkpoints = offset # Set all test cpus with the right number of instructions # for the upcoming simulation for i in xrange(np): testsys.cpu[i].max_insts_any_thread = offset checkpoint_dir = None if options.checkpoint_restore != None: maxtick, checkpoint_dir = findCptDir(options, maxtick, cptdir, testsys) m5.instantiate(checkpoint_dir) if options.standard_switch or cpu_class: if options.standard_switch: print "Switch at instruction count:%s" % str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate(maxtick, numpids) elif cpu_class and options.fast_forward: print "Switch at instruction count:%s" % str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate(maxtick, numpids) else: print "Switch at curTick count:%s" % str(10000) exit_event = m5.simulate(10000) print "Switched CPUS @ tick %s" % (m5.curTick()) # when you change to Timing (or Atomic), you halt the system # given as argument. When you are finished with the system # changes (including switchCpus), you must resume the system # manually. You DON'T need to resume after just switching # CPUs if you haven't changed anything on the system level. m5.changeToTiming(testsys) m5.switchCpus(switch_cpu_list) m5.resume(testsys) if options.standard_switch: print "Switch at instruction count:%d" % (testsys.switch_cpus[0].max_insts_any_thread) # warmup instruction count may have already been set if options.warmup_insts: exit_event = m5.simulate(maxtick, numpids) else: exit_event = m5.simulate(options.standard_switch, numpids) print "Switching CPUS @ tick %s" % (m5.curTick()) print "Simulation ends instruction count:%d" % (testsys.switch_cpus_1[0].max_insts_any_thread) m5.drain(testsys) m5.switchCpus(switch_cpu_list1) m5.resume(testsys) # If we're taking and restoring checkpoints, use checkpoint_dir # option only for finding the checkpoints to restore from. This # lets us test checkpointing by restoring from one set of # checkpoints, generating a second set, and then comparing them. if options.take_checkpoints and options.checkpoint_restore: if m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() if options.take_checkpoints != None: # Checkpoints being taken via the command line at <when> and at # subsequent periods of <period>. Checkpoint instructions # received from the benchmark running are ignored and skipped in # favor of command line checkpoint instructions. exit_cause = scriptCheckpoints(options, cptdir) else: if options.fast_forward: m5.stats.reset() print "**** REAL SIMULATION ****" # If checkpoints are being taken, then the checkpoint instruction # will occur in the benchmark code it self. if options.repeat_switch and maxtick > options.repeat_switch: exit_cause = repeatSwitch(testsys, repeat_switch_cpu_list, maxtick, options.repeat_switch) else: exit_cause = benchCheckpoints(options, maxtick, cptdir, numpids) print "Exiting @ tick %i because %s" % (m5.curTick(), exit_cause) if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d"))
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: cptdir = m5.options.outdir else: cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: fatal("Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: fatal("Must specify --caches when using --standard-switch") if options.standard_switch and options.repeat_switch: fatal("Can't specify both --standard-switch and --repeat-switch") if options.repeat_switch and options.take_checkpoints: fatal("Can't specify both --repeat-switch and --take-checkpoints") np = options.num_cpus switch_cpus = None if options.prog_interval: for i in xrange(np): testsys.cpu[i].progress_interval = options.prog_interval if options.maxinsts: for i in xrange(np): testsys.cpu[i].max_insts_any_thread = options.maxinsts if cpu_class: switch_cpus = [cpu_class(switched_out=True, cpu_id=(i)) for i in xrange(np)] for i in xrange(np): if options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) switch_cpus[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[i].clock # simulation period if options.maxinsts: switch_cpus[i].max_insts_any_thread = options.maxinsts # Add checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() testsys.switch_cpus = switch_cpus switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] if options.repeat_switch: switch_class = getCPUClass(options.cpu_type)[0] if switch_class.require_caches() and \ not options.caches: print "%s: Must be used with caches" % str(switch_class) sys.exit(1) if not switch_class.support_take_over(): print "%s: CPU switching not supported" % str(switch_class) sys.exit(1) repeat_switch_cpus = [switch_class(switched_out=True, \ cpu_id=(i)) for i in xrange(np)] for i in xrange(np): repeat_switch_cpus[i].system = testsys repeat_switch_cpus[i].workload = testsys.cpu[i].workload repeat_switch_cpus[i].clock = testsys.cpu[i].clock if options.maxinsts: repeat_switch_cpus[i].max_insts_any_thread = options.maxinsts if options.checker: repeat_switch_cpus[i].addCheckerCpu() testsys.repeat_switch_cpus = repeat_switch_cpus if cpu_class: repeat_switch_cpu_list = [(switch_cpus[i], repeat_switch_cpus[i]) for i in xrange(np)] else: repeat_switch_cpu_list = [(testsys.cpu[i], repeat_switch_cpus[i]) for i in xrange(np)] if options.standard_switch: switch_cpus = [TimingSimpleCPU(switched_out=True, cpu_id=(i)) for i in xrange(np)] switch_cpus_1 = [DerivO3CPU(switched_out=True, cpu_id=(i)) for i in xrange(np)] for i in xrange(np): switch_cpus[i].system = testsys switch_cpus_1[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus_1[i].workload = testsys.cpu[i].workload switch_cpus[i].clock = testsys.cpu[i].clock switch_cpus_1[i].clock = testsys.cpu[i].clock # if restoring, make atomic cpu simulate only a few instructions if options.checkpoint_restore != None: testsys.cpu[i].max_insts_any_thread = 1 # Fast forward to specified location if we are not restoring elif options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if testsys.cpu[i].workload[0].simpoint == 0: fatal('simpoint not found') testsys.cpu[i].max_insts_any_thread = \ testsys.cpu[i].workload[0].simpoint # No distance specified, just switch else: testsys.cpu[i].max_insts_any_thread = 1 # warmup period if options.warmup_insts: switch_cpus[i].max_insts_any_thread = options.warmup_insts # simulation period if options.maxinsts: switch_cpus_1[i].max_insts_any_thread = options.maxinsts # attach the checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() switch_cpus_1[i].addCheckerCpu() testsys.switch_cpus = switch_cpus testsys.switch_cpus_1 = switch_cpus_1 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] switch_cpu_list1 = [(switch_cpus[i], switch_cpus_1[i]) for i in xrange(np)] # set the checkpoint in the cpu before m5.instantiate is called if options.take_checkpoints != None and \ (options.simpoint or options.at_instruction): offset = int(options.take_checkpoints) # Set an instruction break point if options.simpoint: for i in xrange(np): if testsys.cpu[i].workload[0].simpoint == 0: fatal('no simpoint for testsys.cpu[%d].workload[0]', i) checkpoint_inst = int(testsys.cpu[i].workload[0].simpoint) + offset testsys.cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: options.take_checkpoints = offset # Set all test cpus with the right number of instructions # for the upcoming simulation for i in xrange(np): testsys.cpu[i].max_insts_any_thread = offset checkpoint_dir = None if options.checkpoint_restore != None: maxtick, checkpoint_dir = findCptDir(options, maxtick, cptdir, testsys) m5.instantiate(checkpoint_dir) if options.standard_switch or cpu_class: if options.standard_switch: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() elif cpu_class and options.fast_forward: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() else: print "Switch at curTick count:%s" % str(10000) exit_event = m5.simulate(10000) print "Switched CPUS @ tick %s" % (m5.curTick()) m5.switchCpus(testsys, switch_cpu_list) if options.standard_switch: print "Switch at instruction count:%d" % \ (testsys.switch_cpus[0].max_insts_any_thread) #warmup instruction count may have already been set if options.warmup_insts: exit_event = m5.simulate() else: exit_event = m5.simulate(options.standard_switch) print "Switching CPUS @ tick %s" % (m5.curTick()) print "Simulation ends instruction count:%d" % \ (testsys.switch_cpus_1[0].max_insts_any_thread) m5.switchCpus(testsys, switch_cpu_list1) # If we're taking and restoring checkpoints, use checkpoint_dir # option only for finding the checkpoints to restore from. This # lets us test checkpointing by restoring from one set of # checkpoints, generating a second set, and then comparing them. if options.take_checkpoints and options.checkpoint_restore: if m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() if options.take_checkpoints != None : # Checkpoints being taken via the command line at <when> and at # subsequent periods of <period>. Checkpoint instructions # received from the benchmark running are ignored and skipped in # favor of command line checkpoint instructions. exit_event = scriptCheckpoints(options, maxtick, cptdir) else: if options.fast_forward: m5.stats.reset() print "**** REAL SIMULATION ****" # If checkpoints are being taken, then the checkpoint instruction # will occur in the benchmark code it self. if options.repeat_switch and maxtick > options.repeat_switch: exit_event = repeatSwitch(testsys, repeat_switch_cpu_list, maxtick, options.repeat_switch) else: exit_event = benchCheckpoints(options, maxtick, cptdir) print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause()) if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d")) if not m5.options.interactive: sys.exit(exit_event.getCode())
# Required for running kvm on multiple host cores. # Uses gem5's parallel event queue feature # Note: The simulator is quite picky about this number! root.sim_quantum = int(1e9) # 1 ms # Instantiate all of the objects we've created above m5.instantiate() globalStart = time.time() print("Running the simulation") exit_event = m5.simulate() # While there is still something to do in the guest keep executing. # This is needed since we exit for the ROI begin/end while exit_event.getCause() != "m5_exit instruction encountered": print("Exited because", exit_event.getCause()) # If the user pressed ctrl-c on the host, then we really should exit if exit_event.getCause() == "user interrupt received": print("User interrupt. Exiting") break elif exit_event.getCause() == "checkpoint": checkpoint_dir = opts.checkpoint_dir + "/" + str(opts.num_cpus) m5.checkpoint(checkpoint_dir) print("Continuing") exit_event = m5.simulate() print("Normally exiting simulation: m5_exit instruction encountered")
exit_event = m5.simulate() exit_cause = exit_event.getCause() print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause) while exit_cause != "all threads reached the max instruction count": exit_event = m5.simulate() exit_cause = exit_event.getCause() print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause) inpipe.send("/sbin/m5 checkpoint\n") print 'here' while exit_cause != "checkpoint": exit_event = m5.simulate() exit_cause = exit_event.getCause() if exit_cause == "checkpoint": mkdir_p(options.checkpoint_dir) m5.checkpoint(os.path.join(options.checkpoint_dir, "cpt.%s" % options.benchmark.replace(':', '_'))) pyterm.close_pyterm(term, inpipe) print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause()) if not m5.options.interactive: sys.exit(exit_event.getCode()) sys.exit(0) elif start_count >= len(sorted_points) and options.simpoint_mode =="fastfwd": inpipe.send("/sbin/m5 switchcpus\n") exit_event = m5.simulate() exit_cause = exit_event.getCause() if exit_cause == "switch cpus": print "Done fast-forwarding -- Switching to detailed CPU"
def run(options, root, testsys, cpu_class): if options.disable_ports: m5.disableAllListeners() if options.checkpoint_dir: cptdir = options.checkpoint_dir elif m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: fatal("Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: fatal("Must specify --caches when using --standard-switch") if options.standard_switch and options.repeat_switch: fatal("Can't specify both --standard-switch and --repeat-switch") if options.repeat_switch and options.take_checkpoints: fatal("Can't specify both --repeat-switch and --take-checkpoints") np = options.num_cpus switch_cpus = None if options.prog_interval: for i in xrange(np): testsys.cpu[i].progress_interval = options.prog_interval if options.maxinsts: for i in xrange(np): testsys.cpu[i].max_insts_any_thread = options.maxinsts if cpu_class: switch_cpus = [ cpu_class(switched_out=True, cpu_id=(i)) for i in xrange(np) ] for i in xrange(np): if options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) switch_cpus[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus[i].clk_domain = testsys.cpu[i].clk_domain switch_cpus[i].progress_interval = \ testsys.cpu[i].progress_interval # simulation period if options.maxinsts: switch_cpus[i].max_insts_any_thread = options.maxinsts # Add checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() # If elastic tracing is enabled attach the elastic trace probe # to the switch CPUs if options.elastic_trace_en: CpuConfig.config_etrace(cpu_class, switch_cpus, options) testsys.switch_cpus = switch_cpus switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] if cpu_class == getCPUClass("detailed"): config_O3cpu(options, testsys.switch_cpus) if options.repeat_switch: switch_class = getCPUClass(options.cpu_type)[0] if switch_class.require_caches() and \ not options.caches: print "%s: Must be used with caches" % str(switch_class) sys.exit(1) if not switch_class.support_take_over(): print "%s: CPU switching not supported" % str(switch_class) sys.exit(1) repeat_switch_cpus = [switch_class(switched_out=True, \ cpu_id=(i)) for i in xrange(np)] for i in xrange(np): repeat_switch_cpus[i].system = testsys repeat_switch_cpus[i].workload = testsys.cpu[i].workload repeat_switch_cpus[i].clk_domain = testsys.cpu[i].clk_domain if options.maxinsts: repeat_switch_cpus[i].max_insts_any_thread = options.maxinsts if options.checker: repeat_switch_cpus[i].addCheckerCpu() testsys.repeat_switch_cpus = repeat_switch_cpus if cpu_class: repeat_switch_cpu_list = [(switch_cpus[i], repeat_switch_cpus[i]) for i in xrange(np)] else: repeat_switch_cpu_list = [(testsys.cpu[i], repeat_switch_cpus[i]) for i in xrange(np)] if options.standard_switch: timing_cpus = [ TimingSimpleCPU(switched_out=True, cpu_id=(i)) for i in xrange(np) ] o3_cpus = [ DerivO3CPU(switched_out=True, cpu_id=(i)) for i in xrange(np) ] config_O3cpu(options, o3_cpus) for i in xrange(np): timing_cpus[i].system = testsys o3_cpus[i].system = testsys timing_cpus[i].workload = testsys.cpu[i].workload o3_cpus[i].workload = testsys.cpu[i].workload timing_cpus[i].clk_domain = testsys.cpu[i].clk_domain o3_cpus[i].clk_domain = testsys.cpu[i].clk_domain # if restoring, make atomic cpu simulate only a few instructions if options.checkpoint_restore != None: testsys.cpu[i].max_insts_any_thread = 1 # Fast forward to specified location if we are not restoring elif options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if testsys.cpu[i].workload[0].simpoint == 0: fatal('simpoint not found') testsys.cpu[i].max_insts_any_thread = \ testsys.cpu[i].workload[0].simpoint # No distance specified, just switch else: testsys.cpu[i].max_insts_any_thread = 1 # warmup period if options.warmup_insts: timing_cpus[i].max_insts_any_thread = options.warmup_insts # simulation period if options.maxinsts: o3_cpus[i].max_insts_any_thread = options.maxinsts # attach the checker cpu if selected if options.checker: timing_cpus[i].addCheckerCpu() o3_cpus[i].addCheckerCpu() testsys.timing_cpus = timing_cpus testsys.o3_cpus = o3_cpus switch_cpu_list = [(testsys.cpu[i], timing_cpus[i]) for i in xrange(np)] switch_cpu_list1 = [(timing_cpus[i], o3_cpus[i]) for i in xrange(np)] # set the checkpoint in the cpu before m5.instantiate is called if options.take_checkpoints != None and \ (options.simpoint or options.at_instruction): offset = int(options.take_checkpoints) # Set an instruction break point if options.simpoint: for i in xrange(np): if testsys.cpu[i].workload[0].simpoint == 0: fatal('no simpoint for testsys.cpu[%d].workload[0]', i) checkpoint_inst = int( testsys.cpu[i].workload[0].simpoint) + offset testsys.cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: options.take_checkpoints = offset # Set all test cpus with the right number of instructions # for the upcoming simulation for i in xrange(np): testsys.cpu[i].max_insts_any_thread = offset if options.take_simpoint_checkpoints != None: simpoints, interval_length = parseSimpointAnalysisFile( options, testsys) checkpoint_dir = None if options.checkpoint_restore: cpt_starttick, checkpoint_dir = findCptDir(options, cptdir, testsys) m5.instantiate(checkpoint_dir) # Initialization is complete. If we're not in control of simulation # (that is, if we're a slave simulator acting as a component in another # 'master' simulator) then we're done here. The other simulator will # call simulate() directly. --initialize-only is used to indicate this. if options.initialize_only: return # 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 if options.at_instruction or options.simpoint: warn("Relative max tick specified with --at-instruction or" \ " --simpoint\n These options don't specify the " \ "checkpoint start tick, so assuming\n you mean " \ "absolute max tick") 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" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() elif cpu_class and options.fast_forward: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() else: print "Switch at curTick count:%s" % str(10000) exit_event = m5.simulate(10000) print "Switched CPUS @ tick %s" % (m5.curTick()) m5.switchCpus(testsys, switch_cpu_list) if options.standard_switch: print "Switch at instruction count:%d" % \ (testsys.timing_cpus[0].max_insts_any_thread) #warmup instruction count may have already been set if options.warmup_insts: exit_event = m5.simulate() else: exit_event = m5.simulate(options.standard_switch) print "Switching CPUS @ tick %s" % (m5.curTick()) print "Simulation ends instruction count:%d" % \ (testsys.o3_cpus[0].max_insts_any_thread) m5.switchCpus(testsys, switch_cpu_list1) # If we're taking and restoring checkpoints, use checkpoint_dir # option only for finding the checkpoints to restore from. This # lets us test checkpointing by restoring from one set of # checkpoints, generating a second set, and then comparing them. if (options.take_checkpoints or options.take_simpoint_checkpoints) \ and options.checkpoint_restore: if m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() if options.take_checkpoints != None: # Checkpoints being taken via the command line at <when> and at # subsequent periods of <period>. Checkpoint instructions # received from the benchmark running are ignored and skipped in # favor of command line checkpoint instructions. exit_event = scriptCheckpoints(options, maxtick, cptdir) # Take SimPoint checkpoints elif options.take_simpoint_checkpoints != None: takeSimpointCheckpoints(simpoints, interval_length, cptdir) # Restore from SimPoint checkpoints elif options.restore_simpoint_checkpoint != None: restoreSimpointCheckpoint() else: if options.fast_forward: m5.stats.reset() print "**** REAL SIMULATION ****" # If checkpoints are being taken, then the checkpoint instruction # will occur in the benchmark code it self. if options.repeat_switch and maxtick > options.repeat_switch: exit_event = repeatSwitch(testsys, repeat_switch_cpu_list, maxtick, options.repeat_switch) else: exit_event = benchCheckpoints(options, maxtick, cptdir) print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause()) if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d")) if not m5.options.interactive: sys.exit(exit_event.getCode())
def run(options, root, testsys, cpu_class): if options.checkpoint_dir: cptdir = options.checkpoint_dir elif m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: fatal("Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: fatal("Must specify --caches when using --standard-switch") if options.standard_switch and options.repeat_switch: fatal("Can't specify both --standard-switch and --repeat-switch") if options.repeat_switch and options.take_checkpoints: fatal("Can't specify both --repeat-switch and --take-checkpoints") np = options.num_cpus switch_cpus = None if options.prog_interval: for i in xrange(np): testsys[0].cpu[i].progress_interval = options.prog_interval testsys[1].cpu[i].progress_interval = options.prog_interval if options.maxinsts: for i in xrange(np): testsys[0].cpu[i].max_insts_any_thread = options.maxinsts testsys[1].cpu[i].max_insts_any_thread = options.maxinsts if cpu_class: switch_cpus01 = [ cpu_class(switched_out=True, cpu_id=(i)) for i in xrange(np) ] ncpuswitch = len(switch_cpus01) temp02 = [ cpu_class(switched_out=True, cpu_id=(i + ncpuswitch)) for i in xrange(np) ] switch_cpus = switch_cpus01 + temp02 for i in xrange(np): if options.fast_forward: testsys[0].cpu[i].max_insts_any_thread = int( options.fast_forward) switch_cpus[i].system = testsys[0] switch_cpus[i].workload = testsys[0].cpu[i].workload switch_cpus[i].clk_domain = testsys[0].cpu[i].clk_domain # simulation period if options.maxinsts: switch_cpus[i].max_insts_any_thread = options.maxinsts # Add checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() for i in xrange(np): if options.fast_forward: testsys[1].cpu[i].max_insts_any_thread = int( options.fast_forward) switch_cpus[i + ncpuswitch].system = testsys[1] switch_cpus[i + ncpuswitch].workload = testsys[1].cpu[i].workload switch_cpus[i + ncpuswitch].clk_domain = testsys[1].cpu[i].clk_domain # simulation period if options.maxinsts: switch_cpus[i + ncpuswitch].max_insts_any_thread = options.maxinsts # Add checker cpu if selected if options.checker: switch_cpus[i + ncpuswitch].addCheckerCpu() testsys[0].switch_cpus = switch_cpus01 testsys[1].switch_cpus = temp02 switch_cpu_list = [(testsys[0].cpu[i], switch_cpus[i]) for i in xrange(np)] switch_cpu_list_temp = [(testsys[1].cpu[i], switch_cpus[i + ncpuswitch]) for i in xrange(np)] switch_cpu_list = switch_cpu_list + switch_cpu_list_temp if options.repeat_switch: switch_class = getCPUClass(options.cpu_type)[0] if switch_class.require_caches() and \ not options.caches: print "%s: Must be used with caches" % str(switch_class) sys.exit(1) if not switch_class.support_take_over(): print "%s: CPU switching not supported" % str(switch_class) sys.exit(1) repeat_switch_cpus = [switch_class(switched_out=True, \ cpu_id=(i)) for i in xrange(np*2)] for i in xrange(np): repeat_switch_cpus[i].system = testsys[0] repeat_switch_cpus[i].workload = testsys[0].cpu[i].workload repeat_switch_cpus[i].clk_domain = testsys[0].cpu[i].clk_domain if options.maxinsts: repeat_switch_cpus[i].max_insts_any_thread = options.maxinsts if options.checker: repeat_switch_cpus[i].addCheckerCpu() for i in xrange(np): repeat_switch_cpus[i + ncpuswitch].system = testsys[1] repeat_switch_cpus[ i + ncpuswitch].workload = testsys[1].cpu[i].workload repeat_switch_cpus[ i + ncpuswitch].clk_domain = testsys[1].cpu[i].clk_domain if options.maxinsts: repeat_switch_cpus[ i + ncpuswitch].max_insts_any_thread = options.maxinsts if options.checker: repeat_switch_cpus[i + ncpuswitch].addCheckerCpu() testsys[0].repeat_switch_cpus = [] testsys[1].repeat_switch_cpus = [] for j in xrange(np * 2): if j < np: testsys[0].repeat_switch_cpus.append(repeat_switch_cpus[j]) else: testsys[1].repeat_switch_cpus.append(repeat_switch_cpus[j]) if cpu_class: repeat_switch_cpu_list = [(switch_cpus[i], repeat_switch_cpus[i]) for i in xrange(np * 2)] else: repeat_switch_cpu_list_1 = [ (testsys[0].cpu[i], repeat_switch_cpus[i]) for i in xrange(np) ] repeat_switch_cpu_list_2 = [(testsys[1].cpu[i + ncpuswitch], repeat_switch_cpus[i + ncpuswitch]) for i in xrange(np)] repeat_switch_cpu_list = repeat_switch_cpu_list_1 + repeat_switch_cpu_list_2 if options.standard_switch: switch_cpus = [ TimingSimpleCPU(switched_out=True, cpu_id=(i)) for i in xrange(np * 2) ] switch_cpus_1 = [ DerivO3CPU(switched_out=True, cpu_id=(i)) for i in xrange(np * 2) ] for i in xrange(np * 2): if i < np: switch_cpus[i].system = testsys[0] switch_cpus_1[i].system = testsys[0] switch_cpus[i].workload = testsys[0].cpu[i].workload switch_cpus_1[i].workload = testsys[0].cpu[i].workload switch_cpus[i].clk_domain = testsys[0].cpu[i].clk_domain switch_cpus_1[i].clk_domain = testsys[0].cpu[i].clk_domain else: switch_cpus[i].system = testsys[1] switch_cpus_1[i].system = testsys[1] switch_cpus[i].workload = testsys[1].cpu[i].workload switch_cpus_1[i].workload = testsys[1].cpu[i].workload switch_cpus[i].clk_domain = testsys[1].cpu[i].clk_domain switch_cpus_1[i].clk_domain = testsys[1].cpu[i].clk_domain # if restoring, make atomic cpu simulate only a few instructions if options.checkpoint_restore != None: if i < np: testsys[0].cpu[i].max_insts_any_thread = 1 else: testsys[1].cpu[i].max_insts_any_thread = 1 # Fast forward to specified location if we are not restoring elif options.fast_forward: if i < np: testsys[0].cpu[i].max_insts_any_thread = int( options.fast_forward) else: testsys[1].cpu[i].max_insts_any_thread = int( options.fast_forward) # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if i < np: if testsys[0].cpu[i].workload[0].simpoint == 0: fatal('simpoint not found') testsys[0].cpu[i].max_insts_any_thread = \ testsys[0].cpu[i].workload[0].simpoint else: if testsys[1].cpu[i].workload[0].simpoint == 0: fatal('simpoint not found') testsys[1].cpu[i].max_insts_any_thread = \ testsys[1].cpu[i].workload[0].simpoint # No distance specified, just switch else: if i < np: testsys[0].cpu[i].max_insts_any_thread = 1 else: testsys[1].cpu[i].max_insts_any_thread = 1 # warmup period if options.warmup_insts: switch_cpus[i].max_insts_any_thread = options.warmup_insts # simulation period if options.maxinsts: switch_cpus_1[i].max_insts_any_thread = options.maxinsts # attach the checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() switch_cpus_1[i].addCheckerCpu() testsys[0].switch_cpus = switch_cpus testsys[1].switch_cpus = switch_cpus testsys[0].switch_cpus_1 = switch_cpus_1 testsys[1].switch_cpus_1 = switch_cpus_1 switch_cpu_list_1 = [(testsys[0].cpu[i], switch_cpus[i]) for i in xrange(np)] switch_cpu_list_2 = [(testsys[1].cpu[i], switch_cpus[i]) for i in xrange(np)] switch_cpu_list = switch_cpu_list_1 + switch_cpu_list_2 switch_cpu_list1 = [(switch_cpus[i], switch_cpus_1[i]) for i in switch_cpu_list1] for i in xrange(np * 2): if i < np: switch_cpu_list1_1 = [switch_cpu_list1[i]] else: switch_cpu_list1_2 = [switch_cpu_list1[i]] # set the checkpoint in the cpu before m5.instantiate is called if options.take_checkpoints != None and \ (options.simpoint or options.at_instruction): offset = int(options.take_checkpoints) # Set an instruction break point if options.simpoint: for i in xrange(np * 2): if i < np: if testsys.cpu[i].workload[0].simpoint == 0: fatal('no simpoint for testsys.cpu[%d].workload[0]', i) checkpoint_inst = int( testsys[0].cpu[i].workload[0].simpoint) + offset testsys[0].cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: if testsys[1].cpu[i].workload[0].simpoint == 0: fatal('no simpoint for testsys.cpu[%d].workload[0]', i) checkpoint_inst = int( testsys[1].cpu[i].workload[0].simpoint) + offset testsys[1].cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: options.take_checkpoints = offset # Set all test cpus with the right number of instructions # for the upcoming simulation for i in xrange(np * 2): if i < np: testsys[0].cpu[i].max_insts_any_thread = offset else: testsys[1].cpu[i].max_insts_any_thread = offset checkpoint_dir = None checkpoint_dir1 = None if options.checkpoint_restore: cpt_starttick, checkpoint_dir = findCptDir(options, cptdir, testsys[0]) cpt_starttick1, checkpoint_dir1 = findCptDir(options, cptdir, testsys[1]) m5.instantiate(checkpoint_dir) m5.instantiate(checkpoint_dir1) # 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 explicit_maxticks1 = 0 maxtick_from_abs1 = m5.MaxTick maxtick_from_rel1 = m5.MaxTick maxtick_from_maxtime1 = m5.MaxTick if options.abs_max_tick: maxtick_from_abs = options.abs_max_tick explicit_maxticks += 1 maxtick_from_abs1 = options.abs_max_tick explicit_maxticks1 += 1 if options.rel_max_tick: maxtick_from_rel = options.rel_max_tick maxtick_from_rel1 = 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 maxtick_from_rel1 += cpt_starttick1 if options.at_instruction or options.simpoint: warn("Relative max tick specified with --at-instruction or" \ " --simpoint\n These options don't specify the " \ "checkpoint start tick, so assuming\n you mean " \ "absolute max tick") explicit_maxticks += 1 explicit_maxticks1 += 1 if options.maxtime: maxtick_from_maxtime = m5.ticks.fromSeconds(options.maxtime) explicit_maxticks += 1 maxtick_from_maxtime1 = m5.ticks.fromSeconds(options.maxtime) explicit_maxticks1 += 1 if explicit_maxticks > 1: warn("Specified multiple of --abs-max-tick, --rel-max-tick, --maxtime."\ " Using least") if explicit_maxticks1 > 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]) maxtick1 = min( [maxtick_from_abs1, maxtick_from_rel1, maxtick_from_maxtime1]) 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.checkpoint_restore != None and maxtick1 < cpt_starttick1: fatal("Bad maxtick (%d) specified: " \ "Checkpoint starts starts from tick: %d", maxtick1, cpt_starttick1) if options.standard_switch or cpu_class: if options.standard_switch: print "Switch at instruction count:%s" % \ str(testsys[0].cpu[0].max_insts_any_thread) print "Switch at instruction count:%s" % \ str(testsys[1].cpu[0].max_insts_any_thread) exit_event = m5.simulate() elif cpu_class and options.fast_forward: print "Switch at instruction count:%s" % \ str(testsys[0].cpu[0].max_insts_any_thread) print "Switch at instruction count:%s" % \ str(testsys[1].cpu[0].max_insts_any_thread) exit_event = m5.simulate() else: print "Switch at curTick count:%s" % str(10000) exit_event = m5.simulate(10000) print "Switched CPUS @ tick %s" % (m5.curTick()) m5.switchCpus(testsys[0], switch_cpu_list_1) m5.switchCpus(testsys[1], switch_cpu_list_2) if options.standard_switch: print "Switch at instruction count:%d" % \ (testsys[0].switch_cpus[0].max_insts_any_thread) print "Switch at instruction count:%d" % \ (testsys[1].switch_cpus[0].max_insts_any_thread) #warmup instruction count may have already been set if options.warmup_insts: exit_event = m5.simulate() else: exit_event = m5.simulate(options.standard_switch) print "Switching CPUS @ tick %s" % (m5.curTick()) print "Simulation ends instruction count:%d" % \ (testsys[0].switch_cpus_1[0].max_insts_any_thread) print "Simulation ends instruction count:%d" % \ (testsys[1].switch_cpus_1[0].max_insts_any_thread) m5.switchCpus(testsys[0], switch_cpu_list1_1) m5.switchCpus(testsys[1], switch_cpu_list1_2) # If we're taking and restoring checkpoints, use checkpoint_dir # option only for finding the checkpoints to restore from. This # lets us test checkpointing by restoring from one set of # checkpoints, generating a second set, and then comparing them. if options.take_checkpoints and options.checkpoint_restore: if m5.options.outdir: cptdir = m5.options.outdir cptdir1 = m5.options.outdir else: cptdir = getcwd() cptdir1 = getcwd() if options.take_checkpoints != None: # Checkpoints being taken via the command line at <when> and at # subsequent periods of <period>. Checkpoint instructions # received from the benchmark running are ignored and skipped in # favor of command line checkpoint instructions. exit_event = scriptCheckpoints(options, maxtick, cptdir) exit_event1 = scriptCheckpoints(options, maxtick1, cptdir1) else: if options.fast_forward: m5.stats.reset() print "**** REAL SIMULATION ****" # If checkpoints are being taken, then the checkpoint instruction # will occur in the benchmark code it self. if options.repeat_switch and maxtick > options.repeat_switch: exit_event = repeatSwitch(testsys[0], repeat_switch_cpu_list_1, maxtick, options.repeat_switch) else: exit_event = benchCheckpoints(options, maxtick, cptdir) if options.repeat_switch and maxtick1 > options.repeat_switch: exit_event1 = repeatSwitch(testsys[1], repeat_switch_cpu_list_2, maxtick1, options.repeat_switch) else: exit_event = benchCheckpoints(options, maxtick, cptdir) exit_event1 = benchCheckpoints(options, maxtick1, cptdir1) print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause()) if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d")) m5.checkpoint(joinpath(cptdir1, "cpt.%d")) if not m5.options.interactive: sys.exit(exit_event.getCode()) sys.exit(exit_event1.getCode())
def main(): parser = argparse.ArgumentParser( description="Generic ARM big.LITTLE configuration") parser.add_argument("--restore-from", type=str, default=None, help="Restore from checkpoint") parser.add_argument("--dtb", type=str, default=default_dtb, help="DTB file to load") parser.add_argument("--kernel", type=str, default=default_kernel, help="Linux kernel") parser.add_argument("--disk", action="append", type=str, default=[], help="Disks to instantiate") parser.add_argument("--bootscript", type=str, default=default_rcs, help="Linux bootscript") parser.add_argument("--atomic", action="store_true", default=False, help="Use atomic CPUs") parser.add_argument("--kernel-init", type=str, default="/sbin/init", help="Override init") parser.add_argument("--big-cpus", type=int, default=1, help="Number of big CPUs to instantiate") parser.add_argument("--little-cpus", type=int, default=1, help="Number of little CPUs to instantiate") parser.add_argument("--caches", action="store_true", default=False, help="Instantiate caches") parser.add_argument("--last-cache-level", type=int, default=2, help="Last level of caches (e.g. 3 for L3)") parser.add_argument("--big-cpu-clock", type=str, default="2GHz", help="Big CPU clock frequency") parser.add_argument("--little-cpu-clock", type=str, default="1GHz", help="Little CPU clock frequency") m5.ticks.fixGlobalFrequency() options = parser.parse_args() kernel_cmd = [ "earlyprintk=pl011,0x1c090000", "console=ttyAMA0", "lpj=19988480", "norandmaps", "loglevel=8", "mem=%s" % default_mem_size, "root=/dev/vda1", "rw", "init=%s" % options.kernel_init, "vmalloc=768MB", ] root = Root(full_system=True) disks = default_disk if len(options.disk) == 0 else options.disk system = createSystem(options.kernel, options.bootscript, disks=disks) root.system = system system.boot_osflags = " ".join(kernel_cmd) AtomicCluster = devices.AtomicCluster if options.big_cpus + options.little_cpus == 0: m5.util.panic("Empty CPU clusters") # big cluster if options.big_cpus > 0: if options.atomic: system.bigCluster = AtomicCluster(system, options.big_cpus, options.big_cpu_clock) else: system.bigCluster = BigCluster(system, options.big_cpus, options.big_cpu_clock) mem_mode = system.bigCluster.memoryMode() # little cluster if options.little_cpus > 0: if options.atomic: system.littleCluster = AtomicCluster(system, options.little_cpus, options.little_cpu_clock) else: system.littleCluster = LittleCluster(system, options.little_cpus, options.little_cpu_clock) mem_mode = system.littleCluster.memoryMode() if options.big_cpus > 0 and options.little_cpus > 0: if system.bigCluster.memoryMode() != system.littleCluster.memoryMode(): m5.util.panic("Memory mode missmatch among CPU clusters") system.mem_mode = mem_mode # create caches system.addCaches(options.caches, options.last_cache_level) if not options.caches: if options.big_cpus > 0 and system.bigCluster.requireCaches(): m5.util.panic("Big CPU model requires caches") if options.little_cpus > 0 and system.littleCluster.requireCaches(): m5.util.panic("Little CPU model requires caches") # Linux device tree system.dtb_filename = SysPaths.binary(options.dtb) # Get and load from the chkpt or simpoint checkpoint if options.restore_from is not None: m5.instantiate(options.restore_from) else: m5.instantiate() # start simulation (and drop checkpoints when requested) while True: event = m5.simulate() exit_msg = event.getCause() if exit_msg == "checkpoint": print "Dropping checkpoint at tick %d" % m5.curTick() cpt_dir = os.path.join(m5.options.outdir, "cpt.%d" % m5.curTick()) m5.checkpoint(os.path.join(cpt_dir)) print "Checkpoint done." else: print exit_msg, " @ ", m5.curTick() break sys.exit(event.getCode())
def main(): parser = argparse.ArgumentParser( description="Generic ARM big.LITTLE configuration") parser.add_argument("--restore-from", type=str, default=None, help="Restore from checkpoint") parser.add_argument("--dtb", type=str, default=default_dtb, help="DTB file to load") parser.add_argument("--kernel", type=str, default=default_kernel, help="Linux kernel") parser.add_argument("--disk", action="append", type=str, default=[], help="Disks to instantiate") parser.add_argument("--bootscript", type=str, default=default_rcs, help="Linux bootscript") parser.add_argument("--atomic", action="store_true", default=False, help="Use atomic CPUs") parser.add_argument("--kernel-init", type=str, default="/sbin/init", help="Override init") parser.add_argument("--big-cpus", type=int, default=1, help="Number of big CPUs to instantiate") parser.add_argument("--little-cpus", type=int, default=1, help="Number of little CPUs to instantiate") parser.add_argument("--caches", action="store_true", default=False, help="Instantiate caches") parser.add_argument("--last-cache-level", type=int, default=2, help="Last level of caches (e.g. 3 for L3)") parser.add_argument("--big-cpu-clock", type=str, default="2GHz", help="Big CPU clock frequency") parser.add_argument("--little-cpu-clock", type=str, default="1GHz", help="Little CPU clock frequency") m5.ticks.fixGlobalFrequency() options = parser.parse_args() kernel_cmd = [ "earlyprintk=pl011,0x1c090000", "console=ttyAMA0", "lpj=19988480", "norandmaps", "loglevel=8", "mem=%s" % default_mem_size, "root=/dev/vda1", "rw", "init=%s" % options.kernel_init, "vmalloc=768MB", ] root = Root(full_system=True) disks = [default_disk] if len(options.disk) == 0 else options.disk system = createSystem(options.caches, options.kernel, options.bootscript, disks=disks) root.system = system system.boot_osflags = " ".join(kernel_cmd) AtomicCluster = devices.AtomicCluster if options.big_cpus + options.little_cpus == 0: m5.util.panic("Empty CPU clusters") # big cluster if options.big_cpus > 0: if options.atomic: system.bigCluster = AtomicCluster(system, options.big_cpus, options.big_cpu_clock) else: system.bigCluster = BigCluster(system, options.big_cpus, options.big_cpu_clock) mem_mode = system.bigCluster.memoryMode() # little cluster if options.little_cpus > 0: if options.atomic: system.littleCluster = AtomicCluster(system, options.little_cpus, options.little_cpu_clock) else: system.littleCluster = LittleCluster(system, options.little_cpus, options.little_cpu_clock) mem_mode = system.littleCluster.memoryMode() if options.big_cpus > 0 and options.little_cpus > 0: if system.bigCluster.memoryMode() != system.littleCluster.memoryMode(): m5.util.panic("Memory mode missmatch among CPU clusters") system.mem_mode = mem_mode # create caches system.addCaches(options.caches, options.last_cache_level) if not options.caches: if options.big_cpus > 0 and system.bigCluster.requireCaches(): m5.util.panic("Big CPU model requires caches") if options.little_cpus > 0 and system.littleCluster.requireCaches(): m5.util.panic("Little CPU model requires caches") # Linux device tree system.dtb_filename = SysPaths.binary(options.dtb) # Get and load from the chkpt or simpoint checkpoint if options.restore_from is not None: m5.instantiate(options.restore_from) else: m5.instantiate() # start simulation (and drop checkpoints when requested) while True: event = m5.simulate() exit_msg = event.getCause() if exit_msg == "checkpoint": print "Dropping checkpoint at tick %d" % m5.curTick() cpt_dir = os.path.join(m5.options.outdir, "cpt.%d" % m5.curTick()) m5.checkpoint(os.path.join(cpt_dir)) print "Checkpoint done." else: print exit_msg, " @ ", m5.curTick() break sys.exit(event.getCode())
def run(options, root, testsys, cpu_class): if options.checkpoint_dir: cptdir = options.checkpoint_dir elif m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() if options.fast_forward and options.checkpoint_restore != None: fatal("Can't specify both --fast-forward and --checkpoint-restore") if options.standard_switch and not options.caches: fatal("Must specify --caches when using --standard-switch") if options.standard_switch and options.repeat_switch: fatal("Can't specify both --standard-switch and --repeat-switch") if options.repeat_switch and options.take_checkpoints: fatal("Can't specify both --repeat-switch and --take-checkpoints") np = options.num_cpus switch_cpus = None if options.prog_interval: for i in xrange(np): testsys.cpu[i].progress_interval = options.prog_interval if options.maxinsts: for i in xrange(np): testsys.cpu[i].max_insts_any_thread = options.maxinsts if cpu_class: switch_cpus = [cpu_class(switched_out=True, cpu_id=(i)) for i in xrange(np)] for i in xrange(np): if options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) switch_cpus[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus[i].clk_domain = testsys.cpu[i].clk_domain switch_cpus[i].progress_interval = testsys.cpu[i].progress_interval # simulation period if options.maxinsts: switch_cpus[i].max_insts_any_thread = options.maxinsts # Add checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() testsys.switch_cpus = switch_cpus switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] if options.repeat_switch: switch_class = getCPUClass(options.cpu_type)[0] if switch_class.require_caches() and \ not options.caches: print "%s: Must be used with caches" % str(switch_class) sys.exit(1) if not switch_class.support_take_over(): print "%s: CPU switching not supported" % str(switch_class) sys.exit(1) repeat_switch_cpus = [switch_class(switched_out=True, \ cpu_id=(i)) for i in xrange(np)] for i in xrange(np): repeat_switch_cpus[i].system = testsys repeat_switch_cpus[i].workload = testsys.cpu[i].workload repeat_switch_cpus[i].clk_domain = testsys.cpu[i].clk_domain if options.maxinsts: repeat_switch_cpus[i].max_insts_any_thread = options.maxinsts if options.checker: repeat_switch_cpus[i].addCheckerCpu() testsys.repeat_switch_cpus = repeat_switch_cpus if cpu_class: repeat_switch_cpu_list = [(switch_cpus[i], repeat_switch_cpus[i]) for i in xrange(np)] else: repeat_switch_cpu_list = [(testsys.cpu[i], repeat_switch_cpus[i]) for i in xrange(np)] if options.standard_switch: switch_cpus = [TimingSimpleCPU(switched_out=True, cpu_id=(i)) for i in xrange(np)] switch_cpus_1 = [DerivO3CPU(switched_out=True, cpu_id=(i)) for i in xrange(np)] for i in xrange(np): switch_cpus[i].system = testsys switch_cpus_1[i].system = testsys switch_cpus[i].workload = testsys.cpu[i].workload switch_cpus_1[i].workload = testsys.cpu[i].workload switch_cpus[i].clk_domain = testsys.cpu[i].clk_domain switch_cpus_1[i].clk_domain = testsys.cpu[i].clk_domain # if restoring, make atomic cpu simulate only a few instructions if options.checkpoint_restore != None: testsys.cpu[i].max_insts_any_thread = 1 # Fast forward to specified location if we are not restoring elif options.fast_forward: testsys.cpu[i].max_insts_any_thread = int(options.fast_forward) # Fast forward to a simpoint (warning: time consuming) elif options.simpoint: if testsys.cpu[i].workload[0].simpoint == 0: fatal('simpoint not found') testsys.cpu[i].max_insts_any_thread = \ testsys.cpu[i].workload[0].simpoint # No distance specified, just switch else: testsys.cpu[i].max_insts_any_thread = 1 # warmup period if options.warmup_insts: switch_cpus[i].max_insts_any_thread = options.warmup_insts # simulation period if options.maxinsts: switch_cpus_1[i].max_insts_any_thread = options.maxinsts # attach the checker cpu if selected if options.checker: switch_cpus[i].addCheckerCpu() switch_cpus_1[i].addCheckerCpu() testsys.switch_cpus = switch_cpus testsys.switch_cpus_1 = switch_cpus_1 switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)] switch_cpu_list1 = [(switch_cpus[i], switch_cpus_1[i]) for i in xrange(np)] # set the checkpoint in the cpu before m5.instantiate is called if options.take_checkpoints != None and \ (options.simpoint or options.at_instruction): offset = int(options.take_checkpoints) # Set an instruction break point if options.simpoint: for i in xrange(np): if testsys.cpu[i].workload[0].simpoint == 0: fatal('no simpoint for testsys.cpu[%d].workload[0]', i) checkpoint_inst = int(testsys.cpu[i].workload[0].simpoint) + offset testsys.cpu[i].max_insts_any_thread = checkpoint_inst # used for output below options.take_checkpoints = checkpoint_inst else: options.take_checkpoints = offset # Set all test cpus with the right number of instructions # for the upcoming simulation for i in xrange(np): testsys.cpu[i].max_insts_any_thread = offset if options.take_simpoint_checkpoints != None: simpoints, interval_length = parseSimpointAnalysisFile(options, testsys) checkpoint_dir = None if options.checkpoint_restore: cpt_starttick, checkpoint_dir = findCptDir(options, cptdir, testsys) m5.instantiate(checkpoint_dir) # Initialization is complete. If we're not in control of simulation # (that is, if we're a slave simulator acting as a component in another # 'master' simulator) then we're done here. The other simulator will # call simulate() directly. --initialize-only is used to indicate this. if options.initialize_only: return # 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 if options.at_instruction or options.simpoint: warn("Relative max tick specified with --at-instruction or" \ " --simpoint\n These options don't specify the " \ "checkpoint start tick, so assuming\n you mean " \ "absolute max tick") 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" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() elif cpu_class and options.fast_forward: print "Switch at instruction count:%s" % \ str(testsys.cpu[0].max_insts_any_thread) exit_event = m5.simulate() else: print "Switch at curTick count:%s" % str(10000) exit_event = m5.simulate(10000) print "Switched CPUS @ tick %s" % (m5.curTick()) m5.switchCpus(testsys, switch_cpu_list) if options.standard_switch: print "Switch at instruction count:%d" % \ (testsys.switch_cpus[0].max_insts_any_thread) #warmup instruction count may have already been set if options.warmup_insts: exit_event = m5.simulate() else: exit_event = m5.simulate(options.standard_switch) print "Switching CPUS @ tick %s" % (m5.curTick()) print "Simulation ends instruction count:%d" % \ (testsys.switch_cpus_1[0].max_insts_any_thread) m5.switchCpus(testsys, switch_cpu_list1) # If we're taking and restoring checkpoints, use checkpoint_dir # option only for finding the checkpoints to restore from. This # lets us test checkpointing by restoring from one set of # checkpoints, generating a second set, and then comparing them. if (options.take_checkpoints or options.take_simpoint_checkpoints) \ and options.checkpoint_restore: if m5.options.outdir: cptdir = m5.options.outdir else: cptdir = getcwd() if options.take_checkpoints != None : # Checkpoints being taken via the command line at <when> and at # subsequent periods of <period>. Checkpoint instructions # received from the benchmark running are ignored and skipped in # favor of command line checkpoint instructions. exit_event = scriptCheckpoints(options, maxtick, cptdir) # Take SimPoint checkpoints elif options.take_simpoint_checkpoints != None: takeSimpointCheckpoints(simpoints, interval_length, cptdir) # Restore from SimPoint checkpoints elif options.restore_simpoint_checkpoint != None: restoreSimpointCheckpoint() else: if options.fast_forward: m5.stats.reset() print "**** REAL SIMULATION ****" # If checkpoints are being taken, then the checkpoint instruction # will occur in the benchmark code it self. if options.repeat_switch and maxtick > options.repeat_switch: exit_event = repeatSwitch(testsys, repeat_switch_cpu_list, maxtick, options.repeat_switch) else: exit_event = benchCheckpoints(options, maxtick, cptdir) print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause()) if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d")) if not m5.options.interactive: sys.exit(exit_event.getCode())
print("User interrupt. Exiting") break print("Exited because", exit_event.getCause()) if exit_event.getCause() == "work started count reach": start_tick = m5.curTick() start_insts = system.totalInsts() foundROI = True elif exit_event.getCause() == "work items exit count reached": end_tick = m5.curTick() end_insts = system.totalInsts() print("Continuing") exit_event = m5.simulate() if options.checkpoint_at_end: m5.checkpoint(joinpath(cptdir, "cpt.%d")) print("") print("Performance statistics") print("Ran a total of", m5.curTick() / 1e12, "simulated seconds") print("Total wallclock time: %.2fs, %.2f min" % \ (time.time()-globalStart, (time.time()-globalStart)/60)) if foundROI: print("Simulated time in ROI: %.2fs" % ((end_tick - start_tick) / 1e12)) print("Instructions executed in ROI: %d" % ((end_insts - start_insts)))