Options.py revision 10159
12381SN/A# Copyright (c) 2013 ARM Limited
22592SN/A# All rights reserved.
32381SN/A#
42381SN/A# The license below extends only to copyright in the software and shall
52381SN/A# not be construed as granting a license to any other intellectual
62381SN/A# property including but not limited to intellectual property relating
72381SN/A# to a hardware implementation of the functionality of the software
82381SN/A# licensed hereunder.  You may use the software subject to the license
92381SN/A# terms below provided that you ensure that this notice is replicated
102381SN/A# unmodified and in its entirety in all distributions of the software,
112381SN/A# modified or unmodified, in source code or in binary form.
122381SN/A#
132381SN/A# Copyright (c) 2006-2008 The Regents of The University of Michigan
142381SN/A# All rights reserved.
152381SN/A#
162381SN/A# Redistribution and use in source and binary forms, with or without
172381SN/A# modification, are permitted provided that the following conditions are
182381SN/A# met: redistributions of source code must retain the above copyright
192381SN/A# notice, this list of conditions and the following disclaimer;
202381SN/A# redistributions in binary form must reproduce the above copyright
212381SN/A# notice, this list of conditions and the following disclaimer in the
222381SN/A# documentation and/or other materials provided with the distribution;
232381SN/A# neither the name of the copyright holders nor the names of its
242381SN/A# contributors may be used to endorse or promote products derived from
252381SN/A# this software without specific prior written permission.
262381SN/A#
272665Ssaidi@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
282665Ssaidi@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
292665Ssaidi@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
302665Ssaidi@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
312381SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
322381SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
332381SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
342381SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
352662Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
362381SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
372381SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
382381SN/A#
392381SN/A# Authors: Lisa Hsu
402381SN/A
412392SN/Aimport m5
422423SN/Afrom m5.defines import buildEnv
432394SN/Afrom m5.objects import *
442394SN/Afrom Benchmarks import *
452394SN/A
462394SN/Aimport CpuConfig
472394SN/Aimport MemConfig
482382SN/A
492381SN/Adef _listCpuTypes(option, opt, value, parser):
502662Sstever@eecs.umich.edu    CpuConfig.print_cpu_list()
512662Sstever@eecs.umich.edu    sys.exit(0)
522662Sstever@eecs.umich.edu
532662Sstever@eecs.umich.edudef _listMemTypes(option, opt, value, parser):
542662Sstever@eecs.umich.edu    MemConfig.print_mem_list()
552381SN/A    sys.exit(0)
562641Sstever@eecs.umich.edu
572381SN/Adef addCommonOptions(parser):
582566SN/A    # system options
592662Sstever@eecs.umich.edu    parser.add_option("--list-cpu-types",
602662Sstever@eecs.umich.edu                      action="callback", callback=_listCpuTypes,
612662Sstever@eecs.umich.edu                      help="List available CPU types")
622662Sstever@eecs.umich.edu    parser.add_option("--cpu-type", type="choice", default="atomic",
632662Sstever@eecs.umich.edu                      choices=CpuConfig.cpu_names(),
642566SN/A                      help = "type of cpu to run with")
652566SN/A    parser.add_option("--checker", action="store_true");
662566SN/A    parser.add_option("-n", "--num-cpus", type="int", default=1)
672662Sstever@eecs.umich.edu    parser.add_option("--sys-voltage", action="store", type="string",
682662Sstever@eecs.umich.edu                      default='1.0V',
692566SN/A                      help = """Top-level voltage for blocks running at system
702662Sstever@eecs.umich.edu                      power supply""")
712662Sstever@eecs.umich.edu    parser.add_option("--sys-clock", action="store", type="string",
722566SN/A                      default='1GHz',
732662Sstever@eecs.umich.edu                      help = """Top-level clock for blocks running at system
742662Sstever@eecs.umich.edu                      speed""")
752566SN/A    parser.add_option("--cpu-clock", action="store", type="string",
762566SN/A                      default='2GHz',
772566SN/A                      help="Clock for blocks running at CPU speed")
782662Sstever@eecs.umich.edu    parser.add_option("--smt", action="store_true", default=False,
792662Sstever@eecs.umich.edu                      help = """
802381SN/A                      Only used if multiple programs are specified. If true,
812381SN/A                      then the number of threads per cpu is same as the
822662Sstever@eecs.umich.edu                      number of programs.""")
832381SN/A
842381SN/A    # Memory Options
852662Sstever@eecs.umich.edu    parser.add_option("--list-mem-types",
862662Sstever@eecs.umich.edu                      action="callback", callback=_listMemTypes,
872662Sstever@eecs.umich.edu                      help="List available memory types")
882662Sstever@eecs.umich.edu    parser.add_option("--mem-type", type="choice", default="ddr3_1600_x64",
892381SN/A                      choices=MemConfig.mem_names(),
902381SN/A                      help = "type of memory to use")
912662Sstever@eecs.umich.edu    parser.add_option("--mem-channels", type="int", default=1,
922662Sstever@eecs.umich.edu                      help = "number of memory channels")
932662Sstever@eecs.umich.edu    parser.add_option("--mem-size", action="store", type="string",
942662Sstever@eecs.umich.edu                      default="512MB",
952662Sstever@eecs.umich.edu                      help="Specify the physical memory size (single memory)")
962641Sstever@eecs.umich.edu
972641Sstever@eecs.umich.edu    parser.add_option("-l", "--lpae", action="store_true")
982663Sstever@eecs.umich.edu    parser.add_option("-V", "--virtualisation", action="store_true")
992663Sstever@eecs.umich.edu
1002662Sstever@eecs.umich.edu    # Cache Options
1012641Sstever@eecs.umich.edu    parser.add_option("--caches", action="store_true")
1022641Sstever@eecs.umich.edu    parser.add_option("--l2cache", action="store_true")
1032641Sstever@eecs.umich.edu    parser.add_option("--fastmem", action="store_true")
1042641Sstever@eecs.umich.edu    parser.add_option("--num-dirs", type="int", default=1)
1052662Sstever@eecs.umich.edu    parser.add_option("--num-l2caches", type="int", default=1)
1062662Sstever@eecs.umich.edu    parser.add_option("--num-l3caches", type="int", default=1)
1072623SN/A    parser.add_option("--l1d_size", type="string", default="64kB")
1082623SN/A    parser.add_option("--l1i_size", type="string", default="32kB")
1092662Sstever@eecs.umich.edu    parser.add_option("--l2_size", type="string", default="2MB")
1102641Sstever@eecs.umich.edu    parser.add_option("--l3_size", type="string", default="16MB")
1112641Sstever@eecs.umich.edu    parser.add_option("--l1d_assoc", type="int", default=2)
1122662Sstever@eecs.umich.edu    parser.add_option("--l1i_assoc", type="int", default=2)
1132662Sstever@eecs.umich.edu    parser.add_option("--l2_assoc", type="int", default=8)
1142662Sstever@eecs.umich.edu    parser.add_option("--l3_assoc", type="int", default=16)
1152641Sstever@eecs.umich.edu    parser.add_option("--cacheline_size", type="int", default=64)
1162641Sstever@eecs.umich.edu
1172641Sstever@eecs.umich.edu    # Enable Ruby
1182641Sstever@eecs.umich.edu    parser.add_option("--ruby", action="store_true")
1192641Sstever@eecs.umich.edu
1202662Sstever@eecs.umich.edu    # Run duration options
1212662Sstever@eecs.umich.edu    parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick,
1222662Sstever@eecs.umich.edu                      metavar="TICKS", help="Run to absolute simulated tick " \
1232662Sstever@eecs.umich.edu                      "specified including ticks from a restored checkpoint")
1242641Sstever@eecs.umich.edu    parser.add_option("--rel-max-tick", type="int", default=None,
1252662Sstever@eecs.umich.edu                      metavar="TICKS", help="Simulate for specified number of" \
1262662Sstever@eecs.umich.edu                      " ticks relative to the simulation start tick (e.g. if " \
1272662Sstever@eecs.umich.edu                      "restoring a checkpoint)")
1282662Sstever@eecs.umich.edu    parser.add_option("--maxtime", type="float", default=None,
1292662Sstever@eecs.umich.edu                      help="Run to the specified absolute simulated time in " \
1302662Sstever@eecs.umich.edu                      "seconds")
1312662Sstever@eecs.umich.edu    parser.add_option("-I", "--maxinsts", action="store", type="int",
1322641Sstever@eecs.umich.edu                      default=None, help="""Total number of instructions to
1332641Sstever@eecs.umich.edu                                            simulate (default: run forever)""")
1342641Sstever@eecs.umich.edu    parser.add_option("--work-item-id", action="store", type="int",
1352641Sstever@eecs.umich.edu                      help="the specific work id for exit & checkpointing")
1362641Sstever@eecs.umich.edu    parser.add_option("--num-work-ids", action="store", type="int",
1372662Sstever@eecs.umich.edu                      help="Number of distinct work item types")
1382662Sstever@eecs.umich.edu    parser.add_option("--work-begin-cpu-id-exit", action="store", type="int",
1392662Sstever@eecs.umich.edu                      help="exit when work starts on the specified cpu")
1402641Sstever@eecs.umich.edu    parser.add_option("--work-end-exit-count", action="store", type="int",
1412641Sstever@eecs.umich.edu                      help="exit at specified work end count")
1422641Sstever@eecs.umich.edu    parser.add_option("--work-begin-exit-count", action="store", type="int",
1432641Sstever@eecs.umich.edu                      help="exit at specified work begin count")
1442641Sstever@eecs.umich.edu    parser.add_option("--init-param", action="store", type="int", default=0,
1452641Sstever@eecs.umich.edu                      help="""Parameter available in simulation with m5
1462641Sstever@eecs.umich.edu                              initparam""")
1472641Sstever@eecs.umich.edu
1482641Sstever@eecs.umich.edu    # Simpoint options
1492641Sstever@eecs.umich.edu    parser.add_option("--simpoint-profile", action="store_true",
1502641Sstever@eecs.umich.edu                      help="Enable basic block profiling for SimPoints")
1512641Sstever@eecs.umich.edu    parser.add_option("--simpoint-interval", type="int", default=10000000,
1522641Sstever@eecs.umich.edu                      help="SimPoint interval in num of instructions")
1532641Sstever@eecs.umich.edu
1542641Sstever@eecs.umich.edu    # Checkpointing options
1552641Sstever@eecs.umich.edu    ###Note that performing checkpointing via python script files will override
1562641Sstever@eecs.umich.edu    ###checkpoint instructions built into binaries.
1572641Sstever@eecs.umich.edu    parser.add_option("--take-checkpoints", action="store", type="string",
1582641Sstever@eecs.umich.edu        help="<M,N> take checkpoints at tick M and every N ticks thereafter")
1592641Sstever@eecs.umich.edu    parser.add_option("--max-checkpoints", action="store", type="int",
1602641Sstever@eecs.umich.edu        help="the maximum number of checkpoints to drop", default=5)
1612641Sstever@eecs.umich.edu    parser.add_option("--checkpoint-dir", action="store", type="string",
1622641Sstever@eecs.umich.edu        help="Place all checkpoints in this absolute directory")
1632641Sstever@eecs.umich.edu    parser.add_option("-r", "--checkpoint-restore", action="store", type="int",
1642641Sstever@eecs.umich.edu        help="restore from checkpoint <N>")
1652662Sstever@eecs.umich.edu    parser.add_option("--checkpoint-at-end", action="store_true",
1662662Sstever@eecs.umich.edu                      help="take a checkpoint at end of run")
1672641Sstever@eecs.umich.edu    parser.add_option("--work-begin-checkpoint-count", action="store", type="int",
1682381SN/A                      help="checkpoint at specified work begin count")
1692662Sstever@eecs.umich.edu    parser.add_option("--work-end-checkpoint-count", action="store", type="int",
1702381SN/A                      help="checkpoint at specified work end count")
1712381SN/A    parser.add_option("--work-cpus-checkpoint-count", action="store", type="int",
1722641Sstever@eecs.umich.edu                      help="checkpoint and exit when active cpu count is reached")
1732641Sstever@eecs.umich.edu    parser.add_option("--restore-with-cpu", action="store", type="choice",
1742641Sstever@eecs.umich.edu                      default="atomic", choices=CpuConfig.cpu_names(),
1752641Sstever@eecs.umich.edu                      help = "cpu type for restoring from a checkpoint")
1762641Sstever@eecs.umich.edu
1772662Sstever@eecs.umich.edu
1782641Sstever@eecs.umich.edu    # CPU Switching - default switch model goes from a checkpoint
1792641Sstever@eecs.umich.edu    # to a timing simple CPU with caches to warm up, then to detailed CPU for
1802641Sstever@eecs.umich.edu    # data measurement
1812641Sstever@eecs.umich.edu    parser.add_option("--repeat-switch", action="store", type="int",
1822641Sstever@eecs.umich.edu        default=None,
1832641Sstever@eecs.umich.edu        help="switch back and forth between CPUs with period <N>")
1842641Sstever@eecs.umich.edu    parser.add_option("-s", "--standard-switch", action="store", type="int",
1852662Sstever@eecs.umich.edu        default=None,
1862641Sstever@eecs.umich.edu        help="switch from timing to Detailed CPU after warmup period of <N>")
1872381SN/A    parser.add_option("-p", "--prog-interval", type="str",
1882381SN/A        help="CPU Progress Interval")
1892641Sstever@eecs.umich.edu
1902641Sstever@eecs.umich.edu    # Fastforwarding and simpoint related materials
1912381SN/A    parser.add_option("-W", "--warmup-insts", action="store", type="int",
1922381SN/A        default=None,
1932381SN/A        help="Warmup period in total instructions (requires --standard-switch)")
1942381SN/A    parser.add_option("--bench", action="store", type="string", default=None,
1952641Sstever@eecs.umich.edu        help="base names for --take-checkpoint and --checkpoint-restore")
1962549SN/A    parser.add_option("-F", "--fast-forward", action="store", type="string",
1972663Sstever@eecs.umich.edu        default=None,
1982663Sstever@eecs.umich.edu        help="Number of instructions to fast forward before switching")
1992641Sstever@eecs.umich.edu    parser.add_option("-S", "--simpoint", action="store_true", default=False,
2002662Sstever@eecs.umich.edu        help="""Use workload simpoints as an instruction offset for
2012662Sstever@eecs.umich.edu                --checkpoint-restore or --take-checkpoint.""")
2022662Sstever@eecs.umich.edu    parser.add_option("--at-instruction", action="store_true", default=False,
2032662Sstever@eecs.umich.edu        help="""Treat value of --checkpoint-restore or --take-checkpoint as a
2042641Sstever@eecs.umich.edu                number of instructions.""")
2052566SN/A    parser.add_option("--spec-input", default="ref", type="choice",
2062641Sstever@eecs.umich.edu                      choices=["ref", "test", "train", "smred", "mdred",
2072663Sstever@eecs.umich.edu                               "lgred"],
2082641Sstever@eecs.umich.edu                      help="Input set size for SPEC CPU2000 benchmarks.")
2092641Sstever@eecs.umich.edu    parser.add_option("--arm-iset", default="arm", type="choice",
2102662Sstever@eecs.umich.edu                      choices=["arm", "thumb", "aarch64"],
2112641Sstever@eecs.umich.edu                      help="ARM instruction set.")
2122641Sstever@eecs.umich.edu
2132549SN/A
2142662Sstever@eecs.umich.edudef addSEOptions(parser):
2152566SN/A    # Benchmark options
2162566SN/A    parser.add_option("-c", "--cmd", default="",
2172566SN/A                      help="The binary to run in syscall emulation mode.")
2182662Sstever@eecs.umich.edu    parser.add_option("-o", "--options", default="",
2192662Sstever@eecs.umich.edu                      help="""The options to pass to the binary, use " "
2202662Sstever@eecs.umich.edu                              around the entire string""")
2212662Sstever@eecs.umich.edu    parser.add_option("-i", "--input", default="",
2222662Sstever@eecs.umich.edu                      help="Read stdin from a file.")
2232662Sstever@eecs.umich.edu    parser.add_option("--output", default="",
2242662Sstever@eecs.umich.edu                      help="Redirect stdout to a file.")
2252663Sstever@eecs.umich.edu    parser.add_option("--errout", default="",
2262663Sstever@eecs.umich.edu                      help="Redirect stderr to a file.")
2272663Sstever@eecs.umich.edu
2282662Sstever@eecs.umich.edudef addFSOptions(parser):
2292662Sstever@eecs.umich.edu    # Simulation options
2302662Sstever@eecs.umich.edu    parser.add_option("--timesync", action="store_true",
2312662Sstever@eecs.umich.edu            help="Prevent simulated time from getting ahead of real time")
2322662Sstever@eecs.umich.edu
2332662Sstever@eecs.umich.edu    # System options
2342662Sstever@eecs.umich.edu    parser.add_option("--kernel", action="store", type="string")
2352566SN/A    parser.add_option("--script", action="store", type="string")
2362662Sstever@eecs.umich.edu    parser.add_option("--frame-capture", action="store_true",
2372662Sstever@eecs.umich.edu            help="Stores changed frame buffers from the VNC server to compressed "\
2382662Sstever@eecs.umich.edu            "files in the gem5 output directory")
2392662Sstever@eecs.umich.edu
2402662Sstever@eecs.umich.edu    if buildEnv['TARGET_ISA'] == "arm":
2412662Sstever@eecs.umich.edu        parser.add_option("--bare-metal", action="store_true",
2422662Sstever@eecs.umich.edu                   help="Provide the raw system without the linux specific bits")
2432662Sstever@eecs.umich.edu        parser.add_option("--machine-type", action="store", type="choice",
2442662Sstever@eecs.umich.edu                choices=ArmMachineType.map.keys(), default="RealView_PBX")
2452662Sstever@eecs.umich.edu        parser.add_option("--dtb-filename", action="store", type="string",
2462662Sstever@eecs.umich.edu              help="Specifies device tree blob file to use with device-tree-"\
2472662Sstever@eecs.umich.edu              "enabled kernels")
2482662Sstever@eecs.umich.edu        parser.add_option("--enable-context-switch-stats-dump", \
2492662Sstever@eecs.umich.edu                action="store_true", help="Enable stats dump at context "\
2502641Sstever@eecs.umich.edu                "switches and dump tasks file (required for Streamline)")
2512641Sstever@eecs.umich.edu
2522566SN/A    # Benchmark options
2532566SN/A    parser.add_option("--dual", action="store_true",
2542592SN/A                      help="Simulate two systems attached with an ethernet link")
2552566SN/A    parser.add_option("-b", "--benchmark", action="store", type="string",
2562566SN/A                      dest="benchmark",
2572566SN/A                      help="Specify the benchmark to run. Available benchmarks: %s"\
2582566SN/A                      % DefinedBenchmarks)
2592592SN/A
2602566SN/A    # Metafile options
2612566SN/A    parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
2622566SN/A                      help="Specify the filename to dump a pcap capture of the" \
2632592SN/A                      "ethernet traffic")
2642566SN/A
2652566SN/A    # Disk Image Options
2662566SN/A    parser.add_option("--disk-image", action="store", type="string", default=None,
2672592SN/A                      help="Path to the disk image to use.")
2682566SN/A