run.py revision 10720
111666Stushar@ece.gatech.edu# Copyright (c) 2005-2007 The Regents of The University of Michigan
211666Stushar@ece.gatech.edu# All rights reserved.
311666Stushar@ece.gatech.edu#
411666Stushar@ece.gatech.edu# Redistribution and use in source and binary forms, with or without
511666Stushar@ece.gatech.edu# modification, are permitted provided that the following conditions are
611666Stushar@ece.gatech.edu# met: redistributions of source code must retain the above copyright
711666Stushar@ece.gatech.edu# notice, this list of conditions and the following disclaimer;
811666Stushar@ece.gatech.edu# redistributions in binary form must reproduce the above copyright
911666Stushar@ece.gatech.edu# notice, this list of conditions and the following disclaimer in the
1011666Stushar@ece.gatech.edu# documentation and/or other materials provided with the distribution;
1111666Stushar@ece.gatech.edu# neither the name of the copyright holders nor the names of its
1211666Stushar@ece.gatech.edu# contributors may be used to endorse or promote products derived from
1311666Stushar@ece.gatech.edu# this software without specific prior written permission.
1411666Stushar@ece.gatech.edu#
1511666Stushar@ece.gatech.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1611666Stushar@ece.gatech.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1711666Stushar@ece.gatech.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1811666Stushar@ece.gatech.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1911666Stushar@ece.gatech.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2011666Stushar@ece.gatech.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2111666Stushar@ece.gatech.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2211666Stushar@ece.gatech.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2311666Stushar@ece.gatech.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2411666Stushar@ece.gatech.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2511666Stushar@ece.gatech.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2611666Stushar@ece.gatech.edu#
2711666Stushar@ece.gatech.edu# Authors: Ron Dreslinski
2811666Stushar@ece.gatech.edu
2911666Stushar@ece.gatech.edu# Splash2 Run Script
3011666Stushar@ece.gatech.edu#
3111666Stushar@ece.gatech.edu
3211666Stushar@ece.gatech.eduimport os
3311666Stushar@ece.gatech.eduimport optparse
3411666Stushar@ece.gatech.eduimport sys
3511666Stushar@ece.gatech.edu
3611666Stushar@ece.gatech.eduimport m5
3711666Stushar@ece.gatech.edufrom m5.objects import *
3811666Stushar@ece.gatech.edu
3911666Stushar@ece.gatech.edum5.util.addToPath('../common')
4011666Stushar@ece.gatech.edu
4111666Stushar@ece.gatech.edu# --------------------
4211666Stushar@ece.gatech.edu# Define Command Line Options
4311666Stushar@ece.gatech.edu# ====================
4411666Stushar@ece.gatech.edu
4511666Stushar@ece.gatech.eduparser = optparse.OptionParser()
4611666Stushar@ece.gatech.edu
4711666Stushar@ece.gatech.eduparser.add_option("-d", "--detailed", action="store_true")
4811666Stushar@ece.gatech.eduparser.add_option("-t", "--timing", action="store_true")
4911666Stushar@ece.gatech.eduparser.add_option("-m", "--maxtick", type="int")
5011666Stushar@ece.gatech.eduparser.add_option("-n", "--numcpus",
5111666Stushar@ece.gatech.edu                  help="Number of cpus in total", type="int")
5211666Stushar@ece.gatech.eduparser.add_option("-f", "--frequency",
5311666Stushar@ece.gatech.edu                  default = "1GHz",
5411666Stushar@ece.gatech.edu                  help="Frequency of each CPU")
5511666Stushar@ece.gatech.eduparser.add_option("--l1size",
5611666Stushar@ece.gatech.edu                  default = "32kB")
5711666Stushar@ece.gatech.eduparser.add_option("--l1latency",
5811666Stushar@ece.gatech.edu                  default = "1ns")
5911666Stushar@ece.gatech.eduparser.add_option("--l2size",
6011666Stushar@ece.gatech.edu                  default = "256kB")
6111666Stushar@ece.gatech.eduparser.add_option("--l2latency",
6211666Stushar@ece.gatech.edu                  default = "10ns")
6311666Stushar@ece.gatech.eduparser.add_option("--rootdir",
6411666Stushar@ece.gatech.edu                  help="Root directory of Splash2",
6511666Stushar@ece.gatech.edu                  default="/dist/splash2/codes")
6611666Stushar@ece.gatech.eduparser.add_option("-b", "--benchmark",
6711666Stushar@ece.gatech.edu                  help="Splash 2 benchmark to run")
6811666Stushar@ece.gatech.edu
6911666Stushar@ece.gatech.edu(options, args) = parser.parse_args()
7011666Stushar@ece.gatech.edu
7111666Stushar@ece.gatech.eduif args:
7211666Stushar@ece.gatech.edu    print "Error: script doesn't take any positional arguments"
7311666Stushar@ece.gatech.edu    sys.exit(1)
7411666Stushar@ece.gatech.edu
7511666Stushar@ece.gatech.eduif not options.numcpus:
7611666Stushar@ece.gatech.edu    print "Specify the number of cpus with -n"
7711666Stushar@ece.gatech.edu    sys.exit(1)
7811666Stushar@ece.gatech.edu
7911666Stushar@ece.gatech.edu# --------------------
8011666Stushar@ece.gatech.edu# Define Splash2 Benchmarks
8111666Stushar@ece.gatech.edu# ====================
8211666Stushar@ece.gatech.educlass Cholesky(LiveProcess):
8311666Stushar@ece.gatech.edu    cwd = options.rootdir + '/kernels/cholesky'
8411666Stushar@ece.gatech.edu    executable = options.rootdir + '/kernels/cholesky/CHOLESKY'
8511666Stushar@ece.gatech.edu    cmd = ['CHOLESKY', '-p' +  str(options.numcpus),
8611666Stushar@ece.gatech.edu            options.rootdir + '/kernels/cholesky/inputs/tk23.O']
8711666Stushar@ece.gatech.edu
8811666Stushar@ece.gatech.educlass FFT(LiveProcess):
8911666Stushar@ece.gatech.edu    cwd = options.rootdir + '/kernels/fft'
9011666Stushar@ece.gatech.edu    executable = options.rootdir + '/kernels/fft/FFT'
9111666Stushar@ece.gatech.edu    cmd = ['FFT', '-p', str(options.numcpus), '-m18']
9211666Stushar@ece.gatech.edu
9311666Stushar@ece.gatech.educlass LU_contig(LiveProcess):
9411666Stushar@ece.gatech.edu    executable = options.rootdir + '/kernels/lu/contiguous_blocks/LU'
9511666Stushar@ece.gatech.edu    cmd = ['LU', '-p', str(options.numcpus)]
9611666Stushar@ece.gatech.edu    cwd = options.rootdir + '/kernels/lu/contiguous_blocks'
9711666Stushar@ece.gatech.edu
9811666Stushar@ece.gatech.educlass LU_noncontig(LiveProcess):
9911666Stushar@ece.gatech.edu    executable = options.rootdir + '/kernels/lu/non_contiguous_blocks/LU'
10011666Stushar@ece.gatech.edu    cmd = ['LU', '-p', str(options.numcpus)]
10111666Stushar@ece.gatech.edu    cwd = options.rootdir + '/kernels/lu/non_contiguous_blocks'
10211666Stushar@ece.gatech.edu
10311666Stushar@ece.gatech.educlass Radix(LiveProcess):
10411666Stushar@ece.gatech.edu    executable = options.rootdir + '/kernels/radix/RADIX'
10511666Stushar@ece.gatech.edu    cmd = ['RADIX', '-n524288', '-p', str(options.numcpus)]
10611666Stushar@ece.gatech.edu    cwd = options.rootdir + '/kernels/radix'
10711666Stushar@ece.gatech.edu
10811666Stushar@ece.gatech.educlass Barnes(LiveProcess):
10911666Stushar@ece.gatech.edu    executable = options.rootdir + '/apps/barnes/BARNES'
11011666Stushar@ece.gatech.edu    cmd = ['BARNES']
11111666Stushar@ece.gatech.edu    input = options.rootdir + '/apps/barnes/input.p' + str(options.numcpus)
11211666Stushar@ece.gatech.edu    cwd = options.rootdir + '/apps/barnes'
11311666Stushar@ece.gatech.edu
11411666Stushar@ece.gatech.educlass FMM(LiveProcess):
11511666Stushar@ece.gatech.edu    executable = options.rootdir + '/apps/fmm/FMM'
11611666Stushar@ece.gatech.edu    cmd = ['FMM']
11711666Stushar@ece.gatech.edu    if str(options.numcpus) == '1':
11811666Stushar@ece.gatech.edu        input = options.rootdir + '/apps/fmm/inputs/input.2048'
11911666Stushar@ece.gatech.edu    else:
12011666Stushar@ece.gatech.edu        input = options.rootdir + '/apps/fmm/inputs/input.2048.p' + str(options.numcpus)
12111666Stushar@ece.gatech.edu    cwd = options.rootdir + '/apps/fmm'
12211666Stushar@ece.gatech.edu
12311666Stushar@ece.gatech.educlass Ocean_contig(LiveProcess):
12411666Stushar@ece.gatech.edu    executable = options.rootdir + '/apps/ocean/contiguous_partitions/OCEAN'
12511666Stushar@ece.gatech.edu    cmd = ['OCEAN', '-p', str(options.numcpus)]
12611666Stushar@ece.gatech.edu    cwd = options.rootdir + '/apps/ocean/contiguous_partitions'
12711666Stushar@ece.gatech.edu
12811666Stushar@ece.gatech.educlass Ocean_noncontig(LiveProcess):
12911666Stushar@ece.gatech.edu    executable = options.rootdir + '/apps/ocean/non_contiguous_partitions/OCEAN'
13011666Stushar@ece.gatech.edu    cmd = ['OCEAN', '-p', str(options.numcpus)]
13111666Stushar@ece.gatech.edu    cwd = options.rootdir + '/apps/ocean/non_contiguous_partitions'
13211666Stushar@ece.gatech.edu
13311666Stushar@ece.gatech.educlass Raytrace(LiveProcess):
13411666Stushar@ece.gatech.edu    executable = options.rootdir + '/apps/raytrace/RAYTRACE'
13511666Stushar@ece.gatech.edu    cmd = ['RAYTRACE', '-p' + str(options.numcpus),
13611666Stushar@ece.gatech.edu           options.rootdir + '/apps/raytrace/inputs/teapot.env']
13711666Stushar@ece.gatech.edu    cwd = options.rootdir + '/apps/raytrace'
13811666Stushar@ece.gatech.edu
13911666Stushar@ece.gatech.educlass Water_nsquared(LiveProcess):
14011666Stushar@ece.gatech.edu    executable = options.rootdir + '/apps/water-nsquared/WATER-NSQUARED'
14111666Stushar@ece.gatech.edu    cmd = ['WATER-NSQUARED']
14211666Stushar@ece.gatech.edu    if options.numcpus==1:
14311666Stushar@ece.gatech.edu        input = options.rootdir + '/apps/water-nsquared/input'
14411666Stushar@ece.gatech.edu    else:
14511666Stushar@ece.gatech.edu        input = options.rootdir + '/apps/water-nsquared/input.p' + str(options.numcpus)
14611666Stushar@ece.gatech.edu    cwd = options.rootdir + '/apps/water-nsquared'
14711666Stushar@ece.gatech.edu
14811666Stushar@ece.gatech.educlass Water_spatial(LiveProcess):
14911666Stushar@ece.gatech.edu    executable = options.rootdir + '/apps/water-spatial/WATER-SPATIAL'
15011666Stushar@ece.gatech.edu    cmd = ['WATER-SPATIAL']
15111666Stushar@ece.gatech.edu    if options.numcpus==1:
15211666Stushar@ece.gatech.edu        input = options.rootdir + '/apps/water-spatial/input'
15311666Stushar@ece.gatech.edu    else:
15411666Stushar@ece.gatech.edu        input = options.rootdir + '/apps/water-spatial/input.p' + str(options.numcpus)
15511666Stushar@ece.gatech.edu    cwd = options.rootdir + '/apps/water-spatial'
15611666Stushar@ece.gatech.edu
15711666Stushar@ece.gatech.edu# --------------------
15811666Stushar@ece.gatech.edu# Base L1 Cache Definition
15911666Stushar@ece.gatech.edu# ====================
16011666Stushar@ece.gatech.edu
16111666Stushar@ece.gatech.educlass L1(BaseCache):
16211666Stushar@ece.gatech.edu    latency = options.l1latency
16311666Stushar@ece.gatech.edu    mshrs = 12
16411666Stushar@ece.gatech.edu    tgts_per_mshr = 8
16511666Stushar@ece.gatech.edu
16611666Stushar@ece.gatech.edu# ----------------------
16711666Stushar@ece.gatech.edu# Base L2 Cache Definition
16811666Stushar@ece.gatech.edu# ----------------------
16911666Stushar@ece.gatech.edu
17011666Stushar@ece.gatech.educlass L2(BaseCache):
17111666Stushar@ece.gatech.edu    latency = options.l2latency
17211666Stushar@ece.gatech.edu    mshrs = 92
17311666Stushar@ece.gatech.edu    tgts_per_mshr = 16
17411666Stushar@ece.gatech.edu    write_buffers = 8
17511666Stushar@ece.gatech.edu
17611666Stushar@ece.gatech.edu# ----------------------
17711666Stushar@ece.gatech.edu# Define the cpus
17811666Stushar@ece.gatech.edu# ----------------------
17911666Stushar@ece.gatech.edu
18011666Stushar@ece.gatech.edubusFrequency = Frequency(options.frequency)
18111666Stushar@ece.gatech.edu
18211666Stushar@ece.gatech.eduif options.timing:
18311666Stushar@ece.gatech.edu    cpus = [TimingSimpleCPU(cpu_id = i,
18411667Stushar@ece.gatech.edu                            clock=options.frequency)
18511666Stushar@ece.gatech.edu            for i in xrange(options.numcpus)]
18611666Stushar@ece.gatech.eduelif options.detailed:
18711666Stushar@ece.gatech.edu    cpus = [DerivO3CPU(cpu_id = i,
18811666Stushar@ece.gatech.edu                       clock=options.frequency)
18911666Stushar@ece.gatech.edu            for i in xrange(options.numcpus)]
19011666Stushar@ece.gatech.eduelse:
19111666Stushar@ece.gatech.edu    cpus = [AtomicSimpleCPU(cpu_id = i,
19211666Stushar@ece.gatech.edu                            clock=options.frequency)
19311666Stushar@ece.gatech.edu            for i in xrange(options.numcpus)]
19411666Stushar@ece.gatech.edu
19511666Stushar@ece.gatech.edu# ----------------------
19611666Stushar@ece.gatech.edu# Create a system, and add system wide objects
19711666Stushar@ece.gatech.edu# ----------------------
19811666Stushar@ece.gatech.edusystem = System(cpu = cpus, physmem = SimpleMemory(),
19911666Stushar@ece.gatech.edu                membus = SystemXBar(clock = busFrequency))
20011666Stushar@ece.gatech.edusystem.clock = '1GHz'
20111666Stushar@ece.gatech.edu
20211666Stushar@ece.gatech.edusystem.toL2bus = L2XBar(clock = busFrequency)
20311666Stushar@ece.gatech.edusystem.l2 = L2(size = options.l2size, assoc = 8)
20411666Stushar@ece.gatech.edu
20511666Stushar@ece.gatech.edu# ----------------------
20611666Stushar@ece.gatech.edu# Connect the L2 cache and memory together
20711666Stushar@ece.gatech.edu# ----------------------
20811666Stushar@ece.gatech.edu
20911666Stushar@ece.gatech.edusystem.physmem.port = system.membus.master
21011666Stushar@ece.gatech.edusystem.l2.cpu_side = system.toL2bus.master
21111666Stushar@ece.gatech.edusystem.l2.mem_side = system.membus.slave
21211666Stushar@ece.gatech.edusystem.system_port = system.membus.slave
21311666Stushar@ece.gatech.edu
21411666Stushar@ece.gatech.edu# ----------------------
21511666Stushar@ece.gatech.edu# Connect the L2 cache and clusters together
21611666Stushar@ece.gatech.edu# ----------------------
21711666Stushar@ece.gatech.edufor cpu in cpus:
21811666Stushar@ece.gatech.edu    cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1),
21911666Stushar@ece.gatech.edu                                L1(size = options.l1size, assoc = 4))
22011666Stushar@ece.gatech.edu    # connect cpu level-1 caches to shared level-2 cache
22111666Stushar@ece.gatech.edu    cpu.connectAllPorts(system.toL2bus, system.membus)
22211666Stushar@ece.gatech.edu
22311666Stushar@ece.gatech.edu
22411666Stushar@ece.gatech.edu# ----------------------
22511666Stushar@ece.gatech.edu# Define the root
22611666Stushar@ece.gatech.edu# ----------------------
22711666Stushar@ece.gatech.edu
22811666Stushar@ece.gatech.eduroot = Root(full_system = False, system = system)
22911666Stushar@ece.gatech.edu
23011666Stushar@ece.gatech.edu# --------------------
23111666Stushar@ece.gatech.edu# Pick the correct Splash2 Benchmarks
23211666Stushar@ece.gatech.edu# ====================
23311666Stushar@ece.gatech.eduif options.benchmark == 'Cholesky':
23411666Stushar@ece.gatech.edu    root.workload = Cholesky()
23511666Stushar@ece.gatech.eduelif options.benchmark == 'FFT':
23611666Stushar@ece.gatech.edu    root.workload = FFT()
23711666Stushar@ece.gatech.eduelif options.benchmark == 'LUContig':
23811666Stushar@ece.gatech.edu    root.workload = LU_contig()
23911666Stushar@ece.gatech.eduelif options.benchmark == 'LUNoncontig':
24011666Stushar@ece.gatech.edu    root.workload = LU_noncontig()
24111667Stushar@ece.gatech.eduelif options.benchmark == 'Radix':
24211666Stushar@ece.gatech.edu    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 >> sys.stderr, """The --benchmark environment variable was set to something improper.
259Use Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig,
260OceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial"""
261    sys.exit(1)
262
263# --------------------
264# Assign the workload to the cpus
265# ====================
266
267for cpu in cpus:
268    cpu.workload = root.workload
269
270# ----------------------
271# Run the simulation
272# ----------------------
273
274if options.timing or options.detailed:
275    root.system.mem_mode = 'timing'
276
277# instantiate configuration
278m5.instantiate()
279
280# simulate until program terminates
281if options.maxtick:
282    exit_event = m5.simulate(options.maxtick)
283else:
284    exit_event = m5.simulate(m5.MaxTick)
285
286print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
287
288