Options.py revision 10747:3fe41011333d
17008Snate@binkert.org# Copyright (c) 2013 ARM Limited
27008Snate@binkert.org# All rights reserved.
37008Snate@binkert.org#
47008Snate@binkert.org# The license below extends only to copyright in the software and shall
57008Snate@binkert.org# not be construed as granting a license to any other intellectual
67008Snate@binkert.org# property including but not limited to intellectual property relating
77008Snate@binkert.org# to a hardware implementation of the functionality of the software
87008Snate@binkert.org# licensed hereunder.  You may use the software subject to the license
97008Snate@binkert.org# terms below provided that you ensure that this notice is replicated
107008Snate@binkert.org# unmodified and in its entirety in all distributions of the software,
117008Snate@binkert.org# modified or unmodified, in source code or in binary form.
127008Snate@binkert.org#
137008Snate@binkert.org# Copyright (c) 2006-2008 The Regents of The University of Michigan
147008Snate@binkert.org# All rights reserved.
157008Snate@binkert.org#
167008Snate@binkert.org# Redistribution and use in source and binary forms, with or without
177008Snate@binkert.org# modification, are permitted provided that the following conditions are
187008Snate@binkert.org# met: redistributions of source code must retain the above copyright
197008Snate@binkert.org# notice, this list of conditions and the following disclaimer;
207008Snate@binkert.org# redistributions in binary form must reproduce the above copyright
217008Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
227008Snate@binkert.org# documentation and/or other materials provided with the distribution;
237008Snate@binkert.org# neither the name of the copyright holders nor the names of its
247008Snate@binkert.org# contributors may be used to endorse or promote products derived from
257008Snate@binkert.org# this software without specific prior written permission.
267008Snate@binkert.org#
277008Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
286285Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
297039Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
307039Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
316285Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
327055Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
337055Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
346876Ssteve.reinhardt@amd.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
358341Snilay@cs.wisc.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
366285Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
376506Spdudnik@gmail.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
387055Snate@binkert.org#
398436SBrad.Beckmann@amd.com# Authors: Lisa Hsu
406881SBrad.Beckmann@amd.com
418436SBrad.Beckmann@amd.comimport m5
427055Snate@binkert.orgfrom m5.defines import buildEnv
437055Snate@binkert.orgfrom m5.objects import *
446285Snate@binkert.orgfrom Benchmarks import *
456285Snate@binkert.org
466285Snate@binkert.orgimport CpuConfig
476285Snate@binkert.orgimport MemConfig
487039Snate@binkert.org
497039Snate@binkert.orgfrom FSConfig import os_types
507039Snate@binkert.org
516876Ssteve.reinhardt@amd.comdef _listCpuTypes(option, opt, value, parser):
528436SBrad.Beckmann@amd.com    CpuConfig.print_cpu_list()
538257SBrad.Beckmann@amd.com    sys.exit(0)
546285Snate@binkert.org
557039Snate@binkert.orgdef _listMemTypes(option, opt, value, parser):
567039Snate@binkert.org    MemConfig.print_mem_list()
577039Snate@binkert.org    sys.exit(0)
587039Snate@binkert.org
597055Snate@binkert.orgdef addCommonOptions(parser):
607055Snate@binkert.org    # system options
617055Snate@binkert.org    parser.add_option("--list-cpu-types",
627039Snate@binkert.org                      action="callback", callback=_listCpuTypes,
637039Snate@binkert.org                      help="List available CPU types")
647039Snate@binkert.org    parser.add_option("--cpu-type", type="choice", default="atomic",
657039Snate@binkert.org                      choices=CpuConfig.cpu_names(),
668436SBrad.Beckmann@amd.com                      help = "type of cpu to run with")
678436SBrad.Beckmann@amd.com    parser.add_option("--checker", action="store_true");
686285Snate@binkert.org    parser.add_option("-n", "--num-cpus", type="int", default=1)
697055Snate@binkert.org    parser.add_option("--sys-voltage", action="store", type="string",
707055Snate@binkert.org                      default='1.0V',
717055Snate@binkert.org                      help = """Top-level voltage for blocks running at system
727039Snate@binkert.org                      power supply""")
737055Snate@binkert.org    parser.add_option("--sys-clock", action="store", type="string",
747039Snate@binkert.org                      default='1GHz',
756285Snate@binkert.org                      help = """Top-level clock for blocks running at system
766285Snate@binkert.org                      speed""")
777039Snate@binkert.org    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("--caches", action="store_true")
108    parser.add_option("--l2cache", action="store_true")
109    parser.add_option("--fastmem", action="store_true")
110    parser.add_option("--num-dirs", type="int", default=1)
111    parser.add_option("--num-l2caches", type="int", default=1)
112    parser.add_option("--num-l3caches", type="int", default=1)
113    parser.add_option("--l1d_size", type="string", default="64kB")
114    parser.add_option("--l1i_size", type="string", default="32kB")
115    parser.add_option("--l2_size", type="string", default="2MB")
116    parser.add_option("--l3_size", type="string", default="16MB")
117    parser.add_option("--l1d_assoc", type="int", default=2)
118    parser.add_option("--l1i_assoc", type="int", default=2)
119    parser.add_option("--l2_assoc", type="int", default=8)
120    parser.add_option("--l3_assoc", type="int", default=16)
121    parser.add_option("--cacheline_size", type="int", default=64)
122
123    # Enable Ruby
124    parser.add_option("--ruby", action="store_true")
125
126    # Run duration options
127    parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick,
128                      metavar="TICKS", help="Run to absolute simulated tick " \
129                      "specified including ticks from a restored checkpoint")
130    parser.add_option("--rel-max-tick", type="int", default=None,
131                      metavar="TICKS", help="Simulate for specified number of" \
132                      " ticks relative to the simulation start tick (e.g. if " \
133                      "restoring a checkpoint)")
134    parser.add_option("--maxtime", type="float", default=None,
135                      help="Run to the specified absolute simulated time in " \
136                      "seconds")
137    parser.add_option("-I", "--maxinsts", action="store", type="int",
138                      default=None, help="""Total number of instructions to
139                                            simulate (default: run forever)""")
140    parser.add_option("--work-item-id", action="store", type="int",
141                      help="the specific work id for exit & checkpointing")
142    parser.add_option("--num-work-ids", action="store", type="int",
143                      help="Number of distinct work item types")
144    parser.add_option("--work-begin-cpu-id-exit", action="store", type="int",
145                      help="exit when work starts on the specified cpu")
146    parser.add_option("--work-end-exit-count", action="store", type="int",
147                      help="exit at specified work end count")
148    parser.add_option("--work-begin-exit-count", action="store", type="int",
149                      help="exit at specified work begin count")
150    parser.add_option("--init-param", action="store", type="int", default=0,
151                      help="""Parameter available in simulation with m5
152                              initparam""")
153
154    # Simpoint options
155    parser.add_option("--simpoint-profile", action="store_true",
156                      help="Enable basic block profiling for SimPoints")
157    parser.add_option("--simpoint-interval", type="int", default=10000000,
158                      help="SimPoint interval in num of instructions")
159    parser.add_option("--take-simpoint-checkpoints", action="store", type="string",
160        help="<simpoint file,weight file,interval-length,warmup-length>")
161    parser.add_option("--restore-simpoint-checkpoint", action="store_true",
162        help="restore from a simpoint checkpoint taken with " +
163             "--take-simpoint-checkpoints")
164
165    # Checkpointing options
166    ###Note that performing checkpointing via python script files will override
167    ###checkpoint instructions built into binaries.
168    parser.add_option("--take-checkpoints", action="store", type="string",
169        help="<M,N> take checkpoints at tick M and every N ticks thereafter")
170    parser.add_option("--max-checkpoints", action="store", type="int",
171        help="the maximum number of checkpoints to drop", default=5)
172    parser.add_option("--checkpoint-dir", action="store", type="string",
173        help="Place all checkpoints in this absolute directory")
174    parser.add_option("-r", "--checkpoint-restore", action="store", type="int",
175        help="restore from checkpoint <N>")
176    parser.add_option("--checkpoint-at-end", action="store_true",
177                      help="take a checkpoint at end of run")
178    parser.add_option("--work-begin-checkpoint-count", action="store", type="int",
179                      help="checkpoint at specified work begin count")
180    parser.add_option("--work-end-checkpoint-count", action="store", type="int",
181                      help="checkpoint at specified work end count")
182    parser.add_option("--work-cpus-checkpoint-count", action="store", type="int",
183                      help="checkpoint and exit when active cpu count is reached")
184    parser.add_option("--restore-with-cpu", action="store", type="choice",
185                      default="atomic", choices=CpuConfig.cpu_names(),
186                      help = "cpu type for restoring from a checkpoint")
187
188
189    # CPU Switching - default switch model goes from a checkpoint
190    # to a timing simple CPU with caches to warm up, then to detailed CPU for
191    # data measurement
192    parser.add_option("--repeat-switch", action="store", type="int",
193        default=None,
194        help="switch back and forth between CPUs with period <N>")
195    parser.add_option("-s", "--standard-switch", action="store", type="int",
196        default=None,
197        help="switch from timing to Detailed CPU after warmup period of <N>")
198    parser.add_option("-p", "--prog-interval", type="str",
199        help="CPU Progress Interval")
200
201    # Fastforwarding and simpoint related materials
202    parser.add_option("-W", "--warmup-insts", action="store", type="int",
203        default=None,
204        help="Warmup period in total instructions (requires --standard-switch)")
205    parser.add_option("--bench", action="store", type="string", default=None,
206        help="base names for --take-checkpoint and --checkpoint-restore")
207    parser.add_option("-F", "--fast-forward", action="store", type="string",
208        default=None,
209        help="Number of instructions to fast forward before switching")
210    parser.add_option("-S", "--simpoint", action="store_true", default=False,
211        help="""Use workload simpoints as an instruction offset for
212                --checkpoint-restore or --take-checkpoint.""")
213    parser.add_option("--at-instruction", action="store_true", default=False,
214        help="""Treat value of --checkpoint-restore or --take-checkpoint as a
215                number of instructions.""")
216    parser.add_option("--spec-input", default="ref", type="choice",
217                      choices=["ref", "test", "train", "smred", "mdred",
218                               "lgred"],
219                      help="Input set size for SPEC CPU2000 benchmarks.")
220    parser.add_option("--arm-iset", default="arm", type="choice",
221                      choices=["arm", "thumb", "aarch64"],
222                      help="ARM instruction set.")
223
224
225def addSEOptions(parser):
226    # Benchmark options
227    parser.add_option("-c", "--cmd", default="",
228                      help="The binary to run in syscall emulation mode.")
229    parser.add_option("-o", "--options", default="",
230                      help="""The options to pass to the binary, use " "
231                              around the entire string""")
232    parser.add_option("-i", "--input", default="",
233                      help="Read stdin from a file.")
234    parser.add_option("--output", default="",
235                      help="Redirect stdout to a file.")
236    parser.add_option("--errout", default="",
237                      help="Redirect stderr to a file.")
238
239def addFSOptions(parser):
240    # Simulation options
241    parser.add_option("--timesync", action="store_true",
242            help="Prevent simulated time from getting ahead of real time")
243
244    # System options
245    parser.add_option("--kernel", action="store", type="string")
246    parser.add_option("--os-type", action="store", type="choice",
247            choices=os_types[buildEnv['TARGET_ISA']], default="linux",
248            help="Specifies type of OS to boot")
249    parser.add_option("--script", action="store", type="string")
250    parser.add_option("--frame-capture", action="store_true",
251            help="Stores changed frame buffers from the VNC server to compressed "\
252            "files in the gem5 output directory")
253
254    if buildEnv['TARGET_ISA'] == "arm":
255        parser.add_option("--bare-metal", action="store_true",
256                   help="Provide the raw system without the linux specific bits")
257        parser.add_option("--machine-type", action="store", type="choice",
258                choices=ArmMachineType.map.keys(), default="VExpress_EMM")
259        parser.add_option("--dtb-filename", action="store", type="string",
260              help="Specifies device tree blob file to use with device-tree-"\
261              "enabled kernels")
262        parser.add_option("--enable-context-switch-stats-dump", \
263                action="store_true", help="Enable stats dump at context "\
264                "switches and dump tasks file (required for Streamline)")
265
266    # Benchmark options
267    parser.add_option("--dual", action="store_true",
268                      help="Simulate two systems attached with an ethernet link")
269    parser.add_option("-b", "--benchmark", action="store", type="string",
270                      dest="benchmark",
271                      help="Specify the benchmark to run. Available benchmarks: %s"\
272                      % DefinedBenchmarks)
273
274    # Metafile options
275    parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
276                      help="Specify the filename to dump a pcap capture of the" \
277                      "ethernet traffic")
278
279    # Disk Image Options
280    parser.add_option("--disk-image", action="store", type="string", default=None,
281                      help="Path to the disk image to use.")
282    parser.add_option("--root-device", action="store", type="string", default=None,
283                      help="OS device name for root partition")
284
285    # Command line options
286    parser.add_option("--command-line", action="store", type="string",
287                      default=None,
288                      help="Template for the kernel command line.")
289    parser.add_option("--command-line-file", action="store",
290                      default=None, type="string",
291                      help="File with a template for the kernel command line")
292