67f64f34fcf5f55606d04196008082341b013375
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.
31 from __future__
import print_function
32 from __future__
import absolute_import
39 from m5
.objects
import *
41 # --------------------
42 # Define Command Line Options
43 # ====================
45 parser
= optparse
.OptionParser()
47 parser
.add_option("-d", "--detailed", action
="store_true")
48 parser
.add_option("-t", "--timing", action
="store_true")
49 parser
.add_option("-m", "--maxtick", type="int")
50 parser
.add_option("-c", "--numclusters",
51 help="Number of clusters", type="int")
52 parser
.add_option("-n", "--numcpus",
53 help="Number of cpus in total", type="int")
54 parser
.add_option("-f", "--frequency",
56 help="Frequency of each CPU")
57 parser
.add_option("--l1size",
59 parser
.add_option("--l1latency",
61 parser
.add_option("--l2size",
63 parser
.add_option("--l2latency",
65 parser
.add_option("--rootdir",
66 help="ROot directory of Splash2",
67 default
="/dist/splash2/codes/")
68 parser
.add_option("-b", "--benchmark",
69 help="Splash 2 benchmark to run")
71 (options
, args
) = parser
.parse_args()
74 print("Error: script doesn't take any positional arguments")
77 # --------------------
78 # Define Splash2 Benchmarks
79 # ====================
80 class Cholesky(Process
):
81 executable
= options
.rootdir
+ '/kernels/cholesky/CHOLESKY'
82 cmd
= 'CHOLESKY -p' + str(options
.numcpus
) + ' '\
83 + options
.rootdir
+ '/kernels/cholesky/inputs/tk23.O'
86 executable
= options
.rootdir
+ 'kernels/fft/FFT'
87 cmd
= 'FFT -p' + str(options
.numcpus
) + ' -m18'
89 class LU_contig(Process
):
90 executable
= options
.rootdir
+ 'kernels/lu/contiguous_blocks/LU'
91 cmd
= 'LU -p' + str(options
.numcpus
)
93 class LU_noncontig(Process
):
94 executable
= options
.rootdir
+ 'kernels/lu/non_contiguous_blocks/LU'
95 cmd
= 'LU -p' + str(options
.numcpus
)
98 executable
= options
.rootdir
+ 'kernels/radix/RADIX'
99 cmd
= 'RADIX -n524288 -p' + str(options
.numcpus
)
101 class Barnes(Process
):
102 executable
= options
.rootdir
+ 'apps/barnes/BARNES'
104 input = options
.rootdir
+ 'apps/barnes/input.p' + str(options
.numcpus
)
107 executable
= options
.rootdir
+ 'apps/fmm/FMM'
109 input = options
.rootdir
+ 'apps/fmm/inputs/input.2048.p' + str(options
.numcpus
)
111 class Ocean_contig(Process
):
112 executable
= options
.rootdir
+ 'apps/ocean/contiguous_partitions/OCEAN'
113 cmd
= 'OCEAN -p' + str(options
.numcpus
)
115 class Ocean_noncontig(Process
):
116 executable
= options
.rootdir
+ 'apps/ocean/non_contiguous_partitions/OCEAN'
117 cmd
= 'OCEAN -p' + str(options
.numcpus
)
119 class Raytrace(Process
):
120 executable
= options
.rootdir
+ 'apps/raytrace/RAYTRACE'
121 cmd
= 'RAYTRACE -p' + str(options
.numcpus
) + ' ' \
122 + options
.rootdir
+ 'apps/raytrace/inputs/teapot.env'
124 class Water_nsquared(Process
):
125 executable
= options
.rootdir
+ 'apps/water-nsquared/WATER-NSQUARED'
126 cmd
= 'WATER-NSQUARED'
127 input = options
.rootdir
+ 'apps/water-nsquared/input.p' + str(options
.numcpus
)
129 class Water_spatial(Process
):
130 executable
= options
.rootdir
+ 'apps/water-spatial/WATER-SPATIAL'
131 cmd
= 'WATER-SPATIAL'
132 input = options
.rootdir
+ 'apps/water-spatial/input.p' + str(options
.numcpus
)
135 # --------------------
136 # Base L1 Cache Definition
137 # ====================
140 latency
= options
.l1latency
144 # ----------------------
145 # Base L2 Cache Definition
146 # ----------------------
149 latency
= options
.l2latency
154 # ----------------------
155 # Define the clusters with their cpus
156 # ----------------------
160 cpusPerCluster
= options
.numcpus
/options
.numclusters
162 busFrequency
= Frequency(options
.frequency
)
163 busFrequency
*= cpusPerCluster
169 clusters
= [ Cluster() for i
in range(options
.numclusters
)]
170 for j
in range(options
.numclusters
):
172 for cluster
in clusters
:
173 cluster
.clusterbus
= L2XBar(clock
=busFrequency
)
174 all_l1buses
+= [cluster
.clusterbus
]
175 cluster
.cpus
= [TimingSimpleCPU(cpu_id
= i
+ cluster
.id,
176 clock
=options
.frequency
)
177 for i
in range(cpusPerCluster
)]
178 all_cpus
+= cluster
.cpus
179 cluster
.l1
= L1(size
=options
.l1size
, assoc
= 4)
180 all_l1s
+= [cluster
.l1
]
181 elif options
.detailed
:
182 clusters
= [ Cluster() for i
in range(options
.numclusters
)]
183 for j
in range(options
.numclusters
):
185 for cluster
in clusters
:
186 cluster
.clusterbus
= L2XBar(clock
=busFrequency
)
187 all_l1buses
+= [cluster
.clusterbus
]
188 cluster
.cpus
= [DerivO3CPU(cpu_id
= i
+ cluster
.id,
189 clock
=options
.frequency
)
190 for i
in range(cpusPerCluster
)]
191 all_cpus
+= cluster
.cpus
192 cluster
.l1
= L1(size
=options
.l1size
, assoc
= 4)
193 all_l1s
+= [cluster
.l1
]
195 clusters
= [ Cluster() for i
in range(options
.numclusters
)]
196 for j
in range(options
.numclusters
):
198 for cluster
in clusters
:
199 cluster
.clusterbus
= L2XBar(clock
=busFrequency
)
200 all_l1buses
+= [cluster
.clusterbus
]
201 cluster
.cpus
= [AtomicSimpleCPU(cpu_id
= i
+ cluster
.id,
202 clock
=options
.frequency
)
203 for i
in range(cpusPerCluster
)]
204 all_cpus
+= cluster
.cpus
205 cluster
.l1
= L1(size
=options
.l1size
, assoc
= 4)
206 all_l1s
+= [cluster
.l1
]
208 # ----------------------
209 # Create a system, and add system wide objects
210 # ----------------------
211 system
= System(cpu
= all_cpus
, l1_
= all_l1s
, l1bus_
= all_l1buses
,
212 physmem
= SimpleMemory(),
213 membus
= SystemXBar(clock
= busFrequency
))
214 system
.clock
= '1GHz'
216 system
.toL2bus
= L2XBar(clock
= busFrequency
)
217 system
.l2
= L2(size
= options
.l2size
, assoc
= 8)
219 # ----------------------
220 # Connect the L2 cache and memory together
221 # ----------------------
223 system
.physmem
.port
= system
.membus
.master
224 system
.l2
.cpu_side
= system
.toL2bus
.slave
225 system
.l2
.mem_side
= system
.membus
.master
227 # ----------------------
228 # Connect the L2 cache and clusters together
229 # ----------------------
230 for cluster
in clusters
:
231 cluster
.l1
.cpu_side
= cluster
.clusterbus
.master
232 cluster
.l1
.mem_side
= system
.toL2bus
.slave
233 for cpu
in cluster
.cpus
:
234 cpu
.icache_port
= cluster
.clusterbus
.slave
235 cpu
.dcache_port
= cluster
.clusterbus
.slave
237 # ----------------------
239 # ----------------------
241 root
= Root(full_system
= False, system
= system
)
243 # --------------------
244 # Pick the correct Splash2 Benchmarks
245 # ====================
246 if options
.benchmark
== 'Cholesky':
247 root
.workload
= Cholesky()
248 elif options
.benchmark
== 'FFT':
249 root
.workload
= FFT()
250 elif options
.benchmark
== 'LUContig':
251 root
.workload
= LU_contig()
252 elif options
.benchmark
== 'LUNoncontig':
253 root
.workload
= LU_noncontig()
254 elif options
.benchmark
== 'Radix':
255 root
.workload
= Radix()
256 elif options
.benchmark
== 'Barnes':
257 root
.workload
= Barnes()
258 elif options
.benchmark
== 'FMM':
259 root
.workload
= FMM()
260 elif options
.benchmark
== 'OceanContig':
261 root
.workload
= Ocean_contig()
262 elif options
.benchmark
== 'OceanNoncontig':
263 root
.workload
= Ocean_noncontig()
264 elif options
.benchmark
== 'Raytrace':
265 root
.workload
= Raytrace()
266 elif options
.benchmark
== 'WaterNSquared':
267 root
.workload
= Water_nsquared()
268 elif options
.benchmark
== 'WaterSpatial':
269 root
.workload
= Water_spatial()
272 The --benchmark environment variable was set to something improper.
273 Use Cholesky, FFT, LUContig, LUNoncontig, Radix, Barnes, FMM, OceanContig,
274 OceanNoncontig, Raytrace, WaterNSquared, or WaterSpatial
277 # --------------------
278 # Assign the workload to the cpus
279 # ====================
281 for cluster
in clusters
:
282 for cpu
in cluster
.cpus
:
283 cpu
.workload
= root
.workload
285 system
.workload
= SEWorkload
.init_compatible(root
.workload
.executable
)
287 # ----------------------
289 # ----------------------
291 if options
.timing
or options
.detailed
:
292 root
.system
.mem_mode
= 'timing'
294 # instantiate configuration
297 # simulate until program terminates
299 exit_event
= m5
.simulate(options
.maxtick
)
301 exit_event
= m5
.simulate(m5
.MaxTick
)
303 print('Exiting @ tick', m5
.curTick(), 'because', exit_event
.getCause())