cluster.py revision 8931
112855Sgabeblack@google.com# Copyright (c) 2006-2007 The Regents of The University of Michigan 212855Sgabeblack@google.com# All rights reserved. 312855Sgabeblack@google.com# 412855Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 512855Sgabeblack@google.com# modification, are permitted provided that the following conditions are 612855Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 712855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 812855Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 912855Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 1012855Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 1112855Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 1212855Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 1312855Sgabeblack@google.com# this software without specific prior written permission. 1412855Sgabeblack@google.com# 1512855Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612855Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712855Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812855Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912855Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012855Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112855Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212855Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312855Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412855Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512855Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612855Sgabeblack@google.com# 2712855Sgabeblack@google.com# Authors: Ron Dreslinski 2812855Sgabeblack@google.com 2912855Sgabeblack@google.com# Simple test script 3012855Sgabeblack@google.com# 3112855Sgabeblack@google.com# "m5 test.py" 3212855Sgabeblack@google.com 3312855Sgabeblack@google.comimport os 3412855Sgabeblack@google.comimport optparse 3512855Sgabeblack@google.comimport sys 3612855Sgabeblack@google.com 3712855Sgabeblack@google.comimport m5 3812855Sgabeblack@google.comfrom m5.objects import * 3912855Sgabeblack@google.com 4012855Sgabeblack@google.comm5.util.addToPath('../common') 4112855Sgabeblack@google.com 4212855Sgabeblack@google.com# -------------------- 4312855Sgabeblack@google.com# Define Command Line Options 4412855Sgabeblack@google.com# ==================== 4512855Sgabeblack@google.com 4612855Sgabeblack@google.comparser = optparse.OptionParser() 4712855Sgabeblack@google.com 4812855Sgabeblack@google.comparser.add_option("-d", "--detailed", action="store_true") 4912855Sgabeblack@google.comparser.add_option("-t", "--timing", action="store_true") 5012855Sgabeblack@google.comparser.add_option("-m", "--maxtick", type="int") 5112855Sgabeblack@google.comparser.add_option("-c", "--numclusters", 5212855Sgabeblack@google.com help="Number of clusters", type="int") 5312855Sgabeblack@google.comparser.add_option("-n", "--numcpus", 5412855Sgabeblack@google.com help="Number of cpus in total", type="int") 5512855Sgabeblack@google.comparser.add_option("-f", "--frequency", 5612855Sgabeblack@google.com default = "1GHz", 5712855Sgabeblack@google.com help="Frequency of each CPU") 5812855Sgabeblack@google.comparser.add_option("--l1size", 5912855Sgabeblack@google.com default = "32kB") 6012855Sgabeblack@google.comparser.add_option("--l1latency", 6112855Sgabeblack@google.com default = 1) 6212855Sgabeblack@google.comparser.add_option("--l2size", 6312855Sgabeblack@google.com default = "256kB") 6412855Sgabeblack@google.comparser.add_option("--l2latency", 6512855Sgabeblack@google.com default = 10) 66parser.add_option("--rootdir", 67 help="ROot directory of Splash2", 68 default="/dist/splash2/codes/") 69parser.add_option("-b", "--benchmark", 70 help="Splash 2 benchmark to run") 71 72(options, args) = parser.parse_args() 73 74if args: 75 print "Error: script doesn't take any positional arguments" 76 sys.exit(1) 77 78# -------------------- 79# Define Splash2 Benchmarks 80# ==================== 81class Cholesky(LiveProcess): 82 executable = options.rootdir + '/kernels/cholesky/CHOLESKY' 83 cmd = 'CHOLESKY -p' + str(options.numcpus) + ' '\ 84 + options.rootdir + '/kernels/cholesky/inputs/tk23.O' 85 86class FFT(LiveProcess): 87 executable = options.rootdir + 'kernels/fft/FFT' 88 cmd = 'FFT -p' + str(options.numcpus) + ' -m18' 89 90class LU_contig(LiveProcess): 91 executable = options.rootdir + 'kernels/lu/contiguous_blocks/LU' 92 cmd = 'LU -p' + str(options.numcpus) 93 94class LU_noncontig(LiveProcess): 95 executable = options.rootdir + 'kernels/lu/non_contiguous_blocks/LU' 96 cmd = 'LU -p' + str(options.numcpus) 97 98class Radix(LiveProcess): 99 executable = options.rootdir + 'kernels/radix/RADIX' 100 cmd = 'RADIX -n524288 -p' + str(options.numcpus) 101 102class Barnes(LiveProcess): 103 executable = options.rootdir + 'apps/barnes/BARNES' 104 cmd = 'BARNES' 105 input = options.rootdir + 'apps/barnes/input.p' + str(options.numcpus) 106 107class FMM(LiveProcess): 108 executable = options.rootdir + 'apps/fmm/FMM' 109 cmd = 'FMM' 110 input = options.rootdir + 'apps/fmm/inputs/input.2048.p' + str(options.numcpus) 111 112class Ocean_contig(LiveProcess): 113 executable = options.rootdir + 'apps/ocean/contiguous_partitions/OCEAN' 114 cmd = 'OCEAN -p' + str(options.numcpus) 115 116class Ocean_noncontig(LiveProcess): 117 executable = options.rootdir + 'apps/ocean/non_contiguous_partitions/OCEAN' 118 cmd = 'OCEAN -p' + str(options.numcpus) 119 120class Raytrace(LiveProcess): 121 executable = options.rootdir + 'apps/raytrace/RAYTRACE' 122 cmd = 'RAYTRACE -p' + str(options.numcpus) + ' ' \ 123 + options.rootdir + 'apps/raytrace/inputs/teapot.env' 124 125class Water_nsquared(LiveProcess): 126 executable = options.rootdir + 'apps/water-nsquared/WATER-NSQUARED' 127 cmd = 'WATER-NSQUARED' 128 input = options.rootdir + 'apps/water-nsquared/input.p' + str(options.numcpus) 129 130class Water_spatial(LiveProcess): 131 executable = options.rootdir + 'apps/water-spatial/WATER-SPATIAL' 132 cmd = 'WATER-SPATIAL' 133 input = options.rootdir + 'apps/water-spatial/input.p' + str(options.numcpus) 134 135 136# -------------------- 137# Base L1 Cache Definition 138# ==================== 139 140class L1(BaseCache): 141 latency = options.l1latency 142 block_size = 64 143 mshrs = 12 144 tgts_per_mshr = 8 145 146# ---------------------- 147# Base L2 Cache Definition 148# ---------------------- 149 150class L2(BaseCache): 151 block_size = 64 152 latency = options.l2latency 153 mshrs = 92 154 tgts_per_mshr = 16 155 write_buffers = 8 156 157# ---------------------- 158# Define the clusters with their cpus 159# ---------------------- 160class Cluster: 161 pass 162 163cpusPerCluster = options.numcpus/options.numclusters 164 165busFrequency = Frequency(options.frequency) 166busFrequency *= cpusPerCluster 167 168all_cpus = [] 169all_l1s = [] 170all_l1buses = [] 171if options.timing: 172 clusters = [ Cluster() for i in xrange(options.numclusters)] 173 for j in xrange(options.numclusters): 174 clusters[j].id = j 175 for cluster in clusters: 176 cluster.clusterbus = Bus(clock=busFrequency) 177 all_l1buses += [cluster.clusterbus] 178 cluster.cpus = [TimingSimpleCPU(cpu_id = i + cluster.id, 179 clock=options.frequency) 180 for i in xrange(cpusPerCluster)] 181 all_cpus += cluster.cpus 182 cluster.l1 = L1(size=options.l1size, assoc = 4) 183 all_l1s += [cluster.l1] 184elif options.detailed: 185 clusters = [ Cluster() for i in xrange(options.numclusters)] 186 for j in xrange(options.numclusters): 187 clusters[j].id = j 188 for cluster in clusters: 189 cluster.clusterbus = Bus(clock=busFrequency) 190 all_l1buses += [cluster.clusterbus] 191 cluster.cpus = [DerivO3CPU(cpu_id = i + cluster.id, 192 clock=options.frequency) 193 for i in xrange(cpusPerCluster)] 194 all_cpus += cluster.cpus 195 cluster.l1 = L1(size=options.l1size, assoc = 4) 196 all_l1s += [cluster.l1] 197else: 198 clusters = [ Cluster() for i in xrange(options.numclusters)] 199 for j in xrange(options.numclusters): 200 clusters[j].id = j 201 for cluster in clusters: 202 cluster.clusterbus = Bus(clock=busFrequency) 203 all_l1buses += [cluster.clusterbus] 204 cluster.cpus = [AtomicSimpleCPU(cpu_id = i + cluster.id, 205 clock=options.frequency) 206 for i in xrange(cpusPerCluster)] 207 all_cpus += cluster.cpus 208 cluster.l1 = L1(size=options.l1size, assoc = 4) 209 all_l1s += [cluster.l1] 210 211# ---------------------- 212# Create a system, and add system wide objects 213# ---------------------- 214system = System(cpu = all_cpus, l1_ = all_l1s, l1bus_ = all_l1buses, 215 physmem = SimpleMemory(), membus = Bus(clock = busFrequency)) 216 217system.toL2bus = Bus(clock = busFrequency) 218system.l2 = L2(size = options.l2size, assoc = 8) 219 220# ---------------------- 221# Connect the L2 cache and memory together 222# ---------------------- 223 224system.physmem.port = system.membus.master 225system.l2.cpu_side = system.toL2bus.slave 226system.l2.mem_side = system.membus.master 227 228# ---------------------- 229# Connect the L2 cache and clusters together 230# ---------------------- 231for cluster in clusters: 232 cluster.l1.cpu_side = cluster.clusterbus.master 233 cluster.l1.mem_side = system.toL2bus.slave 234 for cpu in cluster.cpus: 235 cpu.icache_port = cluster.clusterbus.slave 236 cpu.dcache_port = cluster.clusterbus.slave 237 238# ---------------------- 239# Define the root 240# ---------------------- 241 242root = Root(full_system = False, system = system) 243 244# -------------------- 245# Pick the correct Splash2 Benchmarks 246# ==================== 247if options.benchmark == 'Cholesky': 248 root.workload = Cholesky() 249elif options.benchmark == 'FFT': 250 root.workload = FFT() 251elif options.benchmark == 'LUContig': 252 root.workload = LU_contig() 253elif options.benchmark == 'LUNoncontig': 254 root.workload = LU_noncontig() 255elif options.benchmark == 'Radix': 256 root.workload = Radix() 257elif options.benchmark == 'Barnes': 258 root.workload = Barnes() 259elif options.benchmark == 'FMM': 260 root.workload = FMM() 261elif options.benchmark == 'OceanContig': 262 root.workload = Ocean_contig() 263elif options.benchmark == 'OceanNoncontig': 264 root.workload = Ocean_noncontig() 265elif options.benchmark == 'Raytrace': 266 root.workload = Raytrace() 267elif options.benchmark == 'WaterNSquared': 268 root.workload = Water_nsquared() 269elif options.benchmark == 'WaterSpatial': 270 root.workload = Water_spatial() 271else: 272 m5.util.panic(""" 273The --benchmark environment variable was set to something improper. 274Use Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig, 275OceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial 276""") 277 278# -------------------- 279# Assign the workload to the cpus 280# ==================== 281 282for cluster in clusters: 283 for cpu in cluster.cpus: 284 cpu.workload = root.workload 285 286# ---------------------- 287# Run the simulation 288# ---------------------- 289 290if options.timing or options.detailed: 291 root.system.mem_mode = 'timing' 292 293# instantiate configuration 294m5.instantiate() 295 296# simulate until program terminates 297if options.maxtick: 298 exit_event = m5.simulate(options.maxtick) 299else: 300 exit_event = m5.simulate(m5.MaxTick) 301 302print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 303 304