cluster.py revision 9036
16145Snate@binkert.org# Copyright (c) 2006-2007 The Regents of The University of Michigan 26145Snate@binkert.org# All rights reserved. 36145Snate@binkert.org# 46145Snate@binkert.org# Redistribution and use in source and binary forms, with or without 56145Snate@binkert.org# modification, are permitted provided that the following conditions are 66145Snate@binkert.org# met: redistributions of source code must retain the above copyright 76145Snate@binkert.org# notice, this list of conditions and the following disclaimer; 86145Snate@binkert.org# redistributions in binary form must reproduce the above copyright 96145Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 106145Snate@binkert.org# documentation and/or other materials provided with the distribution; 116145Snate@binkert.org# neither the name of the copyright holders nor the names of its 126145Snate@binkert.org# contributors may be used to endorse or promote products derived from 136145Snate@binkert.org# this software without specific prior written permission. 146145Snate@binkert.org# 156145Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 166145Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 176145Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 186145Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 196145Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 206145Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 216145Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 226145Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 236145Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 246145Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 256145Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 266145Snate@binkert.org# 276145Snate@binkert.org# Authors: Ron Dreslinski 286145Snate@binkert.org 297039Snate@binkert.org# Simple test script 307039Snate@binkert.org# 316145Snate@binkert.org# "m5 test.py" 327002Snate@binkert.org 3310472Sandreas.hansson@arm.comimport os 3410808Snilay@cs.wisc.eduimport optparse 357002Snate@binkert.orgimport sys 369466Snilay@cs.wisc.edu 3710895Snilay@cs.wisc.eduimport m5 3814184Sgabeblack@google.comfrom m5.objects import * 396145Snate@binkert.org 406145Snate@binkert.orgm5.util.addToPath('../common') 4110472Sandreas.hansson@arm.com 426145Snate@binkert.org# -------------------- 4310472Sandreas.hansson@arm.com# Define Command Line Options 447039Snate@binkert.org# ==================== 457039Snate@binkert.org 469508Snilay@cs.wisc.eduparser = optparse.OptionParser() 479466Snilay@cs.wisc.edu 489466Snilay@cs.wisc.eduparser.add_option("-d", "--detailed", action="store_true") 4910893Snilay@cs.wisc.eduparser.add_option("-t", "--timing", action="store_true") 5010876Snilay@cs.wisc.eduparser.add_option("-m", "--maxtick", type="int") 517453Snate@binkert.orgparser.add_option("-c", "--numclusters", 527453Snate@binkert.org help="Number of clusters", type="int") 537453Snate@binkert.orgparser.add_option("-n", "--numcpus", 547453Snate@binkert.org help="Number of cpus in total", type="int") 5510893Snilay@cs.wisc.eduparser.add_option("-f", "--frequency", 5610893Snilay@cs.wisc.edu default = "1GHz", 577453Snate@binkert.org help="Frequency of each CPU") 586145Snate@binkert.orgparser.add_option("--l1size", 597039Snate@binkert.org default = "32kB") 606145Snate@binkert.orgparser.add_option("--l1latency", 6110472Sandreas.hansson@arm.com default = 1) 627039Snate@binkert.orgparser.add_option("--l2size", 6310895Snilay@cs.wisc.edu default = "256kB") 6410895Snilay@cs.wisc.eduparser.add_option("--l2latency", 6510895Snilay@cs.wisc.edu default = 10) 6610895Snilay@cs.wisc.eduparser.add_option("--rootdir", 6710895Snilay@cs.wisc.edu help="ROot directory of Splash2", 686145Snate@binkert.org default="/dist/splash2/codes/") 699302Snilay@cs.wisc.eduparser.add_option("-b", "--benchmark", 709302Snilay@cs.wisc.edu help="Splash 2 benchmark to run") 719302Snilay@cs.wisc.edu 729302Snilay@cs.wisc.edu(options, args) = parser.parse_args() 739302Snilay@cs.wisc.edu 749302Snilay@cs.wisc.eduif args: 759302Snilay@cs.wisc.edu print "Error: script doesn't take any positional arguments" 769302Snilay@cs.wisc.edu sys.exit(1) 779302Snilay@cs.wisc.edu 789302Snilay@cs.wisc.edu# -------------------- 7910074Snilay@cs.wisc.edu# Define Splash2 Benchmarks 8010074Snilay@cs.wisc.edu# ==================== 8110074Snilay@cs.wisc.educlass Cholesky(LiveProcess): 8210074Snilay@cs.wisc.edu executable = options.rootdir + '/kernels/cholesky/CHOLESKY' 8310074Snilay@cs.wisc.edu cmd = 'CHOLESKY -p' + str(options.numcpus) + ' '\ 8410074Snilay@cs.wisc.edu + options.rootdir + '/kernels/cholesky/inputs/tk23.O' 8510074Snilay@cs.wisc.edu 8611294Sandreas.hansson@arm.comclass FFT(LiveProcess): 879465Snilay@cs.wisc.edu executable = options.rootdir + 'kernels/fft/FFT' 889508Snilay@cs.wisc.edu cmd = 'FFT -p' + str(options.numcpus) + ' -m18' 8911294Sandreas.hansson@arm.com 906145Snate@binkert.orgclass LU_contig(LiveProcess): 9111294Sandreas.hansson@arm.com executable = options.rootdir + 'kernels/lu/contiguous_blocks/LU' 9210893Snilay@cs.wisc.edu cmd = 'LU -p' + str(options.numcpus) 9310893Snilay@cs.wisc.edu 946145Snate@binkert.orgclass LU_noncontig(LiveProcess): 9510895Snilay@cs.wisc.edu executable = options.rootdir + 'kernels/lu/non_contiguous_blocks/LU' 9610895Snilay@cs.wisc.edu cmd = 'LU -p' + str(options.numcpus) 9710895Snilay@cs.wisc.edu 9810895Snilay@cs.wisc.educlass Radix(LiveProcess): 9910895Snilay@cs.wisc.edu executable = options.rootdir + 'kernels/radix/RADIX' 10010895Snilay@cs.wisc.edu cmd = 'RADIX -n524288 -p' + str(options.numcpus) 10110895Snilay@cs.wisc.edu 10210895Snilay@cs.wisc.educlass Barnes(LiveProcess): 10310895Snilay@cs.wisc.edu executable = options.rootdir + 'apps/barnes/BARNES' 10410895Snilay@cs.wisc.edu cmd = 'BARNES' 10510895Snilay@cs.wisc.edu input = options.rootdir + 'apps/barnes/input.p' + str(options.numcpus) 1067039Snate@binkert.org 10710893Snilay@cs.wisc.educlass FMM(LiveProcess): 1089508Snilay@cs.wisc.edu executable = options.rootdir + 'apps/fmm/FMM' 1099508Snilay@cs.wisc.edu cmd = 'FMM' 11010893Snilay@cs.wisc.edu input = options.rootdir + 'apps/fmm/inputs/input.2048.p' + str(options.numcpus) 11110895Snilay@cs.wisc.edu 11210895Snilay@cs.wisc.educlass Ocean_contig(LiveProcess): 11310895Snilay@cs.wisc.edu executable = options.rootdir + 'apps/ocean/contiguous_partitions/OCEAN' 11410895Snilay@cs.wisc.edu cmd = 'OCEAN -p' + str(options.numcpus) 1156145Snate@binkert.org 1166145Snate@binkert.orgclass Ocean_noncontig(LiveProcess): 11710893Snilay@cs.wisc.edu executable = options.rootdir + 'apps/ocean/non_contiguous_partitions/OCEAN' 11810893Snilay@cs.wisc.edu cmd = 'OCEAN -p' + str(options.numcpus) 11910893Snilay@cs.wisc.edu 12010893Snilay@cs.wisc.educlass Raytrace(LiveProcess): 12110893Snilay@cs.wisc.edu executable = options.rootdir + 'apps/raytrace/RAYTRACE' 12210893Snilay@cs.wisc.edu cmd = 'RAYTRACE -p' + str(options.numcpus) + ' ' \ 12310893Snilay@cs.wisc.edu + options.rootdir + 'apps/raytrace/inputs/teapot.env' 12410893Snilay@cs.wisc.edu 12510893Snilay@cs.wisc.educlass Water_nsquared(LiveProcess): 12610893Snilay@cs.wisc.edu executable = options.rootdir + 'apps/water-nsquared/WATER-NSQUARED' 12710893Snilay@cs.wisc.edu cmd = 'WATER-NSQUARED' 12810893Snilay@cs.wisc.edu input = options.rootdir + 'apps/water-nsquared/input.p' + str(options.numcpus) 1297039Snate@binkert.org 1307039Snate@binkert.orgclass Water_spatial(LiveProcess): 1316145Snate@binkert.org executable = options.rootdir + 'apps/water-spatial/WATER-SPATIAL' 1327039Snate@binkert.org cmd = 'WATER-SPATIAL' 1337039Snate@binkert.org input = options.rootdir + 'apps/water-spatial/input.p' + str(options.numcpus) 1347039Snate@binkert.org 1356145Snate@binkert.org 1366145Snate@binkert.org# -------------------- 1377039Snate@binkert.org# 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 = CoherentBus(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 = CoherentBus(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 = CoherentBus(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(), 216 membus = CoherentBus(clock = busFrequency)) 217 218system.toL2bus = CoherentBus(clock = busFrequency) 219system.l2 = L2(size = options.l2size, assoc = 8) 220 221# ---------------------- 222# Connect the L2 cache and memory together 223# ---------------------- 224 225system.physmem.port = system.membus.master 226system.l2.cpu_side = system.toL2bus.slave 227system.l2.mem_side = system.membus.master 228 229# ---------------------- 230# Connect the L2 cache and clusters together 231# ---------------------- 232for cluster in clusters: 233 cluster.l1.cpu_side = cluster.clusterbus.master 234 cluster.l1.mem_side = system.toL2bus.slave 235 for cpu in cluster.cpus: 236 cpu.icache_port = cluster.clusterbus.slave 237 cpu.dcache_port = cluster.clusterbus.slave 238 239# ---------------------- 240# Define the root 241# ---------------------- 242 243root = Root(full_system = False, system = system) 244 245# -------------------- 246# Pick the correct Splash2 Benchmarks 247# ==================== 248if options.benchmark == 'Cholesky': 249 root.workload = Cholesky() 250elif options.benchmark == 'FFT': 251 root.workload = FFT() 252elif options.benchmark == 'LUContig': 253 root.workload = LU_contig() 254elif options.benchmark == 'LUNoncontig': 255 root.workload = LU_noncontig() 256elif options.benchmark == 'Radix': 257 root.workload = Radix() 258elif options.benchmark == 'Barnes': 259 root.workload = Barnes() 260elif options.benchmark == 'FMM': 261 root.workload = FMM() 262elif options.benchmark == 'OceanContig': 263 root.workload = Ocean_contig() 264elif options.benchmark == 'OceanNoncontig': 265 root.workload = Ocean_noncontig() 266elif options.benchmark == 'Raytrace': 267 root.workload = Raytrace() 268elif options.benchmark == 'WaterNSquared': 269 root.workload = Water_nsquared() 270elif options.benchmark == 'WaterSpatial': 271 root.workload = Water_spatial() 272else: 273 m5.util.panic(""" 274The --benchmark environment variable was set to something improper. 275Use Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig, 276OceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial 277""") 278 279# -------------------- 280# Assign the workload to the cpus 281# ==================== 282 283for cluster in clusters: 284 for cpu in cluster.cpus: 285 cpu.workload = root.workload 286 287# ---------------------- 288# Run the simulation 289# ---------------------- 290 291if options.timing or options.detailed: 292 root.system.mem_mode = 'timing' 293 294# instantiate configuration 295m5.instantiate() 296 297# simulate until program terminates 298if options.maxtick: 299 exit_event = m5.simulate(options.maxtick) 300else: 301 exit_event = m5.simulate(m5.MaxTick) 302 303print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 304 305