run.py (4876:a18cedc19da5) run.py (5255:79825caee5fd)
1# Copyright (c) 2005-2007 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution;
11# neither the name of the copyright holders nor the names of its
12# contributors may be used to endorse or promote products derived from
13# this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Authors: Ron Dreslinski
28
29# Splash2 Run Script
30#
31
32import m5
33from m5.objects import *
34import os, optparse, sys
35m5.AddToPath('../common')
36
37# --------------------
38# Define Command Line Options
39# ====================
40
41parser = optparse.OptionParser()
42
43parser.add_option("-d", "--detailed", action="store_true")
44parser.add_option("-t", "--timing", action="store_true")
45parser.add_option("-m", "--maxtick", type="int")
46parser.add_option("-n", "--numcpus",
47 help="Number of cpus in total", type="int")
48parser.add_option("-f", "--frequency",
49 default = "1GHz",
50 help="Frequency of each CPU")
51parser.add_option("--l1size",
52 default = "32kB")
53parser.add_option("--l1latency",
1# Copyright (c) 2005-2007 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution;
11# neither the name of the copyright holders nor the names of its
12# contributors may be used to endorse or promote products derived from
13# this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27# Authors: Ron Dreslinski
28
29# Splash2 Run Script
30#
31
32import m5
33from m5.objects import *
34import os, optparse, sys
35m5.AddToPath('../common')
36
37# --------------------
38# Define Command Line Options
39# ====================
40
41parser = optparse.OptionParser()
42
43parser.add_option("-d", "--detailed", action="store_true")
44parser.add_option("-t", "--timing", action="store_true")
45parser.add_option("-m", "--maxtick", type="int")
46parser.add_option("-n", "--numcpus",
47 help="Number of cpus in total", type="int")
48parser.add_option("-f", "--frequency",
49 default = "1GHz",
50 help="Frequency of each CPU")
51parser.add_option("--l1size",
52 default = "32kB")
53parser.add_option("--l1latency",
54 default = 1)
54 default = "1ns")
55parser.add_option("--l2size",
56 default = "256kB")
57parser.add_option("--l2latency",
55parser.add_option("--l2size",
56 default = "256kB")
57parser.add_option("--l2latency",
58 default = 10)
58 default = "10ns")
59parser.add_option("--rootdir",
60 help="Root directory of Splash2",
61 default="/dist/splash2/codes")
62parser.add_option("-b", "--benchmark",
63 help="Splash 2 benchmark to run")
64
65(options, args) = parser.parse_args()
66
67if args:
68 print "Error: script doesn't take any positional arguments"
69 sys.exit(1)
70
71if not options.numcpus:
72 print "Specify the number of cpus with -n"
73 sys.exit(1)
74
75# --------------------
76# Define Splash2 Benchmarks
77# ====================
78class Cholesky(LiveProcess):
79 cwd = options.rootdir + '/kernels/cholesky'
80 executable = options.rootdir + '/kernels/cholesky/CHOLESKY'
59parser.add_option("--rootdir",
60 help="Root directory of Splash2",
61 default="/dist/splash2/codes")
62parser.add_option("-b", "--benchmark",
63 help="Splash 2 benchmark to run")
64
65(options, args) = parser.parse_args()
66
67if args:
68 print "Error: script doesn't take any positional arguments"
69 sys.exit(1)
70
71if not options.numcpus:
72 print "Specify the number of cpus with -n"
73 sys.exit(1)
74
75# --------------------
76# Define Splash2 Benchmarks
77# ====================
78class Cholesky(LiveProcess):
79 cwd = options.rootdir + '/kernels/cholesky'
80 executable = options.rootdir + '/kernels/cholesky/CHOLESKY'
81 cmd = 'CHOLESKY -p' + str(options.numcpus) + ' '\
82 + options.rootdir + '/kernels/cholesky/inputs/tk23.O'
81 cmd = ['CHOLESKY', '-p', str(options.numcpus),
82 options.rootdir + '/kernels/cholesky/inputs/tk23.O']
83
84class FFT(LiveProcess):
85 cwd = options.rootdir + '/kernels/fft'
86 executable = options.rootdir + '/kernels/fft/FFT'
83
84class FFT(LiveProcess):
85 cwd = options.rootdir + '/kernels/fft'
86 executable = options.rootdir + '/kernels/fft/FFT'
87 cmd = 'FFT -p' + str(options.numcpus) + ' -m18'
87 cmd = ['FFT', '-p', str(options.numcpus), '-m18']
88
89class LU_contig(LiveProcess):
90 executable = options.rootdir + '/kernels/lu/contiguous_blocks/LU'
88
89class LU_contig(LiveProcess):
90 executable = options.rootdir + '/kernels/lu/contiguous_blocks/LU'
91 cmd = 'LU -p' + str(options.numcpus)
91 cmd = ['LU', '-p', str(options.numcpus)]
92 cwd = options.rootdir + '/kernels/lu/contiguous_blocks'
93
94class LU_noncontig(LiveProcess):
95 executable = options.rootdir + '/kernels/lu/non_contiguous_blocks/LU'
92 cwd = options.rootdir + '/kernels/lu/contiguous_blocks'
93
94class LU_noncontig(LiveProcess):
95 executable = options.rootdir + '/kernels/lu/non_contiguous_blocks/LU'
96 cmd = 'LU -p' + str(options.numcpus)
96 cmd = ['LU', '-p', str(options.numcpus)]
97 cwd = options.rootdir + '/kernels/lu/non_contiguous_blocks'
98
99class Radix(LiveProcess):
100 executable = options.rootdir + '/kernels/radix/RADIX'
97 cwd = options.rootdir + '/kernels/lu/non_contiguous_blocks'
98
99class Radix(LiveProcess):
100 executable = options.rootdir + '/kernels/radix/RADIX'
101 cmd = 'RADIX -n524288 -p' + str(options.numcpus)
101 cmd = ['RADIX', '-n524288', '-p', str(options.numcpus)]
102 cwd = options.rootdir + '/kernels/radix'
103
104class Barnes(LiveProcess):
105 executable = options.rootdir + '/apps/barnes/BARNES'
102 cwd = options.rootdir + '/kernels/radix'
103
104class Barnes(LiveProcess):
105 executable = options.rootdir + '/apps/barnes/BARNES'
106 cmd = 'BARNES'
106 cmd = ['BARNES']
107 input = options.rootdir + '/apps/barnes/input.p' + str(options.numcpus)
108 cwd = options.rootdir + '/apps/barnes'
109
110class FMM(LiveProcess):
111 executable = options.rootdir + '/apps/fmm/FMM'
107 input = options.rootdir + '/apps/barnes/input.p' + str(options.numcpus)
108 cwd = options.rootdir + '/apps/barnes'
109
110class FMM(LiveProcess):
111 executable = options.rootdir + '/apps/fmm/FMM'
112 cmd = 'FMM'
112 cmd = ['FMM']
113 if str(options.numcpus) == '1':
114 input = options.rootdir + '/apps/fmm/inputs/input.2048'
115 else:
116 input = options.rootdir + '/apps/fmm/inputs/input.2048.p' + str(options.numcpus)
117 cwd = options.rootdir + '/apps/fmm'
118
119class Ocean_contig(LiveProcess):
120 executable = options.rootdir + '/apps/ocean/contiguous_partitions/OCEAN'
113 if str(options.numcpus) == '1':
114 input = options.rootdir + '/apps/fmm/inputs/input.2048'
115 else:
116 input = options.rootdir + '/apps/fmm/inputs/input.2048.p' + str(options.numcpus)
117 cwd = options.rootdir + '/apps/fmm'
118
119class Ocean_contig(LiveProcess):
120 executable = options.rootdir + '/apps/ocean/contiguous_partitions/OCEAN'
121 cmd = 'OCEAN -p' + str(options.numcpus)
121 cmd = ['OCEAN', '-p', str(options.numcpus)]
122 cwd = options.rootdir + '/apps/ocean/contiguous_partitions'
123
124class Ocean_noncontig(LiveProcess):
125 executable = options.rootdir + '/apps/ocean/non_contiguous_partitions/OCEAN'
122 cwd = options.rootdir + '/apps/ocean/contiguous_partitions'
123
124class Ocean_noncontig(LiveProcess):
125 executable = options.rootdir + '/apps/ocean/non_contiguous_partitions/OCEAN'
126 cmd = 'OCEAN -p' + str(options.numcpus)
126 cmd = ['OCEAN', '-p', str(options.numcpus)]
127 cwd = options.rootdir + '/apps/ocean/non_contiguous_partitions'
128
129class Raytrace(LiveProcess):
130 executable = options.rootdir + '/apps/raytrace/RAYTRACE'
127 cwd = options.rootdir + '/apps/ocean/non_contiguous_partitions'
128
129class Raytrace(LiveProcess):
130 executable = options.rootdir + '/apps/raytrace/RAYTRACE'
131 cmd = 'RAYTRACE -p' + str(options.numcpus) + ' ' \
132 + options.rootdir + '/apps/raytrace/inputs/teapot.env'
131 cmd = ['RAYTRACE', '-p', str(options.numcpus),
132 options.rootdir + '/apps/raytrace/inputs/teapot.env']
133 cwd = options.rootdir + '/apps/raytrace'
134
135class Water_nsquared(LiveProcess):
136 executable = options.rootdir + '/apps/water-nsquared/WATER-NSQUARED'
133 cwd = options.rootdir + '/apps/raytrace'
134
135class Water_nsquared(LiveProcess):
136 executable = options.rootdir + '/apps/water-nsquared/WATER-NSQUARED'
137 cmd = 'WATER-NSQUARED'
137 cmd = ['WATER-NSQUARED']
138 if options.numcpus==1:
139 input = options.rootdir + '/apps/water-nsquared/input'
140 else:
141 input = options.rootdir + '/apps/water-nsquared/input.p' + str(options.numcpus)
142 cwd = options.rootdir + '/apps/water-nsquared'
143
144class Water_spatial(LiveProcess):
145 executable = options.rootdir + '/apps/water-spatial/WATER-SPATIAL'
138 if options.numcpus==1:
139 input = options.rootdir + '/apps/water-nsquared/input'
140 else:
141 input = options.rootdir + '/apps/water-nsquared/input.p' + str(options.numcpus)
142 cwd = options.rootdir + '/apps/water-nsquared'
143
144class Water_spatial(LiveProcess):
145 executable = options.rootdir + '/apps/water-spatial/WATER-SPATIAL'
146 cmd = 'WATER-SPATIAL'
146 cmd = ['WATER-SPATIAL']
147 if options.numcpus==1:
148 input = options.rootdir + '/apps/water-spatial/input'
149 else:
150 input = options.rootdir + '/apps/water-spatial/input.p' + str(options.numcpus)
151 cwd = options.rootdir + '/apps/water-spatial'
152
153# --------------------
154# Base L1 Cache Definition
155# ====================
156
157class L1(BaseCache):
158 latency = options.l1latency
159 block_size = 64
160 mshrs = 12
161 tgts_per_mshr = 8
162
163# ----------------------
164# Base L2 Cache Definition
165# ----------------------
166
167class L2(BaseCache):
168 block_size = 64
169 latency = options.l2latency
170 mshrs = 92
171 tgts_per_mshr = 16
172 write_buffers = 8
173
174# ----------------------
175# Define the cpus
176# ----------------------
177
178busFrequency = Frequency(options.frequency)
179
180if options.timing:
181 cpus = [TimingSimpleCPU(cpu_id = i,
182 clock=options.frequency)
183 for i in xrange(options.numcpus)]
184elif options.detailed:
185 cpus = [DerivO3CPU(cpu_id = i,
186 clock=options.frequency)
187 for i in xrange(options.numcpus)]
188else:
189 cpus = [AtomicSimpleCPU(cpu_id = i,
190 clock=options.frequency)
191 for i in xrange(options.numcpus)]
192
193# ----------------------
194# Create a system, and add system wide objects
195# ----------------------
196system = System(cpu = cpus, physmem = PhysicalMemory(),
197 membus = Bus(clock = busFrequency))
198
199system.toL2bus = Bus(clock = busFrequency)
200system.l2 = L2(size = options.l2size, assoc = 8)
201
202# ----------------------
203# Connect the L2 cache and memory together
204# ----------------------
205
206system.physmem.port = system.membus.port
207system.l2.cpu_side = system.toL2bus.port
208system.l2.mem_side = system.membus.port
209
210# ----------------------
211# Connect the L2 cache and clusters together
212# ----------------------
213for cpu in cpus:
214 cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1),
215 L1(size = options.l1size, assoc = 4))
216 cpu.mem = cpu.dcache
217 # connect cpu level-1 caches to shared level-2 cache
218 cpu.connectMemPorts(system.toL2bus)
219
220
221# ----------------------
222# Define the root
223# ----------------------
224
225root = Root(system = system)
226
227# --------------------
228# Pick the correct Splash2 Benchmarks
229# ====================
230if options.benchmark == 'Cholesky':
231 root.workload = Cholesky()
232elif options.benchmark == 'FFT':
233 root.workload = FFT()
234elif options.benchmark == 'LUContig':
235 root.workload = LU_contig()
236elif options.benchmark == 'LUNoncontig':
237 root.workload = LU_noncontig()
238elif options.benchmark == 'Radix':
239 root.workload = Radix()
240elif options.benchmark == 'Barnes':
241 root.workload = Barnes()
242elif options.benchmark == 'FMM':
243 root.workload = FMM()
244elif options.benchmark == 'OceanContig':
245 root.workload = Ocean_contig()
246elif options.benchmark == 'OceanNoncontig':
247 root.workload = Ocean_noncontig()
248elif options.benchmark == 'Raytrace':
249 root.workload = Raytrace()
250elif options.benchmark == 'WaterNSquared':
251 root.workload = Water_nsquared()
252elif options.benchmark == 'WaterSpatial':
253 root.workload = Water_spatial()
254else:
255 panic("The --benchmark environment variable was set to something" \
256 +" improper.\nUse Cholesky, FFT, LUContig, LUNoncontig, Radix" \
257 +", Barnes, FMM, OceanContig,\nOceanNoncontig, Raytrace," \
258 +" WaterNSquared, or WaterSpatial\n")
259
260# --------------------
261# Assign the workload to the cpus
262# ====================
263
264for cpu in cpus:
265 cpu.workload = root.workload
266
267# ----------------------
268# Run the simulation
269# ----------------------
270
271if options.timing or options.detailed:
272 root.system.mem_mode = 'timing'
273
274# instantiate configuration
275m5.instantiate(root)
276
277# simulate until program terminates
278if options.maxtick:
279 exit_event = m5.simulate(options.maxtick)
280else:
281 exit_event = m5.simulate(m5.MaxTick)
282
283print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
284
147 if options.numcpus==1:
148 input = options.rootdir + '/apps/water-spatial/input'
149 else:
150 input = options.rootdir + '/apps/water-spatial/input.p' + str(options.numcpus)
151 cwd = options.rootdir + '/apps/water-spatial'
152
153# --------------------
154# Base L1 Cache Definition
155# ====================
156
157class L1(BaseCache):
158 latency = options.l1latency
159 block_size = 64
160 mshrs = 12
161 tgts_per_mshr = 8
162
163# ----------------------
164# Base L2 Cache Definition
165# ----------------------
166
167class L2(BaseCache):
168 block_size = 64
169 latency = options.l2latency
170 mshrs = 92
171 tgts_per_mshr = 16
172 write_buffers = 8
173
174# ----------------------
175# Define the cpus
176# ----------------------
177
178busFrequency = Frequency(options.frequency)
179
180if options.timing:
181 cpus = [TimingSimpleCPU(cpu_id = i,
182 clock=options.frequency)
183 for i in xrange(options.numcpus)]
184elif options.detailed:
185 cpus = [DerivO3CPU(cpu_id = i,
186 clock=options.frequency)
187 for i in xrange(options.numcpus)]
188else:
189 cpus = [AtomicSimpleCPU(cpu_id = i,
190 clock=options.frequency)
191 for i in xrange(options.numcpus)]
192
193# ----------------------
194# Create a system, and add system wide objects
195# ----------------------
196system = System(cpu = cpus, physmem = PhysicalMemory(),
197 membus = Bus(clock = busFrequency))
198
199system.toL2bus = Bus(clock = busFrequency)
200system.l2 = L2(size = options.l2size, assoc = 8)
201
202# ----------------------
203# Connect the L2 cache and memory together
204# ----------------------
205
206system.physmem.port = system.membus.port
207system.l2.cpu_side = system.toL2bus.port
208system.l2.mem_side = system.membus.port
209
210# ----------------------
211# Connect the L2 cache and clusters together
212# ----------------------
213for cpu in cpus:
214 cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1),
215 L1(size = options.l1size, assoc = 4))
216 cpu.mem = cpu.dcache
217 # connect cpu level-1 caches to shared level-2 cache
218 cpu.connectMemPorts(system.toL2bus)
219
220
221# ----------------------
222# Define the root
223# ----------------------
224
225root = Root(system = system)
226
227# --------------------
228# Pick the correct Splash2 Benchmarks
229# ====================
230if options.benchmark == 'Cholesky':
231 root.workload = Cholesky()
232elif options.benchmark == 'FFT':
233 root.workload = FFT()
234elif options.benchmark == 'LUContig':
235 root.workload = LU_contig()
236elif options.benchmark == 'LUNoncontig':
237 root.workload = LU_noncontig()
238elif options.benchmark == 'Radix':
239 root.workload = Radix()
240elif options.benchmark == 'Barnes':
241 root.workload = Barnes()
242elif options.benchmark == 'FMM':
243 root.workload = FMM()
244elif options.benchmark == 'OceanContig':
245 root.workload = Ocean_contig()
246elif options.benchmark == 'OceanNoncontig':
247 root.workload = Ocean_noncontig()
248elif options.benchmark == 'Raytrace':
249 root.workload = Raytrace()
250elif options.benchmark == 'WaterNSquared':
251 root.workload = Water_nsquared()
252elif options.benchmark == 'WaterSpatial':
253 root.workload = Water_spatial()
254else:
255 panic("The --benchmark environment variable was set to something" \
256 +" improper.\nUse Cholesky, FFT, LUContig, LUNoncontig, Radix" \
257 +", Barnes, FMM, OceanContig,\nOceanNoncontig, Raytrace," \
258 +" WaterNSquared, or WaterSpatial\n")
259
260# --------------------
261# Assign the workload to the cpus
262# ====================
263
264for cpu in cpus:
265 cpu.workload = root.workload
266
267# ----------------------
268# Run the simulation
269# ----------------------
270
271if options.timing or options.detailed:
272 root.system.mem_mode = 'timing'
273
274# instantiate configuration
275m5.instantiate(root)
276
277# simulate until program terminates
278if options.maxtick:
279 exit_event = m5.simulate(options.maxtick)
280else:
281 exit_event = m5.simulate(m5.MaxTick)
282
283print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
284