run.py revision 13774
16657Snate@binkert.org# Copyright (c) 2005-2007 The Regents of The University of Michigan
26657Snate@binkert.org# All rights reserved.
36657Snate@binkert.org#
46657Snate@binkert.org# Redistribution and use in source and binary forms, with or without
56657Snate@binkert.org# modification, are permitted provided that the following conditions are
66657Snate@binkert.org# met: redistributions of source code must retain the above copyright
76657Snate@binkert.org# notice, this list of conditions and the following disclaimer;
86657Snate@binkert.org# redistributions in binary form must reproduce the above copyright
96657Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
106657Snate@binkert.org# documentation and/or other materials provided with the distribution;
116657Snate@binkert.org# neither the name of the copyright holders nor the names of its
126657Snate@binkert.org# contributors may be used to endorse or promote products derived from
136657Snate@binkert.org# this software without specific prior written permission.
146657Snate@binkert.org#
156657Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
166657Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
176657Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
186657Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
196657Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
206657Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
216657Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
226657Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
236657Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
246657Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
256657Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
266657Snate@binkert.org#
276657Snate@binkert.org# Authors: Ron Dreslinski
286999Snate@binkert.org
296657Snate@binkert.org# Splash2 Run Script
306657Snate@binkert.org#
316657Snate@binkert.org
326657Snate@binkert.orgfrom __future__ import print_function
336657Snate@binkert.orgfrom __future__ import absolute_import
346657Snate@binkert.org
356657Snate@binkert.orgimport os
366657Snate@binkert.orgimport optparse
376657Snate@binkert.orgimport sys
386657Snate@binkert.org
396657Snate@binkert.orgimport m5
406657Snate@binkert.orgfrom m5.objects import *
416657Snate@binkert.org
426657Snate@binkert.org# --------------------
436657Snate@binkert.org# Define Command Line Options
446657Snate@binkert.org# ====================
456657Snate@binkert.org
466657Snate@binkert.orgparser = optparse.OptionParser()
476657Snate@binkert.org
486657Snate@binkert.orgparser.add_option("-d", "--detailed", action="store_true")
496657Snate@binkert.orgparser.add_option("-t", "--timing", action="store_true")
506657Snate@binkert.orgparser.add_option("-m", "--maxtick", type="int")
516657Snate@binkert.orgparser.add_option("-n", "--numcpus",
526657Snate@binkert.org                  help="Number of cpus in total", type="int")
536657Snate@binkert.orgparser.add_option("-f", "--frequency",
546882SBrad.Beckmann@amd.com                  default = "1GHz",
556657Snate@binkert.org                  help="Frequency of each CPU")
566657Snate@binkert.orgparser.add_option("--l1size",
576657Snate@binkert.org                  default = "32kB")
586657Snate@binkert.orgparser.add_option("--l1latency",
596657Snate@binkert.org                  default = "1ns")
606657Snate@binkert.orgparser.add_option("--l2size",
616657Snate@binkert.org                  default = "256kB")
626657Snate@binkert.orgparser.add_option("--l2latency",
636657Snate@binkert.org                  default = "10ns")
646657Snate@binkert.orgparser.add_option("--rootdir",
656657Snate@binkert.org                  help="Root directory of Splash2",
666657Snate@binkert.org                  default="/dist/splash2/codes")
676657Snate@binkert.orgparser.add_option("-b", "--benchmark",
686657Snate@binkert.org                  help="Splash 2 benchmark to run")
696657Snate@binkert.org
706657Snate@binkert.org(options, args) = parser.parse_args()
716657Snate@binkert.org
726657Snate@binkert.orgif args:
736657Snate@binkert.org    print("Error: script doesn't take any positional arguments")
746657Snate@binkert.org    sys.exit(1)
756657Snate@binkert.org
766657Snate@binkert.orgif not options.numcpus:
776657Snate@binkert.org    print("Specify the number of cpus with -n")
786657Snate@binkert.org    sys.exit(1)
796657Snate@binkert.org
806657Snate@binkert.org# --------------------
816657Snate@binkert.org# Define Splash2 Benchmarks
826657Snate@binkert.org# ====================
836657Snate@binkert.orgclass Cholesky(Process):
846657Snate@binkert.org    cwd = options.rootdir + '/kernels/cholesky'
856657Snate@binkert.org    executable = options.rootdir + '/kernels/cholesky/CHOLESKY'
866657Snate@binkert.org    cmd = ['CHOLESKY', '-p' +  str(options.numcpus),
876657Snate@binkert.org            options.rootdir + '/kernels/cholesky/inputs/tk23.O']
886657Snate@binkert.org
896657Snate@binkert.orgclass FFT(Process):
906657Snate@binkert.org    cwd = options.rootdir + '/kernels/fft'
916657Snate@binkert.org    executable = options.rootdir + '/kernels/fft/FFT'
926657Snate@binkert.org    cmd = ['FFT', '-p', str(options.numcpus), '-m18']
936657Snate@binkert.org
946657Snate@binkert.orgclass LU_contig(Process):
956657Snate@binkert.org    executable = options.rootdir + '/kernels/lu/contiguous_blocks/LU'
966657Snate@binkert.org    cmd = ['LU', '-p', str(options.numcpus)]
976657Snate@binkert.org    cwd = options.rootdir + '/kernels/lu/contiguous_blocks'
986657Snate@binkert.org
996657Snate@binkert.orgclass LU_noncontig(Process):
1006657Snate@binkert.org    executable = options.rootdir + '/kernels/lu/non_contiguous_blocks/LU'
1016657Snate@binkert.org    cmd = ['LU', '-p', str(options.numcpus)]
1026657Snate@binkert.org    cwd = options.rootdir + '/kernels/lu/non_contiguous_blocks'
1038086SBrad.Beckmann@amd.com
1048086SBrad.Beckmann@amd.comclass Radix(Process):
1058086SBrad.Beckmann@amd.com    executable = options.rootdir + '/kernels/radix/RADIX'
1066657Snate@binkert.org    cmd = ['RADIX', '-n524288', '-p', str(options.numcpus)]
1076657Snate@binkert.org    cwd = options.rootdir + '/kernels/radix'
1086657Snate@binkert.org
1096657Snate@binkert.orgclass Barnes(Process):
1106657Snate@binkert.org    executable = options.rootdir + '/apps/barnes/BARNES'
1116657Snate@binkert.org    cmd = ['BARNES']
1126657Snate@binkert.org    input = options.rootdir + '/apps/barnes/input.p' + str(options.numcpus)
1136657Snate@binkert.org    cwd = options.rootdir + '/apps/barnes'
1146657Snate@binkert.org
1156657Snate@binkert.orgclass FMM(Process):
1166657Snate@binkert.org    executable = options.rootdir + '/apps/fmm/FMM'
1176657Snate@binkert.org    cmd = ['FMM']
1186657Snate@binkert.org    if str(options.numcpus) == '1':
1196657Snate@binkert.org        input = options.rootdir + '/apps/fmm/inputs/input.2048'
1206657Snate@binkert.org    else:
1216657Snate@binkert.org        input = options.rootdir + '/apps/fmm/inputs/input.2048.p' + str(options.numcpus)
1226657Snate@binkert.org    cwd = options.rootdir + '/apps/fmm'
1236657Snate@binkert.org
1246657Snate@binkert.orgclass Ocean_contig(Process):
1256657Snate@binkert.org    executable = options.rootdir + '/apps/ocean/contiguous_partitions/OCEAN'
1266657Snate@binkert.org    cmd = ['OCEAN', '-p', str(options.numcpus)]
1276657Snate@binkert.org    cwd = options.rootdir + '/apps/ocean/contiguous_partitions'
1286657Snate@binkert.org
1296657Snate@binkert.orgclass Ocean_noncontig(Process):
1306657Snate@binkert.org    executable = options.rootdir + '/apps/ocean/non_contiguous_partitions/OCEAN'
1316657Snate@binkert.org    cmd = ['OCEAN', '-p', str(options.numcpus)]
1326657Snate@binkert.org    cwd = options.rootdir + '/apps/ocean/non_contiguous_partitions'
1336657Snate@binkert.org
1346657Snate@binkert.orgclass Raytrace(Process):
1356657Snate@binkert.org    executable = options.rootdir + '/apps/raytrace/RAYTRACE'
1366657Snate@binkert.org    cmd = ['RAYTRACE', '-p' + str(options.numcpus),
1376657Snate@binkert.org           options.rootdir + '/apps/raytrace/inputs/teapot.env']
1386657Snate@binkert.org    cwd = options.rootdir + '/apps/raytrace'
1396657Snate@binkert.org
1406657Snate@binkert.orgclass Water_nsquared(Process):
1416657Snate@binkert.org    executable = options.rootdir + '/apps/water-nsquared/WATER-NSQUARED'
1426657Snate@binkert.org    cmd = ['WATER-NSQUARED']
1436657Snate@binkert.org    if options.numcpus==1:
1446657Snate@binkert.org        input = options.rootdir + '/apps/water-nsquared/input'
1456657Snate@binkert.org    else:
1466657Snate@binkert.org        input = options.rootdir + '/apps/water-nsquared/input.p' + str(options.numcpus)
1476657Snate@binkert.org    cwd = options.rootdir + '/apps/water-nsquared'
1486657Snate@binkert.org
1496657Snate@binkert.orgclass Water_spatial(Process):
1506657Snate@binkert.org    executable = options.rootdir + '/apps/water-spatial/WATER-SPATIAL'
1516657Snate@binkert.org    cmd = ['WATER-SPATIAL']
1526657Snate@binkert.org    if options.numcpus==1:
1536657Snate@binkert.org        input = options.rootdir + '/apps/water-spatial/input'
1546657Snate@binkert.org    else:
1556657Snate@binkert.org        input = options.rootdir + '/apps/water-spatial/input.p' + str(options.numcpus)
1566657Snate@binkert.org    cwd = options.rootdir + '/apps/water-spatial'
1576657Snate@binkert.org
1586657Snate@binkert.org# --------------------
1596657Snate@binkert.org# Base L1 Cache Definition
1606657Snate@binkert.org# ====================
1616882SBrad.Beckmann@amd.com
1626882SBrad.Beckmann@amd.comclass L1(Cache):
1636882SBrad.Beckmann@amd.com    latency = options.l1latency
1648086SBrad.Beckmann@amd.com    mshrs = 12
1658086SBrad.Beckmann@amd.com    tgts_per_mshr = 8
1668086SBrad.Beckmann@amd.com
1676657Snate@binkert.org# ----------------------
1686657Snate@binkert.org# Base L2 Cache Definition
1696657Snate@binkert.org# ----------------------
1706657Snate@binkert.org
1716657Snate@binkert.orgclass L2(Cache):
1726657Snate@binkert.org    latency = options.l2latency
1736657Snate@binkert.org    mshrs = 92
1746657Snate@binkert.org    tgts_per_mshr = 16
1756657Snate@binkert.org    write_buffers = 8
1766657Snate@binkert.org
1776657Snate@binkert.org# ----------------------
1786657Snate@binkert.org# Define the cpus
1796657Snate@binkert.org# ----------------------
1806657Snate@binkert.org
1816657Snate@binkert.orgbusFrequency = Frequency(options.frequency)
1826657Snate@binkert.org
1836657Snate@binkert.orgif options.timing:
1846657Snate@binkert.org    cpus = [TimingSimpleCPU(cpu_id = i,
1856657Snate@binkert.org                            clock=options.frequency)
1866657Snate@binkert.org            for i in range(options.numcpus)]
1876657Snate@binkert.orgelif options.detailed:
1886657Snate@binkert.org    cpus = [DerivO3CPU(cpu_id = i,
1896657Snate@binkert.org                       clock=options.frequency)
1906657Snate@binkert.org            for i in range(options.numcpus)]
1916657Snate@binkert.orgelse:
1926657Snate@binkert.org    cpus = [AtomicSimpleCPU(cpu_id = i,
1936657Snate@binkert.org                            clock=options.frequency)
1946657Snate@binkert.org            for i in range(options.numcpus)]
1956657Snate@binkert.org
1966657Snate@binkert.org# ----------------------
1976657Snate@binkert.org# Create a system, and add system wide objects
1986657Snate@binkert.org# ----------------------
1996657Snate@binkert.orgsystem = System(cpu = cpus, physmem = SimpleMemory(),
2006999Snate@binkert.org                membus = SystemXBar(clock = busFrequency))
2016657Snate@binkert.orgsystem.clock = '1GHz'
2026657Snate@binkert.org
2036657Snate@binkert.orgsystem.toL2bus = L2XBar(clock = busFrequency)
2046657Snate@binkert.orgsystem.l2 = L2(size = options.l2size, assoc = 8)
2056657Snate@binkert.org
2066657Snate@binkert.org# ----------------------
2076657Snate@binkert.org# Connect the L2 cache and memory together
2087007Snate@binkert.org# ----------------------
2097007Snate@binkert.org
2106657Snate@binkert.orgsystem.physmem.port = system.membus.master
2117002Snate@binkert.orgsystem.l2.cpu_side = system.toL2bus.master
2127002Snate@binkert.orgsystem.l2.mem_side = system.membus.slave
2136657Snate@binkert.orgsystem.system_port = system.membus.slave
2146657Snate@binkert.org
2156657Snate@binkert.org# ----------------------
2166657Snate@binkert.org# Connect the L2 cache and clusters together
2176657Snate@binkert.org# ----------------------
2186657Snate@binkert.orgfor cpu in cpus:
2196657Snate@binkert.org    cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1),
2206657Snate@binkert.org                                L1(size = options.l1size, assoc = 4))
2216657Snate@binkert.org    # connect cpu level-1 caches to shared level-2 cache
2226657Snate@binkert.org    cpu.connectAllPorts(system.toL2bus, system.membus)
2236657Snate@binkert.org
2246657Snate@binkert.org
2256657Snate@binkert.org# ----------------------
2267007Snate@binkert.org# Define the root
2277007Snate@binkert.org# ----------------------
2286657Snate@binkert.org
2296657Snate@binkert.orgroot = Root(full_system = False, system = system)
2307007Snate@binkert.org
2316657Snate@binkert.org# --------------------
2326657Snate@binkert.org# Pick the correct Splash2 Benchmarks
2336657Snate@binkert.org# ====================
2346657Snate@binkert.orgif options.benchmark == 'Cholesky':
2356657Snate@binkert.org    root.workload = Cholesky()
2366657Snate@binkert.orgelif options.benchmark == 'FFT':
2376657Snate@binkert.org    root.workload = FFT()
2386657Snate@binkert.orgelif options.benchmark == 'LUContig':
2396657Snate@binkert.org    root.workload = LU_contig()
2406657Snate@binkert.orgelif options.benchmark == 'LUNoncontig':
2416657Snate@binkert.org    root.workload = LU_noncontig()
2426657Snate@binkert.orgelif options.benchmark == 'Radix':
2436657Snate@binkert.org    root.workload = Radix()
2446657Snate@binkert.orgelif options.benchmark == 'Barnes':
2456657Snate@binkert.org    root.workload = Barnes()
2466657Snate@binkert.orgelif options.benchmark == 'FMM':
2476657Snate@binkert.org    root.workload = FMM()
2486657Snate@binkert.orgelif options.benchmark == 'OceanContig':
2496657Snate@binkert.org    root.workload = Ocean_contig()
2507453Snate@binkert.orgelif options.benchmark == 'OceanNoncontig':
2517453Snate@binkert.org    root.workload = Ocean_noncontig()
2527453Snate@binkert.orgelif options.benchmark == 'Raytrace':
2537453Snate@binkert.org    root.workload = Raytrace()
2547453Snate@binkert.orgelif options.benchmark == 'WaterNSquared':
2557453Snate@binkert.org    root.workload = Water_nsquared()
2567453Snate@binkert.orgelif options.benchmark == 'WaterSpatial':
2577453Snate@binkert.org    root.workload = Water_spatial()
2587453Snate@binkert.orgelse:
2597453Snate@binkert.org    print("The --benchmark environment variable was set to something "
2607453Snate@binkert.org          "improper. Use Cholesky, FFT, LUContig, LUNoncontig, Radix, "
2617453Snate@binkert.org          "Barnes, FMM, OceanContig, OceanNoncontig, Raytrace, WaterNSquared, "
2627453Snate@binkert.org          "or WaterSpatial", file=sys.stderr)
2637453Snate@binkert.org    sys.exit(1)
2647453Snate@binkert.org
2657453Snate@binkert.org# --------------------
2667453Snate@binkert.org# Assign the workload to the cpus
2676657Snate@binkert.org# ====================
2686657Snate@binkert.org
2696657Snate@binkert.orgfor cpu in cpus:
2706657Snate@binkert.org    cpu.workload = root.workload
2716657Snate@binkert.org
2726657Snate@binkert.org# ----------------------
2736657Snate@binkert.org# Run the simulation
2746657Snate@binkert.org# ----------------------
2756657Snate@binkert.org
2766657Snate@binkert.orgif options.timing or options.detailed:
2776657Snate@binkert.org    root.system.mem_mode = 'timing'
2786657Snate@binkert.org
2796657Snate@binkert.org# instantiate configuration
2806657Snate@binkert.orgm5.instantiate()
2816657Snate@binkert.org
2826657Snate@binkert.org# simulate until program terminates
2836657Snate@binkert.orgif options.maxtick:
2846657Snate@binkert.org    exit_event = m5.simulate(options.maxtick)
2856657Snate@binkert.orgelse:
2866657Snate@binkert.org    exit_event = m5.simulate(m5.MaxTick)
2876657Snate@binkert.org
2886657Snate@binkert.orgprint('Exiting @ tick', m5.curTick(), 'because', exit_event.getCause())
2897453Snate@binkert.org
2907453Snate@binkert.org