cluster.py revision 4876
1# Copyright (c) 2006-2007 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# Simple test script 30# 31# "m5 test.py" 32 33import m5 34from m5.objects import * 35import os, optparse, sys 36m5.AddToPath('../common') 37 38# -------------------- 39# Define Command Line Options 40# ==================== 41 42parser = optparse.OptionParser() 43 44parser.add_option("-d", "--detailed", action="store_true") 45parser.add_option("-t", "--timing", action="store_true") 46parser.add_option("-m", "--maxtick", type="int") 47parser.add_option("-c", "--numclusters", 48 help="Number of clusters", type="int") 49parser.add_option("-n", "--numcpus", 50 help="Number of cpus in total", type="int") 51parser.add_option("-f", "--frequency", 52 default = "1GHz", 53 help="Frequency of each CPU") 54parser.add_option("--l1size", 55 default = "32kB") 56parser.add_option("--l1latency", 57 default = 1) 58parser.add_option("--l2size", 59 default = "256kB") 60parser.add_option("--l2latency", 61 default = 10) 62parser.add_option("--rootdir", 63 help="ROot directory of Splash2", 64 default="/dist/splash2/codes/") 65parser.add_option("-b", "--benchmark", 66 help="Splash 2 benchmark to run") 67 68(options, args) = parser.parse_args() 69 70if args: 71 print "Error: script doesn't take any positional arguments" 72 sys.exit(1) 73 74# -------------------- 75# Define Splash2 Benchmarks 76# ==================== 77class Cholesky(LiveProcess): 78 executable = options.rootdir + '/kernels/cholesky/CHOLESKY' 79 cmd = 'CHOLESKY -p' + str(options.numcpus) + ' '\ 80 + options.rootdir + '/kernels/cholesky/inputs/tk23.O' 81 82class FFT(LiveProcess): 83 executable = options.rootdir + 'kernels/fft/FFT' 84 cmd = 'FFT -p' + str(options.numcpus) + ' -m18' 85 86class LU_contig(LiveProcess): 87 executable = options.rootdir + 'kernels/lu/contiguous_blocks/LU' 88 cmd = 'LU -p' + str(options.numcpus) 89 90class LU_noncontig(LiveProcess): 91 executable = options.rootdir + 'kernels/lu/non_contiguous_blocks/LU' 92 cmd = 'LU -p' + str(options.numcpus) 93 94class Radix(LiveProcess): 95 executable = options.rootdir + 'kernels/radix/RADIX' 96 cmd = 'RADIX -n524288 -p' + str(options.numcpus) 97 98class Barnes(LiveProcess): 99 executable = options.rootdir + 'apps/barnes/BARNES' 100 cmd = 'BARNES' 101 input = options.rootdir + 'apps/barnes/input.p' + str(options.numcpus) 102 103class FMM(LiveProcess): 104 executable = options.rootdir + 'apps/fmm/FMM' 105 cmd = 'FMM' 106 input = options.rootdir + 'apps/fmm/inputs/input.2048.p' + str(options.numcpus) 107 108class Ocean_contig(LiveProcess): 109 executable = options.rootdir + 'apps/ocean/contiguous_partitions/OCEAN' 110 cmd = 'OCEAN -p' + str(options.numcpus) 111 112class Ocean_noncontig(LiveProcess): 113 executable = options.rootdir + 'apps/ocean/non_contiguous_partitions/OCEAN' 114 cmd = 'OCEAN -p' + str(options.numcpus) 115 116class Raytrace(LiveProcess): 117 executable = options.rootdir + 'apps/raytrace/RAYTRACE' 118 cmd = 'RAYTRACE -p' + str(options.numcpus) + ' ' \ 119 + options.rootdir + 'apps/raytrace/inputs/teapot.env' 120 121class Water_nsquared(LiveProcess): 122 executable = options.rootdir + 'apps/water-nsquared/WATER-NSQUARED' 123 cmd = 'WATER-NSQUARED' 124 input = options.rootdir + 'apps/water-nsquared/input.p' + str(options.numcpus) 125 126class Water_spatial(LiveProcess): 127 executable = options.rootdir + 'apps/water-spatial/WATER-SPATIAL' 128 cmd = 'WATER-SPATIAL' 129 input = options.rootdir + 'apps/water-spatial/input.p' + str(options.numcpus) 130 131 132# -------------------- 133# Base L1 Cache Definition 134# ==================== 135 136class L1(BaseCache): 137 latency = options.l1latency 138 block_size = 64 139 mshrs = 12 140 tgts_per_mshr = 8 141 142# ---------------------- 143# Base L2 Cache Definition 144# ---------------------- 145 146class L2(BaseCache): 147 block_size = 64 148 latency = options.l2latency 149 mshrs = 92 150 tgts_per_mshr = 16 151 write_buffers = 8 152 153# ---------------------- 154# Define the clusters with their cpus 155# ---------------------- 156class Cluster: 157 pass 158 159cpusPerCluster = options.numcpus/options.numclusters 160 161busFrequency = Frequency(options.frequency) 162busFrequency *= cpusPerCluster 163 164all_cpus = [] 165all_l1s = [] 166all_l1buses = [] 167if options.timing: 168 clusters = [ Cluster() for i in xrange(options.numclusters)] 169 for j in xrange(options.numclusters): 170 clusters[j].id = j 171 for cluster in clusters: 172 cluster.clusterbus = Bus(clock=busFrequency) 173 all_l1buses += [cluster.clusterbus] 174 cluster.cpus = [TimingSimpleCPU(cpu_id = i + cluster.id, 175 clock=options.frequency) 176 for i in xrange(cpusPerCluster)] 177 all_cpus += cluster.cpus 178 cluster.l1 = L1(size=options.l1size, assoc = 4) 179 all_l1s += [cluster.l1] 180elif options.detailed: 181 clusters = [ Cluster() for i in xrange(options.numclusters)] 182 for j in xrange(options.numclusters): 183 clusters[j].id = j 184 for cluster in clusters: 185 cluster.clusterbus = Bus(clock=busFrequency) 186 all_l1buses += [cluster.clusterbus] 187 cluster.cpus = [DerivO3CPU(cpu_id = i + cluster.id, 188 clock=options.frequency) 189 for i in xrange(cpusPerCluster)] 190 all_cpus += cluster.cpus 191 cluster.l1 = L1(size=options.l1size, assoc = 4) 192 all_l1s += [cluster.l1] 193else: 194 clusters = [ Cluster() for i in xrange(options.numclusters)] 195 for j in xrange(options.numclusters): 196 clusters[j].id = j 197 for cluster in clusters: 198 cluster.clusterbus = Bus(clock=busFrequency) 199 all_l1buses += [cluster.clusterbus] 200 cluster.cpus = [AtomicSimpleCPU(cpu_id = i + cluster.id, 201 clock=options.frequency) 202 for i in xrange(cpusPerCluster)] 203 all_cpus += cluster.cpus 204 cluster.l1 = L1(size=options.l1size, assoc = 4) 205 all_l1s += [cluster.l1] 206 207# ---------------------- 208# Create a system, and add system wide objects 209# ---------------------- 210system = System(cpu = all_cpus, l1_ = all_l1s, l1bus_ = all_l1buses, physmem = PhysicalMemory(), 211 membus = Bus(clock = busFrequency)) 212 213system.toL2bus = Bus(clock = busFrequency) 214system.l2 = L2(size = options.l2size, assoc = 8) 215 216# ---------------------- 217# Connect the L2 cache and memory together 218# ---------------------- 219 220system.physmem.port = system.membus.port 221system.l2.cpu_side = system.toL2bus.port 222system.l2.mem_side = system.membus.port 223 224# ---------------------- 225# Connect the L2 cache and clusters together 226# ---------------------- 227for cluster in clusters: 228 cluster.l1.cpu_side = cluster.clusterbus.port 229 cluster.l1.mem_side = system.toL2bus.port 230 for cpu in cluster.cpus: 231 cpu.icache_port = cluster.clusterbus.port 232 cpu.dcache_port = cluster.clusterbus.port 233 cpu.mem = cluster.l1 234 235# ---------------------- 236# Define the root 237# ---------------------- 238 239root = Root(system = system) 240 241# -------------------- 242# Pick the correct Splash2 Benchmarks 243# ==================== 244if options.benchmark == 'Cholesky': 245 root.workload = Cholesky() 246elif options.benchmark == 'FFT': 247 root.workload = FFT() 248elif options.benchmark == 'LUContig': 249 root.workload = LU_contig() 250elif options.benchmark == 'LUNoncontig': 251 root.workload = LU_noncontig() 252elif options.benchmark == 'Radix': 253 root.workload = Radix() 254elif options.benchmark == 'Barnes': 255 root.workload = Barnes() 256elif options.benchmark == 'FMM': 257 root.workload = FMM() 258elif options.benchmark == 'OceanContig': 259 root.workload = Ocean_contig() 260elif options.benchmark == 'OceanNoncontig': 261 root.workload = Ocean_noncontig() 262elif options.benchmark == 'Raytrace': 263 root.workload = Raytrace() 264elif options.benchmark == 'WaterNSquared': 265 root.workload = Water_nsquared() 266elif options.benchmark == 'WaterSpatial': 267 root.workload = Water_spatial() 268else: 269 panic("The --benchmark environment variable was set to something" \ 270 +" improper.\nUse Cholesky, FFT, LUContig, LUNoncontig, Radix" \ 271 +", Barnes, FMM, OceanContig,\nOceanNoncontig, Raytrace," \ 272 +" WaterNSquared, or WaterSpatial\n") 273 274# -------------------- 275# Assign the workload to the cpus 276# ==================== 277 278for cluster in clusters: 279 for cpu in cluster.cpus: 280 cpu.workload = root.workload 281 282# ---------------------- 283# Run the simulation 284# ---------------------- 285 286if options.timing or options.detailed: 287 root.system.mem_mode = 'timing' 288 289# instantiate configuration 290m5.instantiate(root) 291 292# simulate until program terminates 293if options.maxtick: 294 exit_event = m5.simulate(options.maxtick) 295else: 296 exit_event = m5.simulate(m5.MaxTick) 297 298print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 299 300