config: Default the indirect branch predictor to "None".
[gem5.git] / configs / common / Options.py
1 # Copyright (c) 2013-2019 ARM Limited
2 # All rights reserved.
3 #
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.
12 #
13 # Copyright (c) 2006-2008 The Regents of The University of Michigan
14 # All rights reserved.
15 #
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.
26 #
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.
38 #
39 # Authors: Lisa Hsu
40
41 from __future__ import print_function
42 from __future__ import absolute_import
43
44 import m5
45 from m5.defines import buildEnv
46 from m5.objects import *
47
48 from .Benchmarks import *
49 from . import ObjectList
50
51 vio_9p_help = """\
52 Enable the Virtio 9P device and set the path to share. The default 9p path is
53 m5ou5/9p/share, and it can be changed by setting VirtIO9p.root with --param. A
54 sample guest mount command is: "mount -t 9p -o
55 trans=virtio,version=9p2000.L,aname=<host-full-path> gem5 /mnt/9p" where
56 "<host-full-path>" is the full path being shared on the host, and "gem5" is a
57 fixed mount tag. This option requires the diod 9P server to be installed in the
58 host PATH or selected with with: VirtIO9PDiod.diod.
59 """
60
61 def _listCpuTypes(option, opt, value, parser):
62 ObjectList.cpu_list.print()
63 sys.exit(0)
64
65 def _listBPTypes(option, opt, value, parser):
66 ObjectList.bp_list.print()
67 sys.exit(0)
68
69 def _listHWPTypes(option, opt, value, parser):
70 ObjectList.hwp_list.print()
71 sys.exit(0)
72
73 def _listIndirectBPTypes(option, opt, value, parser):
74 ObjectList.indirect_bp_list.print()
75 sys.exit(0)
76
77 def _listMemTypes(option, opt, value, parser):
78 ObjectList.mem_list.print()
79 sys.exit(0)
80
81 def _listPlatformTypes(option, opt, value, parser):
82 ObjectList.platform_list.print()
83 sys.exit(0)
84
85 # Add the very basic options that work also in the case of the no ISA
86 # being used, and consequently no CPUs, but rather various types of
87 # testers and traffic generators.
88 def addNoISAOptions(parser):
89 parser.add_option("-n", "--num-cpus", type="int", default=1)
90 parser.add_option("--sys-voltage", action="store", type="string",
91 default='1.0V',
92 help = """Top-level voltage for blocks running at system
93 power supply""")
94 parser.add_option("--sys-clock", action="store", type="string",
95 default='1GHz',
96 help = """Top-level clock for blocks running at system
97 speed""")
98
99 # Memory Options
100 parser.add_option("--list-mem-types",
101 action="callback", callback=_listMemTypes,
102 help="List available memory types")
103 parser.add_option("--mem-type", type="choice", default="DDR3_1600_8x8",
104 choices=ObjectList.mem_list.get_names(),
105 help = "type of memory to use")
106 parser.add_option("--mem-channels", type="int", default=1,
107 help = "number of memory channels")
108 parser.add_option("--mem-ranks", type="int", default=None,
109 help = "number of memory ranks per channel")
110 parser.add_option("--mem-size", action="store", type="string",
111 default="512MB",
112 help="Specify the physical memory size (single memory)")
113 parser.add_option("--enable-dram-powerdown", action="store_true",
114 help="Enable low-power states in DRAMCtrl")
115
116
117 parser.add_option("--memchecker", action="store_true")
118
119 # Cache Options
120 parser.add_option("--external-memory-system", type="string",
121 help="use external ports of this port_type for caches")
122 parser.add_option("--tlm-memory", type="string",
123 help="use external port for SystemC TLM cosimulation")
124 parser.add_option("--caches", action="store_true")
125 parser.add_option("--l2cache", action="store_true")
126 parser.add_option("--num-dirs", type="int", default=1)
127 parser.add_option("--num-l2caches", type="int", default=1)
128 parser.add_option("--num-l3caches", type="int", default=1)
129 parser.add_option("--l1d_size", type="string", default="64kB")
130 parser.add_option("--l1i_size", type="string", default="32kB")
131 parser.add_option("--l2_size", type="string", default="2MB")
132 parser.add_option("--l3_size", type="string", default="16MB")
133 parser.add_option("--l1d_assoc", type="int", default=2)
134 parser.add_option("--l1i_assoc", type="int", default=2)
135 parser.add_option("--l2_assoc", type="int", default=8)
136 parser.add_option("--l3_assoc", type="int", default=16)
137 parser.add_option("--cacheline_size", type="int", default=64)
138
139 # Enable Ruby
140 parser.add_option("--ruby", action="store_true")
141
142 # Run duration options
143 parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick,
144 metavar="TICKS", help="Run to absolute simulated tick "
145 "specified including ticks from a restored checkpoint")
146 parser.add_option("--rel-max-tick", type="int", default=None,
147 metavar="TICKS", help="Simulate for specified number of"
148 " ticks relative to the simulation start tick (e.g. if "
149 "restoring a checkpoint)")
150 parser.add_option("--maxtime", type="float", default=None,
151 help="Run to the specified absolute simulated time in "
152 "seconds")
153 parser.add_option("-P", "--param", action="append", default=[],
154 help="Set a SimObject parameter relative to the root node. "
155 "An extended Python multi range slicing syntax can be used "
156 "for arrays. For example: "
157 "'system.cpu[0,1,3:8:2].max_insts_all_threads = 42' "
158 "sets max_insts_all_threads for cpus 0, 1, 3, 5 and 7 "
159 "Direct parameters of the root object are not accessible, "
160 "only parameters of its children.")
161
162 # Add common options that assume a non-NULL ISA.
163 def addCommonOptions(parser):
164 # start by adding the base options that do not assume an ISA
165 addNoISAOptions(parser)
166
167 # system options
168 parser.add_option("--list-cpu-types",
169 action="callback", callback=_listCpuTypes,
170 help="List available CPU types")
171 parser.add_option("--cpu-type", type="choice", default="AtomicSimpleCPU",
172 choices=ObjectList.cpu_list.get_names(),
173 help = "type of cpu to run with")
174 parser.add_option("--list-bp-types",
175 action="callback", callback=_listBPTypes,
176 help="List available branch predictor types")
177 parser.add_option("--list-indirect-bp-types",
178 action="callback", callback=_listIndirectBPTypes,
179 help="List available indirect branch predictor types")
180 parser.add_option("--bp-type", type="choice", default=None,
181 choices=ObjectList.bp_list.get_names(),
182 help = """
183 type of branch predictor to run with
184 (if not set, use the default branch predictor of
185 the selected CPU)""")
186 parser.add_option("--indirect-bp-type", type="choice", default=None,
187 choices=ObjectList.indirect_bp_list.get_names(),
188 help = "type of indirect branch predictor to run with")
189 parser.add_option("--list-hwp-types",
190 action="callback", callback=_listHWPTypes,
191 help="List available hardware prefetcher types")
192 parser.add_option("--l1i-hwp-type", type="choice", default=None,
193 choices=ObjectList.hwp_list.get_names(),
194 help = """
195 type of hardware prefetcher to use with the L1
196 instruction cache.
197 (if not set, use the default prefetcher of
198 the selected cache)""")
199 parser.add_option("--l1d-hwp-type", type="choice", default=None,
200 choices=ObjectList.hwp_list.get_names(),
201 help = """
202 type of hardware prefetcher to use with the L1
203 data cache.
204 (if not set, use the default prefetcher of
205 the selected cache)""")
206 parser.add_option("--l2-hwp-type", type="choice", default=None,
207 choices=ObjectList.hwp_list.get_names(),
208 help = """
209 type of hardware prefetcher to use with the L2 cache.
210 (if not set, use the default prefetcher of
211 the selected cache)""")
212 parser.add_option("--checker", action="store_true");
213 parser.add_option("--cpu-clock", action="store", type="string",
214 default='2GHz',
215 help="Clock for blocks running at CPU speed")
216 parser.add_option("--smt", action="store_true", default=False,
217 help = """
218 Only used if multiple programs are specified. If true,
219 then the number of threads per cpu is same as the
220 number of programs.""")
221 parser.add_option("--elastic-trace-en", action="store_true",
222 help="""Enable capture of data dependency and instruction
223 fetch traces using elastic trace probe.""")
224 # Trace file paths input to trace probe in a capture simulation and input
225 # to Trace CPU in a replay simulation
226 parser.add_option("--inst-trace-file", action="store", type="string",
227 help="""Instruction fetch trace file input to
228 Elastic Trace probe in a capture simulation and
229 Trace CPU in a replay simulation""", default="")
230 parser.add_option("--data-trace-file", action="store", type="string",
231 help="""Data dependency trace file input to
232 Elastic Trace probe in a capture simulation and
233 Trace CPU in a replay simulation""", default="")
234
235 parser.add_option("-l", "--lpae", action="store_true")
236 parser.add_option("-V", "--virtualisation", action="store_true")
237
238 # dist-gem5 options
239 parser.add_option("--dist", action="store_true",
240 help="Parallel distributed gem5 simulation.")
241 parser.add_option("--dist-sync-on-pseudo-op", action="store_true",
242 help="Use a pseudo-op to start dist-gem5 synchronization.")
243 parser.add_option("--is-switch", action="store_true",
244 help="Select the network switch simulator process for a"\
245 "distributed gem5 run")
246 parser.add_option("--dist-rank", default=0, action="store", type="int",
247 help="Rank of this system within the dist gem5 run.")
248 parser.add_option("--dist-size", default=0, action="store", type="int",
249 help="Number of gem5 processes within the dist gem5 run.")
250 parser.add_option("--dist-server-name",
251 default="127.0.0.1",
252 action="store", type="string",
253 help="Name of the message server host\nDEFAULT: localhost")
254 parser.add_option("--dist-server-port",
255 default=2200,
256 action="store", type="int",
257 help="Message server listen port\nDEFAULT: 2200")
258 parser.add_option("--dist-sync-repeat",
259 default="0us",
260 action="store", type="string",
261 help="Repeat interval for synchronisation barriers among dist-gem5 processes\nDEFAULT: --ethernet-linkdelay")
262 parser.add_option("--dist-sync-start",
263 default="5200000000000t",
264 action="store", type="string",
265 help="Time to schedule the first dist synchronisation barrier\nDEFAULT:5200000000000t")
266 parser.add_option("--ethernet-linkspeed", default="10Gbps",
267 action="store", type="string",
268 help="Link speed in bps\nDEFAULT: 10Gbps")
269 parser.add_option("--ethernet-linkdelay", default="10us",
270 action="store", type="string",
271 help="Link delay in seconds\nDEFAULT: 10us")
272
273 # Run duration options
274 parser.add_option("-I", "--maxinsts", action="store", type="int",
275 default=None, help="""Total number of instructions to
276 simulate (default: run forever)""")
277 parser.add_option("--work-item-id", action="store", type="int",
278 help="the specific work id for exit & checkpointing")
279 parser.add_option("--num-work-ids", action="store", type="int",
280 help="Number of distinct work item types")
281 parser.add_option("--work-begin-cpu-id-exit", action="store", type="int",
282 help="exit when work starts on the specified cpu")
283 parser.add_option("--work-end-exit-count", action="store", type="int",
284 help="exit at specified work end count")
285 parser.add_option("--work-begin-exit-count", action="store", type="int",
286 help="exit at specified work begin count")
287 parser.add_option("--init-param", action="store", type="int", default=0,
288 help="""Parameter available in simulation with m5
289 initparam""")
290 parser.add_option("--initialize-only", action="store_true", default=False,
291 help="""Exit after initialization. Do not simulate time.
292 Useful when gem5 is run as a library.""")
293
294 # Simpoint options
295 parser.add_option("--simpoint-profile", action="store_true",
296 help="Enable basic block profiling for SimPoints")
297 parser.add_option("--simpoint-interval", type="int", default=10000000,
298 help="SimPoint interval in num of instructions")
299 parser.add_option("--take-simpoint-checkpoints", action="store", type="string",
300 help="<simpoint file,weight file,interval-length,warmup-length>")
301 parser.add_option("--restore-simpoint-checkpoint", action="store_true",
302 help="restore from a simpoint checkpoint taken with " +
303 "--take-simpoint-checkpoints")
304
305 # Checkpointing options
306 ###Note that performing checkpointing via python script files will override
307 ###checkpoint instructions built into binaries.
308 parser.add_option("--take-checkpoints", action="store", type="string",
309 help="<M,N> take checkpoints at tick M and every N ticks thereafter")
310 parser.add_option("--max-checkpoints", action="store", type="int",
311 help="the maximum number of checkpoints to drop", default=5)
312 parser.add_option("--checkpoint-dir", action="store", type="string",
313 help="Place all checkpoints in this absolute directory")
314 parser.add_option("-r", "--checkpoint-restore", action="store", type="int",
315 help="restore from checkpoint <N>")
316 parser.add_option("--checkpoint-at-end", action="store_true",
317 help="take a checkpoint at end of run")
318 parser.add_option("--work-begin-checkpoint-count", action="store", type="int",
319 help="checkpoint at specified work begin count")
320 parser.add_option("--work-end-checkpoint-count", action="store", type="int",
321 help="checkpoint at specified work end count")
322 parser.add_option("--work-cpus-checkpoint-count", action="store", type="int",
323 help="checkpoint and exit when active cpu count is reached")
324 parser.add_option("--restore-with-cpu", action="store", type="choice",
325 default="AtomicSimpleCPU",
326 choices=ObjectList.cpu_list.get_names(),
327 help = "cpu type for restoring from a checkpoint")
328
329
330 # CPU Switching - default switch model goes from a checkpoint
331 # to a timing simple CPU with caches to warm up, then to detailed CPU for
332 # data measurement
333 parser.add_option("--repeat-switch", action="store", type="int",
334 default=None,
335 help="switch back and forth between CPUs with period <N>")
336 parser.add_option("-s", "--standard-switch", action="store", type="int",
337 default=None,
338 help="switch from timing to Detailed CPU after warmup period of <N>")
339 parser.add_option("-p", "--prog-interval", type="str",
340 help="CPU Progress Interval")
341
342 # Fastforwarding and simpoint related materials
343 parser.add_option("-W", "--warmup-insts", action="store", type="int",
344 default=None,
345 help="Warmup period in total instructions (requires --standard-switch)")
346 parser.add_option("--bench", action="store", type="string", default=None,
347 help="base names for --take-checkpoint and --checkpoint-restore")
348 parser.add_option("-F", "--fast-forward", action="store", type="string",
349 default=None,
350 help="Number of instructions to fast forward before switching")
351 parser.add_option("-S", "--simpoint", action="store_true", default=False,
352 help="""Use workload simpoints as an instruction offset for
353 --checkpoint-restore or --take-checkpoint.""")
354 parser.add_option("--at-instruction", action="store_true", default=False,
355 help="""Treat value of --checkpoint-restore or --take-checkpoint as a
356 number of instructions.""")
357 parser.add_option("--spec-input", default="ref", type="choice",
358 choices=["ref", "test", "train", "smred", "mdred",
359 "lgred"],
360 help="Input set size for SPEC CPU2000 benchmarks.")
361 parser.add_option("--arm-iset", default="arm", type="choice",
362 choices=["arm", "thumb", "aarch64"],
363 help="ARM instruction set.")
364
365
366 def addSEOptions(parser):
367 # Benchmark options
368 parser.add_option("-c", "--cmd", default="",
369 help="The binary to run in syscall emulation mode.")
370 parser.add_option("-o", "--options", default="",
371 help="""The options to pass to the binary, use " "
372 around the entire string""")
373 parser.add_option("-e", "--env", default="",
374 help="Initialize workload environment from text file.")
375 parser.add_option("-i", "--input", default="",
376 help="Read stdin from a file.")
377 parser.add_option("--output", default="",
378 help="Redirect stdout to a file.")
379 parser.add_option("--errout", default="",
380 help="Redirect stderr to a file.")
381 parser.add_option("--chroot", action="store", type="string", default=None,
382 help="The chroot option allows a user to alter the " \
383 "search path for processes running in SE mode. " \
384 "Normally, the search path would begin at the " \
385 "root of the filesystem (i.e. /). With chroot, " \
386 "a user can force the process to begin looking at" \
387 "some other location (i.e. /home/user/rand_dir)." \
388 "The intended use is to trick sophisticated " \
389 "software which queries the __HOST__ filesystem " \
390 "for information or functionality. Instead of " \
391 "finding files on the __HOST__ filesystem, the " \
392 "process will find the user's replacment files.")
393 parser.add_option("--interp-dir", action="store", type="string",
394 default=None,
395 help="The interp-dir option is used for "
396 "setting the interpreter's path. This will "
397 "allow to load the guest dynamic linker/loader "
398 "itself from the elf binary. The option points to "
399 "the parent folder of the guest /lib in the "
400 "host fs")
401
402 parser.add_option("--redirects", action="append", type="string",
403 default=[],
404 help="A collection of one or more redirect paths "
405 "to be used in syscall emulation."
406 "Usage: gem5.opt [...] --redirects /dir1=/path/"
407 "to/host/dir1 --redirects /dir2=/path/to/host/dir2")
408
409
410
411 def addFSOptions(parser):
412 from .FSConfig import os_types
413
414 # Simulation options
415 parser.add_option("--timesync", action="store_true",
416 help="Prevent simulated time from getting ahead of real time")
417
418 # System options
419 parser.add_option("--kernel", action="store", type="string")
420 parser.add_option("--os-type", action="store", type="choice",
421 choices=os_types[str(buildEnv['TARGET_ISA'])],
422 default="linux",
423 help="Specifies type of OS to boot")
424 parser.add_option("--script", action="store", type="string")
425 parser.add_option("--frame-capture", action="store_true",
426 help="Stores changed frame buffers from the VNC server to compressed "\
427 "files in the gem5 output directory")
428
429 if buildEnv['TARGET_ISA'] == "arm":
430 parser.add_option("--bare-metal", action="store_true",
431 help="Provide the raw system without the linux specific bits")
432 parser.add_option("--list-machine-types",
433 action="callback", callback=_listPlatformTypes,
434 help="List available platform types")
435 parser.add_option("--machine-type", action="store", type="choice",
436 choices=ObjectList.platform_list.get_names(),
437 default="VExpress_EMM")
438 parser.add_option("--dtb-filename", action="store", type="string",
439 help="Specifies device tree blob file to use with device-tree-"\
440 "enabled kernels")
441 parser.add_option("--enable-security-extensions", action="store_true",
442 help="Turn on the ARM Security Extensions")
443 parser.add_option("--enable-context-switch-stats-dump", \
444 action="store_true", help="Enable stats dump at context "\
445 "switches and dump tasks file (required for Streamline)")
446 parser.add_option("--vio-9p", action="store_true", help=vio_9p_help)
447
448 # Benchmark options
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",
452 dest="benchmark",
453 help="Specify the benchmark to run. Available benchmarks: %s"\
454 % DefinedBenchmarks)
455
456 # Metafile options
457 parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
458 help="Specify the filename to dump a pcap capture of the" \
459 "ethernet traffic")
460
461 # Disk Image Options
462 parser.add_option("--disk-image", action="store", type="string", default=None,
463 help="Path to the disk image to use.")
464 parser.add_option("--root-device", action="store", type="string", default=None,
465 help="OS device name for root partition")
466
467 # Command line options
468 parser.add_option("--command-line", action="store", type="string",
469 default=None,
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")