Options.py revision 10159
11693Sstever@eecs.umich.edu# Copyright (c) 2013 ARM Limited
21693Sstever@eecs.umich.edu# All rights reserved.
31693Sstever@eecs.umich.edu#
41693Sstever@eecs.umich.edu# The license below extends only to copyright in the software and shall
51693Sstever@eecs.umich.edu# not be construed as granting a license to any other intellectual
61693Sstever@eecs.umich.edu# property including but not limited to intellectual property relating
71693Sstever@eecs.umich.edu# to a hardware implementation of the functionality of the software
81693Sstever@eecs.umich.edu# licensed hereunder.  You may use the software subject to the license
91693Sstever@eecs.umich.edu# terms below provided that you ensure that this notice is replicated
101693Sstever@eecs.umich.edu# unmodified and in its entirety in all distributions of the software,
111693Sstever@eecs.umich.edu# modified or unmodified, in source code or in binary form.
121693Sstever@eecs.umich.edu#
131693Sstever@eecs.umich.edu# Copyright (c) 2006-2008 The Regents of The University of Michigan
141693Sstever@eecs.umich.edu# All rights reserved.
151693Sstever@eecs.umich.edu#
161693Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
171693Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are
181693Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright
191693Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
201693Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
211693Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
221693Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution;
231693Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its
241693Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from
251693Sstever@eecs.umich.edu# this software without specific prior written permission.
261693Sstever@eecs.umich.edu#
271693Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
281693Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
291693Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
301516SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
311516SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
321516SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
331516SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
341516SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
351516SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
361516SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
371569SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
381516SN/A#
391516SN/A# Authors: Lisa Hsu
401516SN/A
411516SN/Aimport m5
421569SN/Afrom m5.defines import buildEnv
431516SN/Afrom m5.objects import *
441516SN/Afrom Benchmarks import *
451516SN/A
461516SN/Aimport CpuConfig
471516SN/Aimport MemConfig
481516SN/A
491516SN/Adef _listCpuTypes(option, opt, value, parser):
501516SN/A    CpuConfig.print_cpu_list()
511516SN/A    sys.exit(0)
521516SN/A
531516SN/Adef _listMemTypes(option, opt, value, parser):
541516SN/A    MemConfig.print_mem_list()
551516SN/A    sys.exit(0)
561516SN/A
571516SN/Adef addCommonOptions(parser):
581516SN/A    # system options
591516SN/A    parser.add_option("--list-cpu-types",
601516SN/A                      action="callback", callback=_listCpuTypes,
611516SN/A                      help="List available CPU types")
621516SN/A    parser.add_option("--cpu-type", type="choice", default="atomic",
631516SN/A                      choices=CpuConfig.cpu_names(),
641516SN/A                      help = "type of cpu to run with")
651516SN/A    parser.add_option("--checker", action="store_true");
661516SN/A    parser.add_option("-n", "--num-cpus", type="int", default=1)
671516SN/A    parser.add_option("--sys-voltage", action="store", type="string",
681516SN/A                      default='1.0V',
691516SN/A                      help = """Top-level voltage for blocks running at system
701516SN/A                      power supply""")
711516SN/A    parser.add_option("--sys-clock", action="store", type="string",
721516SN/A                      default='1GHz',
731516SN/A                      help = """Top-level clock for blocks running at system
741516SN/A                      speed""")
751516SN/A    parser.add_option("--cpu-clock", action="store", type="string",
761516SN/A                      default='2GHz',
771516SN/A                      help="Clock for blocks running at CPU speed")
781516SN/A    parser.add_option("--smt", action="store_true", default=False,
791516SN/A                      help = """
80                      Only used if multiple programs are specified. If true,
81                      then the number of threads per cpu is same as the
82                      number of programs.""")
83
84    # Memory Options
85    parser.add_option("--list-mem-types",
86                      action="callback", callback=_listMemTypes,
87                      help="List available memory types")
88    parser.add_option("--mem-type", type="choice", default="ddr3_1600_x64",
89                      choices=MemConfig.mem_names(),
90                      help = "type of memory to use")
91    parser.add_option("--mem-channels", type="int", default=1,
92                      help = "number of memory channels")
93    parser.add_option("--mem-size", action="store", type="string",
94                      default="512MB",
95                      help="Specify the physical memory size (single memory)")
96
97    parser.add_option("-l", "--lpae", action="store_true")
98    parser.add_option("-V", "--virtualisation", action="store_true")
99
100    # Cache Options
101    parser.add_option("--caches", action="store_true")
102    parser.add_option("--l2cache", action="store_true")
103    parser.add_option("--fastmem", action="store_true")
104    parser.add_option("--num-dirs", type="int", default=1)
105    parser.add_option("--num-l2caches", type="int", default=1)
106    parser.add_option("--num-l3caches", type="int", default=1)
107    parser.add_option("--l1d_size", type="string", default="64kB")
108    parser.add_option("--l1i_size", type="string", default="32kB")
109    parser.add_option("--l2_size", type="string", default="2MB")
110    parser.add_option("--l3_size", type="string", default="16MB")
111    parser.add_option("--l1d_assoc", type="int", default=2)
112    parser.add_option("--l1i_assoc", type="int", default=2)
113    parser.add_option("--l2_assoc", type="int", default=8)
114    parser.add_option("--l3_assoc", type="int", default=16)
115    parser.add_option("--cacheline_size", type="int", default=64)
116
117    # Enable Ruby
118    parser.add_option("--ruby", action="store_true")
119
120    # Run duration options
121    parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick,
122                      metavar="TICKS", help="Run to absolute simulated tick " \
123                      "specified including ticks from a restored checkpoint")
124    parser.add_option("--rel-max-tick", type="int", default=None,
125                      metavar="TICKS", help="Simulate for specified number of" \
126                      " ticks relative to the simulation start tick (e.g. if " \
127                      "restoring a checkpoint)")
128    parser.add_option("--maxtime", type="float", default=None,
129                      help="Run to the specified absolute simulated time in " \
130                      "seconds")
131    parser.add_option("-I", "--maxinsts", action="store", type="int",
132                      default=None, help="""Total number of instructions to
133                                            simulate (default: run forever)""")
134    parser.add_option("--work-item-id", action="store", type="int",
135                      help="the specific work id for exit & checkpointing")
136    parser.add_option("--num-work-ids", action="store", type="int",
137                      help="Number of distinct work item types")
138    parser.add_option("--work-begin-cpu-id-exit", action="store", type="int",
139                      help="exit when work starts on the specified cpu")
140    parser.add_option("--work-end-exit-count", action="store", type="int",
141                      help="exit at specified work end count")
142    parser.add_option("--work-begin-exit-count", action="store", type="int",
143                      help="exit at specified work begin count")
144    parser.add_option("--init-param", action="store", type="int", default=0,
145                      help="""Parameter available in simulation with m5
146                              initparam""")
147
148    # Simpoint options
149    parser.add_option("--simpoint-profile", action="store_true",
150                      help="Enable basic block profiling for SimPoints")
151    parser.add_option("--simpoint-interval", type="int", default=10000000,
152                      help="SimPoint interval in num of instructions")
153
154    # Checkpointing options
155    ###Note that performing checkpointing via python script files will override
156    ###checkpoint instructions built into binaries.
157    parser.add_option("--take-checkpoints", action="store", type="string",
158        help="<M,N> take checkpoints at tick M and every N ticks thereafter")
159    parser.add_option("--max-checkpoints", action="store", type="int",
160        help="the maximum number of checkpoints to drop", default=5)
161    parser.add_option("--checkpoint-dir", action="store", type="string",
162        help="Place all checkpoints in this absolute directory")
163    parser.add_option("-r", "--checkpoint-restore", action="store", type="int",
164        help="restore from checkpoint <N>")
165    parser.add_option("--checkpoint-at-end", action="store_true",
166                      help="take a checkpoint at end of run")
167    parser.add_option("--work-begin-checkpoint-count", action="store", type="int",
168                      help="checkpoint at specified work begin count")
169    parser.add_option("--work-end-checkpoint-count", action="store", type="int",
170                      help="checkpoint at specified work end count")
171    parser.add_option("--work-cpus-checkpoint-count", action="store", type="int",
172                      help="checkpoint and exit when active cpu count is reached")
173    parser.add_option("--restore-with-cpu", action="store", type="choice",
174                      default="atomic", choices=CpuConfig.cpu_names(),
175                      help = "cpu type for restoring from a checkpoint")
176
177
178    # CPU Switching - default switch model goes from a checkpoint
179    # to a timing simple CPU with caches to warm up, then to detailed CPU for
180    # data measurement
181    parser.add_option("--repeat-switch", action="store", type="int",
182        default=None,
183        help="switch back and forth between CPUs with period <N>")
184    parser.add_option("-s", "--standard-switch", action="store", type="int",
185        default=None,
186        help="switch from timing to Detailed CPU after warmup period of <N>")
187    parser.add_option("-p", "--prog-interval", type="str",
188        help="CPU Progress Interval")
189
190    # Fastforwarding and simpoint related materials
191    parser.add_option("-W", "--warmup-insts", action="store", type="int",
192        default=None,
193        help="Warmup period in total instructions (requires --standard-switch)")
194    parser.add_option("--bench", action="store", type="string", default=None,
195        help="base names for --take-checkpoint and --checkpoint-restore")
196    parser.add_option("-F", "--fast-forward", action="store", type="string",
197        default=None,
198        help="Number of instructions to fast forward before switching")
199    parser.add_option("-S", "--simpoint", action="store_true", default=False,
200        help="""Use workload simpoints as an instruction offset for
201                --checkpoint-restore or --take-checkpoint.""")
202    parser.add_option("--at-instruction", action="store_true", default=False,
203        help="""Treat value of --checkpoint-restore or --take-checkpoint as a
204                number of instructions.""")
205    parser.add_option("--spec-input", default="ref", type="choice",
206                      choices=["ref", "test", "train", "smred", "mdred",
207                               "lgred"],
208                      help="Input set size for SPEC CPU2000 benchmarks.")
209    parser.add_option("--arm-iset", default="arm", type="choice",
210                      choices=["arm", "thumb", "aarch64"],
211                      help="ARM instruction set.")
212
213
214def addSEOptions(parser):
215    # Benchmark options
216    parser.add_option("-c", "--cmd", default="",
217                      help="The binary to run in syscall emulation mode.")
218    parser.add_option("-o", "--options", default="",
219                      help="""The options to pass to the binary, use " "
220                              around the entire string""")
221    parser.add_option("-i", "--input", default="",
222                      help="Read stdin from a file.")
223    parser.add_option("--output", default="",
224                      help="Redirect stdout to a file.")
225    parser.add_option("--errout", default="",
226                      help="Redirect stderr to a file.")
227
228def addFSOptions(parser):
229    # Simulation options
230    parser.add_option("--timesync", action="store_true",
231            help="Prevent simulated time from getting ahead of real time")
232
233    # System options
234    parser.add_option("--kernel", action="store", type="string")
235    parser.add_option("--script", action="store", type="string")
236    parser.add_option("--frame-capture", action="store_true",
237            help="Stores changed frame buffers from the VNC server to compressed "\
238            "files in the gem5 output directory")
239
240    if buildEnv['TARGET_ISA'] == "arm":
241        parser.add_option("--bare-metal", action="store_true",
242                   help="Provide the raw system without the linux specific bits")
243        parser.add_option("--machine-type", action="store", type="choice",
244                choices=ArmMachineType.map.keys(), default="RealView_PBX")
245        parser.add_option("--dtb-filename", action="store", type="string",
246              help="Specifies device tree blob file to use with device-tree-"\
247              "enabled kernels")
248        parser.add_option("--enable-context-switch-stats-dump", \
249                action="store_true", help="Enable stats dump at context "\
250                "switches and dump tasks file (required for Streamline)")
251
252    # Benchmark options
253    parser.add_option("--dual", action="store_true",
254                      help="Simulate two systems attached with an ethernet link")
255    parser.add_option("-b", "--benchmark", action="store", type="string",
256                      dest="benchmark",
257                      help="Specify the benchmark to run. Available benchmarks: %s"\
258                      % DefinedBenchmarks)
259
260    # Metafile options
261    parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
262                      help="Specify the filename to dump a pcap capture of the" \
263                      "ethernet traffic")
264
265    # Disk Image Options
266    parser.add_option("--disk-image", action="store", type="string", default=None,
267                      help="Path to the disk image to use.")
268