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