run.py (11851:824055fe6b30) run.py (12564:2778478ca882)
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
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
32from __future__ import print_function
33
32import os
33import optparse
34import sys
35
36import m5
37from m5.objects import *
38
39# --------------------
40# Define Command Line Options
41# ====================
42
43parser = optparse.OptionParser()
44
45parser.add_option("-d", "--detailed", action="store_true")
46parser.add_option("-t", "--timing", action="store_true")
47parser.add_option("-m", "--maxtick", type="int")
48parser.add_option("-n", "--numcpus",
49 help="Number of cpus in total", type="int")
50parser.add_option("-f", "--frequency",
51 default = "1GHz",
52 help="Frequency of each CPU")
53parser.add_option("--l1size",
54 default = "32kB")
55parser.add_option("--l1latency",
56 default = "1ns")
57parser.add_option("--l2size",
58 default = "256kB")
59parser.add_option("--l2latency",
60 default = "10ns")
61parser.add_option("--rootdir",
62 help="Root directory of Splash2",
63 default="/dist/splash2/codes")
64parser.add_option("-b", "--benchmark",
65 help="Splash 2 benchmark to run")
66
67(options, args) = parser.parse_args()
68
69if args:
34import os
35import optparse
36import sys
37
38import m5
39from m5.objects import *
40
41# --------------------
42# Define Command Line Options
43# ====================
44
45parser = optparse.OptionParser()
46
47parser.add_option("-d", "--detailed", action="store_true")
48parser.add_option("-t", "--timing", action="store_true")
49parser.add_option("-m", "--maxtick", type="int")
50parser.add_option("-n", "--numcpus",
51 help="Number of cpus in total", type="int")
52parser.add_option("-f", "--frequency",
53 default = "1GHz",
54 help="Frequency of each CPU")
55parser.add_option("--l1size",
56 default = "32kB")
57parser.add_option("--l1latency",
58 default = "1ns")
59parser.add_option("--l2size",
60 default = "256kB")
61parser.add_option("--l2latency",
62 default = "10ns")
63parser.add_option("--rootdir",
64 help="Root directory of Splash2",
65 default="/dist/splash2/codes")
66parser.add_option("-b", "--benchmark",
67 help="Splash 2 benchmark to run")
68
69(options, args) = parser.parse_args()
70
71if args:
70 print "Error: script doesn't take any positional arguments"
72 print("Error: script doesn't take any positional arguments")
71 sys.exit(1)
72
73if not options.numcpus:
73 sys.exit(1)
74
75if not options.numcpus:
74 print "Specify the number of cpus with -n"
76 print("Specify the number of cpus with -n")
75 sys.exit(1)
76
77# --------------------
78# Define Splash2 Benchmarks
79# ====================
80class Cholesky(Process):
81 cwd = options.rootdir + '/kernels/cholesky'
82 executable = options.rootdir + '/kernels/cholesky/CHOLESKY'
83 cmd = ['CHOLESKY', '-p' + str(options.numcpus),
84 options.rootdir + '/kernels/cholesky/inputs/tk23.O']
85
86class FFT(Process):
87 cwd = options.rootdir + '/kernels/fft'
88 executable = options.rootdir + '/kernels/fft/FFT'
89 cmd = ['FFT', '-p', str(options.numcpus), '-m18']
90
91class LU_contig(Process):
92 executable = options.rootdir + '/kernels/lu/contiguous_blocks/LU'
93 cmd = ['LU', '-p', str(options.numcpus)]
94 cwd = options.rootdir + '/kernels/lu/contiguous_blocks'
95
96class LU_noncontig(Process):
97 executable = options.rootdir + '/kernels/lu/non_contiguous_blocks/LU'
98 cmd = ['LU', '-p', str(options.numcpus)]
99 cwd = options.rootdir + '/kernels/lu/non_contiguous_blocks'
100
101class Radix(Process):
102 executable = options.rootdir + '/kernels/radix/RADIX'
103 cmd = ['RADIX', '-n524288', '-p', str(options.numcpus)]
104 cwd = options.rootdir + '/kernels/radix'
105
106class Barnes(Process):
107 executable = options.rootdir + '/apps/barnes/BARNES'
108 cmd = ['BARNES']
109 input = options.rootdir + '/apps/barnes/input.p' + str(options.numcpus)
110 cwd = options.rootdir + '/apps/barnes'
111
112class FMM(Process):
113 executable = options.rootdir + '/apps/fmm/FMM'
114 cmd = ['FMM']
115 if str(options.numcpus) == '1':
116 input = options.rootdir + '/apps/fmm/inputs/input.2048'
117 else:
118 input = options.rootdir + '/apps/fmm/inputs/input.2048.p' + str(options.numcpus)
119 cwd = options.rootdir + '/apps/fmm'
120
121class Ocean_contig(Process):
122 executable = options.rootdir + '/apps/ocean/contiguous_partitions/OCEAN'
123 cmd = ['OCEAN', '-p', str(options.numcpus)]
124 cwd = options.rootdir + '/apps/ocean/contiguous_partitions'
125
126class Ocean_noncontig(Process):
127 executable = options.rootdir + '/apps/ocean/non_contiguous_partitions/OCEAN'
128 cmd = ['OCEAN', '-p', str(options.numcpus)]
129 cwd = options.rootdir + '/apps/ocean/non_contiguous_partitions'
130
131class Raytrace(Process):
132 executable = options.rootdir + '/apps/raytrace/RAYTRACE'
133 cmd = ['RAYTRACE', '-p' + str(options.numcpus),
134 options.rootdir + '/apps/raytrace/inputs/teapot.env']
135 cwd = options.rootdir + '/apps/raytrace'
136
137class Water_nsquared(Process):
138 executable = options.rootdir + '/apps/water-nsquared/WATER-NSQUARED'
139 cmd = ['WATER-NSQUARED']
140 if options.numcpus==1:
141 input = options.rootdir + '/apps/water-nsquared/input'
142 else:
143 input = options.rootdir + '/apps/water-nsquared/input.p' + str(options.numcpus)
144 cwd = options.rootdir + '/apps/water-nsquared'
145
146class Water_spatial(Process):
147 executable = options.rootdir + '/apps/water-spatial/WATER-SPATIAL'
148 cmd = ['WATER-SPATIAL']
149 if options.numcpus==1:
150 input = options.rootdir + '/apps/water-spatial/input'
151 else:
152 input = options.rootdir + '/apps/water-spatial/input.p' + str(options.numcpus)
153 cwd = options.rootdir + '/apps/water-spatial'
154
155# --------------------
156# Base L1 Cache Definition
157# ====================
158
159class L1(Cache):
160 latency = options.l1latency
161 mshrs = 12
162 tgts_per_mshr = 8
163
164# ----------------------
165# Base L2 Cache Definition
166# ----------------------
167
168class L2(Cache):
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 = SimpleMemory(),
197 membus = SystemXBar(clock = busFrequency))
198system.clock = '1GHz'
199
200system.toL2bus = L2XBar(clock = busFrequency)
201system.l2 = L2(size = options.l2size, assoc = 8)
202
203# ----------------------
204# Connect the L2 cache and memory together
205# ----------------------
206
207system.physmem.port = system.membus.master
208system.l2.cpu_side = system.toL2bus.master
209system.l2.mem_side = system.membus.slave
210system.system_port = system.membus.slave
211
212# ----------------------
213# Connect the L2 cache and clusters together
214# ----------------------
215for cpu in cpus:
216 cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1),
217 L1(size = options.l1size, assoc = 4))
218 # connect cpu level-1 caches to shared level-2 cache
219 cpu.connectAllPorts(system.toL2bus, system.membus)
220
221
222# ----------------------
223# Define the root
224# ----------------------
225
226root = Root(full_system = False, system = system)
227
228# --------------------
229# Pick the correct Splash2 Benchmarks
230# ====================
231if options.benchmark == 'Cholesky':
232 root.workload = Cholesky()
233elif options.benchmark == 'FFT':
234 root.workload = FFT()
235elif options.benchmark == 'LUContig':
236 root.workload = LU_contig()
237elif options.benchmark == 'LUNoncontig':
238 root.workload = LU_noncontig()
239elif options.benchmark == 'Radix':
240 root.workload = Radix()
241elif options.benchmark == 'Barnes':
242 root.workload = Barnes()
243elif options.benchmark == 'FMM':
244 root.workload = FMM()
245elif options.benchmark == 'OceanContig':
246 root.workload = Ocean_contig()
247elif options.benchmark == 'OceanNoncontig':
248 root.workload = Ocean_noncontig()
249elif options.benchmark == 'Raytrace':
250 root.workload = Raytrace()
251elif options.benchmark == 'WaterNSquared':
252 root.workload = Water_nsquared()
253elif options.benchmark == 'WaterSpatial':
254 root.workload = Water_spatial()
255else:
77 sys.exit(1)
78
79# --------------------
80# Define Splash2 Benchmarks
81# ====================
82class Cholesky(Process):
83 cwd = options.rootdir + '/kernels/cholesky'
84 executable = options.rootdir + '/kernels/cholesky/CHOLESKY'
85 cmd = ['CHOLESKY', '-p' + str(options.numcpus),
86 options.rootdir + '/kernels/cholesky/inputs/tk23.O']
87
88class FFT(Process):
89 cwd = options.rootdir + '/kernels/fft'
90 executable = options.rootdir + '/kernels/fft/FFT'
91 cmd = ['FFT', '-p', str(options.numcpus), '-m18']
92
93class LU_contig(Process):
94 executable = options.rootdir + '/kernels/lu/contiguous_blocks/LU'
95 cmd = ['LU', '-p', str(options.numcpus)]
96 cwd = options.rootdir + '/kernels/lu/contiguous_blocks'
97
98class LU_noncontig(Process):
99 executable = options.rootdir + '/kernels/lu/non_contiguous_blocks/LU'
100 cmd = ['LU', '-p', str(options.numcpus)]
101 cwd = options.rootdir + '/kernels/lu/non_contiguous_blocks'
102
103class Radix(Process):
104 executable = options.rootdir + '/kernels/radix/RADIX'
105 cmd = ['RADIX', '-n524288', '-p', str(options.numcpus)]
106 cwd = options.rootdir + '/kernels/radix'
107
108class Barnes(Process):
109 executable = options.rootdir + '/apps/barnes/BARNES'
110 cmd = ['BARNES']
111 input = options.rootdir + '/apps/barnes/input.p' + str(options.numcpus)
112 cwd = options.rootdir + '/apps/barnes'
113
114class FMM(Process):
115 executable = options.rootdir + '/apps/fmm/FMM'
116 cmd = ['FMM']
117 if str(options.numcpus) == '1':
118 input = options.rootdir + '/apps/fmm/inputs/input.2048'
119 else:
120 input = options.rootdir + '/apps/fmm/inputs/input.2048.p' + str(options.numcpus)
121 cwd = options.rootdir + '/apps/fmm'
122
123class Ocean_contig(Process):
124 executable = options.rootdir + '/apps/ocean/contiguous_partitions/OCEAN'
125 cmd = ['OCEAN', '-p', str(options.numcpus)]
126 cwd = options.rootdir + '/apps/ocean/contiguous_partitions'
127
128class Ocean_noncontig(Process):
129 executable = options.rootdir + '/apps/ocean/non_contiguous_partitions/OCEAN'
130 cmd = ['OCEAN', '-p', str(options.numcpus)]
131 cwd = options.rootdir + '/apps/ocean/non_contiguous_partitions'
132
133class Raytrace(Process):
134 executable = options.rootdir + '/apps/raytrace/RAYTRACE'
135 cmd = ['RAYTRACE', '-p' + str(options.numcpus),
136 options.rootdir + '/apps/raytrace/inputs/teapot.env']
137 cwd = options.rootdir + '/apps/raytrace'
138
139class Water_nsquared(Process):
140 executable = options.rootdir + '/apps/water-nsquared/WATER-NSQUARED'
141 cmd = ['WATER-NSQUARED']
142 if options.numcpus==1:
143 input = options.rootdir + '/apps/water-nsquared/input'
144 else:
145 input = options.rootdir + '/apps/water-nsquared/input.p' + str(options.numcpus)
146 cwd = options.rootdir + '/apps/water-nsquared'
147
148class Water_spatial(Process):
149 executable = options.rootdir + '/apps/water-spatial/WATER-SPATIAL'
150 cmd = ['WATER-SPATIAL']
151 if options.numcpus==1:
152 input = options.rootdir + '/apps/water-spatial/input'
153 else:
154 input = options.rootdir + '/apps/water-spatial/input.p' + str(options.numcpus)
155 cwd = options.rootdir + '/apps/water-spatial'
156
157# --------------------
158# Base L1 Cache Definition
159# ====================
160
161class L1(Cache):
162 latency = options.l1latency
163 mshrs = 12
164 tgts_per_mshr = 8
165
166# ----------------------
167# Base L2 Cache Definition
168# ----------------------
169
170class L2(Cache):
171 latency = options.l2latency
172 mshrs = 92
173 tgts_per_mshr = 16
174 write_buffers = 8
175
176# ----------------------
177# Define the cpus
178# ----------------------
179
180busFrequency = Frequency(options.frequency)
181
182if options.timing:
183 cpus = [TimingSimpleCPU(cpu_id = i,
184 clock=options.frequency)
185 for i in xrange(options.numcpus)]
186elif options.detailed:
187 cpus = [DerivO3CPU(cpu_id = i,
188 clock=options.frequency)
189 for i in xrange(options.numcpus)]
190else:
191 cpus = [AtomicSimpleCPU(cpu_id = i,
192 clock=options.frequency)
193 for i in xrange(options.numcpus)]
194
195# ----------------------
196# Create a system, and add system wide objects
197# ----------------------
198system = System(cpu = cpus, physmem = SimpleMemory(),
199 membus = SystemXBar(clock = busFrequency))
200system.clock = '1GHz'
201
202system.toL2bus = L2XBar(clock = busFrequency)
203system.l2 = L2(size = options.l2size, assoc = 8)
204
205# ----------------------
206# Connect the L2 cache and memory together
207# ----------------------
208
209system.physmem.port = system.membus.master
210system.l2.cpu_side = system.toL2bus.master
211system.l2.mem_side = system.membus.slave
212system.system_port = system.membus.slave
213
214# ----------------------
215# Connect the L2 cache and clusters together
216# ----------------------
217for cpu in cpus:
218 cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1),
219 L1(size = options.l1size, assoc = 4))
220 # connect cpu level-1 caches to shared level-2 cache
221 cpu.connectAllPorts(system.toL2bus, system.membus)
222
223
224# ----------------------
225# Define the root
226# ----------------------
227
228root = Root(full_system = False, system = system)
229
230# --------------------
231# Pick the correct Splash2 Benchmarks
232# ====================
233if options.benchmark == 'Cholesky':
234 root.workload = Cholesky()
235elif options.benchmark == 'FFT':
236 root.workload = FFT()
237elif options.benchmark == 'LUContig':
238 root.workload = LU_contig()
239elif options.benchmark == 'LUNoncontig':
240 root.workload = LU_noncontig()
241elif options.benchmark == 'Radix':
242 root.workload = Radix()
243elif options.benchmark == 'Barnes':
244 root.workload = Barnes()
245elif options.benchmark == 'FMM':
246 root.workload = FMM()
247elif options.benchmark == 'OceanContig':
248 root.workload = Ocean_contig()
249elif options.benchmark == 'OceanNoncontig':
250 root.workload = Ocean_noncontig()
251elif options.benchmark == 'Raytrace':
252 root.workload = Raytrace()
253elif options.benchmark == 'WaterNSquared':
254 root.workload = Water_nsquared()
255elif options.benchmark == 'WaterSpatial':
256 root.workload = Water_spatial()
257else:
256 print >> sys.stderr, """The --benchmark environment variable was set to something improper.
257Use Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig,
258OceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial"""
258 print("The --benchmark environment variable was set to something "
259 "improper. Use Cholesky, FFT, LUContig, LUNoncontig, Radix, "
260 "Barnes, FMM, OceanContig, OceanNoncontig, Raytrace, WaterNSquared, "
261 "or WaterSpatial", file=sys.stderr)
259 sys.exit(1)
260
261# --------------------
262# Assign the workload to the cpus
263# ====================
264
265for cpu in cpus:
266 cpu.workload = root.workload
267
268# ----------------------
269# Run the simulation
270# ----------------------
271
272if options.timing or options.detailed:
273 root.system.mem_mode = 'timing'
274
275# instantiate configuration
276m5.instantiate()
277
278# simulate until program terminates
279if options.maxtick:
280 exit_event = m5.simulate(options.maxtick)
281else:
282 exit_event = m5.simulate(m5.MaxTick)
283
262 sys.exit(1)
263
264# --------------------
265# Assign the workload to the cpus
266# ====================
267
268for cpu in cpus:
269 cpu.workload = root.workload
270
271# ----------------------
272# Run the simulation
273# ----------------------
274
275if options.timing or options.detailed:
276 root.system.mem_mode = 'timing'
277
278# instantiate configuration
279m5.instantiate()
280
281# simulate until program terminates
282if options.maxtick:
283 exit_event = m5.simulate(options.maxtick)
284else:
285 exit_event = m5.simulate(m5.MaxTick)
286
284print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
287print('Exiting @ tick', m5.curTick(), 'because', exit_event.getCause())
285
288