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