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.
36 from m5
.objects
import *
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(Process
):
78 executable
= options
.rootdir
+ '/kernels/cholesky/CHOLESKY'
79 cmd
= 'CHOLESKY -p' + str(options
.numcpus
) + ' '\
80 + options
.rootdir
+ '/kernels/cholesky/inputs/tk23.O'
83 executable
= options
.rootdir
+ 'kernels/fft/FFT'
84 cmd
= 'FFT -p' + str(options
.numcpus
) + ' -m18'
86 class LU_contig(Process
):
87 executable
= options
.rootdir
+ 'kernels/lu/contiguous_blocks/LU'
88 cmd
= 'LU -p' + str(options
.numcpus
)
90 class LU_noncontig(Process
):
91 executable
= options
.rootdir
+ 'kernels/lu/non_contiguous_blocks/LU'
92 cmd
= 'LU -p' + str(options
.numcpus
)
95 executable
= options
.rootdir
+ 'kernels/radix/RADIX'
96 cmd
= 'RADIX -n524288 -p' + str(options
.numcpus
)
98 class Barnes(Process
):
99 executable
= options
.rootdir
+ 'apps/barnes/BARNES'
101 input = options
.rootdir
+ 'apps/barnes/input.p' + str(options
.numcpus
)
104 executable
= options
.rootdir
+ 'apps/fmm/FMM'
106 input = options
.rootdir
+ 'apps/fmm/inputs/input.2048.p' + str(options
.numcpus
)
108 class Ocean_contig(Process
):
109 executable
= options
.rootdir
+ 'apps/ocean/contiguous_partitions/OCEAN'
110 cmd
= 'OCEAN -p' + str(options
.numcpus
)
112 class Ocean_noncontig(Process
):
113 executable
= options
.rootdir
+ 'apps/ocean/non_contiguous_partitions/OCEAN'
114 cmd
= 'OCEAN -p' + str(options
.numcpus
)
116 class Raytrace(Process
):
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(Process
):
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(Process
):
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
141 # ----------------------
142 # Base L2 Cache Definition
143 # ----------------------
146 latency
= options
.l2latency
151 # ----------------------
152 # Define the clusters with their cpus
153 # ----------------------
157 cpusPerCluster
= options
.numcpus
/options
.numclusters
159 busFrequency
= Frequency(options
.frequency
)
160 busFrequency
*= cpusPerCluster
166 clusters
= [ Cluster() for i
in range(options
.numclusters
)]
167 for j
in range(options
.numclusters
):
169 for cluster
in clusters
:
170 cluster
.clusterbus
= L2XBar(clock
=busFrequency
)
171 all_l1buses
+= [cluster
.clusterbus
]
172 cluster
.cpus
= [TimingSimpleCPU(cpu_id
= i
+ cluster
.id,
173 clock
=options
.frequency
)
174 for i
in range(cpusPerCluster
)]
175 all_cpus
+= cluster
.cpus
176 cluster
.l1
= L1(size
=options
.l1size
, assoc
= 4)
177 all_l1s
+= [cluster
.l1
]
178 elif options
.detailed
:
179 clusters
= [ Cluster() for i
in range(options
.numclusters
)]
180 for j
in range(options
.numclusters
):
182 for cluster
in clusters
:
183 cluster
.clusterbus
= L2XBar(clock
=busFrequency
)
184 all_l1buses
+= [cluster
.clusterbus
]
185 cluster
.cpus
= [DerivO3CPU(cpu_id
= i
+ cluster
.id,
186 clock
=options
.frequency
)
187 for i
in range(cpusPerCluster
)]
188 all_cpus
+= cluster
.cpus
189 cluster
.l1
= L1(size
=options
.l1size
, assoc
= 4)
190 all_l1s
+= [cluster
.l1
]
192 clusters
= [ Cluster() for i
in range(options
.numclusters
)]
193 for j
in range(options
.numclusters
):
195 for cluster
in clusters
:
196 cluster
.clusterbus
= L2XBar(clock
=busFrequency
)
197 all_l1buses
+= [cluster
.clusterbus
]
198 cluster
.cpus
= [AtomicSimpleCPU(cpu_id
= i
+ cluster
.id,
199 clock
=options
.frequency
)
200 for i
in range(cpusPerCluster
)]
201 all_cpus
+= cluster
.cpus
202 cluster
.l1
= L1(size
=options
.l1size
, assoc
= 4)
203 all_l1s
+= [cluster
.l1
]
205 # ----------------------
206 # Create a system, and add system wide objects
207 # ----------------------
208 system
= System(cpu
= all_cpus
, l1_
= all_l1s
, l1bus_
= all_l1buses
,
209 physmem
= SimpleMemory(),
210 membus
= SystemXBar(clock
= busFrequency
))
211 system
.clock
= '1GHz'
213 system
.toL2bus
= L2XBar(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
.master
221 system
.l2
.cpu_side
= system
.toL2bus
.slave
222 system
.l2
.mem_side
= system
.membus
.master
224 # ----------------------
225 # Connect the L2 cache and clusters together
226 # ----------------------
227 for cluster
in clusters
:
228 cluster
.l1
.cpu_side
= cluster
.clusterbus
.master
229 cluster
.l1
.mem_side
= system
.toL2bus
.slave
230 for cpu
in cluster
.cpus
:
231 cpu
.icache_port
= cluster
.clusterbus
.slave
232 cpu
.dcache_port
= cluster
.clusterbus
.slave
234 # ----------------------
236 # ----------------------
238 root
= Root(full_system
= False, system
= system
)
240 # --------------------
241 # Pick the correct Splash2 Benchmarks
242 # ====================
243 if options
.benchmark
== 'Cholesky':
244 root
.workload
= Cholesky()
245 elif options
.benchmark
== 'FFT':
246 root
.workload
= FFT()
247 elif options
.benchmark
== 'LUContig':
248 root
.workload
= LU_contig()
249 elif options
.benchmark
== 'LUNoncontig':
250 root
.workload
= LU_noncontig()
251 elif options
.benchmark
== 'Radix':
252 root
.workload
= Radix()
253 elif options
.benchmark
== 'Barnes':
254 root
.workload
= Barnes()
255 elif options
.benchmark
== 'FMM':
256 root
.workload
= FMM()
257 elif options
.benchmark
== 'OceanContig':
258 root
.workload
= Ocean_contig()
259 elif options
.benchmark
== 'OceanNoncontig':
260 root
.workload
= Ocean_noncontig()
261 elif options
.benchmark
== 'Raytrace':
262 root
.workload
= Raytrace()
263 elif options
.benchmark
== 'WaterNSquared':
264 root
.workload
= Water_nsquared()
265 elif options
.benchmark
== 'WaterSpatial':
266 root
.workload
= Water_spatial()
269 The --benchmark environment variable was set to something improper.
270 Use Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig,
271 OceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial
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 system
.workload
= SEWorkload
.init_compatible(root
.workload
.executable
)
284 # ----------------------
286 # ----------------------
288 if options
.timing
or options
.detailed
:
289 root
.system
.mem_mode
= 'timing'
291 # instantiate configuration
294 # simulate until program terminates
296 exit_event
= m5
.simulate(options
.maxtick
)
298 exit_event
= m5
.simulate(m5
.MaxTick
)
300 print('Exiting @ tick', m5
.curTick(), 'because', exit_event
.getCause())