71d22a4619f0f5b552e801e93097de917936a6aa
[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",
187 default="SimpleIndirectPredictor",
188 choices=ObjectList.indirect_bp_list.get_names(),
189 help = "type of indirect branch predictor to run with")
190 parser.add_option("--list-hwp-types",
191 action="callback", callback=_listHWPTypes,
192 help="List available hardware prefetcher types")
193 parser.add_option("--l1i-hwp-type", type="choice", default=None,
194 choices=ObjectList.hwp_list.get_names(),
195 help = """
196 type of hardware prefetcher to use with the L1
197 instruction cache.
198 (if not set, use the default prefetcher of
199 the selected cache)""")
200 parser.add_option("--l1d-hwp-type", type="choice", default=None,
201 choices=ObjectList.hwp_list.get_names(),
202 help = """
203 type of hardware prefetcher to use with the L1
204 data cache.
205 (if not set, use the default prefetcher of
206 the selected cache)""")
207 parser.add_option("--l2-hwp-type", type="choice", default=None,
208 choices=ObjectList.hwp_list.get_names(),
209 help = """
210 type of hardware prefetcher to use with the L2 cache.
211 (if not set, use the default prefetcher of
212 the selected cache)""")
213 parser.add_option("--checker", action="store_true");
214 parser.add_option("--cpu-clock", action="store", type="string",
215 default='2GHz',
216 help="Clock for blocks running at CPU speed")
217 parser.add_option("--smt", action="store_true", default=False,
218 help = """
219 Only used if multiple programs are specified. If true,
220 then the number of threads per cpu is same as the
221 number of programs.""")
222 parser.add_option("--elastic-trace-en", action="store_true",
223 help="""Enable capture of data dependency and instruction
224 fetch traces using elastic trace probe.""")
225 # Trace file paths input to trace probe in a capture simulation and input
226 # to Trace CPU in a replay simulation
227 parser.add_option("--inst-trace-file", action="store", type="string",
228 help="""Instruction fetch trace file input to
229 Elastic Trace probe in a capture simulation and
230 Trace CPU in a replay simulation""", default="")
231 parser.add_option("--data-trace-file", action="store", type="string",
232 help="""Data dependency trace file input to
233 Elastic Trace probe in a capture simulation and
234 Trace CPU in a replay simulation""", default="")
235
236 parser.add_option("-l", "--lpae", action="store_true")
237 parser.add_option("-V", "--virtualisation", action="store_true")
238
239 # dist-gem5 options
240 parser.add_option("--dist", action="store_true",
241 help="Parallel distributed gem5 simulation.")
242 parser.add_option("--dist-sync-on-pseudo-op", action="store_true",
243 help="Use a pseudo-op to start dist-gem5 synchronization.")
244 parser.add_option("--is-switch", action="store_true",
245 help="Select the network switch simulator process for a"\
246 "distributed gem5 run")
247 parser.add_option("--dist-rank", default=0, action="store", type="int",
248 help="Rank of this system within the dist gem5 run.")
249 parser.add_option("--dist-size", default=0, action="store", type="int",
250 help="Number of gem5 processes within the dist gem5 run.")
251 parser.add_option("--dist-server-name",
252 default="127.0.0.1",
253 action="store", type="string",
254 help="Name of the message server host\nDEFAULT: localhost")
255 parser.add_option("--dist-server-port",
256 default=2200,
257 action="store", type="int",
258 help="Message server listen port\nDEFAULT: 2200")
259 parser.add_option("--dist-sync-repeat",
260 default="0us",
261 action="store", type="string",
262 help="Repeat interval for synchronisation barriers among dist-gem5 processes\nDEFAULT: --ethernet-linkdelay")
263 parser.add_option("--dist-sync-start",
264 default="5200000000000t",
265 action="store", type="string",
266 help="Time to schedule the first dist synchronisation barrier\nDEFAULT:5200000000000t")
267 parser.add_option("--ethernet-linkspeed", default="10Gbps",
268 action="store", type="string",
269 help="Link speed in bps\nDEFAULT: 10Gbps")
270 parser.add_option("--ethernet-linkdelay", default="10us",
271 action="store", type="string",
272 help="Link delay in seconds\nDEFAULT: 10us")
273
274 # Run duration options
275 parser.add_option("-I", "--maxinsts", action="store", type="int",
276 default=None, help="""Total number of instructions to
277 simulate (default: run forever)""")
278 parser.add_option("--work-item-id", action="store", type="int",
279 help="the specific work id for exit & checkpointing")
280 parser.add_option("--num-work-ids", action="store", type="int",
281 help="Number of distinct work item types")
282 parser.add_option("--work-begin-cpu-id-exit", action="store", type="int",
283 help="exit when work starts on the specified cpu")
284 parser.add_option("--work-end-exit-count", action="store", type="int",
285 help="exit at specified work end count")
286 parser.add_option("--work-begin-exit-count", action="store", type="int",
287 help="exit at specified work begin count")
288 parser.add_option("--init-param", action="store", type="int", default=0,
289 help="""Parameter available in simulation with m5
290 initparam""")
291 parser.add_option("--initialize-only", action="store_true", default=False,
292 help="""Exit after initialization. Do not simulate time.
293 Useful when gem5 is run as a library.""")
294
295 # Simpoint options
296 parser.add_option("--simpoint-profile", action="store_true",
297 help="Enable basic block profiling for SimPoints")
298 parser.add_option("--simpoint-interval", type="int", default=10000000,
299 help="SimPoint interval in num of instructions")
300 parser.add_option("--take-simpoint-checkpoints", action="store", type="string",
301 help="<simpoint file,weight file,interval-length,warmup-length>")
302 parser.add_option("--restore-simpoint-checkpoint", action="store_true",
303 help="restore from a simpoint checkpoint taken with " +
304 "--take-simpoint-checkpoints")
305
306 # Checkpointing options
307 ###Note that performing checkpointing via python script files will override
308 ###checkpoint instructions built into binaries.
309 parser.add_option("--take-checkpoints", action="store", type="string",
310 help="<M,N> take checkpoints at tick M and every N ticks thereafter")
311 parser.add_option("--max-checkpoints", action="store", type="int",
312 help="the maximum number of checkpoints to drop", default=5)
313 parser.add_option("--checkpoint-dir", action="store", type="string",
314 help="Place all checkpoints in this absolute directory")
315 parser.add_option("-r", "--checkpoint-restore", action="store", type="int",
316 help="restore from checkpoint <N>")
317 parser.add_option("--checkpoint-at-end", action="store_true",
318 help="take a checkpoint at end of run")
319 parser.add_option("--work-begin-checkpoint-count", action="store", type="int",
320 help="checkpoint at specified work begin count")
321 parser.add_option("--work-end-checkpoint-count", action="store", type="int",
322 help="checkpoint at specified work end count")
323 parser.add_option("--work-cpus-checkpoint-count", action="store", type="int",
324 help="checkpoint and exit when active cpu count is reached")
325 parser.add_option("--restore-with-cpu", action="store", type="choice",
326 default="AtomicSimpleCPU",
327 choices=ObjectList.cpu_list.get_names(),
328 help = "cpu type for restoring from a checkpoint")
329
330
331 # CPU Switching - default switch model goes from a checkpoint
332 # to a timing simple CPU with caches to warm up, then to detailed CPU for
333 # data measurement
334 parser.add_option("--repeat-switch", action="store", type="int",
335 default=None,
336 help="switch back and forth between CPUs with period <N>")
337 parser.add_option("-s", "--standard-switch", action="store", type="int",
338 default=None,
339 help="switch from timing to Detailed CPU after warmup period of <N>")
340 parser.add_option("-p", "--prog-interval", type="str",
341 help="CPU Progress Interval")
342
343 # Fastforwarding and simpoint related materials
344 parser.add_option("-W", "--warmup-insts", action="store", type="int",
345 default=None,
346 help="Warmup period in total instructions (requires --standard-switch)")
347 parser.add_option("--bench", action="store", type="string", default=None,
348 help="base names for --take-checkpoint and --checkpoint-restore")
349 parser.add_option("-F", "--fast-forward", action="store", type="string",
350 default=None,
351 help="Number of instructions to fast forward before switching")
352 parser.add_option("-S", "--simpoint", action="store_true", default=False,
353 help="""Use workload simpoints as an instruction offset for
354 --checkpoint-restore or --take-checkpoint.""")
355 parser.add_option("--at-instruction", action="store_true", default=False,
356 help="""Treat value of --checkpoint-restore or --take-checkpoint as a
357 number of instructions.""")
358 parser.add_option("--spec-input", default="ref", type="choice",
359 choices=["ref", "test", "train", "smred", "mdred",
360 "lgred"],
361 help="Input set size for SPEC CPU2000 benchmarks.")
362 parser.add_option("--arm-iset", default="arm", type="choice",
363 choices=["arm", "thumb", "aarch64"],
364 help="ARM instruction set.")
365
366
367 def addSEOptions(parser):
368 # Benchmark options
369 parser.add_option("-c", "--cmd", default="",
370 help="The binary to run in syscall emulation mode.")
371 parser.add_option("-o", "--options", default="",
372 help="""The options to pass to the binary, use " "
373 around the entire string""")
374 parser.add_option("-e", "--env", default="",
375 help="Initialize workload environment from text file.")
376 parser.add_option("-i", "--input", default="",
377 help="Read stdin from a file.")
378 parser.add_option("--output", default="",
379 help="Redirect stdout to a file.")
380 parser.add_option("--errout", default="",
381 help="Redirect stderr to a file.")
382 parser.add_option("--chroot", action="store", type="string", default=None,
383 help="The chroot option allows a user to alter the " \
384 "search path for processes running in SE mode. " \
385 "Normally, the search path would begin at the " \
386 "root of the filesystem (i.e. /). With chroot, " \
387 "a user can force the process to begin looking at" \
388 "some other location (i.e. /home/user/rand_dir)." \
389 "The intended use is to trick sophisticated " \
390 "software which queries the __HOST__ filesystem " \
391 "for information or functionality. Instead of " \
392 "finding files on the __HOST__ filesystem, the " \
393 "process will find the user's replacment files.")
394 parser.add_option("--interp-dir", action="store", type="string",
395 default=None,
396 help="The interp-dir option is used for "
397 "setting the interpreter's path. This will "
398 "allow to load the guest dynamic linker/loader "
399 "itself from the elf binary. The option points to "
400 "the parent folder of the guest /lib in the "
401 "host fs")
402
403 parser.add_option("--redirects", action="append", type="string",
404 default=[],
405 help="A collection of one or more redirect paths "
406 "to be used in syscall emulation."
407 "Usage: gem5.opt [...] --redirects /dir1=/path/"
408 "to/host/dir1 --redirects /dir2=/path/to/host/dir2")
409
410
411
412 def addFSOptions(parser):
413 from .FSConfig import os_types
414
415 # Simulation options
416 parser.add_option("--timesync", action="store_true",
417 help="Prevent simulated time from getting ahead of real time")
418
419 # System options
420 parser.add_option("--kernel", action="store", type="string")
421 parser.add_option("--os-type", action="store", type="choice",
422 choices=os_types[str(buildEnv['TARGET_ISA'])],
423 default="linux",
424 help="Specifies type of OS to boot")
425 parser.add_option("--script", action="store", type="string")
426 parser.add_option("--frame-capture", action="store_true",
427 help="Stores changed frame buffers from the VNC server to compressed "\
428 "files in the gem5 output directory")
429
430 if buildEnv['TARGET_ISA'] == "arm":
431 parser.add_option("--bare-metal", action="store_true",
432 help="Provide the raw system without the linux specific bits")
433 parser.add_option("--list-machine-types",
434 action="callback", callback=_listPlatformTypes,
435 help="List available platform types")
436 parser.add_option("--machine-type", action="store", type="choice",
437 choices=ObjectList.platform_list.get_names(),
438 default="VExpress_EMM")
439 parser.add_option("--dtb-filename", action="store", type="string",
440 help="Specifies device tree blob file to use with device-tree-"\
441 "enabled kernels")
442 parser.add_option("--enable-security-extensions", action="store_true",
443 help="Turn on the ARM Security Extensions")
444 parser.add_option("--enable-context-switch-stats-dump", \
445 action="store_true", help="Enable stats dump at context "\
446 "switches and dump tasks file (required for Streamline)")
447 parser.add_option("--vio-9p", action="store_true", help=vio_9p_help)
448
449 # Benchmark options
450 parser.add_option("--dual", action="store_true",
451 help="Simulate two systems attached with an ethernet link")
452 parser.add_option("-b", "--benchmark", action="store", type="string",
453 dest="benchmark",
454 help="Specify the benchmark to run. Available benchmarks: %s"\
455 % DefinedBenchmarks)
456
457 # Metafile options
458 parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
459 help="Specify the filename to dump a pcap capture of the" \
460 "ethernet traffic")
461
462 # Disk Image Options
463 parser.add_option("--disk-image", action="store", type="string", default=None,
464 help="Path to the disk image to use.")
465 parser.add_option("--root-device", action="store", type="string", default=None,
466 help="OS device name for root partition")
467
468 # Command line options
469 parser.add_option("--command-line", action="store", type="string",
470 default=None,
471 help="Template for the kernel command line.")
472 parser.add_option("--command-line-file", action="store",
473 default=None, type="string",
474 help="File with a template for the kernel command line")