Options.py revision 10993:4e27d8806403
1# Copyright (c) 2013 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
41import m5
42from m5.defines import buildEnv
43from m5.objects import *
44from Benchmarks import *
45
46import CpuConfig
47import MemConfig
48
49from FSConfig import os_types
50
51def _listCpuTypes(option, opt, value, parser):
52    CpuConfig.print_cpu_list()
53    sys.exit(0)
54
55def _listMemTypes(option, opt, value, parser):
56    MemConfig.print_mem_list()
57    sys.exit(0)
58
59def addCommonOptions(parser):
60    # system options
61    parser.add_option("--list-cpu-types",
62                      action="callback", callback=_listCpuTypes,
63                      help="List available CPU types")
64    parser.add_option("--cpu-type", type="choice", default="atomic",
65                      choices=CpuConfig.cpu_names(),
66                      help = "type of cpu to run with")
67    parser.add_option("--checker", action="store_true");
68    parser.add_option("-n", "--num-cpus", type="int", default=1)
69    parser.add_option("--sys-voltage", action="store", type="string",
70                      default='1.0V',
71                      help = """Top-level voltage for blocks running at system
72                      power supply""")
73    parser.add_option("--sys-clock", action="store", type="string",
74                      default='1GHz',
75                      help = """Top-level clock for blocks running at system
76                      speed""")
77    parser.add_option("--cpu-clock", action="store", type="string",
78                      default='2GHz',
79                      help="Clock for blocks running at CPU speed")
80    parser.add_option("--smt", action="store_true", default=False,
81                      help = """
82                      Only used if multiple programs are specified. If true,
83                      then the number of threads per cpu is same as the
84                      number of programs.""")
85
86    # Memory Options
87    parser.add_option("--list-mem-types",
88                      action="callback", callback=_listMemTypes,
89                      help="List available memory types")
90    parser.add_option("--mem-type", type="choice", default="DDR3_1600_x64",
91                      choices=MemConfig.mem_names(),
92                      help = "type of memory to use")
93    parser.add_option("--mem-channels", type="int", default=1,
94                      help = "number of memory channels")
95    parser.add_option("--mem-ranks", type="int", default=None,
96                      help = "number of memory ranks per channel")
97    parser.add_option("--mem-size", action="store", type="string",
98                      default="512MB",
99                      help="Specify the physical memory size (single memory)")
100
101    parser.add_option("-l", "--lpae", action="store_true")
102    parser.add_option("-V", "--virtualisation", action="store_true")
103
104    parser.add_option("--memchecker", action="store_true")
105
106    # Cache Options
107    parser.add_option("--external-memory-system", type="string",
108                      help="use external ports of this port_type for caches")
109    parser.add_option("--tlm-memory", type="string",
110                      help="use external port for SystemC TLM cosimulation")
111    parser.add_option("--caches", action="store_true")
112    parser.add_option("--l2cache", action="store_true")
113    parser.add_option("--fastmem", action="store_true")
114    parser.add_option("--num-dirs", type="int", default=1)
115    parser.add_option("--num-l2caches", type="int", default=1)
116    parser.add_option("--num-l3caches", type="int", default=1)
117    parser.add_option("--l1d_size", type="string", default="64kB")
118    parser.add_option("--l1i_size", type="string", default="32kB")
119    parser.add_option("--l2_size", type="string", default="2MB")
120    parser.add_option("--l3_size", type="string", default="16MB")
121    parser.add_option("--l1d_assoc", type="int", default=2)
122    parser.add_option("--l1i_assoc", type="int", default=2)
123    parser.add_option("--l2_assoc", type="int", default=8)
124    parser.add_option("--l3_assoc", type="int", default=16)
125    parser.add_option("--cacheline_size", type="int", default=64)
126
127    # Enable Ruby
128    parser.add_option("--ruby", action="store_true")
129
130    # Run duration options
131    parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick,
132                      metavar="TICKS", help="Run to absolute simulated tick " \
133                      "specified including ticks from a restored checkpoint")
134    parser.add_option("--rel-max-tick", type="int", default=None,
135                      metavar="TICKS", help="Simulate for specified number of" \
136                      " ticks relative to the simulation start tick (e.g. if " \
137                      "restoring a checkpoint)")
138    parser.add_option("--maxtime", type="float", default=None,
139                      help="Run to the specified absolute simulated time in " \
140                      "seconds")
141    parser.add_option("-I", "--maxinsts", action="store", type="int",
142                      default=None, help="""Total number of instructions to
143                                            simulate (default: run forever)""")
144    parser.add_option("--work-item-id", action="store", type="int",
145                      help="the specific work id for exit & checkpointing")
146    parser.add_option("--num-work-ids", action="store", type="int",
147                      help="Number of distinct work item types")
148    parser.add_option("--work-begin-cpu-id-exit", action="store", type="int",
149                      help="exit when work starts on the specified cpu")
150    parser.add_option("--work-end-exit-count", action="store", type="int",
151                      help="exit at specified work end count")
152    parser.add_option("--work-begin-exit-count", action="store", type="int",
153                      help="exit at specified work begin count")
154    parser.add_option("--init-param", action="store", type="int", default=0,
155                      help="""Parameter available in simulation with m5
156                              initparam""")
157    parser.add_option("--initialize-only", action="store_true", default=False,
158                      help="""Exit after initialization. Do not simulate time.
159                              Useful when gem5 is run as a library.""")
160
161    # Simpoint options
162    parser.add_option("--simpoint-profile", action="store_true",
163                      help="Enable basic block profiling for SimPoints")
164    parser.add_option("--simpoint-interval", type="int", default=10000000,
165                      help="SimPoint interval in num of instructions")
166    parser.add_option("--take-simpoint-checkpoints", action="store", type="string",
167        help="<simpoint file,weight file,interval-length,warmup-length>")
168    parser.add_option("--restore-simpoint-checkpoint", action="store_true",
169        help="restore from a simpoint checkpoint taken with " +
170             "--take-simpoint-checkpoints")
171
172    # Checkpointing options
173    ###Note that performing checkpointing via python script files will override
174    ###checkpoint instructions built into binaries.
175    parser.add_option("--take-checkpoints", action="store", type="string",
176        help="<M,N> take checkpoints at tick M and every N ticks thereafter")
177    parser.add_option("--max-checkpoints", action="store", type="int",
178        help="the maximum number of checkpoints to drop", default=5)
179    parser.add_option("--checkpoint-dir", action="store", type="string",
180        help="Place all checkpoints in this absolute directory")
181    parser.add_option("-r", "--checkpoint-restore", action="store", type="int",
182        help="restore from checkpoint <N>")
183    parser.add_option("--checkpoint-at-end", action="store_true",
184                      help="take a checkpoint at end of run")
185    parser.add_option("--work-begin-checkpoint-count", action="store", type="int",
186                      help="checkpoint at specified work begin count")
187    parser.add_option("--work-end-checkpoint-count", action="store", type="int",
188                      help="checkpoint at specified work end count")
189    parser.add_option("--work-cpus-checkpoint-count", action="store", type="int",
190                      help="checkpoint and exit when active cpu count is reached")
191    parser.add_option("--restore-with-cpu", action="store", type="choice",
192                      default="atomic", choices=CpuConfig.cpu_names(),
193                      help = "cpu type for restoring from a checkpoint")
194
195
196    # CPU Switching - default switch model goes from a checkpoint
197    # to a timing simple CPU with caches to warm up, then to detailed CPU for
198    # data measurement
199    parser.add_option("--repeat-switch", action="store", type="int",
200        default=None,
201        help="switch back and forth between CPUs with period <N>")
202    parser.add_option("-s", "--standard-switch", action="store", type="int",
203        default=None,
204        help="switch from timing to Detailed CPU after warmup period of <N>")
205    parser.add_option("-p", "--prog-interval", type="str",
206        help="CPU Progress Interval")
207
208    # Fastforwarding and simpoint related materials
209    parser.add_option("-W", "--warmup-insts", action="store", type="int",
210        default=None,
211        help="Warmup period in total instructions (requires --standard-switch)")
212    parser.add_option("--bench", action="store", type="string", default=None,
213        help="base names for --take-checkpoint and --checkpoint-restore")
214    parser.add_option("-F", "--fast-forward", action="store", type="string",
215        default=None,
216        help="Number of instructions to fast forward before switching")
217    parser.add_option("-S", "--simpoint", action="store_true", default=False,
218        help="""Use workload simpoints as an instruction offset for
219                --checkpoint-restore or --take-checkpoint.""")
220    parser.add_option("--at-instruction", action="store_true", default=False,
221        help="""Treat value of --checkpoint-restore or --take-checkpoint as a
222                number of instructions.""")
223    parser.add_option("--spec-input", default="ref", type="choice",
224                      choices=["ref", "test", "train", "smred", "mdred",
225                               "lgred"],
226                      help="Input set size for SPEC CPU2000 benchmarks.")
227    parser.add_option("--arm-iset", default="arm", type="choice",
228                      choices=["arm", "thumb", "aarch64"],
229                      help="ARM instruction set.")
230
231
232def addSEOptions(parser):
233    # Benchmark options
234    parser.add_option("-c", "--cmd", default="",
235                      help="The binary to run in syscall emulation mode.")
236    parser.add_option("-o", "--options", default="",
237                      help="""The options to pass to the binary, use " "
238                              around the entire string""")
239    parser.add_option("-e", "--env", default="",
240                      help="Initialize workload environment from text file.")
241    parser.add_option("-i", "--input", default="",
242                      help="Read stdin from a file.")
243    parser.add_option("--output", default="",
244                      help="Redirect stdout to a file.")
245    parser.add_option("--errout", default="",
246                      help="Redirect stderr to a file.")
247
248def addFSOptions(parser):
249    # Simulation options
250    parser.add_option("--timesync", action="store_true",
251            help="Prevent simulated time from getting ahead of real time")
252
253    # System options
254    parser.add_option("--kernel", action="store", type="string")
255    parser.add_option("--os-type", action="store", type="choice",
256            choices=os_types[buildEnv['TARGET_ISA']], default="linux",
257            help="Specifies type of OS to boot")
258    parser.add_option("--script", action="store", type="string")
259    parser.add_option("--frame-capture", action="store_true",
260            help="Stores changed frame buffers from the VNC server to compressed "\
261            "files in the gem5 output directory")
262
263    if buildEnv['TARGET_ISA'] == "arm":
264        parser.add_option("--bare-metal", action="store_true",
265                   help="Provide the raw system without the linux specific bits")
266        parser.add_option("--machine-type", action="store", type="choice",
267                choices=ArmMachineType.map.keys(), default="VExpress_EMM")
268        parser.add_option("--dtb-filename", action="store", type="string",
269              help="Specifies device tree blob file to use with device-tree-"\
270              "enabled kernels")
271        parser.add_option("--enable-context-switch-stats-dump", \
272                action="store_true", help="Enable stats dump at context "\
273                "switches and dump tasks file (required for Streamline)")
274
275    # Benchmark options
276    parser.add_option("--dual", action="store_true",
277                      help="Simulate two systems attached with an ethernet link")
278    parser.add_option("-b", "--benchmark", action="store", type="string",
279                      dest="benchmark",
280                      help="Specify the benchmark to run. Available benchmarks: %s"\
281                      % DefinedBenchmarks)
282
283    # Metafile options
284    parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
285                      help="Specify the filename to dump a pcap capture of the" \
286                      "ethernet traffic")
287
288    # Disk Image Options
289    parser.add_option("--disk-image", action="store", type="string", default=None,
290                      help="Path to the disk image to use.")
291    parser.add_option("--root-device", action="store", type="string", default=None,
292                      help="OS device name for root partition")
293
294    # Command line options
295    parser.add_option("--command-line", action="store", type="string",
296                      default=None,
297                      help="Template for the kernel command line.")
298    parser.add_option("--command-line-file", action="store",
299                      default=None, type="string",
300                      help="File with a template for the kernel command line")
301