run.py revision 3358
1# Copyright (c) 2005-2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright 9# notice, this list of conditions and the following disclaimer in the 10# documentation and/or other materials provided with the distribution; 11# neither the name of the copyright holders nor the names of its 12# contributors may be used to endorse or promote products derived from 13# this software without specific prior written permission. 14# 15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26# 27# Authors: Ron Dreslinski 28 29# Splash2 Run Script 30# 31 32import m5 33from m5.objects import * 34import os, optparse, sys 35m5.AddToPath('../common') 36 37# -------------------- 38# Define Command Line Options 39# ==================== 40 41parser = optparse.OptionParser() 42 43parser.add_option("-d", "--detailed", action="store_true") 44parser.add_option("-t", "--timing", action="store_true") 45parser.add_option("-m", "--maxtick", type="int") 46parser.add_option("-n", "--numcpus", 47 help="Number of cpus in total", type="int") 48parser.add_option("-f", "--frequency", 49 help="Frequency of each CPU") 50parser.add_option("-p", "--protocol", 51 default="moesi", 52 help="The coherence protocol to use for the L1'a (i.e. MOESI, MOSI)") 53parser.add_option("--l1size") 54parser.add_option("--l1latency") 55parser.add_option("--l2size") 56parser.add_option("--l2latency") 57parser.add_option("--rootdir", 58 help="ROot directory of Splash2", 59 default="../../Splash2/codes") 60parser.add_option("-b", "--benchmark", 61 help="Splash 2 benchmark to run") 62 63(options, args) = parser.parse_args() 64 65if args: 66 print "Error: script doesn't take any positional arguments" 67 sys.exit(1) 68 69# -------------------- 70# Define Splash2 Benchmarks 71# ==================== 72class Cholesky(LiveProcess): 73 executable = options.rootdir + '/kernels/cholesky/CHOLESKY' 74 cmd = 'CHOLESKY -p' + str(options.numcpus) + ' '\ 75 + options.rootdir + '/kernels/cholesky/inputs/tk23.O' 76 77class FFT(LiveProcess): 78 executable = options.rootdir + 'kernels/fft/FFT' 79 cmd = 'FFT -p' + str(options.numcpus) + ' -m18' 80 81class LU_contig(LiveProcess): 82 executable = options.rootdir + 'kernels/lu/contiguous_blocks/LU' 83 cmd = 'LU -p' + str(options.numcpus) 84 85class LU_noncontig(LiveProcess): 86 executable = options.rootdir + 'kernels/lu/non_contiguous_blocks/LU' 87 cmd = 'LU -p' + str(options.numcpus) 88 89class Radix(LiveProcess): 90 executable = options.rootdir + 'kernels/radix/RADIX' 91 cmd = 'RADIX -n524288 -p' + str(options.numcpus) 92 93class Barnes(LiveProcess): 94 executable = options.rootdir + 'apps/barnes/BARNES' 95 cmd = 'BARNES' 96 input = options.rootdir + 'apps/barnes/input.p' + str(options.numcpus) 97 98class FMM(LiveProcess): 99 executable = options.rootdir + 'apps/fmm/FMM' 100 cmd = 'FMM' 101 input = options.rootdir + 'apps/fmm/inputs/input.2048.p' + str(options.numcpus) 102 103class Ocean_contig(LiveProcess): 104 executable = options.rootdir + 'apps/ocean/contiguous_partitions/OCEAN' 105 cmd = 'OCEAN -p' + str(options.numcpus) 106 107class Ocean_noncontig(LiveProcess): 108 executable = options.rootdir + 'apps/ocean/non_contiguous_partitions/OCEAN' 109 cmd = 'OCEAN -p' + str(options.numcpus) 110 111class Raytrace(LiveProcess): 112 executable = options.rootdir + 'apps/raytrace/RAYTRACE' 113 cmd = 'RAYTRACE -p' + str(options.numcpus) + ' ' \ 114 + options.rootdir + 'apps/raytrace/inputs/teapot.env' 115 116class Water_nsquared(LiveProcess): 117 executable = options.rootdir + 'apps/water-nsquared/WATER-NSQUARED' 118 cmd = 'WATER-NSQUARED' 119 input = options.rootdir + 'apps/water-nsquared/input.p' + str(options.numcpus) 120 121class Water_spatial(LiveProcess): 122 executable = options.rootdir + 'apps/water-spatial/WATER-SPATIAL' 123 cmd = 'WATER-SPATIAL' 124 input = options.rootdir + 'apps/water-spatial/input.p' + str(options.numcpus) 125 126 127# -------------------- 128# Base L1 Cache Definition 129# ==================== 130 131class L1(BaseCache): 132 latency = options.l1latency 133 block_size = 64 134 mshrs = 12 135 tgts_per_mshr = 8 136 protocol = CoherenceProtocol(protocol=options.protocol) 137 138# ---------------------- 139# Base L2 Cache Definition 140# ---------------------- 141 142class L2(BaseCache): 143 block_size = 64 144 latency = options.l2latency 145 mshrs = 92 146 tgts_per_mshr = 16 147 write_buffers = 8 148 149# ---------------------- 150# Define the cpus 151# ---------------------- 152 153busFrequency = Frequency(options.frequency) 154 155if options.timing: 156 cpus = [TimingSimpleCPU(cpu_id = i, 157 clock=options.frequency) 158 for i in xrange(options.numcpus)] 159elif options.detailed: 160 cpus = [DerivO3CPU(cpu_id = i, 161 clock=options.frequency) 162 for i in xrange(options.numcpus)] 163else: 164 cpus = [AtomicSimpleCPU(cpu_id = i, 165 clock=options.frequency) 166 for i in xrange(options.numcpus)] 167 168# ---------------------- 169# Create a system, and add system wide objects 170# ---------------------- 171system = System(cpu = cpus, physmem = PhysicalMemory(), 172 membus = Bus(clock = busFrequency)) 173 174system.toL2bus = Bus(clock = busFrequency) 175system.l2 = L2(size = options.l2size, assoc = 8) 176 177# ---------------------- 178# Connect the L2 cache and memory together 179# ---------------------- 180 181system.physmem.port = system.membus.port 182system.l2.cpu_side = system.toL2bus.port 183system.l2.mem_side = system.membus.port 184 185# ---------------------- 186# Connect the L2 cache and clusters together 187# ---------------------- 188for cpu in cpus: 189 cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1), 190 L1(size = options.l1size, assoc = 4)) 191 cpu.mem = cpu.dcache 192 # connect cpu level-1 caches to shared level-2 cache 193 cpu.connectMemPorts(system.toL2bus) 194 195 196# ---------------------- 197# Define the root 198# ---------------------- 199 200root = Root(system = system) 201 202# -------------------- 203# Pick the correct Splash2 Benchmarks 204# ==================== 205if options.benchmark == 'Cholesky': 206 root.workload = Cholesky() 207elif options.benchmark == 'FFT': 208 root.workload = FFT() 209elif options.benchmark == 'LUContig': 210 root.workload = LU_contig() 211elif options.benchmark == 'LUNoncontig': 212 root.workload = LU_noncontig() 213elif options.benchmark == 'Radix': 214 root.workload = Radix() 215elif options.benchmark == 'Barnes': 216 root.workload = Barnes() 217elif options.benchmark == 'FMM': 218 root.workload = FMM() 219elif options.benchmark == 'OceanContig': 220 root.workload = Ocean_contig() 221elif options.benchmark == 'OceanNoncontig': 222 root.workload = Ocean_noncontig() 223elif options.benchmark == 'Raytrace': 224 root.workload = Raytrace() 225elif options.benchmark == 'WaterNSquared': 226 root.workload = Water_nsquared() 227elif options.benchmark == 'WaterSpatial': 228 root.workload = Water_spatial() 229else: 230 panic("The --benchmark environment variable was set to something" \ 231 +" improper.\nUse Cholesky, FFT, LUContig, LUNoncontig, Radix" \ 232 +", Barnes, FMM, OceanContig,\nOceanNoncontig, Raytrace," \ 233 +" WaterNSquared, or WaterSpatial\n") 234 235# -------------------- 236# Assign the workload to the cpus 237# ==================== 238 239for cpu in cpus: 240 cpu.workload = root.workload 241 242# ---------------------- 243# Run the simulation 244# ---------------------- 245 246if options.timing or options.detailed: 247 root.system.mem_mode = 'timing' 248 249# instantiate configuration 250m5.instantiate(root) 251 252# simulate until program terminates 253if options.maxtick: 254 exit_event = m5.simulate(options.maxtick) 255else: 256 exit_event = m5.simulate() 257 258print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 259 260