1 # Copyright (c) 2013-2019 ARM Limited
4 # The license below extends only to copyright in the software and shall
5 # not be construed as granting a license to any other intellectual
6 # property including but not limited to intellectual property relating
7 # to a hardware implementation of the functionality of the software
8 # licensed hereunder. You may use the software subject to the license
9 # terms below provided that you ensure that this notice is replicated
10 # unmodified and in its entirety in all distributions of the software,
11 # modified or unmodified, in source code or in binary form.
13 # Copyright (c) 2006-2008 The Regents of The University of Michigan
14 # All rights reserved.
16 # Redistribution and use in source and binary forms, with or without
17 # modification, are permitted provided that the following conditions are
18 # met: redistributions of source code must retain the above copyright
19 # notice, this list of conditions and the following disclaimer;
20 # redistributions in binary form must reproduce the above copyright
21 # notice, this list of conditions and the following disclaimer in the
22 # documentation and/or other materials provided with the distribution;
23 # neither the name of the copyright holders nor the names of its
24 # contributors may be used to endorse or promote products derived from
25 # this software without specific prior written permission.
27 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 from __future__
import print_function
40 from __future__
import absolute_import
43 from m5
.defines
import buildEnv
44 from m5
.objects
import *
46 from common
.Benchmarks
import *
47 from common
import ObjectList
50 Enable the Virtio 9P device and set the path to share. The default 9p path is
51 m5ou5/9p/share, and it can be changed by setting VirtIO9p.root with --param. A
52 sample guest mount command is: "mount -t 9p -o
53 trans=virtio,version=9p2000.L,aname=<host-full-path> gem5 /mnt/9p" where
54 "<host-full-path>" is the full path being shared on the host, and "gem5" is a
55 fixed mount tag. This option requires the diod 9P server to be installed in the
56 host PATH or selected with with: VirtIO9PDiod.diod.
59 def _listCpuTypes(option
, opt
, value
, parser
):
60 ObjectList
.cpu_list
.print()
63 def _listBPTypes(option
, opt
, value
, parser
):
64 ObjectList
.bp_list
.print()
67 def _listHWPTypes(option
, opt
, value
, parser
):
68 ObjectList
.hwp_list
.print()
71 def _listIndirectBPTypes(option
, opt
, value
, parser
):
72 ObjectList
.indirect_bp_list
.print()
75 def _listMemTypes(option
, opt
, value
, parser
):
76 ObjectList
.mem_list
.print()
79 def _listPlatformTypes(option
, opt
, value
, parser
):
80 ObjectList
.platform_list
.print()
83 # Add the very basic options that work also in the case of the no ISA
84 # being used, and consequently no CPUs, but rather various types of
85 # testers and traffic generators.
86 def addNoISAOptions(parser
):
87 parser
.add_option("-n", "--num-cpus", type="int", default
=1)
88 parser
.add_option("--sys-voltage", action
="store", type="string",
90 help = """Top-level voltage for blocks running at system
92 parser
.add_option("--sys-clock", action
="store", type="string",
94 help = """Top-level clock for blocks running at system
98 parser
.add_option("--list-mem-types",
99 action
="callback", callback
=_listMemTypes
,
100 help="List available memory types")
101 parser
.add_option("--mem-type", type="choice", default
="DDR3_1600_8x8",
102 choices
=ObjectList
.mem_list
.get_names(),
103 help = "type of memory to use")
104 parser
.add_option("--mem-channels", type="int", default
=1,
105 help = "number of memory channels")
106 parser
.add_option("--mem-ranks", type="int", default
=None,
107 help = "number of memory ranks per channel")
108 parser
.add_option("--mem-size", action
="store", type="string",
110 help="Specify the physical memory size (single memory)")
111 parser
.add_option("--enable-dram-powerdown", action
="store_true",
112 help="Enable low-power states in DRAMCtrl")
115 parser
.add_option("--memchecker", action
="store_true")
118 parser
.add_option("--external-memory-system", type="string",
119 help="use external ports of this port_type for caches")
120 parser
.add_option("--tlm-memory", type="string",
121 help="use external port for SystemC TLM cosimulation")
122 parser
.add_option("--caches", action
="store_true")
123 parser
.add_option("--l2cache", action
="store_true")
124 parser
.add_option("--num-dirs", type="int", default
=1)
125 parser
.add_option("--num-l2caches", type="int", default
=1)
126 parser
.add_option("--num-l3caches", type="int", default
=1)
127 parser
.add_option("--l1d_size", type="string", default
="64kB")
128 parser
.add_option("--l1i_size", type="string", default
="32kB")
129 parser
.add_option("--l2_size", type="string", default
="2MB")
130 parser
.add_option("--l3_size", type="string", default
="16MB")
131 parser
.add_option("--l1d_assoc", type="int", default
=2)
132 parser
.add_option("--l1i_assoc", type="int", default
=2)
133 parser
.add_option("--l2_assoc", type="int", default
=8)
134 parser
.add_option("--l3_assoc", type="int", default
=16)
135 parser
.add_option("--cacheline_size", type="int", default
=64)
138 parser
.add_option("--ruby", action
="store_true")
140 # Run duration options
141 parser
.add_option("-m", "--abs-max-tick", type="int", default
=m5
.MaxTick
,
142 metavar
="TICKS", help="Run to absolute simulated tick "
143 "specified including ticks from a restored checkpoint")
144 parser
.add_option("--rel-max-tick", type="int", default
=None,
145 metavar
="TICKS", help="Simulate for specified number of"
146 " ticks relative to the simulation start tick (e.g. if "
147 "restoring a checkpoint)")
148 parser
.add_option("--maxtime", type="float", default
=None,
149 help="Run to the specified absolute simulated time in "
151 parser
.add_option("-P", "--param", action
="append", default
=[],
152 help="Set a SimObject parameter relative to the root node. "
153 "An extended Python multi range slicing syntax can be used "
154 "for arrays. For example: "
155 "'system.cpu[0,1,3:8:2].max_insts_all_threads = 42' "
156 "sets max_insts_all_threads for cpus 0, 1, 3, 5 and 7 "
157 "Direct parameters of the root object are not accessible, "
158 "only parameters of its children.")
160 # Add common options that assume a non-NULL ISA.
161 def addCommonOptions(parser
):
162 # start by adding the base options that do not assume an ISA
163 addNoISAOptions(parser
)
166 parser
.add_option("--list-cpu-types",
167 action
="callback", callback
=_listCpuTypes
,
168 help="List available CPU types")
169 parser
.add_option("--cpu-type", type="choice", default
="AtomicSimpleCPU",
170 choices
=ObjectList
.cpu_list
.get_names(),
171 help = "type of cpu to run with")
172 parser
.add_option("--list-bp-types",
173 action
="callback", callback
=_listBPTypes
,
174 help="List available branch predictor types")
175 parser
.add_option("--list-indirect-bp-types",
176 action
="callback", callback
=_listIndirectBPTypes
,
177 help="List available indirect branch predictor types")
178 parser
.add_option("--bp-type", type="choice", default
=None,
179 choices
=ObjectList
.bp_list
.get_names(),
181 type of branch predictor to run with
182 (if not set, use the default branch predictor of
183 the selected CPU)""")
184 parser
.add_option("--indirect-bp-type", type="choice", default
=None,
185 choices
=ObjectList
.indirect_bp_list
.get_names(),
186 help = "type of indirect branch predictor to run with")
187 parser
.add_option("--list-hwp-types",
188 action
="callback", callback
=_listHWPTypes
,
189 help="List available hardware prefetcher types")
190 parser
.add_option("--l1i-hwp-type", type="choice", default
=None,
191 choices
=ObjectList
.hwp_list
.get_names(),
193 type of hardware prefetcher to use with the L1
195 (if not set, use the default prefetcher of
196 the selected cache)""")
197 parser
.add_option("--l1d-hwp-type", type="choice", default
=None,
198 choices
=ObjectList
.hwp_list
.get_names(),
200 type of hardware prefetcher to use with the L1
202 (if not set, use the default prefetcher of
203 the selected cache)""")
204 parser
.add_option("--l2-hwp-type", type="choice", default
=None,
205 choices
=ObjectList
.hwp_list
.get_names(),
207 type of hardware prefetcher to use with the L2 cache.
208 (if not set, use the default prefetcher of
209 the selected cache)""")
210 parser
.add_option("--checker", action
="store_true");
211 parser
.add_option("--cpu-clock", action
="store", type="string",
213 help="Clock for blocks running at CPU speed")
214 parser
.add_option("--smt", action
="store_true", default
=False,
216 Only used if multiple programs are specified. If true,
217 then the number of threads per cpu is same as the
218 number of programs.""")
219 parser
.add_option("--elastic-trace-en", action
="store_true",
220 help="""Enable capture of data dependency and instruction
221 fetch traces using elastic trace probe.""")
222 # Trace file paths input to trace probe in a capture simulation and input
223 # to Trace CPU in a replay simulation
224 parser
.add_option("--inst-trace-file", action
="store", type="string",
225 help="""Instruction fetch trace file input to
226 Elastic Trace probe in a capture simulation and
227 Trace CPU in a replay simulation""", default
="")
228 parser
.add_option("--data-trace-file", action
="store", type="string",
229 help="""Data dependency trace file input to
230 Elastic Trace probe in a capture simulation and
231 Trace CPU in a replay simulation""", default
="")
233 parser
.add_option("-l", "--lpae", action
="store_true")
234 parser
.add_option("-V", "--virtualisation", action
="store_true")
237 parser
.add_option("--dist", action
="store_true",
238 help="Parallel distributed gem5 simulation.")
239 parser
.add_option("--dist-sync-on-pseudo-op", action
="store_true",
240 help="Use a pseudo-op to start dist-gem5 synchronization.")
241 parser
.add_option("--is-switch", action
="store_true",
242 help="Select the network switch simulator process for a"\
243 "distributed gem5 run")
244 parser
.add_option("--dist-rank", default
=0, action
="store", type="int",
245 help="Rank of this system within the dist gem5 run.")
246 parser
.add_option("--dist-size", default
=0, action
="store", type="int",
247 help="Number of gem5 processes within the dist gem5 run.")
248 parser
.add_option("--dist-server-name",
250 action
="store", type="string",
251 help="Name of the message server host\nDEFAULT: localhost")
252 parser
.add_option("--dist-server-port",
254 action
="store", type="int",
255 help="Message server listen port\nDEFAULT: 2200")
256 parser
.add_option("--dist-sync-repeat",
258 action
="store", type="string",
259 help="Repeat interval for synchronisation barriers among dist-gem5 processes\nDEFAULT: --ethernet-linkdelay")
260 parser
.add_option("--dist-sync-start",
261 default
="5200000000000t",
262 action
="store", type="string",
263 help="Time to schedule the first dist synchronisation barrier\nDEFAULT:5200000000000t")
264 parser
.add_option("--ethernet-linkspeed", default
="10Gbps",
265 action
="store", type="string",
266 help="Link speed in bps\nDEFAULT: 10Gbps")
267 parser
.add_option("--ethernet-linkdelay", default
="10us",
268 action
="store", type="string",
269 help="Link delay in seconds\nDEFAULT: 10us")
271 # Run duration options
272 parser
.add_option("-I", "--maxinsts", action
="store", type="int",
273 default
=None, help="""Total number of instructions to
274 simulate (default: run forever)""")
275 parser
.add_option("--work-item-id", action
="store", type="int",
276 help="the specific work id for exit & checkpointing")
277 parser
.add_option("--num-work-ids", action
="store", type="int",
278 help="Number of distinct work item types")
279 parser
.add_option("--work-begin-cpu-id-exit", action
="store", type="int",
280 help="exit when work starts on the specified cpu")
281 parser
.add_option("--work-end-exit-count", action
="store", type="int",
282 help="exit at specified work end count")
283 parser
.add_option("--work-begin-exit-count", action
="store", type="int",
284 help="exit at specified work begin count")
285 parser
.add_option("--init-param", action
="store", type="int", default
=0,
286 help="""Parameter available in simulation with m5
288 parser
.add_option("--initialize-only", action
="store_true", default
=False,
289 help="""Exit after initialization. Do not simulate time.
290 Useful when gem5 is run as a library.""")
293 parser
.add_option("--simpoint-profile", action
="store_true",
294 help="Enable basic block profiling for SimPoints")
295 parser
.add_option("--simpoint-interval", type="int", default
=10000000,
296 help="SimPoint interval in num of instructions")
297 parser
.add_option("--take-simpoint-checkpoints", action
="store", type="string",
298 help="<simpoint file,weight file,interval-length,warmup-length>")
299 parser
.add_option("--restore-simpoint-checkpoint", action
="store_true",
300 help="restore from a simpoint checkpoint taken with " +
301 "--take-simpoint-checkpoints")
303 # Checkpointing options
304 ###Note that performing checkpointing via python script files will override
305 ###checkpoint instructions built into binaries.
306 parser
.add_option("--take-checkpoints", action
="store", type="string",
307 help="<M,N> take checkpoints at tick M and every N ticks thereafter")
308 parser
.add_option("--max-checkpoints", action
="store", type="int",
309 help="the maximum number of checkpoints to drop", default
=5)
310 parser
.add_option("--checkpoint-dir", action
="store", type="string",
311 help="Place all checkpoints in this absolute directory")
312 parser
.add_option("-r", "--checkpoint-restore", action
="store", type="int",
313 help="restore from checkpoint <N>")
314 parser
.add_option("--checkpoint-at-end", action
="store_true",
315 help="take a checkpoint at end of run")
316 parser
.add_option("--work-begin-checkpoint-count", action
="store", type="int",
317 help="checkpoint at specified work begin count")
318 parser
.add_option("--work-end-checkpoint-count", action
="store", type="int",
319 help="checkpoint at specified work end count")
320 parser
.add_option("--work-cpus-checkpoint-count", action
="store", type="int",
321 help="checkpoint and exit when active cpu count is reached")
322 parser
.add_option("--restore-with-cpu", action
="store", type="choice",
323 default
="AtomicSimpleCPU",
324 choices
=ObjectList
.cpu_list
.get_names(),
325 help = "cpu type for restoring from a checkpoint")
328 # CPU Switching - default switch model goes from a checkpoint
329 # to a timing simple CPU with caches to warm up, then to detailed CPU for
331 parser
.add_option("--repeat-switch", action
="store", type="int",
333 help="switch back and forth between CPUs with period <N>")
334 parser
.add_option("-s", "--standard-switch", action
="store", type="int",
336 help="switch from timing to Detailed CPU after warmup period of <N>")
337 parser
.add_option("-p", "--prog-interval", type="str",
338 help="CPU Progress Interval")
340 # Fastforwarding and simpoint related materials
341 parser
.add_option("-W", "--warmup-insts", action
="store", type="int",
343 help="Warmup period in total instructions (requires --standard-switch)")
344 parser
.add_option("--bench", action
="store", type="string", default
=None,
345 help="base names for --take-checkpoint and --checkpoint-restore")
346 parser
.add_option("-F", "--fast-forward", action
="store", type="string",
348 help="Number of instructions to fast forward before switching")
349 parser
.add_option("-S", "--simpoint", action
="store_true", default
=False,
350 help="""Use workload simpoints as an instruction offset for
351 --checkpoint-restore or --take-checkpoint.""")
352 parser
.add_option("--at-instruction", action
="store_true", default
=False,
353 help="""Treat value of --checkpoint-restore or --take-checkpoint as a
354 number of instructions.""")
355 parser
.add_option("--spec-input", default
="ref", type="choice",
356 choices
=["ref", "test", "train", "smred", "mdred",
358 help="Input set size for SPEC CPU2000 benchmarks.")
359 parser
.add_option("--arm-iset", default
="arm", type="choice",
360 choices
=["arm", "thumb", "aarch64"],
361 help="ARM instruction set.")
364 def addSEOptions(parser
):
366 parser
.add_option("-c", "--cmd", default
="",
367 help="The binary to run in syscall emulation mode.")
368 parser
.add_option("-o", "--options", default
="",
369 help="""The options to pass to the binary, use " "
370 around the entire string""")
371 parser
.add_option("-e", "--env", default
="",
372 help="Initialize workload environment from text file.")
373 parser
.add_option("-i", "--input", default
="",
374 help="Read stdin from a file.")
375 parser
.add_option("--output", default
="",
376 help="Redirect stdout to a file.")
377 parser
.add_option("--errout", default
="",
378 help="Redirect stderr to a file.")
379 parser
.add_option("--chroot", action
="store", type="string", default
=None,
380 help="The chroot option allows a user to alter the " \
381 "search path for processes running in SE mode. " \
382 "Normally, the search path would begin at the " \
383 "root of the filesystem (i.e. /). With chroot, " \
384 "a user can force the process to begin looking at" \
385 "some other location (i.e. /home/user/rand_dir)." \
386 "The intended use is to trick sophisticated " \
387 "software which queries the __HOST__ filesystem " \
388 "for information or functionality. Instead of " \
389 "finding files on the __HOST__ filesystem, the " \
390 "process will find the user's replacment files.")
391 parser
.add_option("--interp-dir", action
="store", type="string",
393 help="The interp-dir option is used for "
394 "setting the interpreter's path. This will "
395 "allow to load the guest dynamic linker/loader "
396 "itself from the elf binary. The option points to "
397 "the parent folder of the guest /lib in the "
400 parser
.add_option("--redirects", action
="append", type="string",
402 help="A collection of one or more redirect paths "
403 "to be used in syscall emulation."
404 "Usage: gem5.opt [...] --redirects /dir1=/path/"
405 "to/host/dir1 --redirects /dir2=/path/to/host/dir2")
409 def addFSOptions(parser
):
410 from common
.FSConfig
import os_types
413 parser
.add_option("--timesync", action
="store_true",
414 help="Prevent simulated time from getting ahead of real time")
417 parser
.add_option("--kernel", action
="store", type="string")
418 parser
.add_option("--os-type", action
="store", type="choice",
419 choices
=os_types
[str(buildEnv
['TARGET_ISA'])],
421 help="Specifies type of OS to boot")
422 parser
.add_option("--script", action
="store", type="string")
423 parser
.add_option("--frame-capture", action
="store_true",
424 help="Stores changed frame buffers from the VNC server to compressed "\
425 "files in the gem5 output directory")
427 if buildEnv
['TARGET_ISA'] == "arm":
428 parser
.add_option("--bare-metal", action
="store_true",
429 help="Provide the raw system without the linux specific bits")
430 parser
.add_option("--list-machine-types",
431 action
="callback", callback
=_listPlatformTypes
,
432 help="List available platform types")
433 parser
.add_option("--machine-type", action
="store", type="choice",
434 choices
=ObjectList
.platform_list
.get_names(),
435 default
="VExpress_GEM5_V1")
436 parser
.add_option("--dtb-filename", action
="store", type="string",
437 help="Specifies device tree blob file to use with device-tree-"\
439 parser
.add_option("--enable-security-extensions", action
="store_true",
440 help="Turn on the ARM Security Extensions")
441 parser
.add_option("--enable-context-switch-stats-dump", \
442 action
="store_true", help="Enable stats dump at context "\
443 "switches and dump tasks file (required for Streamline)")
444 parser
.add_option("--vio-9p", action
="store_true", help=vio_9p_help
)
445 parser
.add_option("--bootloader", action
='append',
446 help="executable file that runs before the --kernel")
449 parser
.add_option("--dual", action
="store_true",
450 help="Simulate two systems attached with an ethernet link")
451 parser
.add_option("-b", "--benchmark", action
="store", type="string",
453 help="Specify the benchmark to run. Available benchmarks: %s"\
457 parser
.add_option("--etherdump", action
="store", type="string", dest
="etherdump",
458 help="Specify the filename to dump a pcap capture of the" \
462 parser
.add_option("--disk-image", action
="append", type="string",
463 default
=[], help="Path to the disk images to use.")
464 parser
.add_option("--root-device", action
="store", type="string",
465 default
=None, help="OS device name for root partition")
467 # Command line options
468 parser
.add_option("--command-line", action
="store", type="string",
470 help="Template for the kernel command line.")
471 parser
.add_option("--command-line-file", action
="store",
472 default
=None, type="string",
473 help="File with a template for the kernel command line")