cluster.py revision 7525
111251Sradhika.jagtap@ARM.com# Copyright (c) 2006-2007 The Regents of The University of Michigan
211251Sradhika.jagtap@ARM.com# All rights reserved.
311251Sradhika.jagtap@ARM.com#
411251Sradhika.jagtap@ARM.com# Redistribution and use in source and binary forms, with or without
511251Sradhika.jagtap@ARM.com# modification, are permitted provided that the following conditions are
611251Sradhika.jagtap@ARM.com# met: redistributions of source code must retain the above copyright
711251Sradhika.jagtap@ARM.com# notice, this list of conditions and the following disclaimer;
811251Sradhika.jagtap@ARM.com# redistributions in binary form must reproduce the above copyright
911251Sradhika.jagtap@ARM.com# notice, this list of conditions and the following disclaimer in the
1011251Sradhika.jagtap@ARM.com# documentation and/or other materials provided with the distribution;
1111251Sradhika.jagtap@ARM.com# neither the name of the copyright holders nor the names of its
1211251Sradhika.jagtap@ARM.com# contributors may be used to endorse or promote products derived from
1311251Sradhika.jagtap@ARM.com# this software without specific prior written permission.
1411251Sradhika.jagtap@ARM.com#
1511251Sradhika.jagtap@ARM.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1611251Sradhika.jagtap@ARM.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1711251Sradhika.jagtap@ARM.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1811251Sradhika.jagtap@ARM.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1911251Sradhika.jagtap@ARM.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2011251Sradhika.jagtap@ARM.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2111251Sradhika.jagtap@ARM.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2211251Sradhika.jagtap@ARM.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2311251Sradhika.jagtap@ARM.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2411251Sradhika.jagtap@ARM.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2511251Sradhika.jagtap@ARM.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2611251Sradhika.jagtap@ARM.com#
2711251Sradhika.jagtap@ARM.com# Authors: Ron Dreslinski
2811251Sradhika.jagtap@ARM.com
2911251Sradhika.jagtap@ARM.com# Simple test script
3011251Sradhika.jagtap@ARM.com#
3111251Sradhika.jagtap@ARM.com# "m5 test.py"
3211251Sradhika.jagtap@ARM.com
3311251Sradhika.jagtap@ARM.comimport os
3411251Sradhika.jagtap@ARM.comimport optparse
3511251Sradhika.jagtap@ARM.comimport sys
3611251Sradhika.jagtap@ARM.com
3711251Sradhika.jagtap@ARM.comimport m5
3811251Sradhika.jagtap@ARM.comfrom m5.objects import *
3911251Sradhika.jagtap@ARM.com
4012564Sgabeblack@google.comm5.util.addToPath('../common')
4112564Sgabeblack@google.com
4211251Sradhika.jagtap@ARM.com# --------------------
4311251Sradhika.jagtap@ARM.com# Define Command Line Options
4411251Sradhika.jagtap@ARM.com# ====================
4511251Sradhika.jagtap@ARM.com
4611682Sandreas.hansson@arm.comparser = optparse.OptionParser()
4711251Sradhika.jagtap@ARM.com
4811682Sandreas.hansson@arm.comparser.add_option("-d", "--detailed", action="store_true")
4911682Sandreas.hansson@arm.comparser.add_option("-t", "--timing", action="store_true")
5011682Sandreas.hansson@arm.comparser.add_option("-m", "--maxtick", type="int")
5111682Sandreas.hansson@arm.comparser.add_option("-c", "--numclusters",
5211682Sandreas.hansson@arm.com                  help="Number of clusters", type="int")
5311251Sradhika.jagtap@ARM.comparser.add_option("-n", "--numcpus",
5411251Sradhika.jagtap@ARM.com                  help="Number of cpus in total", type="int")
5511251Sradhika.jagtap@ARM.comparser.add_option("-f", "--frequency",
5611251Sradhika.jagtap@ARM.com                  default = "1GHz",
5711251Sradhika.jagtap@ARM.com                  help="Frequency of each CPU")
5812564Sgabeblack@google.comparser.add_option("--l1size",
5912564Sgabeblack@google.com                  default = "32kB")
6011251Sradhika.jagtap@ARM.comparser.add_option("--l1latency",
6111251Sradhika.jagtap@ARM.com                  default = 1)
6211251Sradhika.jagtap@ARM.comparser.add_option("--l2size",
6311251Sradhika.jagtap@ARM.com                  default = "256kB")
6411251Sradhika.jagtap@ARM.comparser.add_option("--l2latency",
6512564Sgabeblack@google.com                  default = 10)
6611251Sradhika.jagtap@ARM.comparser.add_option("--rootdir",
6711251Sradhika.jagtap@ARM.com                  help="ROot directory of Splash2",
6811251Sradhika.jagtap@ARM.com                  default="/dist/splash2/codes/")
6911251Sradhika.jagtap@ARM.comparser.add_option("-b", "--benchmark",
7012014Sgabeblack@google.com                  help="Splash 2 benchmark to run")
7111251Sradhika.jagtap@ARM.com
7212014Sgabeblack@google.com(options, args) = parser.parse_args()
7311251Sradhika.jagtap@ARM.com
7411251Sradhika.jagtap@ARM.comif args:
7511251Sradhika.jagtap@ARM.com    print "Error: script doesn't take any positional arguments"
7611251Sradhika.jagtap@ARM.com    sys.exit(1)
7711251Sradhika.jagtap@ARM.com
7811251Sradhika.jagtap@ARM.com# --------------------
7911251Sradhika.jagtap@ARM.com# Define Splash2 Benchmarks
8011251Sradhika.jagtap@ARM.com# ====================
8111251Sradhika.jagtap@ARM.comclass Cholesky(LiveProcess):
8211251Sradhika.jagtap@ARM.com        executable = options.rootdir + '/kernels/cholesky/CHOLESKY'
8311251Sradhika.jagtap@ARM.com        cmd = 'CHOLESKY -p' + str(options.numcpus) + ' '\
8411251Sradhika.jagtap@ARM.com             + options.rootdir + '/kernels/cholesky/inputs/tk23.O'
8511251Sradhika.jagtap@ARM.com
8611251Sradhika.jagtap@ARM.comclass FFT(LiveProcess):
8711251Sradhika.jagtap@ARM.com        executable = options.rootdir + 'kernels/fft/FFT'
8811251Sradhika.jagtap@ARM.com        cmd = 'FFT -p' + str(options.numcpus) + ' -m18'
8911251Sradhika.jagtap@ARM.com
9011251Sradhika.jagtap@ARM.comclass LU_contig(LiveProcess):
9111251Sradhika.jagtap@ARM.com        executable = options.rootdir + 'kernels/lu/contiguous_blocks/LU'
9211251Sradhika.jagtap@ARM.com        cmd = 'LU -p' + str(options.numcpus)
9311251Sradhika.jagtap@ARM.com
9411251Sradhika.jagtap@ARM.comclass LU_noncontig(LiveProcess):
9511251Sradhika.jagtap@ARM.com        executable = options.rootdir + 'kernels/lu/non_contiguous_blocks/LU'
9611251Sradhika.jagtap@ARM.com        cmd = 'LU -p' + str(options.numcpus)
9711251Sradhika.jagtap@ARM.com
9811251Sradhika.jagtap@ARM.comclass Radix(LiveProcess):
9911251Sradhika.jagtap@ARM.com        executable = options.rootdir + 'kernels/radix/RADIX'
10011251Sradhika.jagtap@ARM.com        cmd = 'RADIX -n524288 -p' + str(options.numcpus)
10111251Sradhika.jagtap@ARM.com
10211251Sradhika.jagtap@ARM.comclass Barnes(LiveProcess):
10311251Sradhika.jagtap@ARM.com        executable = options.rootdir + 'apps/barnes/BARNES'
10411251Sradhika.jagtap@ARM.com        cmd = 'BARNES'
10511251Sradhika.jagtap@ARM.com        input = options.rootdir + 'apps/barnes/input.p' + str(options.numcpus)
10611251Sradhika.jagtap@ARM.com
10711251Sradhika.jagtap@ARM.comclass FMM(LiveProcess):
10811251Sradhika.jagtap@ARM.com        executable = options.rootdir + 'apps/fmm/FMM'
10912430Schenzou@uchicago.edu        cmd = 'FMM'
11012430Schenzou@uchicago.edu        input = options.rootdir + 'apps/fmm/inputs/input.2048.p' + str(options.numcpus)
11112430Schenzou@uchicago.edu
11212430Schenzou@uchicago.educlass Ocean_contig(LiveProcess):
11312430Schenzou@uchicago.edu        executable = options.rootdir + 'apps/ocean/contiguous_partitions/OCEAN'
11411251Sradhika.jagtap@ARM.com        cmd = 'OCEAN -p' + str(options.numcpus)
11511251Sradhika.jagtap@ARM.com
11611251Sradhika.jagtap@ARM.comclass Ocean_noncontig(LiveProcess):
11711251Sradhika.jagtap@ARM.com        executable = options.rootdir + 'apps/ocean/non_contiguous_partitions/OCEAN'
11811251Sradhika.jagtap@ARM.com        cmd = 'OCEAN -p' + str(options.numcpus)
11911251Sradhika.jagtap@ARM.com
12011251Sradhika.jagtap@ARM.comclass Raytrace(LiveProcess):
12111251Sradhika.jagtap@ARM.com        executable = options.rootdir + 'apps/raytrace/RAYTRACE'
12211251Sradhika.jagtap@ARM.com        cmd = 'RAYTRACE -p' + str(options.numcpus) + ' ' \
12311251Sradhika.jagtap@ARM.com             + options.rootdir + 'apps/raytrace/inputs/teapot.env'
12411251Sradhika.jagtap@ARM.com
12511251Sradhika.jagtap@ARM.comclass Water_nsquared(LiveProcess):
12611251Sradhika.jagtap@ARM.com        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
130class 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
140class L1(BaseCache):
141    latency = options.l1latency
142    block_size = 64
143    mshrs = 12
144    tgts_per_mshr = 8
145
146# ----------------------
147# Base L2 Cache Definition
148# ----------------------
149
150class 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# ----------------------
160class Cluster:
161    pass
162
163cpusPerCluster = options.numcpus/options.numclusters
164
165busFrequency = Frequency(options.frequency)
166busFrequency *= cpusPerCluster
167
168all_cpus = []
169all_l1s = []
170all_l1buses = []
171if 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]
184elif 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]
197else:
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# ----------------------
214system = System(cpu = all_cpus, l1_ = all_l1s, l1bus_ = all_l1buses, physmem = PhysicalMemory(),
215                membus = Bus(clock = busFrequency))
216
217system.toL2bus = Bus(clock = busFrequency)
218system.l2 = L2(size = options.l2size, assoc = 8)
219
220# ----------------------
221# Connect the L2 cache and memory together
222# ----------------------
223
224system.physmem.port = system.membus.port
225system.l2.cpu_side = system.toL2bus.port
226system.l2.mem_side = system.membus.port
227
228# ----------------------
229# Connect the L2 cache and clusters together
230# ----------------------
231for 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
243root = Root(system = system)
244
245# --------------------
246# Pick the correct Splash2 Benchmarks
247# ====================
248if options.benchmark == 'Cholesky':
249    root.workload = Cholesky()
250elif options.benchmark == 'FFT':
251    root.workload = FFT()
252elif options.benchmark == 'LUContig':
253    root.workload = LU_contig()
254elif options.benchmark == 'LUNoncontig':
255    root.workload = LU_noncontig()
256elif options.benchmark == 'Radix':
257    root.workload = Radix()
258elif options.benchmark == 'Barnes':
259    root.workload = Barnes()
260elif options.benchmark == 'FMM':
261    root.workload = FMM()
262elif options.benchmark == 'OceanContig':
263    root.workload = Ocean_contig()
264elif options.benchmark == 'OceanNoncontig':
265    root.workload = Ocean_noncontig()
266elif options.benchmark == 'Raytrace':
267    root.workload = Raytrace()
268elif options.benchmark == 'WaterNSquared':
269    root.workload = Water_nsquared()
270elif options.benchmark == 'WaterSpatial':
271    root.workload = Water_spatial()
272else:
273    m5.util.panic("""
274The --benchmark environment variable was set to something improper.
275Use Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig,
276OceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial
277""")
278
279# --------------------
280# Assign the workload to the cpus
281# ====================
282
283for cluster in clusters:
284    for cpu in cluster.cpus:
285        cpu.workload = root.workload
286
287# ----------------------
288# Run the simulation
289# ----------------------
290
291if options.timing or options.detailed:
292    root.system.mem_mode = 'timing'
293
294# instantiate configuration
295m5.instantiate()
296
297# simulate until program terminates
298if options.maxtick:
299    exit_event = m5.simulate(options.maxtick)
300else:
301    exit_event = m5.simulate(m5.MaxTick)
302
303print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
304
305