diff -r 0d38e56356c7 -r 4e2ed6befc63 configs/example/arm/fs_bigLITTLE.py --- a/configs/example/arm/fs_bigLITTLE.py Tue Dec 06 17:10:36 2016 +0000 +++ b/configs/example/arm/fs_bigLITTLE.py Thu Dec 08 11:14:21 2016 +0000 @@ -108,9 +108,10 @@ return sys -def main(): - parser = argparse.ArgumentParser( - description="Generic ARM big.LITTLE configuration") +def addOptions(parser): + """ + This function adds the commmon big.LITTLE options to the parser. + """ parser.add_argument("--restore-from", type=str, default=None, help="Restore from checkpoint") @@ -138,11 +139,16 @@ help="Big CPU clock frequency") parser.add_argument("--little-cpu-clock", type=str, default="1GHz", help="Little CPU clock frequency") + return parser + +def build(options): + """ + This function creates and configures all the simObjects of the + big.LITTLE system. It returns the root object. + """ m5.ticks.fixGlobalFrequency() - options = parser.parse_args() - kernel_cmd = [ "earlyprintk=pl011,0x1c090000", "console=ttyAMA0", @@ -208,20 +214,38 @@ # Linux device tree system.dtb_filename = SysPaths.binary(options.dtb) + return root + + +def instantiate(checkpoint_path=None): + """ + This function instantiates the system.The checkpoint_path parameter must + contain the full path to a checkpoint if we want to restore the + simulation from that checkpoint. + """ + # Get and load from the chkpt or simpoint checkpoint - if options.restore_from is not None: - m5.instantiate(options.restore_from) + if checkpoint_path is not None: + m5.util.inform("Restoring from checkpoint %s", checkpoint_path) + m5.instantiate(checkpoint_path) else: m5.instantiate() + +def run(checkpoint_dir=m5.options.outdir): + """ + This function runs the simulation. The checkpoint_dir parameter specifies + the directory we want to write checkpoints into. + """ + # 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)) + cpt_dir = os.path.join(checkpoint_dir, "cpt.%d" % m5.curTick()) + m5.checkpoint(cpt_dir) print "Checkpoint done." else: print exit_msg, " @ ", m5.curTick() @@ -230,5 +254,15 @@ sys.exit(event.getCode()) +def main(): + parser = argparse.ArgumentParser( + description="Generic ARM big.LITTLE configuration") + addOptions(parser) + options = parser.parse_args() + root = build(options) + instantiate(options.restore_from) + run() + + if __name__ == "__m5_main__": main()