run.py revision 13731
16100Sgblack@eecs.umich.edu# Copyright (c) 2005-2007 The Regents of The University of Michigan
26098Sgblack@eecs.umich.edu# All rights reserved.
36098Sgblack@eecs.umich.edu#
46100Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
56100Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
66100Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
76100Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
86100Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
96100Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
106100Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
116100Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
126098Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
136100Sgblack@eecs.umich.edu# this software without specific prior written permission.
146098Sgblack@eecs.umich.edu#
156098Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
166098Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
176098Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
186098Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
196098Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
206098Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
216098Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
226098Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
236098Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
246098Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
256098Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
266098Sgblack@eecs.umich.edu#
276098Sgblack@eecs.umich.edu# Authors: Ron Dreslinski
286098Sgblack@eecs.umich.edu
296098Sgblack@eecs.umich.edu# Splash2 Run Script
306098Sgblack@eecs.umich.edu#
316098Sgblack@eecs.umich.edu
326098Sgblack@eecs.umich.edufrom __future__ import print_function
336098Sgblack@eecs.umich.edu
346098Sgblack@eecs.umich.eduimport os
356098Sgblack@eecs.umich.eduimport optparse
366098Sgblack@eecs.umich.eduimport sys
376098Sgblack@eecs.umich.edu
386098Sgblack@eecs.umich.eduimport m5
396098Sgblack@eecs.umich.edufrom m5.objects import *
406098Sgblack@eecs.umich.edu
416098Sgblack@eecs.umich.edu# --------------------
426098Sgblack@eecs.umich.edu# Define Command Line Options
436098Sgblack@eecs.umich.edu# ====================
446098Sgblack@eecs.umich.edu
456098Sgblack@eecs.umich.eduparser = optparse.OptionParser()
466098Sgblack@eecs.umich.edu
476098Sgblack@eecs.umich.eduparser.add_option("-d", "--detailed", action="store_true")
486098Sgblack@eecs.umich.eduparser.add_option("-t", "--timing", action="store_true")
496098Sgblack@eecs.umich.eduparser.add_option("-m", "--maxtick", type="int")
506098Sgblack@eecs.umich.eduparser.add_option("-n", "--numcpus",
516098Sgblack@eecs.umich.edu                  help="Number of cpus in total", type="int")
526098Sgblack@eecs.umich.eduparser.add_option("-f", "--frequency",
536098Sgblack@eecs.umich.edu                  default = "1GHz",
546098Sgblack@eecs.umich.edu                  help="Frequency of each CPU")
556098Sgblack@eecs.umich.eduparser.add_option("--l1size",
566098Sgblack@eecs.umich.edu                  default = "32kB")
576098Sgblack@eecs.umich.eduparser.add_option("--l1latency",
586098Sgblack@eecs.umich.edu                  default = "1ns")
596098Sgblack@eecs.umich.eduparser.add_option("--l2size",
606098Sgblack@eecs.umich.edu                  default = "256kB")
616098Sgblack@eecs.umich.eduparser.add_option("--l2latency",
626098Sgblack@eecs.umich.edu                  default = "10ns")
636098Sgblack@eecs.umich.eduparser.add_option("--rootdir",
646098Sgblack@eecs.umich.edu                  help="Root directory of Splash2",
656098Sgblack@eecs.umich.edu                  default="/dist/splash2/codes")
666098Sgblack@eecs.umich.eduparser.add_option("-b", "--benchmark",
676098Sgblack@eecs.umich.edu                  help="Splash 2 benchmark to run")
686098Sgblack@eecs.umich.edu
696098Sgblack@eecs.umich.edu(options, args) = parser.parse_args()
706098Sgblack@eecs.umich.edu
716098Sgblack@eecs.umich.eduif args:
726098Sgblack@eecs.umich.edu    print("Error: script doesn't take any positional arguments")
736098Sgblack@eecs.umich.edu    sys.exit(1)
746098Sgblack@eecs.umich.edu
756098Sgblack@eecs.umich.eduif not options.numcpus:
766098Sgblack@eecs.umich.edu    print("Specify the number of cpus with -n")
776098Sgblack@eecs.umich.edu    sys.exit(1)
786098Sgblack@eecs.umich.edu
796098Sgblack@eecs.umich.edu# --------------------
806098Sgblack@eecs.umich.edu# Define Splash2 Benchmarks
816098Sgblack@eecs.umich.edu# ====================
826098Sgblack@eecs.umich.educlass Cholesky(Process):
836098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/kernels/cholesky'
846098Sgblack@eecs.umich.edu    executable = options.rootdir + '/kernels/cholesky/CHOLESKY'
856098Sgblack@eecs.umich.edu    cmd = ['CHOLESKY', '-p' +  str(options.numcpus),
866098Sgblack@eecs.umich.edu            options.rootdir + '/kernels/cholesky/inputs/tk23.O']
876098Sgblack@eecs.umich.edu
886098Sgblack@eecs.umich.educlass FFT(Process):
896098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/kernels/fft'
906098Sgblack@eecs.umich.edu    executable = options.rootdir + '/kernels/fft/FFT'
916098Sgblack@eecs.umich.edu    cmd = ['FFT', '-p', str(options.numcpus), '-m18']
926098Sgblack@eecs.umich.edu
936098Sgblack@eecs.umich.educlass LU_contig(Process):
946098Sgblack@eecs.umich.edu    executable = options.rootdir + '/kernels/lu/contiguous_blocks/LU'
956098Sgblack@eecs.umich.edu    cmd = ['LU', '-p', str(options.numcpus)]
966098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/kernels/lu/contiguous_blocks'
976098Sgblack@eecs.umich.edu
986098Sgblack@eecs.umich.educlass LU_noncontig(Process):
996098Sgblack@eecs.umich.edu    executable = options.rootdir + '/kernels/lu/non_contiguous_blocks/LU'
1006098Sgblack@eecs.umich.edu    cmd = ['LU', '-p', str(options.numcpus)]
1016098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/kernels/lu/non_contiguous_blocks'
1026098Sgblack@eecs.umich.edu
1036098Sgblack@eecs.umich.educlass Radix(Process):
1046098Sgblack@eecs.umich.edu    executable = options.rootdir + '/kernels/radix/RADIX'
1056098Sgblack@eecs.umich.edu    cmd = ['RADIX', '-n524288', '-p', str(options.numcpus)]
1066098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/kernels/radix'
1076098Sgblack@eecs.umich.edu
1086098Sgblack@eecs.umich.educlass Barnes(Process):
1096098Sgblack@eecs.umich.edu    executable = options.rootdir + '/apps/barnes/BARNES'
1106098Sgblack@eecs.umich.edu    cmd = ['BARNES']
1116098Sgblack@eecs.umich.edu    input = options.rootdir + '/apps/barnes/input.p' + str(options.numcpus)
1126098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/apps/barnes'
1136098Sgblack@eecs.umich.edu
1146098Sgblack@eecs.umich.educlass FMM(Process):
1156098Sgblack@eecs.umich.edu    executable = options.rootdir + '/apps/fmm/FMM'
1166098Sgblack@eecs.umich.edu    cmd = ['FMM']
1176098Sgblack@eecs.umich.edu    if str(options.numcpus) == '1':
1186098Sgblack@eecs.umich.edu        input = options.rootdir + '/apps/fmm/inputs/input.2048'
1196098Sgblack@eecs.umich.edu    else:
1206098Sgblack@eecs.umich.edu        input = options.rootdir + '/apps/fmm/inputs/input.2048.p' + str(options.numcpus)
1216098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/apps/fmm'
1226098Sgblack@eecs.umich.edu
1236098Sgblack@eecs.umich.educlass Ocean_contig(Process):
1246098Sgblack@eecs.umich.edu    executable = options.rootdir + '/apps/ocean/contiguous_partitions/OCEAN'
1256098Sgblack@eecs.umich.edu    cmd = ['OCEAN', '-p', str(options.numcpus)]
1266098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/apps/ocean/contiguous_partitions'
1276098Sgblack@eecs.umich.edu
1286098Sgblack@eecs.umich.educlass Ocean_noncontig(Process):
1296098Sgblack@eecs.umich.edu    executable = options.rootdir + '/apps/ocean/non_contiguous_partitions/OCEAN'
1306098Sgblack@eecs.umich.edu    cmd = ['OCEAN', '-p', str(options.numcpus)]
1316098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/apps/ocean/non_contiguous_partitions'
1326098Sgblack@eecs.umich.edu
1336098Sgblack@eecs.umich.educlass Raytrace(Process):
1346098Sgblack@eecs.umich.edu    executable = options.rootdir + '/apps/raytrace/RAYTRACE'
1356098Sgblack@eecs.umich.edu    cmd = ['RAYTRACE', '-p' + str(options.numcpus),
1366098Sgblack@eecs.umich.edu           options.rootdir + '/apps/raytrace/inputs/teapot.env']
1376098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/apps/raytrace'
1386098Sgblack@eecs.umich.edu
1396098Sgblack@eecs.umich.educlass Water_nsquared(Process):
1406098Sgblack@eecs.umich.edu    executable = options.rootdir + '/apps/water-nsquared/WATER-NSQUARED'
1416098Sgblack@eecs.umich.edu    cmd = ['WATER-NSQUARED']
1426611Sgblack@eecs.umich.edu    if options.numcpus==1:
1436611Sgblack@eecs.umich.edu        input = options.rootdir + '/apps/water-nsquared/input'
1446611Sgblack@eecs.umich.edu    else:
1456611Sgblack@eecs.umich.edu        input = options.rootdir + '/apps/water-nsquared/input.p' + str(options.numcpus)
1466098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/apps/water-nsquared'
1476098Sgblack@eecs.umich.edu
1486098Sgblack@eecs.umich.educlass Water_spatial(Process):
1496098Sgblack@eecs.umich.edu    executable = options.rootdir + '/apps/water-spatial/WATER-SPATIAL'
1506098Sgblack@eecs.umich.edu    cmd = ['WATER-SPATIAL']
1516098Sgblack@eecs.umich.edu    if options.numcpus==1:
1526098Sgblack@eecs.umich.edu        input = options.rootdir + '/apps/water-spatial/input'
1536098Sgblack@eecs.umich.edu    else:
1546098Sgblack@eecs.umich.edu        input = options.rootdir + '/apps/water-spatial/input.p' + str(options.numcpus)
1556098Sgblack@eecs.umich.edu    cwd = options.rootdir + '/apps/water-spatial'
1566098Sgblack@eecs.umich.edu
1576098Sgblack@eecs.umich.edu# --------------------
1586098Sgblack@eecs.umich.edu# Base L1 Cache Definition
1596098Sgblack@eecs.umich.edu# ====================
1606098Sgblack@eecs.umich.edu
1616098Sgblack@eecs.umich.educlass L1(Cache):
1626098Sgblack@eecs.umich.edu    latency = options.l1latency
1636098Sgblack@eecs.umich.edu    mshrs = 12
1646098Sgblack@eecs.umich.edu    tgts_per_mshr = 8
1656098Sgblack@eecs.umich.edu
1666098Sgblack@eecs.umich.edu# ----------------------
1676486Sgblack@eecs.umich.edu# Base L2 Cache Definition
1686486Sgblack@eecs.umich.edu# ----------------------
1696098Sgblack@eecs.umich.edu
1706098Sgblack@eecs.umich.educlass L2(Cache):
1716098Sgblack@eecs.umich.edu    latency = options.l2latency
1726098Sgblack@eecs.umich.edu    mshrs = 92
1736098Sgblack@eecs.umich.edu    tgts_per_mshr = 16
1746098Sgblack@eecs.umich.edu    write_buffers = 8
1756098Sgblack@eecs.umich.edu
1766098Sgblack@eecs.umich.edu# ----------------------
1776098Sgblack@eecs.umich.edu# Define the cpus
178# ----------------------
179
180busFrequency = Frequency(options.frequency)
181
182if options.timing:
183    cpus = [TimingSimpleCPU(cpu_id = i,
184                            clock=options.frequency)
185            for i in range(options.numcpus)]
186elif options.detailed:
187    cpus = [DerivO3CPU(cpu_id = i,
188                       clock=options.frequency)
189            for i in range(options.numcpus)]
190else:
191    cpus = [AtomicSimpleCPU(cpu_id = i,
192                            clock=options.frequency)
193            for i in range(options.numcpus)]
194
195# ----------------------
196# Create a system, and add system wide objects
197# ----------------------
198system = System(cpu = cpus, physmem = SimpleMemory(),
199                membus = SystemXBar(clock = busFrequency))
200system.clock = '1GHz'
201
202system.toL2bus = L2XBar(clock = busFrequency)
203system.l2 = L2(size = options.l2size, assoc = 8)
204
205# ----------------------
206# Connect the L2 cache and memory together
207# ----------------------
208
209system.physmem.port = system.membus.master
210system.l2.cpu_side = system.toL2bus.master
211system.l2.mem_side = system.membus.slave
212system.system_port = system.membus.slave
213
214# ----------------------
215# Connect the L2 cache and clusters together
216# ----------------------
217for cpu in cpus:
218    cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1),
219                                L1(size = options.l1size, assoc = 4))
220    # connect cpu level-1 caches to shared level-2 cache
221    cpu.connectAllPorts(system.toL2bus, system.membus)
222
223
224# ----------------------
225# Define the root
226# ----------------------
227
228root = Root(full_system = False, system = system)
229
230# --------------------
231# Pick the correct Splash2 Benchmarks
232# ====================
233if options.benchmark == 'Cholesky':
234    root.workload = Cholesky()
235elif options.benchmark == 'FFT':
236    root.workload = FFT()
237elif options.benchmark == 'LUContig':
238    root.workload = LU_contig()
239elif options.benchmark == 'LUNoncontig':
240    root.workload = LU_noncontig()
241elif options.benchmark == 'Radix':
242    root.workload = Radix()
243elif options.benchmark == 'Barnes':
244    root.workload = Barnes()
245elif options.benchmark == 'FMM':
246    root.workload = FMM()
247elif options.benchmark == 'OceanContig':
248    root.workload = Ocean_contig()
249elif options.benchmark == 'OceanNoncontig':
250    root.workload = Ocean_noncontig()
251elif options.benchmark == 'Raytrace':
252    root.workload = Raytrace()
253elif options.benchmark == 'WaterNSquared':
254    root.workload = Water_nsquared()
255elif options.benchmark == 'WaterSpatial':
256    root.workload = Water_spatial()
257else:
258    print("The --benchmark environment variable was set to something "
259          "improper. Use Cholesky, FFT, LUContig, LUNoncontig, Radix, "
260          "Barnes, FMM, OceanContig, OceanNoncontig, Raytrace, WaterNSquared, "
261          "or WaterSpatial", file=sys.stderr)
262    sys.exit(1)
263
264# --------------------
265# Assign the workload to the cpus
266# ====================
267
268for cpu in cpus:
269    cpu.workload = root.workload
270
271# ----------------------
272# Run the simulation
273# ----------------------
274
275if options.timing or options.detailed:
276    root.system.mem_mode = 'timing'
277
278# instantiate configuration
279m5.instantiate()
280
281# simulate until program terminates
282if options.maxtick:
283    exit_event = m5.simulate(options.maxtick)
284else:
285    exit_event = m5.simulate(m5.MaxTick)
286
287print('Exiting @ tick', m5.curTick(), 'because', exit_event.getCause())
288
289