def runFullSystem(): (opts, args) = SimpleOpts.parse_args() kernel, disk, cpu, benchmark, num_cpus = args # Don't init GPU stuff in Ruby if no GPU is specified if opts.dgpu or opts.apu: opts.cpu_only_mode = False else: opts.cpu_only_mode = True # create the system we are going to simulate system = MySystem(kernel, disk, int(num_cpus), opts, no_kvm=False) # Exit from guest on workbegin/workend system.exit_on_work_items = True # Set up the root SimObject and start the simulation root = Root(full_system=True, system=system) if system.getHostParallel(): # 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 if opts.checkpoint_restore: m5.instantiate(opts.checkpoint_dir) else: m5.instantiate() globalStart = time.time() print("Running the simulation") print("Using cpu: {}".format(cpu)) exit_event = m5.simulate(opts.abs_max_tick) # While there is still something to do in the guest keep executing. while exit_event.getCause() != "m5_exit instruction encountered": # 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 if exit_event.getCause() == "simulate() limit reached": break elif "checkpoint" in exit_event.getCause(): m5.checkpoint(opts.checkpoint_dir) break elif "switchcpu" in exit_event.getCause(): system.switchCpus(system.cpu, system.warmupCpu) else: break print('Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause()))
end_insts = system.totalInsts() m5.stats.reset() exit_event = m5.simulate() if exit_event.getCause() == "workbegin": # Reached the start of ROI # start of ROI is marked by an # m5_work_begin() call print("Resetting stats at the start of ROI!") m5.stats.reset() start_tick = m5.curTick() start_insts = system.totalInsts() # switching to atomic cpu if argument cpu == atomic if cpu == 'timing': system.switchCpus(system.cpu, system.timingCpu) else: print("Unexpected termination of simulation!") print() m5.stats.dump() end_tick = m5.curTick() end_insts = system.totalInsts() m5.stats.reset() print("Performance statistics:") print("Simulated time: %.2fs" % ((end_tick-start_tick)/1e12)) print("Instructions executed: %d" % ((end_insts-start_insts))) print("Ran a total of", m5.curTick()/1e12, "simulated seconds") print("Total wallclock time: %.2fs, %.2f min" % \ (time.time()-globalStart, (time.time()-globalStart)/60)) exit()
print("Running the simulation") print("Using cpu: {}".format(cpu)) exit_event = m5.simulate() if exit_event.getCause() == "workbegin": # Reached the start of ROI # start of ROI is marked by an # m5_work_begin() call print("Resetting stats at the start of ROI!") m5.stats.reset() start_tick = m5.curTick() start_insts = system.totalInsts() # switching to atomic cpu if argument cpu == atomic if cpu == 'atomic': system.switchCpus(system.cpu, system.atomicCpu) else: print("Unexpected termination of simulation !") exit() # Simulate the ROI exit_event = m5.simulate() # Reached the end of ROI # Finish executing the benchmark with kvm cpu print("Dump stats at the end of the ROI!") m5.stats.dump() end_tick = m5.curTick() end_insts = system.totalInsts() m5.stats.reset()