run.py revision 8931
12428SN/A# Copyright (c) 2005-2007 The Regents of The University of Michigan 22428SN/A# All rights reserved. 32428SN/A# 42428SN/A# Redistribution and use in source and binary forms, with or without 52428SN/A# modification, are permitted provided that the following conditions are 62428SN/A# met: redistributions of source code must retain the above copyright 72428SN/A# notice, this list of conditions and the following disclaimer; 82428SN/A# redistributions in binary form must reproduce the above copyright 92428SN/A# notice, this list of conditions and the following disclaimer in the 102428SN/A# documentation and/or other materials provided with the distribution; 112428SN/A# neither the name of the copyright holders nor the names of its 122428SN/A# contributors may be used to endorse or promote products derived from 132428SN/A# this software without specific prior written permission. 142428SN/A# 152428SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162428SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 172428SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 182428SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 192428SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 202428SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 212428SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222428SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232428SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242428SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 252428SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262428SN/A# 272665Ssaidi@eecs.umich.edu# Authors: Ron Dreslinski 282665Ssaidi@eecs.umich.edu 292665Ssaidi@eecs.umich.edu# Splash2 Run Script 302428SN/A# 312428SN/A 322428SN/Aimport os 332428SN/Aimport optparse 342428SN/Aimport sys 358229Snate@binkert.org 366214Snate@binkert.orgimport m5 372428SN/Afrom m5.objects import * 385569Snate@binkert.org 395569Snate@binkert.orgm5.util.addToPath('../common') 405569Snate@binkert.org 415569Snate@binkert.org# -------------------- 425569Snate@binkert.org# Define Command Line Options 437720Sgblack@eecs.umich.edu# ==================== 447720Sgblack@eecs.umich.edu 455569Snate@binkert.orgparser = optparse.OptionParser() 465569Snate@binkert.org 475569Snate@binkert.orgparser.add_option("-d", "--detailed", action="store_true") 485569Snate@binkert.orgparser.add_option("-t", "--timing", action="store_true") 495569Snate@binkert.orgparser.add_option("-m", "--maxtick", type="int") 505569Snate@binkert.orgparser.add_option("-n", "--numcpus", 518902Sandreas.hansson@arm.com help="Number of cpus in total", type="int") 525569Snate@binkert.orgparser.add_option("-f", "--frequency", 532428SN/A default = "1GHz", 542428SN/A help="Frequency of each CPU") 552428SN/Aparser.add_option("--l1size", 565569Snate@binkert.org default = "32kB") 57parser.add_option("--l1latency", 58 default = "1ns") 59parser.add_option("--l2size", 60 default = "256kB") 61parser.add_option("--l2latency", 62 default = "10ns") 63parser.add_option("--rootdir", 64 help="Root directory of Splash2", 65 default="/dist/splash2/codes") 66parser.add_option("-b", "--benchmark", 67 help="Splash 2 benchmark to run") 68 69(options, args) = parser.parse_args() 70 71if args: 72 print "Error: script doesn't take any positional arguments" 73 sys.exit(1) 74 75if not options.numcpus: 76 print "Specify the number of cpus with -n" 77 sys.exit(1) 78 79# -------------------- 80# Define Splash2 Benchmarks 81# ==================== 82class Cholesky(LiveProcess): 83 cwd = options.rootdir + '/kernels/cholesky' 84 executable = options.rootdir + '/kernels/cholesky/CHOLESKY' 85 cmd = ['CHOLESKY', '-p' + str(options.numcpus), 86 options.rootdir + '/kernels/cholesky/inputs/tk23.O'] 87 88class FFT(LiveProcess): 89 cwd = options.rootdir + '/kernels/fft' 90 executable = options.rootdir + '/kernels/fft/FFT' 91 cmd = ['FFT', '-p', str(options.numcpus), '-m18'] 92 93class LU_contig(LiveProcess): 94 executable = options.rootdir + '/kernels/lu/contiguous_blocks/LU' 95 cmd = ['LU', '-p', str(options.numcpus)] 96 cwd = options.rootdir + '/kernels/lu/contiguous_blocks' 97 98class LU_noncontig(LiveProcess): 99 executable = options.rootdir + '/kernels/lu/non_contiguous_blocks/LU' 100 cmd = ['LU', '-p', str(options.numcpus)] 101 cwd = options.rootdir + '/kernels/lu/non_contiguous_blocks' 102 103class Radix(LiveProcess): 104 executable = options.rootdir + '/kernels/radix/RADIX' 105 cmd = ['RADIX', '-n524288', '-p', str(options.numcpus)] 106 cwd = options.rootdir + '/kernels/radix' 107 108class Barnes(LiveProcess): 109 executable = options.rootdir + '/apps/barnes/BARNES' 110 cmd = ['BARNES'] 111 input = options.rootdir + '/apps/barnes/input.p' + str(options.numcpus) 112 cwd = options.rootdir + '/apps/barnes' 113 114class FMM(LiveProcess): 115 executable = options.rootdir + '/apps/fmm/FMM' 116 cmd = ['FMM'] 117 if str(options.numcpus) == '1': 118 input = options.rootdir + '/apps/fmm/inputs/input.2048' 119 else: 120 input = options.rootdir + '/apps/fmm/inputs/input.2048.p' + str(options.numcpus) 121 cwd = options.rootdir + '/apps/fmm' 122 123class Ocean_contig(LiveProcess): 124 executable = options.rootdir + '/apps/ocean/contiguous_partitions/OCEAN' 125 cmd = ['OCEAN', '-p', str(options.numcpus)] 126 cwd = options.rootdir + '/apps/ocean/contiguous_partitions' 127 128class Ocean_noncontig(LiveProcess): 129 executable = options.rootdir + '/apps/ocean/non_contiguous_partitions/OCEAN' 130 cmd = ['OCEAN', '-p', str(options.numcpus)] 131 cwd = options.rootdir + '/apps/ocean/non_contiguous_partitions' 132 133class Raytrace(LiveProcess): 134 executable = options.rootdir + '/apps/raytrace/RAYTRACE' 135 cmd = ['RAYTRACE', '-p' + str(options.numcpus), 136 options.rootdir + '/apps/raytrace/inputs/teapot.env'] 137 cwd = options.rootdir + '/apps/raytrace' 138 139class Water_nsquared(LiveProcess): 140 executable = options.rootdir + '/apps/water-nsquared/WATER-NSQUARED' 141 cmd = ['WATER-NSQUARED'] 142 if options.numcpus==1: 143 input = options.rootdir + '/apps/water-nsquared/input' 144 else: 145 input = options.rootdir + '/apps/water-nsquared/input.p' + str(options.numcpus) 146 cwd = options.rootdir + '/apps/water-nsquared' 147 148class Water_spatial(LiveProcess): 149 executable = options.rootdir + '/apps/water-spatial/WATER-SPATIAL' 150 cmd = ['WATER-SPATIAL'] 151 if options.numcpus==1: 152 input = options.rootdir + '/apps/water-spatial/input' 153 else: 154 input = options.rootdir + '/apps/water-spatial/input.p' + str(options.numcpus) 155 cwd = options.rootdir + '/apps/water-spatial' 156 157# -------------------- 158# Base L1 Cache Definition 159# ==================== 160 161class L1(BaseCache): 162 latency = options.l1latency 163 block_size = 64 164 mshrs = 12 165 tgts_per_mshr = 8 166 167# ---------------------- 168# Base L2 Cache Definition 169# ---------------------- 170 171class L2(BaseCache): 172 block_size = 64 173 latency = options.l2latency 174 mshrs = 92 175 tgts_per_mshr = 16 176 write_buffers = 8 177 178# ---------------------- 179# Define the cpus 180# ---------------------- 181 182busFrequency = Frequency(options.frequency) 183 184if options.timing: 185 cpus = [TimingSimpleCPU(cpu_id = i, 186 clock=options.frequency) 187 for i in xrange(options.numcpus)] 188elif options.detailed: 189 cpus = [DerivO3CPU(cpu_id = i, 190 clock=options.frequency) 191 for i in xrange(options.numcpus)] 192else: 193 cpus = [AtomicSimpleCPU(cpu_id = i, 194 clock=options.frequency) 195 for i in xrange(options.numcpus)] 196 197# ---------------------- 198# Create a system, and add system wide objects 199# ---------------------- 200system = System(cpu = cpus, physmem = SimpleMemory(), 201 membus = Bus(clock = busFrequency)) 202 203system.toL2bus = Bus(clock = busFrequency) 204system.l2 = L2(size = options.l2size, assoc = 8) 205 206# ---------------------- 207# Connect the L2 cache and memory together 208# ---------------------- 209 210system.physmem.port = system.membus.master 211system.l2.cpu_side = system.toL2bus.master 212system.l2.mem_side = system.membus.slave 213system.system_port = system.membus.slave 214 215# ---------------------- 216# Connect the L2 cache and clusters together 217# ---------------------- 218for cpu in cpus: 219 cpu.addPrivateSplitL1Caches(L1(size = options.l1size, assoc = 1), 220 L1(size = options.l1size, assoc = 4)) 221 # connect cpu level-1 caches to shared level-2 cache 222 cpu.connectAllPorts(system.toL2bus, system.membus) 223 224 225# ---------------------- 226# Define the root 227# ---------------------- 228 229root = Root(full_system = False, system = system) 230 231# -------------------- 232# Pick the correct Splash2 Benchmarks 233# ==================== 234if options.benchmark == 'Cholesky': 235 root.workload = Cholesky() 236elif options.benchmark == 'FFT': 237 root.workload = FFT() 238elif options.benchmark == 'LUContig': 239 root.workload = LU_contig() 240elif options.benchmark == 'LUNoncontig': 241 root.workload = LU_noncontig() 242elif options.benchmark == 'Radix': 243 root.workload = Radix() 244elif options.benchmark == 'Barnes': 245 root.workload = Barnes() 246elif options.benchmark == 'FMM': 247 root.workload = FMM() 248elif options.benchmark == 'OceanContig': 249 root.workload = Ocean_contig() 250elif options.benchmark == 'OceanNoncontig': 251 root.workload = Ocean_noncontig() 252elif options.benchmark == 'Raytrace': 253 root.workload = Raytrace() 254elif options.benchmark == 'WaterNSquared': 255 root.workload = Water_nsquared() 256elif options.benchmark == 'WaterSpatial': 257 root.workload = Water_spatial() 258else: 259 print >> sys.stderr, """The --benchmark environment variable was set to something improper. 260Use Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig, 261OceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial""" 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