Set cpu_id params (required by ll/sc code now).
[gem5.git] / configs / example / fs.py
index 958fc435314edf3a07cdce10041c72f5f07a588e..6db26a02a47d6aaa06199664484002a1c0f13089 100644 (file)
@@ -35,6 +35,9 @@ from FSConfig import *
 from SysPaths import *
 from Benchmarks import *
 
+if not m5.build_env['FULL_SYSTEM']:
+    m5.panic("This script requires full-system mode (ALPHA_FS).")
+
 parser = optparse.OptionParser()
 
 parser.add_option("-d", "--detailed", action="store_true")
@@ -46,10 +49,12 @@ parser.add_option("--dual", action="store_true",
 parser.add_option("-b", "--benchmark", action="store", type="string",
                   dest="benchmark",
                   help="Specify the benchmark to run. Available benchmarks: %s"\
-                          % DefinedBenchmarks)
+                  % DefinedBenchmarks)
 parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
-                  help="Specify the filename to dump a pcap capture of the ethernet"
-                  "traffic")
+                  help="Specify the filename to dump a pcap capture of the" \
+                  "ethernet traffic")
+parser.add_option("--checkpoint_dir", action="store", type="string",
+                  help="Place all checkpoints in this absolute directory")
 
 (options, args) = parser.parse_args()
 
@@ -72,6 +77,8 @@ else:
 
 cpu.clock = '2GHz'
 cpu2.clock = '2GHz'
+cpu.cpu_id = 0
+cpu2.cpu_id = 0
 
 if options.benchmark:
     if options.benchmark not in Benchmarks:
@@ -90,15 +97,18 @@ if len(bm) == 2:
     s1 = makeLinuxAlphaSystem(mem_mode, bm[0])
     s1.cpu = cpu
     cpu.connectMemPorts(s1.membus)
+    cpu.mem = s1.physmem
     s2 = makeLinuxAlphaSystem(mem_mode, bm[1])
     s2.cpu = cpu2
     cpu2.connectMemPorts(s2.membus)
+    cpu2.mem = s2.physmem
     root = makeDualRoot(s1, s2, options.etherdump)
 elif len(bm) == 1:
     root = Root(clock = '1THz',
                 system = makeLinuxAlphaSystem(mem_mode, bm[0]))
     root.system.cpu = cpu
     cpu.connectMemPorts(root.system.membus)
+    cpu.mem = root.system.physmem
 else:
     print "Error I don't know how to create more than 2 systems."
     sys.exit(1)
@@ -106,18 +116,25 @@ else:
 m5.instantiate(root)
 
 if options.maxtick:
-    arg = options.maxtick
+    maxtick = options.maxtick
 elif options.maxtime:
     simtime = int(options.maxtime * root.clock.value)
     print "simulating for: ", simtime
-    arg = simtime
+    maxtick = simtime
 else:
-    arg = -1
+    maxtick = -1
 
-exit_event = m5.simulate(arg)
+exit_event = m5.simulate(maxtick)
 
 while exit_event.getCause() == "checkpoint":
+    if options.checkpoint_dir:
+        m5.checkpoint(root, "/".join([options.checkpoint_dir, "cpt.%d"]))
+    else:
         m5.checkpoint(root, "cpt.%d")
-        exit_event = m5.simulate(arg)
+
+    if maxtick == -1:
+        exit_event = m5.simulate(maxtick)
+    else:
+        exit_event = m5.simulate(maxtick - m5.curTick())
 
 print 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause()