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