def create_system(linux_kernel_path, disk_image_path, detailed_cpu_model): # create the system we are going to simulate system = MySystem( kernel=linux_kernel_path, disk=disk_image_path, num_cpus=1, # run the benchmark in a single thread no_kvm=False, TimingCPUModel=detailed_cpu_model) # For workitems to work correctly # This will cause the simulator to exit simulation when the first work # item is reached and when the first work item is finished. system.work_begin_exit_count = 1 system.work_end_exit_count = 1 # 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 return root, system
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()))
import sys import m5 from m5.objects import * sys.path.append('configs/common/') import SimpleOpts from system import MySystem SimpleOpts.add_option("--script", default='', help="Script to execute in the simulated system") if __name__ == "__m5_main__": (opts, args) = SimpleOpts.parse_args() system = MySystem(opts) system.readfile = opts.script root = Root(full_system=True, system=system) m5.instantiate() print("Running the simulation") exit_event = m5.simulate() print('Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause()))
# sleeping for sometime makes sure # that the benchmark's output has been # printed to the console bench_file.write('sleep 5 \n') bench_file.write('m5 exit \n') bench_file.close() return file_name if __name__ == "__m5_main__": (opts, args) = SimpleOpts.parse_args() kernel, disk, cpu, benchmark, size, num_cpus = args if not cpu in ['timing', 'kvm']: m5.fatal("cpu not supported") # 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 # Create and pass a script to the simulated system to run the reuired # benchmark system.readfile = writeBenchScript(m5.options.outdir, benchmark, size) # 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!
import m5.ticks from m5.objects import * sys.path.append('configs/common/') # For the next line... import SimpleOpts from system import MySystem SimpleOpts.add_option("--script", default='', help="Script to execute in the simulated system") if __name__ == "__m5_main__": (opts, args) = SimpleOpts.parse_args() # create the system we are going to simulate system = MySystem(opts) # For workitems to work correctly # This will cause the simulator to exit simulation when the first work # item is reached and when the first work item is finished. system.work_begin_exit_count = 1 system.work_end_exit_count = 1 # Read in the script file passed in via an option. # This file gets read and executed by the simulated system after boot. # Note: The disk image needs to be configured to do this. system.readfile = opts.script # set up the root SimObject and start the simulation root = Root(full_system = True, system = system)
sys.path.append('configs/common/') # For the next line... import SimpleOpts from system import MySystem SimpleOpts.add_option("--script", default='', help="Script to execute in the simulated system") SimpleOpts.add_option("--n", default='1', help="No of processors") if __name__ == "__m5_main__": (opts, args) = SimpleOpts.parse_args() # create the system we are going to simulate system = MySystem(opts) # Read in the script file passed in via an option. # This file gets read and executed by the simulated system after boot. # Note: The disk image needs to be configured to do this. system.readfile = opts.script # set up the root SimObject and start the simulation root = Root(full_system = True, system = system) # instantiate all of the objects we've created above m5.instantiate() # Keep running until we are done. print "Running the simulation" exit_event = m5.simulate()
help = 'Fault register.') parser.add_argument('-rfbp', '--reg-fault-bit-posi', type = int, dest = 'bitPosition', help = 'Register fault bit position.') parser.add_argument('-tb', '--tick-begin', type = int, dest = 'tickBegin', help = 'Start tick for register fault.') parser.add_argument('-te', '--tick-end', type = int, dest = 'tickEnd', help = 'End tick for register fault.') args = parser.parse_args() if __name__ == "__m5_main__": system = MySystem(args) system.readfile = args.script root = Root(full_system = True, system = system) if args.faultEnabled: if args.tickBegin == 0 and args.tickEnd == -1: # If the fault is permanent root.registerPermanentFault = RegisterPermanentFault() root.registerPermanentFault.system = system root.registerPermanentFault.registerCategory = args.regCategory root.registerPermanentFault.faultRegister = args.faultReg root.registerPermanentFault.bitPosition = args.bitPosition root.registerPermanentFault.faultLabel = args.label root.registerPermanentFault.faultStuckBit = args.stuckBit
# Just exit in the child. No need to do anything else. sys.exit(0) else: # in parent # Append the child's PID and fast forward to the next point pids.append(pid) print "Waiting for children...", pids while pids: time.sleep(1) if __name__ == "__m5_main__": (opts, args) = SimpleOpts.parse_args() # create the system we are going to simulate system = MySystem(opts) if not (len(args) == 1 or len(args) == 2): SimpleOpts.print_help() fatal("Simulate script requires one or two arguments") roiInstructions = int(args[0]) if len(args) == 2: samples = int(args[1]) else: samples = 1 # For workitems to work correctly # This will cause the simulator to exit simulation when the first work # item is reached and when the first work item is finished.
sys.path.append('configs/common/') # For the next line... import SimpleOpts from system import MySystem SimpleOpts.add_option("--script", default='', help="Script to execute in the simulated system") #SimpleOpts.add_option("--num-cpus", default='', # help="Script to execute in the simulated system") if __name__ == "__m5_main__": (opts, args) = SimpleOpts.parse_args() # create the system we are going to simulate system = MySystem(opts) # For workitems to work correctly # This will cause the simulator to exit simulation when the first work # item is reached and when the first work item is finished. system.work_begin_exit_count = 1 system.work_end_exit_count = 1 # Read in the script file passed in via an option. # This file gets read and executed by the simulated system after boot. # Note: The disk image needs to be configured to do this. system.readfile = opts.script # set up the root SimObject and start the simulation root = Root(full_system=True, system=system,
from m5.objects import * sys.path.append('configs/common/') # For the next line... import SimpleOpts from system import MySystem SimpleOpts.add_option("--script", default='', help="Script to execute in the simulated system") if __name__ == "__m5_main__": (opts, args) = SimpleOpts.parse_args() # create the system we are going to simulate system = MySystem(opts, no_kvm=False) # For workitems to work correctly # This will cause the simulator to exit simulation when the first work # item is reached and when the first work item is finished. system.work_begin_exit_count = 1 system.work_end_exit_count = 1 # Read in the script file passed in via an option. # This file gets read and executed by the simulated system after boot. # Note: The disk image needs to be configured to do this. system.readfile = opts.script # set up the root SimObject and start the simulation root = Root(full_system=True, system=system)
from m5.objects import * sys.path.append('../../../configs/common/') # For the next line... import SimpleOpts from system import MySystem SimpleOpts.add_option("--script", default='', help="Script to execute in the simulated system") if __name__ == "__m5_main__": (opts, args) = SimpleOpts.parse_args() # create the system we are going to simulate system1 = MySystem(opts) # Read in the script file passed in via an option. # This file gets read and executed by the simulated system after boot. # Note: The disk image needs to be configured to do this. system1.readfile = opts.script # '.readfile is an object of LinuxX86System # set up the root SimObject and start the simulation root = Root(full_system=True, system=system1) # instantiate all of the objects we've created above m5.instantiate() # Keep running until we are done. print("Running the simulation") exit_event = m5.simulate()