Options.py revision 10145
114184Sgabeblack@google.com# Copyright (c) 2013 ARM Limited
214184Sgabeblack@google.com# All rights reserved.
314184Sgabeblack@google.com#
414184Sgabeblack@google.com# The license below extends only to copyright in the software and shall
514184Sgabeblack@google.com# not be construed as granting a license to any other intellectual
614184Sgabeblack@google.com# property including but not limited to intellectual property relating
714184Sgabeblack@google.com# to a hardware implementation of the functionality of the software
814184Sgabeblack@google.com# licensed hereunder.  You may use the software subject to the license
914184Sgabeblack@google.com# terms below provided that you ensure that this notice is replicated
1014184Sgabeblack@google.com# unmodified and in its entirety in all distributions of the software,
1114184Sgabeblack@google.com# modified or unmodified, in source code or in binary form.
1214184Sgabeblack@google.com#
1314184Sgabeblack@google.com# Copyright (c) 2006-2008 The Regents of The University of Michigan
1414184Sgabeblack@google.com# All rights reserved.
1514184Sgabeblack@google.com#
1614184Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without
1714184Sgabeblack@google.com# modification, are permitted provided that the following conditions are
1814184Sgabeblack@google.com# met: redistributions of source code must retain the above copyright
1914184Sgabeblack@google.com# notice, this list of conditions and the following disclaimer;
2014184Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright
2114184Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the
2214184Sgabeblack@google.com# documentation and/or other materials provided with the distribution;
2314184Sgabeblack@google.com# neither the name of the copyright holders nor the names of its
2414184Sgabeblack@google.com# contributors may be used to endorse or promote products derived from
2514184Sgabeblack@google.com# this software without specific prior written permission.
2614184Sgabeblack@google.com#
2714184Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2814184Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2914184Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3014184Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3114184Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3214184Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3314184Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3414184Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3514184Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3614184Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3714184Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3814184Sgabeblack@google.com#
3914184Sgabeblack@google.com# Authors: Lisa Hsu
4014184Sgabeblack@google.com
4114184Sgabeblack@google.comimport m5
4214184Sgabeblack@google.comfrom m5.defines import buildEnv
4314184Sgabeblack@google.comfrom m5.objects import *
4414184Sgabeblack@google.comfrom Benchmarks import *
4514184Sgabeblack@google.com
4614184Sgabeblack@google.comimport CpuConfig
4714184Sgabeblack@google.comimport MemConfig
4814184Sgabeblack@google.com
4914184Sgabeblack@google.comdef _listCpuTypes(option, opt, value, parser):
5014184Sgabeblack@google.com    CpuConfig.print_cpu_list()
5114184Sgabeblack@google.com    sys.exit(0)
5214184Sgabeblack@google.com
5314184Sgabeblack@google.comdef _listMemTypes(option, opt, value, parser):
5414184Sgabeblack@google.com    MemConfig.print_mem_list()
5514184Sgabeblack@google.com    sys.exit(0)
5614184Sgabeblack@google.com
5714184Sgabeblack@google.comdef addCommonOptions(parser):
5814184Sgabeblack@google.com    # system options
5914184Sgabeblack@google.com    parser.add_option("--list-cpu-types",
6014184Sgabeblack@google.com                      action="callback", callback=_listCpuTypes,
6114184Sgabeblack@google.com                      help="List available CPU types")
6214184Sgabeblack@google.com    parser.add_option("--cpu-type", type="choice", default="atomic",
6314184Sgabeblack@google.com                      choices=CpuConfig.cpu_names(),
6414184Sgabeblack@google.com                      help = "type of cpu to run with")
6514184Sgabeblack@google.com    parser.add_option("--checker", action="store_true");
6614184Sgabeblack@google.com    parser.add_option("-n", "--num-cpus", type="int", default=1)
6714184Sgabeblack@google.com    parser.add_option("--sys-voltage", action="store", type="string",
6814184Sgabeblack@google.com                      default='1.0V',
6914184Sgabeblack@google.com                      help = """Top-level voltage for blocks running at system
7014184Sgabeblack@google.com                      power supply""")
7114184Sgabeblack@google.com    parser.add_option("--sys-clock", action="store", type="string",
7214184Sgabeblack@google.com                      default='1GHz',
7314184Sgabeblack@google.com                      help = """Top-level clock for blocks running at system
7414184Sgabeblack@google.com                      speed""")
7514184Sgabeblack@google.com    parser.add_option("--cpu-clock", action="store", type="string",
7614184Sgabeblack@google.com                      default='2GHz',
7714184Sgabeblack@google.com                      help="Clock for blocks running at CPU speed")
7814184Sgabeblack@google.com    parser.add_option("--smt", action="store_true", default=False,
7914184Sgabeblack@google.com                      help = """
8014184Sgabeblack@google.com                      Only used if multiple programs are specified. If true,
8114184Sgabeblack@google.com                      then the number of threads per cpu is same as the
8214184Sgabeblack@google.com                      number of programs.""")
8314184Sgabeblack@google.com
8414184Sgabeblack@google.com    # Memory Options
8514184Sgabeblack@google.com    parser.add_option("--list-mem-types",
8614184Sgabeblack@google.com                      action="callback", callback=_listMemTypes,
8714184Sgabeblack@google.com                      help="List available memory types")
8814184Sgabeblack@google.com    parser.add_option("--mem-type", type="choice", default="ddr3_1600_x64",
8914184Sgabeblack@google.com                      choices=MemConfig.mem_names(),
9014184Sgabeblack@google.com                      help = "type of memory to use")
9114184Sgabeblack@google.com    parser.add_option("--mem-channels", type="int", default=1,
9214184Sgabeblack@google.com                      help = "number of memory channels")
9314184Sgabeblack@google.com    parser.add_option("--mem-size", action="store", type="string",
9414184Sgabeblack@google.com                      default="512MB",
9514184Sgabeblack@google.com                      help="Specify the physical memory size (single memory)")
9614184Sgabeblack@google.com
9714184Sgabeblack@google.com    parser.add_option("-l", "--lpae", action="store_true")
9814184Sgabeblack@google.com    parser.add_option("-V", "--virtualisation", action="store_true")
9914184Sgabeblack@google.com
10014184Sgabeblack@google.com    # Cache Options
10114184Sgabeblack@google.com    parser.add_option("--caches", action="store_true")
10214184Sgabeblack@google.com    parser.add_option("--l2cache", action="store_true")
10314184Sgabeblack@google.com    parser.add_option("--fastmem", action="store_true")
10414184Sgabeblack@google.com    parser.add_option("--num-dirs", type="int", default=1)
10514184Sgabeblack@google.com    parser.add_option("--num-l2caches", type="int", default=1)
10614184Sgabeblack@google.com    parser.add_option("--num-l3caches", type="int", default=1)
10714184Sgabeblack@google.com    parser.add_option("--l1d_size", type="string", default="64kB")
10814184Sgabeblack@google.com    parser.add_option("--l1i_size", type="string", default="32kB")
10914184Sgabeblack@google.com    parser.add_option("--l2_size", type="string", default="2MB")
11014184Sgabeblack@google.com    parser.add_option("--l3_size", type="string", default="16MB")
11114184Sgabeblack@google.com    parser.add_option("--l1d_assoc", type="int", default=2)
11214184Sgabeblack@google.com    parser.add_option("--l1i_assoc", type="int", default=2)
11314184Sgabeblack@google.com    parser.add_option("--l2_assoc", type="int", default=8)
11414184Sgabeblack@google.com    parser.add_option("--l3_assoc", type="int", default=16)
11514184Sgabeblack@google.com    parser.add_option("--cacheline_size", type="int", default=64)
11614184Sgabeblack@google.com
11714184Sgabeblack@google.com    # Enable Ruby
11814184Sgabeblack@google.com    parser.add_option("--ruby", action="store_true")
11914184Sgabeblack@google.com
12014184Sgabeblack@google.com    # Run duration options
12114184Sgabeblack@google.com    parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick,
12214184Sgabeblack@google.com                      metavar="TICKS", help="Run to absolute simulated tick " \
12314184Sgabeblack@google.com                      "specified including ticks from a restored checkpoint")
12414184Sgabeblack@google.com    parser.add_option("--rel-max-tick", type="int", default=None,
12514184Sgabeblack@google.com                      metavar="TICKS", help="Simulate for specified number of" \
12614184Sgabeblack@google.com                      " ticks relative to the simulation start tick (e.g. if " \
12714184Sgabeblack@google.com                      "restoring a checkpoint)")
12814184Sgabeblack@google.com    parser.add_option("--maxtime", type="float", default=None,
12914184Sgabeblack@google.com                      help="Run to the specified absolute simulated time in " \
13014184Sgabeblack@google.com                      "seconds")
13114184Sgabeblack@google.com    parser.add_option("-I", "--maxinsts", action="store", type="int",
13214184Sgabeblack@google.com                      default=None, help="""Total number of instructions to
13314184Sgabeblack@google.com                                            simulate (default: run forever)""")
13414184Sgabeblack@google.com    parser.add_option("--work-item-id", action="store", type="int",
13514184Sgabeblack@google.com                      help="the specific work id for exit & checkpointing")
13614184Sgabeblack@google.com    parser.add_option("--work-begin-cpu-id-exit", action="store", type="int",
13714184Sgabeblack@google.com                      help="exit when work starts on the specified cpu")
13814184Sgabeblack@google.com    parser.add_option("--work-end-exit-count", action="store", type="int",
13914184Sgabeblack@google.com                      help="exit at specified work end count")
14014184Sgabeblack@google.com    parser.add_option("--work-begin-exit-count", action="store", type="int",
14114184Sgabeblack@google.com                      help="exit at specified work begin count")
14214184Sgabeblack@google.com    parser.add_option("--init-param", action="store", type="int", default=0,
14314184Sgabeblack@google.com                      help="""Parameter available in simulation with m5
14414184Sgabeblack@google.com                              initparam""")
14514184Sgabeblack@google.com
14614184Sgabeblack@google.com    # Simpoint options
14714184Sgabeblack@google.com    parser.add_option("--simpoint-profile", action="store_true",
14814184Sgabeblack@google.com                      help="Enable basic block profiling for SimPoints")
14914184Sgabeblack@google.com    parser.add_option("--simpoint-interval", type="int", default=10000000,
15014184Sgabeblack@google.com                      help="SimPoint interval in num of instructions")
15114184Sgabeblack@google.com
15214184Sgabeblack@google.com    # Checkpointing options
15314184Sgabeblack@google.com    ###Note that performing checkpointing via python script files will override
15414184Sgabeblack@google.com    ###checkpoint instructions built into binaries.
15514184Sgabeblack@google.com    parser.add_option("--take-checkpoints", action="store", type="string",
15614184Sgabeblack@google.com        help="<M,N> take checkpoints at tick M and every N ticks thereafter")
15714184Sgabeblack@google.com    parser.add_option("--max-checkpoints", action="store", type="int",
15814184Sgabeblack@google.com        help="the maximum number of checkpoints to drop", default=5)
15914184Sgabeblack@google.com    parser.add_option("--checkpoint-dir", action="store", type="string",
16014184Sgabeblack@google.com        help="Place all checkpoints in this absolute directory")
16114184Sgabeblack@google.com    parser.add_option("-r", "--checkpoint-restore", action="store", type="int",
16214184Sgabeblack@google.com        help="restore from checkpoint <N>")
16314184Sgabeblack@google.com    parser.add_option("--checkpoint-at-end", action="store_true",
16414184Sgabeblack@google.com                      help="take a checkpoint at end of run")
16514184Sgabeblack@google.com    parser.add_option("--work-begin-checkpoint-count", action="store", type="int",
16614184Sgabeblack@google.com                      help="checkpoint at specified work begin count")
16714184Sgabeblack@google.com    parser.add_option("--work-end-checkpoint-count", action="store", type="int",
16814184Sgabeblack@google.com                      help="checkpoint at specified work end count")
16914184Sgabeblack@google.com    parser.add_option("--work-cpus-checkpoint-count", action="store", type="int",
17014184Sgabeblack@google.com                      help="checkpoint and exit when active cpu count is reached")
17114184Sgabeblack@google.com    parser.add_option("--restore-with-cpu", action="store", type="choice",
17214184Sgabeblack@google.com                      default="atomic", choices=CpuConfig.cpu_names(),
17314184Sgabeblack@google.com                      help = "cpu type for restoring from a checkpoint")
17414184Sgabeblack@google.com
17514184Sgabeblack@google.com
17614184Sgabeblack@google.com    # CPU Switching - default switch model goes from a checkpoint
17714184Sgabeblack@google.com    # to a timing simple CPU with caches to warm up, then to detailed CPU for
17814184Sgabeblack@google.com    # data measurement
17914184Sgabeblack@google.com    parser.add_option("--repeat-switch", action="store", type="int",
18014184Sgabeblack@google.com        default=None,
18114184Sgabeblack@google.com        help="switch back and forth between CPUs with period <N>")
18214184Sgabeblack@google.com    parser.add_option("-s", "--standard-switch", action="store", type="int",
18314184Sgabeblack@google.com        default=None,
18414184Sgabeblack@google.com        help="switch from timing to Detailed CPU after warmup period of <N>")
18514184Sgabeblack@google.com    parser.add_option("-p", "--prog-interval", type="str",
18614184Sgabeblack@google.com        help="CPU Progress Interval")
18714184Sgabeblack@google.com
18814184Sgabeblack@google.com    # Fastforwarding and simpoint related materials
18914184Sgabeblack@google.com    parser.add_option("-W", "--warmup-insts", action="store", type="int",
19014184Sgabeblack@google.com        default=None,
19114184Sgabeblack@google.com        help="Warmup period in total instructions (requires --standard-switch)")
19214184Sgabeblack@google.com    parser.add_option("--bench", action="store", type="string", default=None,
19314184Sgabeblack@google.com        help="base names for --take-checkpoint and --checkpoint-restore")
19414184Sgabeblack@google.com    parser.add_option("-F", "--fast-forward", action="store", type="string",
19514184Sgabeblack@google.com        default=None,
19614184Sgabeblack@google.com        help="Number of instructions to fast forward before switching")
19714184Sgabeblack@google.com    parser.add_option("-S", "--simpoint", action="store_true", default=False,
19814184Sgabeblack@google.com        help="""Use workload simpoints as an instruction offset for
19914184Sgabeblack@google.com                --checkpoint-restore or --take-checkpoint.""")
20014184Sgabeblack@google.com    parser.add_option("--at-instruction", action="store_true", default=False,
20114184Sgabeblack@google.com        help="""Treat value of --checkpoint-restore or --take-checkpoint as a
20214184Sgabeblack@google.com                number of instructions.""")
20314184Sgabeblack@google.com    parser.add_option("--spec-input", default="ref", type="choice",
20414184Sgabeblack@google.com                      choices=["ref", "test", "train", "smred", "mdred",
20514184Sgabeblack@google.com                               "lgred"],
20614184Sgabeblack@google.com                      help="Input set size for SPEC CPU2000 benchmarks.")
20714184Sgabeblack@google.com    parser.add_option("--arm-iset", default="arm", type="choice",
20814184Sgabeblack@google.com                      choices=["arm", "thumb", "aarch64"],
20914184Sgabeblack@google.com                      help="ARM instruction set.")
21014184Sgabeblack@google.com
21114184Sgabeblack@google.com
21214184Sgabeblack@google.comdef addSEOptions(parser):
21314184Sgabeblack@google.com    # Benchmark options
21414184Sgabeblack@google.com    parser.add_option("-c", "--cmd", default="",
21514184Sgabeblack@google.com                      help="The binary to run in syscall emulation mode.")
21614184Sgabeblack@google.com    parser.add_option("-o", "--options", default="",
21714184Sgabeblack@google.com                      help="""The options to pass to the binary, use " "
21814184Sgabeblack@google.com                              around the entire string""")
21914184Sgabeblack@google.com    parser.add_option("-i", "--input", default="",
22014184Sgabeblack@google.com                      help="Read stdin from a file.")
22114184Sgabeblack@google.com    parser.add_option("--output", default="",
22214184Sgabeblack@google.com                      help="Redirect stdout to a file.")
22314184Sgabeblack@google.com    parser.add_option("--errout", default="",
22414184Sgabeblack@google.com                      help="Redirect stderr to a file.")
22514184Sgabeblack@google.com
22614184Sgabeblack@google.comdef addFSOptions(parser):
22714184Sgabeblack@google.com    # Simulation options
22814184Sgabeblack@google.com    parser.add_option("--timesync", action="store_true",
22914184Sgabeblack@google.com            help="Prevent simulated time from getting ahead of real time")
23014184Sgabeblack@google.com
23114184Sgabeblack@google.com    # System options
23214184Sgabeblack@google.com    parser.add_option("--kernel", action="store", type="string")
23314184Sgabeblack@google.com    parser.add_option("--script", action="store", type="string")
23414184Sgabeblack@google.com    parser.add_option("--frame-capture", action="store_true",
23514184Sgabeblack@google.com            help="Stores changed frame buffers from the VNC server to compressed "\
23614184Sgabeblack@google.com            "files in the gem5 output directory")
23714184Sgabeblack@google.com
23814184Sgabeblack@google.com    if buildEnv['TARGET_ISA'] == "arm":
23914184Sgabeblack@google.com        parser.add_option("--bare-metal", action="store_true",
24014184Sgabeblack@google.com                   help="Provide the raw system without the linux specific bits")
24114184Sgabeblack@google.com        parser.add_option("--machine-type", action="store", type="choice",
24214184Sgabeblack@google.com                choices=ArmMachineType.map.keys(), default="RealView_PBX")
24314184Sgabeblack@google.com        parser.add_option("--dtb-filename", action="store", type="string",
24414184Sgabeblack@google.com              help="Specifies device tree blob file to use with device-tree-"\
24514184Sgabeblack@google.com              "enabled kernels")
24614184Sgabeblack@google.com        parser.add_option("--enable-context-switch-stats-dump", \
24714184Sgabeblack@google.com                action="store_true", help="Enable stats dump at context "\
24814184Sgabeblack@google.com                "switches and dump tasks file (required for Streamline)")
24914184Sgabeblack@google.com
25014184Sgabeblack@google.com    # Benchmark options
25114184Sgabeblack@google.com    parser.add_option("--dual", action="store_true",
25214184Sgabeblack@google.com                      help="Simulate two systems attached with an ethernet link")
25314184Sgabeblack@google.com    parser.add_option("-b", "--benchmark", action="store", type="string",
25414184Sgabeblack@google.com                      dest="benchmark",
25514184Sgabeblack@google.com                      help="Specify the benchmark to run. Available benchmarks: %s"\
25614184Sgabeblack@google.com                      % DefinedBenchmarks)
25714184Sgabeblack@google.com
25814184Sgabeblack@google.com    # Metafile options
25914184Sgabeblack@google.com    parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
26014184Sgabeblack@google.com                      help="Specify the filename to dump a pcap capture of the" \
26114184Sgabeblack@google.com                      "ethernet traffic")
26214184Sgabeblack@google.com
26314184Sgabeblack@google.com    # Disk Image Options
26414184Sgabeblack@google.com    parser.add_option("--disk-image", action="store", type="string", default=None,
26514184Sgabeblack@google.com                      help="Path to the disk image to use.")
26614184Sgabeblack@google.com