run.py revision 11851:824055fe6b30
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
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:
70    print "Error: script doesn't take any positional arguments"
71    sys.exit(1)
72
73if not options.numcpus:
74    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:
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"""
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
284print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
285
286