run.py revision 8847
19651SAndreas.Sandberg@ARM.com# Copyright (c) 2005-2007 The Regents of The University of Michigan
210858Sandreas.sandberg@arm.com# All rights reserved.
39651SAndreas.Sandberg@ARM.com#
49651SAndreas.Sandberg@ARM.com# Redistribution and use in source and binary forms, with or without
59651SAndreas.Sandberg@ARM.com# modification, are permitted provided that the following conditions are
69651SAndreas.Sandberg@ARM.com# met: redistributions of source code must retain the above copyright
79651SAndreas.Sandberg@ARM.com# notice, this list of conditions and the following disclaimer;
89651SAndreas.Sandberg@ARM.com# redistributions in binary form must reproduce the above copyright
99651SAndreas.Sandberg@ARM.com# notice, this list of conditions and the following disclaimer in the
109651SAndreas.Sandberg@ARM.com# documentation and/or other materials provided with the distribution;
119651SAndreas.Sandberg@ARM.com# neither the name of the copyright holders nor the names of its
129651SAndreas.Sandberg@ARM.com# contributors may be used to endorse or promote products derived from
139651SAndreas.Sandberg@ARM.com# this software without specific prior written permission.
149651SAndreas.Sandberg@ARM.com#
159651SAndreas.Sandberg@ARM.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
169651SAndreas.Sandberg@ARM.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
179651SAndreas.Sandberg@ARM.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
189651SAndreas.Sandberg@ARM.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
199651SAndreas.Sandberg@ARM.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
209651SAndreas.Sandberg@ARM.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
219651SAndreas.Sandberg@ARM.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
229651SAndreas.Sandberg@ARM.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
239651SAndreas.Sandberg@ARM.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
249651SAndreas.Sandberg@ARM.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
259651SAndreas.Sandberg@ARM.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
269651SAndreas.Sandberg@ARM.com#
279651SAndreas.Sandberg@ARM.com# Authors: Ron Dreslinski
289651SAndreas.Sandberg@ARM.com
299651SAndreas.Sandberg@ARM.com# Splash2 Run Script
309651SAndreas.Sandberg@ARM.com#
319651SAndreas.Sandberg@ARM.com
329651SAndreas.Sandberg@ARM.comimport os
339651SAndreas.Sandberg@ARM.comimport optparse
349651SAndreas.Sandberg@ARM.comimport sys
359651SAndreas.Sandberg@ARM.com
369651SAndreas.Sandberg@ARM.comimport m5
379651SAndreas.Sandberg@ARM.comfrom m5.objects import *
389651SAndreas.Sandberg@ARM.com
399651SAndreas.Sandberg@ARM.comm5.util.addToPath('../common')
4011793Sbrandon.potter@amd.com
4111793Sbrandon.potter@amd.com# --------------------
429651SAndreas.Sandberg@ARM.com# Define Command Line Options
439651SAndreas.Sandberg@ARM.com# ====================
449651SAndreas.Sandberg@ARM.com
459651SAndreas.Sandberg@ARM.comparser = optparse.OptionParser()
469651SAndreas.Sandberg@ARM.com
479651SAndreas.Sandberg@ARM.comparser.add_option("-d", "--detailed", action="store_true")
489651SAndreas.Sandberg@ARM.comparser.add_option("-t", "--timing", action="store_true")
499651SAndreas.Sandberg@ARM.comparser.add_option("-m", "--maxtick", type="int")
509651SAndreas.Sandberg@ARM.comparser.add_option("-n", "--numcpus",
519760Sandreas@sandberg.pp.se                  help="Number of cpus in total", type="int")
529651SAndreas.Sandberg@ARM.comparser.add_option("-f", "--frequency",
539683Sandreas@sandberg.pp.se                  default = "1GHz",
549753Sandreas@sandberg.pp.se                  help="Frequency of each CPU")
559651SAndreas.Sandberg@ARM.comparser.add_option("--l1size",
569651SAndreas.Sandberg@ARM.com                  default = "32kB")
579651SAndreas.Sandberg@ARM.comparser.add_option("--l1latency",
589651SAndreas.Sandberg@ARM.com                  default = "1ns")
599651SAndreas.Sandberg@ARM.comparser.add_option("--l2size",
609651SAndreas.Sandberg@ARM.com                  default = "256kB")
619651SAndreas.Sandberg@ARM.comparser.add_option("--l2latency",
629651SAndreas.Sandberg@ARM.com                  default = "10ns")
639651SAndreas.Sandberg@ARM.comparser.add_option("--rootdir",
649651SAndreas.Sandberg@ARM.com                  help="Root directory of Splash2",
659651SAndreas.Sandberg@ARM.com                  default="/dist/splash2/codes")
669651SAndreas.Sandberg@ARM.comparser.add_option("-b", "--benchmark",
679651SAndreas.Sandberg@ARM.com                  help="Splash 2 benchmark to run")
689651SAndreas.Sandberg@ARM.com
699651SAndreas.Sandberg@ARM.com(options, args) = parser.parse_args()
709651SAndreas.Sandberg@ARM.com
7111399Sandreas.sandberg@arm.comif args:
729652SAndreas.Sandberg@ARM.com    print "Error: script doesn't take any positional arguments"
739652SAndreas.Sandberg@ARM.com    sys.exit(1)
749651SAndreas.Sandberg@ARM.com
759651SAndreas.Sandberg@ARM.comif not options.numcpus:
769651SAndreas.Sandberg@ARM.com    print "Specify the number of cpus with -n"
779651SAndreas.Sandberg@ARM.com    sys.exit(1)
789892Sandreas@sandberg.pp.se
799655SAndreas.Sandberg@ARM.com# --------------------
809752Sandreas@sandberg.pp.se# Define Splash2 Benchmarks
819752Sandreas@sandberg.pp.se# ====================
829651SAndreas.Sandberg@ARM.comclass Cholesky(LiveProcess):
839651SAndreas.Sandberg@ARM.com    cwd = options.rootdir + '/kernels/cholesky'
849651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/kernels/cholesky/CHOLESKY'
859651SAndreas.Sandberg@ARM.com    cmd = ['CHOLESKY', '-p' +  str(options.numcpus),
869651SAndreas.Sandberg@ARM.com            options.rootdir + '/kernels/cholesky/inputs/tk23.O']
8710553Salexandru.dutu@amd.com
8810553Salexandru.dutu@amd.comclass FFT(LiveProcess):
8910553Salexandru.dutu@amd.com    cwd = options.rootdir + '/kernels/fft'
9010553Salexandru.dutu@amd.com    executable = options.rootdir + '/kernels/fft/FFT'
9110553Salexandru.dutu@amd.com    cmd = ['FFT', '-p', str(options.numcpus), '-m18']
9210553Salexandru.dutu@amd.com
9310553Salexandru.dutu@amd.comclass LU_contig(LiveProcess):
9410553Salexandru.dutu@amd.com    executable = options.rootdir + '/kernels/lu/contiguous_blocks/LU'
959651SAndreas.Sandberg@ARM.com    cmd = ['LU', '-p', str(options.numcpus)]
969651SAndreas.Sandberg@ARM.com    cwd = options.rootdir + '/kernels/lu/contiguous_blocks'
979651SAndreas.Sandberg@ARM.com
989651SAndreas.Sandberg@ARM.comclass LU_noncontig(LiveProcess):
999651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/kernels/lu/non_contiguous_blocks/LU'
1009651SAndreas.Sandberg@ARM.com    cmd = ['LU', '-p', str(options.numcpus)]
1019651SAndreas.Sandberg@ARM.com    cwd = options.rootdir + '/kernels/lu/non_contiguous_blocks'
1029651SAndreas.Sandberg@ARM.com
1039651SAndreas.Sandberg@ARM.comclass Radix(LiveProcess):
1049651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/kernels/radix/RADIX'
1059651SAndreas.Sandberg@ARM.com    cmd = ['RADIX', '-n524288', '-p', str(options.numcpus)]
1069651SAndreas.Sandberg@ARM.com    cwd = options.rootdir + '/kernels/radix'
1079651SAndreas.Sandberg@ARM.com
1089651SAndreas.Sandberg@ARM.comclass Barnes(LiveProcess):
1099651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/apps/barnes/BARNES'
1109651SAndreas.Sandberg@ARM.com    cmd = ['BARNES']
1119651SAndreas.Sandberg@ARM.com    input = options.rootdir + '/apps/barnes/input.p' + str(options.numcpus)
1129651SAndreas.Sandberg@ARM.com    cwd = options.rootdir + '/apps/barnes'
1139651SAndreas.Sandberg@ARM.com
1149651SAndreas.Sandberg@ARM.comclass FMM(LiveProcess):
1159651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/apps/fmm/FMM'
1169651SAndreas.Sandberg@ARM.com    cmd = ['FMM']
1179651SAndreas.Sandberg@ARM.com    if str(options.numcpus) == '1':
1189651SAndreas.Sandberg@ARM.com        input = options.rootdir + '/apps/fmm/inputs/input.2048'
1199651SAndreas.Sandberg@ARM.com    else:
1209651SAndreas.Sandberg@ARM.com        input = options.rootdir + '/apps/fmm/inputs/input.2048.p' + str(options.numcpus)
1219651SAndreas.Sandberg@ARM.com    cwd = options.rootdir + '/apps/fmm'
1229651SAndreas.Sandberg@ARM.com
1239651SAndreas.Sandberg@ARM.comclass Ocean_contig(LiveProcess):
1249651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/apps/ocean/contiguous_partitions/OCEAN'
1259690Sandreas@sandberg.pp.se    cmd = ['OCEAN', '-p', str(options.numcpus)]
1269690Sandreas@sandberg.pp.se    cwd = options.rootdir + '/apps/ocean/contiguous_partitions'
1279690Sandreas@sandberg.pp.se
12811363Sandreas@sandberg.pp.seclass Ocean_noncontig(LiveProcess):
1299651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/apps/ocean/non_contiguous_partitions/OCEAN'
1309651SAndreas.Sandberg@ARM.com    cmd = ['OCEAN', '-p', str(options.numcpus)]
1319651SAndreas.Sandberg@ARM.com    cwd = options.rootdir + '/apps/ocean/non_contiguous_partitions'
1329651SAndreas.Sandberg@ARM.com
1339651SAndreas.Sandberg@ARM.comclass Raytrace(LiveProcess):
1349651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/apps/raytrace/RAYTRACE'
1359651SAndreas.Sandberg@ARM.com    cmd = ['RAYTRACE', '-p' + str(options.numcpus),
1369651SAndreas.Sandberg@ARM.com           options.rootdir + '/apps/raytrace/inputs/teapot.env']
1379651SAndreas.Sandberg@ARM.com    cwd = options.rootdir + '/apps/raytrace'
1389651SAndreas.Sandberg@ARM.com
1399651SAndreas.Sandberg@ARM.comclass Water_nsquared(LiveProcess):
1409651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/apps/water-nsquared/WATER-NSQUARED'
1419651SAndreas.Sandberg@ARM.com    cmd = ['WATER-NSQUARED']
1429651SAndreas.Sandberg@ARM.com    if options.numcpus==1:
1439651SAndreas.Sandberg@ARM.com        input = options.rootdir + '/apps/water-nsquared/input'
1449651SAndreas.Sandberg@ARM.com    else:
1459651SAndreas.Sandberg@ARM.com        input = options.rootdir + '/apps/water-nsquared/input.p' + str(options.numcpus)
1469651SAndreas.Sandberg@ARM.com    cwd = options.rootdir + '/apps/water-nsquared'
1479651SAndreas.Sandberg@ARM.com
1489651SAndreas.Sandberg@ARM.comclass Water_spatial(LiveProcess):
1499651SAndreas.Sandberg@ARM.com    executable = options.rootdir + '/apps/water-spatial/WATER-SPATIAL'
1509651SAndreas.Sandberg@ARM.com    cmd = ['WATER-SPATIAL']
1519651SAndreas.Sandberg@ARM.com    if options.numcpus==1:
1529651SAndreas.Sandberg@ARM.com        input = options.rootdir + '/apps/water-spatial/input'
1539651SAndreas.Sandberg@ARM.com    else:
1549690Sandreas@sandberg.pp.se        input = options.rootdir + '/apps/water-spatial/input.p' + str(options.numcpus)
1559690Sandreas@sandberg.pp.se    cwd = options.rootdir + '/apps/water-spatial'
1569690Sandreas@sandberg.pp.se
1579651SAndreas.Sandberg@ARM.com# --------------------
1589651SAndreas.Sandberg@ARM.com# Base L1 Cache Definition
1599651SAndreas.Sandberg@ARM.com# ====================
1609651SAndreas.Sandberg@ARM.com
1619651SAndreas.Sandberg@ARM.comclass L1(BaseCache):
1629651SAndreas.Sandberg@ARM.com    latency = options.l1latency
1639732Sandreas@sandberg.pp.se    block_size = 64
1649732Sandreas@sandberg.pp.se    mshrs = 12
16510073Sandreas@sandberg.pp.se    tgts_per_mshr = 8
16610073Sandreas@sandberg.pp.se
16710073Sandreas@sandberg.pp.se# ----------------------
16810073Sandreas@sandberg.pp.se# Base L2 Cache Definition
16910073Sandreas@sandberg.pp.se# ----------------------
17010073Sandreas@sandberg.pp.se
17110073Sandreas@sandberg.pp.seclass L2(BaseCache):
17211629Smichael.lebeane@amd.com    block_size = 64
17311629Smichael.lebeane@amd.com    latency = options.l2latency
17411629Smichael.lebeane@amd.com    mshrs = 92
17511629Smichael.lebeane@amd.com    tgts_per_mshr = 16
17611629Smichael.lebeane@amd.com    write_buffers = 8
17711629Smichael.lebeane@amd.com
17811629Smichael.lebeane@amd.com# ----------------------
17911629Smichael.lebeane@amd.com# Define the cpus
18011629Smichael.lebeane@amd.com# ----------------------
18111629Smichael.lebeane@amd.com
18211629Smichael.lebeane@amd.combusFrequency = Frequency(options.frequency)
18311629Smichael.lebeane@amd.com
18411629Smichael.lebeane@amd.comif options.timing:
18511629Smichael.lebeane@amd.com    cpus = [TimingSimpleCPU(cpu_id = i,
18611629Smichael.lebeane@amd.com                            clock=options.frequency)
18711629Smichael.lebeane@amd.com            for i in xrange(options.numcpus)]
18811629Smichael.lebeane@amd.comelif options.detailed:
18911629Smichael.lebeane@amd.com    cpus = [DerivO3CPU(cpu_id = i,
19011629Smichael.lebeane@amd.com                       clock=options.frequency)
19111629Smichael.lebeane@amd.com            for i in xrange(options.numcpus)]
19211629Smichael.lebeane@amd.comelse:
19311629Smichael.lebeane@amd.com    cpus = [AtomicSimpleCPU(cpu_id = i,
19411629Smichael.lebeane@amd.com                            clock=options.frequency)
19511629Smichael.lebeane@amd.com            for i in xrange(options.numcpus)]
19611629Smichael.lebeane@amd.com
19711629Smichael.lebeane@amd.com# ----------------------
19811629Smichael.lebeane@amd.com# Create a system, and add system wide objects
19911629Smichael.lebeane@amd.com# ----------------------
20011629Smichael.lebeane@amd.comsystem = System(cpu = cpus, physmem = PhysicalMemory(),
20111629Smichael.lebeane@amd.com                membus = Bus(clock = busFrequency))
20211629Smichael.lebeane@amd.com
20311629Smichael.lebeane@amd.comsystem.toL2bus = Bus(clock = busFrequency)
20411629Smichael.lebeane@amd.comsystem.l2 = L2(size = options.l2size, assoc = 8)
20511629Smichael.lebeane@amd.com
20611629Smichael.lebeane@amd.com# ----------------------
20711629Smichael.lebeane@amd.com# Connect the L2 cache and memory together
20811629Smichael.lebeane@amd.com# ----------------------
20911629Smichael.lebeane@amd.com
21011629Smichael.lebeane@amd.comsystem.physmem.port = system.membus.master
21111629Smichael.lebeane@amd.comsystem.l2.cpu_side = system.toL2bus.master
21211629Smichael.lebeane@amd.comsystem.l2.mem_side = system.membus.slave
21311629Smichael.lebeane@amd.comsystem.system_port = system.membus.slave
21411629Smichael.lebeane@amd.com
21511629Smichael.lebeane@amd.com# ----------------------
21611629Smichael.lebeane@amd.com# Connect the L2 cache and clusters together
21711629Smichael.lebeane@amd.com# ----------------------
21811629Smichael.lebeane@amd.comfor cpu in cpus:
21911629Smichael.lebeane@amd.com    cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1),
22011629Smichael.lebeane@amd.com                                L1(size = options.l1size, assoc = 4))
22111629Smichael.lebeane@amd.com    # connect cpu level-1 caches to shared level-2 cache
22211629Smichael.lebeane@amd.com    cpu.connectAllPorts(system.toL2bus, system.membus)
22311629Smichael.lebeane@amd.com
22411629Smichael.lebeane@amd.com
22511629Smichael.lebeane@amd.com# ----------------------
22611629Smichael.lebeane@amd.com# Define the root
22711629Smichael.lebeane@amd.com# ----------------------
22811629Smichael.lebeane@amd.com
22911629Smichael.lebeane@amd.comroot = Root(full_system = False, system = system)
23011629Smichael.lebeane@amd.com
23111629Smichael.lebeane@amd.com# --------------------
23211629Smichael.lebeane@amd.com# Pick the correct Splash2 Benchmarks
23311629Smichael.lebeane@amd.com# ====================
23411629Smichael.lebeane@amd.comif options.benchmark == 'Cholesky':
23511629Smichael.lebeane@amd.com    root.workload = Cholesky()
23611629Smichael.lebeane@amd.comelif options.benchmark == 'FFT':
23711629Smichael.lebeane@amd.com    root.workload = FFT()
23811629Smichael.lebeane@amd.comelif options.benchmark == 'LUContig':
23911629Smichael.lebeane@amd.com    root.workload = LU_contig()
24011629Smichael.lebeane@amd.comelif options.benchmark == 'LUNoncontig':
24111629Smichael.lebeane@amd.com    root.workload = LU_noncontig()
24210073Sandreas@sandberg.pp.seelif options.benchmark == 'Radix':
24310073Sandreas@sandberg.pp.se    root.workload = Radix()
24410073Sandreas@sandberg.pp.seelif options.benchmark == 'Barnes':
24510073Sandreas@sandberg.pp.se    root.workload = Barnes()
24610073Sandreas@sandberg.pp.seelif options.benchmark == 'FMM':
24710073Sandreas@sandberg.pp.se    root.workload = FMM()
24810073Sandreas@sandberg.pp.seelif options.benchmark == 'OceanContig':
24910073Sandreas@sandberg.pp.se    root.workload = Ocean_contig()
25010073Sandreas@sandberg.pp.seelif options.benchmark == 'OceanNoncontig':
25110073Sandreas@sandberg.pp.se    root.workload = Ocean_noncontig()
25210114Sandreas@sandberg.pp.seelif options.benchmark == 'Raytrace':
25310114Sandreas@sandberg.pp.se    root.workload = Raytrace()
25410098Sandreas@sandberg.pp.seelif options.benchmark == 'WaterNSquared':
25510098Sandreas@sandberg.pp.se    root.workload = Water_nsquared()
25610098Sandreas@sandberg.pp.seelif options.benchmark == 'WaterSpatial':
25710098Sandreas@sandberg.pp.se    root.workload = Water_spatial()
25810073Sandreas@sandberg.pp.seelse:
25910073Sandreas@sandberg.pp.se    print >> sys.stderr, """The --benchmark environment variable was set to something improper.
26010073Sandreas@sandberg.pp.seUse Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig,
26110073Sandreas@sandberg.pp.seOceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial"""
26210114Sandreas@sandberg.pp.se    sys.exit(1)
26310073Sandreas@sandberg.pp.se
26410073Sandreas@sandberg.pp.se# --------------------
26510073Sandreas@sandberg.pp.se# Assign the workload to the cpus
26610114Sandreas@sandberg.pp.se# ====================
26710073Sandreas@sandberg.pp.se
26810073Sandreas@sandberg.pp.sefor cpu in cpus:
26910073Sandreas@sandberg.pp.se    cpu.workload = root.workload
2709651SAndreas.Sandberg@ARM.com
2719651SAndreas.Sandberg@ARM.com# ----------------------
2729651SAndreas.Sandberg@ARM.com# Run the simulation
2739651SAndreas.Sandberg@ARM.com# ----------------------
2749651SAndreas.Sandberg@ARM.com
2759651SAndreas.Sandberg@ARM.comif options.timing or options.detailed:
2769651SAndreas.Sandberg@ARM.com    root.system.mem_mode = 'timing'
2779651SAndreas.Sandberg@ARM.com
2789651SAndreas.Sandberg@ARM.com# instantiate configuration
2799684Sandreas@sandberg.pp.sem5.instantiate()
2809684Sandreas@sandberg.pp.se
2819684Sandreas@sandberg.pp.se# simulate until program terminates
2829684Sandreas@sandberg.pp.seif options.maxtick:
2839684Sandreas@sandberg.pp.se    exit_event = m5.simulate(options.maxtick)
2849651SAndreas.Sandberg@ARM.comelse:
2859651SAndreas.Sandberg@ARM.com    exit_event = m5.simulate(m5.MaxTick)
2869651SAndreas.Sandberg@ARM.com
2879651SAndreas.Sandberg@ARM.comprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
2889651SAndreas.Sandberg@ARM.com
2899755Sandreas@sandberg.pp.se