1 # Copyright (c) 2006-2007 The Regents of The University of Michigan
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.
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.
27 # Authors: Ron Dreslinski
34 from m5
.objects
import *
35 import os
, optparse
, sys
36 m5
.AddToPath('../common')
38 # --------------------
39 # Define Command Line Options
40 # ====================
42 parser
= optparse
.OptionParser()
44 parser
.add_option("-d", "--detailed", action
="store_true")
45 parser
.add_option("-t", "--timing", action
="store_true")
46 parser
.add_option("-m", "--maxtick", type="int")
47 parser
.add_option("-c", "--numclusters",
48 help="Number of clusters", type="int")
49 parser
.add_option("-n", "--numcpus",
50 help="Number of cpus in total", type="int")
51 parser
.add_option("-f", "--frequency",
53 help="Frequency of each CPU")
54 parser
.add_option("--l1size",
56 parser
.add_option("--l1latency",
58 parser
.add_option("--l2size",
60 parser
.add_option("--l2latency",
62 parser
.add_option("--rootdir",
63 help="ROot directory of Splash2",
64 default
="/dist/splash2/codes/")
65 parser
.add_option("-b", "--benchmark",
66 help="Splash 2 benchmark to run")
68 (options
, args
) = parser
.parse_args()
71 print "Error: script doesn't take any positional arguments"
74 # --------------------
75 # Define Splash2 Benchmarks
76 # ====================
77 class Cholesky(LiveProcess
):
78 executable
= options
.rootdir
+ '/kernels/cholesky/CHOLESKY'
79 cmd
= 'CHOLESKY -p' + str(options
.numcpus
) + ' '\
80 + options
.rootdir
+ '/kernels/cholesky/inputs/tk23.O'
82 class FFT(LiveProcess
):
83 executable
= options
.rootdir
+ 'kernels/fft/FFT'
84 cmd
= 'FFT -p' + str(options
.numcpus
) + ' -m18'
86 class LU_contig(LiveProcess
):
87 executable
= options
.rootdir
+ 'kernels/lu/contiguous_blocks/LU'
88 cmd
= 'LU -p' + str(options
.numcpus
)
90 class LU_noncontig(LiveProcess
):
91 executable
= options
.rootdir
+ 'kernels/lu/non_contiguous_blocks/LU'
92 cmd
= 'LU -p' + str(options
.numcpus
)
94 class Radix(LiveProcess
):
95 executable
= options
.rootdir
+ 'kernels/radix/RADIX'
96 cmd
= 'RADIX -n524288 -p' + str(options
.numcpus
)
98 class Barnes(LiveProcess
):
99 executable
= options
.rootdir
+ 'apps/barnes/BARNES'
101 input = options
.rootdir
+ 'apps/barnes/input.p' + str(options
.numcpus
)
103 class FMM(LiveProcess
):
104 executable
= options
.rootdir
+ 'apps/fmm/FMM'
106 input = options
.rootdir
+ 'apps/fmm/inputs/input.2048.p' + str(options
.numcpus
)
108 class Ocean_contig(LiveProcess
):
109 executable
= options
.rootdir
+ 'apps/ocean/contiguous_partitions/OCEAN'
110 cmd
= 'OCEAN -p' + str(options
.numcpus
)
112 class Ocean_noncontig(LiveProcess
):
113 executable
= options
.rootdir
+ 'apps/ocean/non_contiguous_partitions/OCEAN'
114 cmd
= 'OCEAN -p' + str(options
.numcpus
)
116 class Raytrace(LiveProcess
):
117 executable
= options
.rootdir
+ 'apps/raytrace/RAYTRACE'
118 cmd
= 'RAYTRACE -p' + str(options
.numcpus
) + ' ' \
119 + options
.rootdir
+ 'apps/raytrace/inputs/teapot.env'
121 class 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
)
126 class 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
)
132 # --------------------
133 # Base L1 Cache Definition
134 # ====================
137 latency
= options
.l1latency
142 # ----------------------
143 # Base L2 Cache Definition
144 # ----------------------
148 latency
= options
.l2latency
153 # ----------------------
154 # Define the clusters with their cpus
155 # ----------------------
159 cpusPerCluster
= options
.numcpus
/options
.numclusters
161 busFrequency
= Frequency(options
.frequency
)
162 busFrequency
*= cpusPerCluster
168 clusters
= [ Cluster() for i
in xrange(options
.numclusters
)]
169 for j
in xrange(options
.numclusters
):
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
]
180 elif options
.detailed
:
181 clusters
= [ Cluster() for i
in xrange(options
.numclusters
)]
182 for j
in xrange(options
.numclusters
):
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
]
194 clusters
= [ Cluster() for i
in xrange(options
.numclusters
)]
195 for j
in xrange(options
.numclusters
):
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
]
207 # ----------------------
208 # Create a system, and add system wide objects
209 # ----------------------
210 system
= System(cpu
= all_cpus
, l1_
= all_l1s
, l1bus_
= all_l1buses
, physmem
= PhysicalMemory(),
211 membus
= Bus(clock
= busFrequency
))
213 system
.toL2bus
= Bus(clock
= busFrequency
)
214 system
.l2
= L2(size
= options
.l2size
, assoc
= 8)
216 # ----------------------
217 # Connect the L2 cache and memory together
218 # ----------------------
220 system
.physmem
.port
= system
.membus
.port
221 system
.l2
.cpu_side
= system
.toL2bus
.port
222 system
.l2
.mem_side
= system
.membus
.port
224 # ----------------------
225 # Connect the L2 cache and clusters together
226 # ----------------------
227 for 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
235 # ----------------------
237 # ----------------------
239 root
= Root(system
= system
)
241 # --------------------
242 # Pick the correct Splash2 Benchmarks
243 # ====================
244 if options
.benchmark
== 'Cholesky':
245 root
.workload
= Cholesky()
246 elif options
.benchmark
== 'FFT':
247 root
.workload
= FFT()
248 elif options
.benchmark
== 'LUContig':
249 root
.workload
= LU_contig()
250 elif options
.benchmark
== 'LUNoncontig':
251 root
.workload
= LU_noncontig()
252 elif options
.benchmark
== 'Radix':
253 root
.workload
= Radix()
254 elif options
.benchmark
== 'Barnes':
255 root
.workload
= Barnes()
256 elif options
.benchmark
== 'FMM':
257 root
.workload
= FMM()
258 elif options
.benchmark
== 'OceanContig':
259 root
.workload
= Ocean_contig()
260 elif options
.benchmark
== 'OceanNoncontig':
261 root
.workload
= Ocean_noncontig()
262 elif options
.benchmark
== 'Raytrace':
263 root
.workload
= Raytrace()
264 elif options
.benchmark
== 'WaterNSquared':
265 root
.workload
= Water_nsquared()
266 elif options
.benchmark
== 'WaterSpatial':
267 root
.workload
= Water_spatial()
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")
274 # --------------------
275 # Assign the workload to the cpus
276 # ====================
278 for cluster
in clusters
:
279 for cpu
in cluster
.cpus
:
280 cpu
.workload
= root
.workload
282 # ----------------------
284 # ----------------------
286 if options
.timing
or options
.detailed
:
287 root
.system
.mem_mode
= 'timing'
289 # instantiate configuration
292 # simulate until program terminates
294 exit_event
= m5
.simulate(options
.maxtick
)
296 exit_event
= m5
.simulate(m5
.MaxTick
)
298 print 'Exiting @ tick', m5
.curTick(), 'because', exit_event
.getCause()