add instruction count fast forwaing and max instruction options
authorVilas Sridharan <vilas.sridharan@gmail.com>
Fri, 22 Feb 2008 22:48:10 +0000 (17:48 -0500)
committerVilas Sridharan <vilas.sridharan@gmail.com>
Fri, 22 Feb 2008 22:48:10 +0000 (17:48 -0500)
--HG--
extra : convert_revision : 8fe45e512229cdc3e0dcd23e3e5c54516c445d0f

configs/common/Options.py
configs/common/Simulation.py

index 22591684068580ea5b9824d06f0a9cfeeae02320..3cd3342b86bf5e928b6163624fe1e12b7f7b0a3c 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2006-2007 The Regents of The University of Michigan
+# Copyright (c) 2006-2008 The Regents of The University of Michigan
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -60,3 +60,7 @@ parser.add_option("-s", "--standard_switch", action="store_true",
 parser.add_option("-w", "--warmup", action="store", type="int",
                   help="if -s, then this is the warmup period.  else, this is ignored",
                   default=5000000000)
+parser.add_option("-f", "--fast_forward", type="int", action="store",
+                  help="fast_forward count in instructions: use alone to checkpoint or with -s and -max_inst")
+parser.add_option("--max_inst", type="int", action="store",
+                  help="max_insts_any_thread value")
index cea391c5d0c8a5ac69cf4f03d74d7fa8fa8d4b25..f6b289fb5a26cc7e4198b78fc732972fa19f2d8f 100644 (file)
@@ -95,6 +95,9 @@ def run(options, root, testsys, cpu_class):
         switch_cpu_list = [(testsys.cpu[i], switch_cpus[i]) for i in xrange(np)]
 
     if options.standard_switch:
+        if (options.fast_forward and options.warmup):
+            m5.panic("Must specify either warmup OR fast-forward with -s!")
+
         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))
@@ -109,6 +112,11 @@ def run(options, root, testsys, cpu_class):
             switch_cpus[i].clock = testsys.cpu[0].clock
             switch_cpus_1[i].clock = testsys.cpu[0].clock
 
+            if options.fast_forward:
+                switch_cpus[i].max_insts_any_thread = options.fast_forward
+            if options.max_inst:
+                switch_cpus_1[i].max_insts_any_thread = options.max_inst
+
             if not options.caches:
                 # O3 CPU must have a cache to work.
                 switch_cpus_1[i].addPrivateSplitL1Caches(L1Cache(size = '32kB'),
@@ -121,6 +129,10 @@ def run(options, root, testsys, cpu_class):
             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)]
 
+    elif options.fast_forward:
+        for i in xrange(np):
+            testsys.cpu[i].max_insts_any_thread = options.fast_forward
+
     m5.instantiate(root)
 
     if options.checkpoint_restore:
@@ -167,11 +179,32 @@ def run(options, root, testsys, cpu_class):
         m5.resume(testsys)
 
         if options.standard_switch:
-            exit_event = m5.simulate(options.warmup)
+            if (options.warmup):
+                exit_event = m5.simulate(options.warmup)
+            if options.fast_forward:
+                exit_event = m5.simulate()
             m5.drain(testsys)
             m5.switchCpus(switch_cpu_list1)
             m5.resume(testsys)
 
+    # This should *only* be used by itself to take a checkpoint!
+    # Otherwise, use standard_switch
+    elif options.fast_forward:
+        exit_event = m5.simulate()
+
+        while exit_event.getCause() != "a thread reached the max instruction count":
+            if exit_event.getCause() == "user interrupt received":
+                print "User interrupt! Switching to simulation mode"
+                break
+            else:
+                m5.simulate(True)
+
+        if exit_event.getCause() == "a thread reached the max instruction count":
+            print "Reached fast_forward count %d; starting simulation at cycle %d" % (options.fast_forward, m5.curTick())
+
+        m5.checkpoint(root, joinpath(cptdir, "cpt.%d"))
+        return
+
     num_checkpoints = 0
     exit_cause = ''