summaryrefslogtreecommitdiff
path: root/configs
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-09-22 15:24:16 -0700
committerNathan Binkert <nate@binkert.org>2009-09-22 15:24:16 -0700
commit9a8cb7db7e86c25a755f2e2817a0385b13e3ac32 (patch)
tree56c7b56824b967ad385b6e8890f345d18c102980 /configs
parent0d58d32ad51eed32e6c7f9135b901006777fbe87 (diff)
downloadgem5-9a8cb7db7e86c25a755f2e2817a0385b13e3ac32.tar.xz
python: Move more code into m5.util allow SCons to use that code.
Get rid of misc.py and just stick misc things in __init__.py Move utility functions out of SCons files and into m5.util Move utility type stuff from m5/__init__.py to m5/util/__init__.py Remove buildEnv from m5 and allow access only from m5.defines Rename AddToPath to addToPath while we're moving it to m5.util Rename read_command to readCommand while we're moving it Rename compare_versions to compareVersions while we're moving it. --HG-- rename : src/python/m5/convert.py => src/python/m5/util/convert.py rename : src/python/m5/smartdict.py => src/python/m5/util/smartdict.py
Diffstat (limited to 'configs')
-rw-r--r--configs/common/Caches.py1
-rw-r--r--configs/common/FSConfig.py2
-rw-r--r--configs/common/Simulation.py31
-rw-r--r--configs/example/fs.py35
-rw-r--r--configs/example/memtest.py5
-rw-r--r--configs/example/ruby_se.py21
-rw-r--r--configs/example/se.py20
-rw-r--r--configs/splash2/cluster.py17
-rw-r--r--configs/splash2/run.py8
9 files changed, 83 insertions, 57 deletions
diff --git a/configs/common/Caches.py b/configs/common/Caches.py
index 1c3b089c7..412cfd3b1 100644
--- a/configs/common/Caches.py
+++ b/configs/common/Caches.py
@@ -26,7 +26,6 @@
#
# Authors: Lisa Hsu
-import m5
from m5.objects import *
class L1Cache(BaseCache):
diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py
index 180e0ac52..bd20a2bac 100644
--- a/configs/common/FSConfig.py
+++ b/configs/common/FSConfig.py
@@ -26,8 +26,6 @@
#
# Authors: Kevin Lim
-import m5
-from m5 import makeList
from m5.objects import *
from Benchmarks import *
diff --git a/configs/common/Simulation.py b/configs/common/Simulation.py
index 23dfad6c6..112a951b6 100644
--- a/configs/common/Simulation.py
+++ b/configs/common/Simulation.py
@@ -28,9 +28,13 @@
from os import getcwd
from os.path import join as joinpath
+
import m5
+from m5.defines import buildEnv
from m5.objects import *
-m5.AddToPath('../common')
+from m5.util import *
+
+addToPath('../common')
def setCPUClass(options):
@@ -82,10 +86,10 @@ def run(options, root, testsys, cpu_class):
cptdir = getcwd()
if options.fast_forward and options.checkpoint_restore != None:
- m5.fatal("Error: Can't specify both --fast-forward and --checkpoint-restore")
+ fatal("Can't specify both --fast-forward and --checkpoint-restore")
if options.standard_switch and not options.caches:
- m5.fatal("Error: Must specify --caches when using --standard-switch")
+ fatal("Must specify --caches when using --standard-switch")
np = options.num_cpus
max_checkpoints = options.max_checkpoints
@@ -107,7 +111,7 @@ def run(options, root, testsys, cpu_class):
if options.fast_forward:
testsys.cpu[i].max_insts_any_thread = int(options.fast_forward)
switch_cpus[i].system = testsys
- if not m5.build_env['FULL_SYSTEM']:
+ if not buildEnv['FULL_SYSTEM']:
switch_cpus[i].workload = testsys.cpu[i].workload
switch_cpus[i].clock = testsys.cpu[0].clock
# simulation period
@@ -126,7 +130,7 @@ def run(options, root, testsys, cpu_class):
for i in xrange(np):
switch_cpus[i].system = testsys
switch_cpus_1[i].system = testsys
- if not m5.build_env['FULL_SYSTEM']:
+ if not buildEnv['FULL_SYSTEM']:
switch_cpus[i].workload = testsys.cpu[i].workload
switch_cpus_1[i].workload = testsys.cpu[i].workload
switch_cpus[i].clock = testsys.cpu[0].clock
@@ -141,7 +145,7 @@ def run(options, root, testsys, cpu_class):
# Fast forward to a simpoint (warning: time consuming)
elif options.simpoint:
if testsys.cpu[i].workload[0].simpoint == 0:
- m5.fatal('simpoint not found')
+ fatal('simpoint not found')
testsys.cpu[i].max_insts_any_thread = \
testsys.cpu[i].workload[0].simpoint
# No distance specified, just switch
@@ -174,7 +178,7 @@ def run(options, root, testsys, cpu_class):
if options.simpoint:
for i in xrange(np):
if testsys.cpu[i].workload[0].simpoint == 0:
- m5.fatal('no simpoint for testsys.cpu[%d].workload[0]', i)
+ fatal('no simpoint for testsys.cpu[%d].workload[0]', i)
checkpoint_inst = int(testsys.cpu[i].workload[0].simpoint) + offset
testsys.cpu[i].max_insts_any_thread = checkpoint_inst
# used for output below
@@ -194,14 +198,13 @@ def run(options, root, testsys, cpu_class):
import re
if not isdir(cptdir):
- m5.fatal("checkpoint dir %s does not exist!", cptdir)
+ fatal("checkpoint dir %s does not exist!", cptdir)
if options.at_instruction:
checkpoint_dir = joinpath(cptdir, "cpt.%s.%s" % \
(options.bench, options.checkpoint_restore))
if not exists(checkpoint_dir):
- m5.fatal("Unable to find checkpoint directory %s",
- checkpoint_dir)
+ fatal("Unable to find checkpoint directory %s", checkpoint_dir)
print "Restoring checkpoint ..."
m5.restoreCheckpoint(root, checkpoint_dir)
@@ -209,7 +212,7 @@ def run(options, root, testsys, cpu_class):
elif options.simpoint:
# assume workload 0 has the simpoint
if testsys.cpu[0].workload[0].simpoint == 0:
- m5.fatal('Unable to find simpoint')
+ fatal('Unable to find simpoint')
options.checkpoint_restore += \
int(testsys.cpu[0].workload[0].simpoint)
@@ -217,8 +220,8 @@ def run(options, root, testsys, cpu_class):
checkpoint_dir = joinpath(cptdir, "cpt.%s.%d" % \
(options.bench, options.checkpoint_restore))
if not exists(checkpoint_dir):
- m5.fatal("Unable to find checkpoint directory %s.%s",
- options.bench, options.checkpoint_restore)
+ fatal("Unable to find checkpoint directory %s.%s",
+ options.bench, options.checkpoint_restore)
print "Restoring checkpoint ..."
m5.restoreCheckpoint(root,checkpoint_dir)
@@ -237,7 +240,7 @@ def run(options, root, testsys, cpu_class):
cpt_num = options.checkpoint_restore
if cpt_num > len(cpts):
- m5.fatal('Checkpoint %d not found', cpt_num)
+ fatal('Checkpoint %d not found', cpt_num)
## Adjust max tick based on our starting tick
maxtick = maxtick - int(cpts[cpt_num - 1])
diff --git a/configs/example/fs.py b/configs/example/fs.py
index 3164b6fb4..23285e101 100644
--- a/configs/example/fs.py
+++ b/configs/example/fs.py
@@ -26,15 +26,20 @@
#
# Authors: Ali Saidi
-import optparse, os, sys
+import optparse
+import os
+import sys
import m5
+from m5.defines import buildEnv
+from m5.objects import *
+from m5.util import addToPath, fatal
-if not m5.build_env['FULL_SYSTEM']:
- m5.fatal("This script requires full-system mode (*_FS).")
+if not buildEnv['FULL_SYSTEM']:
+ fatal("This script requires full-system mode (*_FS).")
+
+addToPath('../common')
-from m5.objects import *
-m5.AddToPath('../common')
from FSConfig import *
from SysPaths import *
from Benchmarks import *
@@ -98,16 +103,16 @@ else:
np = options.num_cpus
-if m5.build_env['TARGET_ISA'] == "alpha":
+if buildEnv['TARGET_ISA'] == "alpha":
test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0])
-elif m5.build_env['TARGET_ISA'] == "mips":
+elif buildEnv['TARGET_ISA'] == "mips":
test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0])
-elif m5.build_env['TARGET_ISA'] == "sparc":
+elif buildEnv['TARGET_ISA'] == "sparc":
test_sys = makeSparcSystem(test_mem_mode, bm[0])
-elif m5.build_env['TARGET_ISA'] == "x86":
+elif buildEnv['TARGET_ISA'] == "x86":
test_sys = makeLinuxX86System(test_mem_mode, np, bm[0])
else:
- m5.fatal("incapable of building non-alpha or non-sparc full system!")
+ fatal("incapable of building non-alpha or non-sparc full system!")
if options.kernel is not None:
test_sys.kernel = binary(options.kernel)
@@ -142,17 +147,17 @@ for i in xrange(np):
if options.fastmem:
test_sys.cpu[i].physmem_port = test_sys.physmem.port
-if m5.build_env['TARGET_ISA'] == 'mips':
+if buildEnv['TARGET_ISA'] == 'mips':
setMipsOptions(TestCPUClass)
if len(bm) == 2:
- if m5.build_env['TARGET_ISA'] == 'alpha':
+ if buildEnv['TARGET_ISA'] == 'alpha':
drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1])
- elif m5.build_env['TARGET_ISA'] == 'mips':
+ elif buildEnv['TARGET_ISA'] == 'mips':
drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1])
- elif m5.build_env['TARGET_ISA'] == 'sparc':
+ elif buildEnv['TARGET_ISA'] == 'sparc':
drive_sys = makeSparcSystem(drive_mem_mode, bm[1])
- elif m5.build.env['TARGET_ISA'] == 'x86':
+ elif buildEnv['TARGET_ISA'] == 'x86':
drive_sys = makeX86System(drive_mem_mode, np, bm[1])
drive_sys.cpu = DriveCPUClass(cpu_id=0)
drive_sys.cpu.connectMemPorts(drive_sys.membus)
diff --git a/configs/example/memtest.py b/configs/example/memtest.py
index 5bb874e85..d4497092b 100644
--- a/configs/example/memtest.py
+++ b/configs/example/memtest.py
@@ -26,10 +26,11 @@
#
# Authors: Ron Dreslinski
+import optparse
+import sys
+
import m5
from m5.objects import *
-import os, optparse, sys
-m5.AddToPath('../common')
parser = optparse.OptionParser()
diff --git a/configs/example/ruby_se.py b/configs/example/ruby_se.py
index 488ccb64a..76668f763 100644
--- a/configs/example/ruby_se.py
+++ b/configs/example/ruby_se.py
@@ -30,17 +30,22 @@
#
# "m5 test.py"
+import os
+import optparse
+import sys
+from os.path import join as joinpath
+
import m5
+from m5.defines import buildEnv
+from m5.objects import *
+from m5.util import addToPath, panic
-if m5.build_env['FULL_SYSTEM']:
- m5.panic("This script requires syscall emulation mode (*_SE).")
+if buildEnv['FULL_SYSTEM']:
+ panic("This script requires syscall emulation mode (*_SE).")
+
+addToPath('../common')
-from m5.objects import *
-import os, optparse, sys
-from os.path import join as joinpath
-m5.AddToPath('../common')
import Simulation
-#from Caches import *
from cpu2000 import *
# Get paths we might need. It's expected this file is in m5/configs/example.
@@ -72,7 +77,7 @@ if args:
if options.bench:
try:
- if m5.build_env['TARGET_ISA'] != 'alpha':
+ if buildEnv['TARGET_ISA'] != 'alpha':
print >>sys.stderr, "Simpoints code only works for Alpha ISA at this time"
sys.exit(1)
exec("workload = %s('alpha', 'tru64', 'ref')" % options.bench)
diff --git a/configs/example/se.py b/configs/example/se.py
index e7fcc8261..c490ed6b6 100644
--- a/configs/example/se.py
+++ b/configs/example/se.py
@@ -30,15 +30,21 @@
#
# "m5 test.py"
+import os
+import optparse
+import sys
+from os.path import join as joinpath
+
import m5
+from m5.defines import buildEnv
+from m5.objects import *
+from m5.util import addToPath, fatal
-if m5.build_env['FULL_SYSTEM']:
- m5.fatal("This script requires syscall emulation mode (*_SE).")
+if buildEnv['FULL_SYSTEM']:
+ fatal("This script requires syscall emulation mode (*_SE).")
+
+addToPath('../common')
-from m5.objects import *
-import os, optparse, sys
-from os.path import join as joinpath
-m5.AddToPath('../common')
import Simulation
from Caches import *
from cpu2000 import *
@@ -70,7 +76,7 @@ if args:
if options.bench:
try:
- if m5.build_env['TARGET_ISA'] != 'alpha':
+ if buildEnv['TARGET_ISA'] != 'alpha':
print >>sys.stderr, "Simpoints code only works for Alpha ISA at this time"
sys.exit(1)
exec("workload = %s('alpha', 'tru64', 'ref')" % options.bench)
diff --git a/configs/splash2/cluster.py b/configs/splash2/cluster.py
index 769bdcf5a..45c9ede82 100644
--- a/configs/splash2/cluster.py
+++ b/configs/splash2/cluster.py
@@ -30,10 +30,14 @@
#
# "m5 test.py"
+import os
+import optparse
+import sys
+
import m5
from m5.objects import *
-import os, optparse, sys
-m5.AddToPath('../common')
+
+m5.util.addToPath('../common')
# --------------------
# Define Command Line Options
@@ -266,10 +270,11 @@ elif options.benchmark == 'WaterNSquared':
elif options.benchmark == 'WaterSpatial':
root.workload = Water_spatial()
else:
- panic("The --benchmark environment variable was set to something" \
- +" improper.\nUse Cholesky, FFT, LUContig, LUNoncontig, Radix" \
- +", Barnes, FMM, OceanContig,\nOceanNoncontig, Raytrace," \
- +" WaterNSquared, or WaterSpatial\n")
+ m5.util.panic("""
+The --benchmark environment variable was set to something improper.
+Use Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig,
+OceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial
+""")
# --------------------
# Assign the workload to the cpus
diff --git a/configs/splash2/run.py b/configs/splash2/run.py
index afa85a8f1..95ec790ba 100644
--- a/configs/splash2/run.py
+++ b/configs/splash2/run.py
@@ -29,10 +29,14 @@
# Splash2 Run Script
#
+import os
+import optparse
+import sys
+
import m5
from m5.objects import *
-import os, optparse, sys
-m5.AddToPath('../common')
+
+m5.util.addToPath('../common')
# --------------------
# Define Command Line Options