changeset 0281650db548 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=0281650db548
description:
        se.py: support specifying multiple programs via command line
        This patch allows for specifying multiple programs via command line. It 
also
        adds an option for specifying whether to use of SMT. But SMT does not 
work for
        the o3 cpu as of now.

diffstat:

 configs/common/Options.py |    5 ++
 configs/example/se.py     |  107 ++++++++++++++++++++++++---------------------
 2 files changed, 61 insertions(+), 51 deletions(-)

diffs (162 lines):

diff -r 87967784f101 -r 0281650db548 configs/common/Options.py
--- a/configs/common/Options.py Fri Sep 07 14:20:53 2012 -0500
+++ b/configs/common/Options.py Sun Sep 09 09:33:45 2012 -0500
@@ -56,6 +56,11 @@
     parser.add_option("--l3_assoc", type="int", default=16)
     parser.add_option("--cacheline_size", type="int", default=64)
     parser.add_option("--ruby", action="store_true")
+    parser.add_option("--smt", action="store_true", default=False,
+                      help = """
+                      Only used if multiple programs are specified. If true,
+                      then the number of threads per cpu is same as the
+                      number of programs.""")
 
     # Run duration options
     parser.add_option("-m", "--maxtick", type="int", default=m5.MaxTick,
diff -r 87967784f101 -r 0281650db548 configs/example/se.py
--- a/configs/example/se.py     Fri Sep 07 14:20:53 2012 -0500
+++ b/configs/example/se.py     Sun Sep 09 09:33:45 2012 -0500
@@ -61,6 +61,52 @@
 from Caches import *
 from cpu2000 import *
 
+def get_processes(options):
+    """Interprets provided options and returns a list of processes"""
+
+    multiprocesses = []
+    inputs = []
+    outputs = []
+    errouts = []
+    pargs = []
+
+    workloads = options.cmd.split(';')
+    if options.input != "":
+        inputs = options.input.split(';')
+    if options.output != "":
+        outputs = options.output.split(';')
+    if options.errout != "":
+        errouts = options.errout.split(';')
+    if options.options != "":
+        pargs = options.options.split(';')
+
+    idx = 0
+    for wrkld in workloads:
+        process = LiveProcess()
+        process.executable = wrkld
+
+        if len(pargs) > idx:
+            process.cmd = [wrkld] + [" "] + [pargs[idx]]
+        else:
+            process.cmd = [wrkld]
+
+        if len(inputs) > idx:
+            process.input = inputs[idx]
+        if len(outputs) > idx:
+            process.output = outputs[idx]
+        if len(errouts) > idx:
+            process.errout = errouts[idx]
+
+        multiprocesses.append(process)
+        idx += 1
+
+    if options.smt:
+        assert(options.cpu_type == "detailed" or options.cpu_type == "inorder")
+        return multiprocesses, idx
+    else:
+        return multiprocesses, 1
+
+
 parser = optparse.OptionParser()
 Options.addCommonOptions(parser)
 Options.addSEOptions(parser)
@@ -75,7 +121,7 @@
     sys.exit(1)
 
 multiprocesses = []
-apps = []
+numThreads = 1
 
 if options.bench:
     apps = options.bench.split("-")
@@ -94,64 +140,21 @@
             print >>sys.stderr, "Unable to find workload for %s: %s" % 
(buildEnv['TARGET_ISA'], app)
             sys.exit(1)
 elif options.cmd:
-    process = LiveProcess()
-    process.executable = options.cmd
-    process.cmd = [options.cmd] + options.options.split()
-    multiprocesses.append(process)
+    multiprocesses, numThreads = get_processes(options)
 else:
     print >> sys.stderr, "No workload specified. Exiting!\n"
     sys.exit(1)
 
 
-if options.input != "":
-    process.input = options.input
-if options.output != "":
-    process.output = options.output
-if options.errout != "":
-    process.errout = options.errout
-
-
-# By default, set workload to path of user-specified binary
-workloads = options.cmd
-numThreads = 1
-
-if options.cpu_type == "detailed" or options.cpu_type == "inorder":
-    #check for SMT workload
-    workloads = options.cmd.split(';')
-    if len(workloads) > 1:
-        process = []
-        smt_idx = 0
-        inputs = []
-        outputs = []
-        errouts = []
-
-        if options.input != "":
-            inputs = options.input.split(';')
-        if options.output != "":
-            outputs = options.output.split(';')
-        if options.errout != "":
-            errouts = options.errout.split(';')
-
-        for wrkld in workloads:
-            smt_process = LiveProcess()
-            smt_process.executable = wrkld
-            smt_process.cmd = wrkld + " " + options.options
-            if inputs and inputs[smt_idx]:
-                smt_process.input = inputs[smt_idx]
-            if outputs and outputs[smt_idx]:
-                smt_process.output = outputs[smt_idx]
-            if errouts and errouts[smt_idx]:
-                smt_process.errout = errouts[smt_idx]
-            process += [smt_process, ]
-            smt_idx += 1
-    numThreads = len(workloads)
-
 (CPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options)
 CPUClass.clock = options.clock
-CPUClass.numThreads = numThreads;
+CPUClass.numThreads = numThreads
+
+# Check -- do not allow SMT with multiple CPUs
+if options.smt and options.num_cpus > 1:
+    fatal("You cannot use SMT with multiple CPUs!")
 
 np = options.num_cpus
-
 system = System(cpu = [CPUClass(cpu_id=i) for i in xrange(np)],
                 physmem = SimpleMemory(range=AddrRange("512MB")),
                 membus = CoherentBus(), mem_mode = test_mem_mode)
@@ -161,7 +164,9 @@
     fatal("You cannot use fastmem in combination with caches!")
 
 for i in xrange(np):
-    if len(multiprocesses) == 1:
+    if options.smt:
+        system.cpu[i].workload = multiprocesses
+    elif len(multiprocesses) == 1:
         system.cpu[i].workload = multiprocesses[0]
     else:
         system.cpu[i].workload = multiprocesses[i]
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to