run.py revision 11851
15450Sgblack@eecs.umich.edu# Copyright (c) 2005-2007 The Regents of The University of Michigan
25450Sgblack@eecs.umich.edu# All rights reserved.
35450Sgblack@eecs.umich.edu#
47087Snate@binkert.org# Redistribution and use in source and binary forms, with or without
57087Snate@binkert.org# modification, are permitted provided that the following conditions are
67087Snate@binkert.org# met: redistributions of source code must retain the above copyright
77087Snate@binkert.org# notice, this list of conditions and the following disclaimer;
87087Snate@binkert.org# redistributions in binary form must reproduce the above copyright
97087Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
107087Snate@binkert.org# documentation and/or other materials provided with the distribution;
117087Snate@binkert.org# neither the name of the copyright holders nor the names of its
125450Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
137087Snate@binkert.org# this software without specific prior written permission.
147087Snate@binkert.org#
157087Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
167087Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
177087Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
187087Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
197087Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
207087Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
215450Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
227087Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
235450Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
245450Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
255450Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
265450Sgblack@eecs.umich.edu#
275450Sgblack@eecs.umich.edu# Authors: Ron Dreslinski
285450Sgblack@eecs.umich.edu
295450Sgblack@eecs.umich.edu# Splash2 Run Script
305450Sgblack@eecs.umich.edu#
315450Sgblack@eecs.umich.edu
325450Sgblack@eecs.umich.eduimport os
335450Sgblack@eecs.umich.eduimport optparse
345450Sgblack@eecs.umich.eduimport sys
355450Sgblack@eecs.umich.edu
365450Sgblack@eecs.umich.eduimport m5
375450Sgblack@eecs.umich.edufrom m5.objects import *
385450Sgblack@eecs.umich.edu
395450Sgblack@eecs.umich.edu# --------------------
405450Sgblack@eecs.umich.edu# Define Command Line Options
415450Sgblack@eecs.umich.edu# ====================
425450Sgblack@eecs.umich.edu
435610Snate@binkert.orgparser = optparse.OptionParser()
449338SAndreas.Sandberg@arm.com
455450Sgblack@eecs.umich.eduparser.add_option("-d", "--detailed", action="store_true")
465450Sgblack@eecs.umich.eduparser.add_option("-t", "--timing", action="store_true")
475450Sgblack@eecs.umich.eduparser.add_option("-m", "--maxtick", type="int")
485450Sgblack@eecs.umich.eduparser.add_option("-n", "--numcpus",
495450Sgblack@eecs.umich.edu                  help="Number of cpus in total", type="int")
505450Sgblack@eecs.umich.eduparser.add_option("-f", "--frequency",
515450Sgblack@eecs.umich.edu                  default = "1GHz",
525610Snate@binkert.org                  help="Frequency of each CPU")
539338SAndreas.Sandberg@arm.comparser.add_option("--l1size",
545450Sgblack@eecs.umich.edu                  default = "32kB")
558323Ssteve.reinhardt@amd.comparser.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