Options.py revision 10803:a91eb7b4a442
11689SN/A# Copyright (c) 2013 ARM Limited
22329SN/A# All rights reserved.
31689SN/A#
41689SN/A# The license below extends only to copyright in the software and shall
51689SN/A# not be construed as granting a license to any other intellectual
61689SN/A# property including but not limited to intellectual property relating
71689SN/A# to a hardware implementation of the functionality of the software
81689SN/A# licensed hereunder.  You may use the software subject to the license
91689SN/A# terms below provided that you ensure that this notice is replicated
101689SN/A# unmodified and in its entirety in all distributions of the software,
111689SN/A# modified or unmodified, in source code or in binary form.
121689SN/A#
131689SN/A# Copyright (c) 2006-2008 The Regents of The University of Michigan
141689SN/A# All rights reserved.
151689SN/A#
161689SN/A# Redistribution and use in source and binary forms, with or without
171689SN/A# modification, are permitted provided that the following conditions are
181689SN/A# met: redistributions of source code must retain the above copyright
191689SN/A# notice, this list of conditions and the following disclaimer;
201689SN/A# redistributions in binary form must reproduce the above copyright
211689SN/A# notice, this list of conditions and the following disclaimer in the
221689SN/A# documentation and/or other materials provided with the distribution;
231689SN/A# neither the name of the copyright holders nor the names of its
241689SN/A# contributors may be used to endorse or promote products derived from
251689SN/A# this software without specific prior written permission.
261689SN/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
292756Sksewell@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
301689SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
311689SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
322292SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
332292SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
341060SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
352669Sktlim@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
364182Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
371461SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
381060SN/A#
396658Snate@binkert.org# Authors: Lisa Hsu
401060SN/A
413348Sbinkertn@umich.eduimport m5
422669Sktlim@umich.edufrom m5.defines import buildEnv
431461SN/Afrom m5.objects import *
441060SN/Afrom Benchmarks import *
455529Snate@binkert.org
465529Snate@binkert.orgimport CpuConfig
471060SN/Aimport MemConfig
482329SN/A
492329SN/Afrom FSConfig import os_types
502329SN/A
512329SN/Adef _listCpuTypes(option, opt, value, parser):
522348SN/A    CpuConfig.print_cpu_list()
532329SN/A    sys.exit(0)
541060SN/A
551060SN/Adef _listMemTypes(option, opt, value, parser):
562292SN/A    MemConfig.print_mem_list()
571060SN/A    sys.exit(0)
581060SN/A
591060SN/Adef addCommonOptions(parser):
601061SN/A    # system options
611060SN/A    parser.add_option("--list-cpu-types",
621061SN/A                      action="callback", callback=_listCpuTypes,
632733Sktlim@umich.edu                      help="List available CPU types")
641060SN/A    parser.add_option("--cpu-type", type="choice", default="atomic",
652292SN/A                      choices=CpuConfig.cpu_names(),
661061SN/A                      help = "type of cpu to run with")
671061SN/A    parser.add_option("--checker", action="store_true");
681061SN/A    parser.add_option("-n", "--num-cpus", type="int", default=1)
691060SN/A    parser.add_option("--sys-voltage", action="store", type="string",
701060SN/A                      default='1.0V',
712107SN/A                      help = """Top-level voltage for blocks running at system
722292SN/A                      power supply""")
732632Sstever@eecs.umich.edu    parser.add_option("--sys-clock", action="store", type="string",
742698Sktlim@umich.edu                      default='1GHz',
752698Sktlim@umich.edu                      help = """Top-level clock for blocks running at system
762698Sktlim@umich.edu                      speed""")
772669Sktlim@umich.edu    parser.add_option("--cpu-clock", action="store", type="string",
782669Sktlim@umich.edu                      default='2GHz',
792669Sktlim@umich.edu                      help="Clock for blocks running at CPU speed")
802698Sktlim@umich.edu    parser.add_option("--smt", action="store_true", default=False,
812669Sktlim@umich.edu                      help = """
822669Sktlim@umich.edu                      Only used if multiple programs are specified. If true,
832669Sktlim@umich.edu                      then the number of threads per cpu is same as the
842698Sktlim@umich.edu                      number of programs.""")
855494Sstever@gmail.com
865606Snate@binkert.org    # Memory Options
872669Sktlim@umich.edu    parser.add_option("--list-mem-types",
882669Sktlim@umich.edu                      action="callback", callback=_listMemTypes,
893647Srdreslin@umich.edu                      help="List available memory types")
903647Srdreslin@umich.edu    parser.add_option("--mem-type", type="choice", default="DDR3_1600_x64",
914302Sktlim@umich.edu                      choices=MemConfig.mem_names(),
924302Sktlim@umich.edu                      help = "type of memory to use")
932669Sktlim@umich.edu    parser.add_option("--mem-channels", type="int", default=1,
942698Sktlim@umich.edu                      help = "number of memory channels")
952669Sktlim@umich.edu    parser.add_option("--mem-ranks", type="int", default=None,
962669Sktlim@umich.edu                      help = "number of memory ranks per channel")
972698Sktlim@umich.edu    parser.add_option("--mem-size", action="store", type="string",
982669Sktlim@umich.edu                      default="512MB",
992669Sktlim@umich.edu                      help="Specify the physical memory size (single memory)")
1002698Sktlim@umich.edu
1012669Sktlim@umich.edu    parser.add_option("-l", "--lpae", action="store_true")
1022669Sktlim@umich.edu    parser.add_option("-V", "--virtualisation", action="store_true")
1032698Sktlim@umich.edu
1042669Sktlim@umich.edu    parser.add_option("--memchecker", action="store_true")
1054475Sstever@eecs.umich.edu
1064475Sstever@eecs.umich.edu    # Cache Options
1072669Sktlim@umich.edu    parser.add_option("--external-memory-system", type="string",
1082698Sktlim@umich.edu                      help="use external ports of this port_type for caches")
1092698Sktlim@umich.edu    parser.add_option("--caches", action="store_true")
1102669Sktlim@umich.edu    parser.add_option("--l2cache", action="store_true")
1112669Sktlim@umich.edu    parser.add_option("--fastmem", action="store_true")
1122698Sktlim@umich.edu    parser.add_option("--num-dirs", type="int", default=1)
1132669Sktlim@umich.edu    parser.add_option("--num-l2caches", type="int", default=1)
1142669Sktlim@umich.edu    parser.add_option("--num-l3caches", type="int", default=1)
1151060SN/A    parser.add_option("--l1d_size", type="string", default="64kB")
1162935Sksewell@umich.edu    parser.add_option("--l1i_size", type="string", default="32kB")
1171060SN/A    parser.add_option("--l2_size", type="string", default="2MB")
1182329SN/A    parser.add_option("--l3_size", type="string", default="16MB")
1192329SN/A    parser.add_option("--l1d_assoc", type="int", default=2)
1202292SN/A    parser.add_option("--l1i_assoc", type="int", default=2)
1212292SN/A    parser.add_option("--l2_assoc", type="int", default=8)
1222292SN/A    parser.add_option("--l3_assoc", type="int", default=16)
1232292SN/A    parser.add_option("--cacheline_size", type="int", default=64)
1242292SN/A
1252292SN/A    # Enable Ruby
1262292SN/A    parser.add_option("--ruby", action="store_true")
1272292SN/A
1281060SN/A    # Run duration options
1291060SN/A    parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick,
1301060SN/A                      metavar="TICKS", help="Run to absolute simulated tick " \
1311060SN/A                      "specified including ticks from a restored checkpoint")
1322292SN/A    parser.add_option("--rel-max-tick", type="int", default=None,
1332292SN/A                      metavar="TICKS", help="Simulate for specified number of" \
1342292SN/A                      " ticks relative to the simulation start tick (e.g. if " \
1352307SN/A                      "restoring a checkpoint)")
1362669Sktlim@umich.edu    parser.add_option("--maxtime", type="float", default=None,
1372696Sktlim@umich.edu                      help="Run to the specified absolute simulated time in " \
1382669Sktlim@umich.edu                      "seconds")
1391060SN/A    parser.add_option("-I", "--maxinsts", action="store", type="int",
1401060SN/A                      default=None, help="""Total number of instructions to
1412292SN/A                                            simulate (default: run forever)""")
1422292SN/A    parser.add_option("--work-item-id", action="store", type="int",
1432292SN/A                      help="the specific work id for exit & checkpointing")
1442292SN/A    parser.add_option("--num-work-ids", action="store", type="int",
1452292SN/A                      help="Number of distinct work item types")
1462292SN/A    parser.add_option("--work-begin-cpu-id-exit", action="store", type="int",
1472292SN/A                      help="exit when work starts on the specified cpu")
1482292SN/A    parser.add_option("--work-end-exit-count", action="store", type="int",
1491060SN/A                      help="exit at specified work end count")
1502292SN/A    parser.add_option("--work-begin-exit-count", action="store", type="int",
1512292SN/A                      help="exit at specified work begin count")
1522292SN/A    parser.add_option("--init-param", action="store", type="int", default=0,
1532292SN/A                      help="""Parameter available in simulation with m5
1542292SN/A                              initparam""")
1552292SN/A    parser.add_option("--initialize-only", action="store_true", default=False,
1562292SN/A                      help="""Exit after initialization. Do not simulate time.
1572292SN/A                              Useful when gem5 is run as a library.""")
1582292SN/A
1592292SN/A    # Simpoint options
1602292SN/A    parser.add_option("--simpoint-profile", action="store_true",
1616221Snate@binkert.org                      help="Enable basic block profiling for SimPoints")
1621060SN/A    parser.add_option("--simpoint-interval", type="int", default=10000000,
1631060SN/A                      help="SimPoint interval in num of instructions")
1642292SN/A    parser.add_option("--take-simpoint-checkpoints", action="store", type="string",
1655529Snate@binkert.org        help="<simpoint file,weight file,interval-length,warmup-length>")
1661684SN/A    parser.add_option("--restore-simpoint-checkpoint", action="store_true",
1672292SN/A        help="restore from a simpoint checkpoint taken with " +
1682292SN/A             "--take-simpoint-checkpoints")
1691684SN/A
1702292SN/A    # Checkpointing options
1711062SN/A    ###Note that performing checkpointing via python script files will override
1721062SN/A    ###checkpoint instructions built into binaries.
1732871Sktlim@umich.edu    parser.add_option("--take-checkpoints", action="store", type="string",
1742871Sktlim@umich.edu        help="<M,N> take checkpoints at tick M and every N ticks thereafter")
1752871Sktlim@umich.edu    parser.add_option("--max-checkpoints", action="store", type="int",
1762292SN/A        help="the maximum number of checkpoints to drop", default=5)
1771060SN/A    parser.add_option("--checkpoint-dir", action="store", type="string",
1781060SN/A        help="Place all checkpoints in this absolute directory")
1792292SN/A    parser.add_option("-r", "--checkpoint-restore", action="store", type="int",
1806221Snate@binkert.org        help="restore from checkpoint <N>")
1812292SN/A    parser.add_option("--checkpoint-at-end", action="store_true",
1822292SN/A                      help="take a checkpoint at end of run")
1831060SN/A    parser.add_option("--work-begin-checkpoint-count", action="store", type="int",
1841060SN/A                      help="checkpoint at specified work begin count")
1852292SN/A    parser.add_option("--work-end-checkpoint-count", action="store", type="int",
1862292SN/A                      help="checkpoint at specified work end count")
1872292SN/A    parser.add_option("--work-cpus-checkpoint-count", action="store", type="int",
1884302Sktlim@umich.edu                      help="checkpoint and exit when active cpu count is reached")
1894302Sktlim@umich.edu    parser.add_option("--restore-with-cpu", action="store", type="choice",
1904302Sktlim@umich.edu                      default="atomic", choices=CpuConfig.cpu_names(),
1912292SN/A                      help = "cpu type for restoring from a checkpoint")
1922669Sktlim@umich.edu
1932292SN/A
1942843Sktlim@umich.edu    # CPU Switching - default switch model goes from a checkpoint
1952863Sktlim@umich.edu    # to a timing simple CPU with caches to warm up, then to detailed CPU for
1962843Sktlim@umich.edu    # data measurement
1972843Sktlim@umich.edu    parser.add_option("--repeat-switch", action="store", type="int",
1982843Sktlim@umich.edu        default=None,
1992843Sktlim@umich.edu        help="switch back and forth between CPUs with period <N>")
2002843Sktlim@umich.edu    parser.add_option("-s", "--standard-switch", action="store", type="int",
2012307SN/A        default=None,
2022307SN/A        help="switch from timing to Detailed CPU after warmup period of <N>")
2032348SN/A    parser.add_option("-p", "--prog-interval", type="str",
2042307SN/A        help="CPU Progress Interval")
2052307SN/A
2062348SN/A    # Fastforwarding and simpoint related materials
2072307SN/A    parser.add_option("-W", "--warmup-insts", action="store", type="int",
2082307SN/A        default=None,
2092348SN/A        help="Warmup period in total instructions (requires --standard-switch)")
2102292SN/A    parser.add_option("--bench", action="store", type="string", default=None,
2111060SN/A        help="base names for --take-checkpoint and --checkpoint-restore")
2121061SN/A    parser.add_option("-F", "--fast-forward", action="store", type="string",
2132329SN/A        default=None,
2142329SN/A        help="Number of instructions to fast forward before switching")
2152292SN/A    parser.add_option("-S", "--simpoint", action="store_true", default=False,
2162292SN/A        help="""Use workload simpoints as an instruction offset for
2172292SN/A                --checkpoint-restore or --take-checkpoint.""")
2182329SN/A    parser.add_option("--at-instruction", action="store_true", default=False,
2192329SN/A        help="""Treat value of --checkpoint-restore or --take-checkpoint as a
2202292SN/A                number of instructions.""")
2212292SN/A    parser.add_option("--spec-input", default="ref", type="choice",
2222292SN/A                      choices=["ref", "test", "train", "smred", "mdred",
2231061SN/A                               "lgred"],
2241061SN/A                      help="Input set size for SPEC CPU2000 benchmarks.")
2251061SN/A    parser.add_option("--arm-iset", default="arm", type="choice",
2261763SN/A                      choices=["arm", "thumb", "aarch64"],
2271061SN/A                      help="ARM instruction set.")
2281061SN/A
2292935Sksewell@umich.edu
2301061SN/Adef addSEOptions(parser):
2311061SN/A    # Benchmark options
2324636Sgblack@eecs.umich.edu    parser.add_option("-c", "--cmd", default="",
2331062SN/A                      help="The binary to run in syscall emulation mode.")
2341062SN/A    parser.add_option("-o", "--options", default="",
2351062SN/A                      help="""The options to pass to the binary, use " "
2361062SN/A                              around the entire string""")
2371062SN/A    parser.add_option("-e", "--env", default="",
2381763SN/A                      help="Initialize workload environment from text file.")
2392292SN/A    parser.add_option("-i", "--input", default="",
2402292SN/A                      help="Read stdin from a file.")
2412292SN/A    parser.add_option("--output", default="",
2421062SN/A                      help="Redirect stdout to a file.")
2431062SN/A    parser.add_option("--errout", default="",
2446221Snate@binkert.org                      help="Redirect stderr to a file.")
2451062SN/A
2462292SN/Adef addFSOptions(parser):
2474636Sgblack@eecs.umich.edu    # Simulation options
2486221Snate@binkert.org    parser.add_option("--timesync", action="store_true",
2491684SN/A            help="Prevent simulated time from getting ahead of real time")
2502292SN/A
2512292SN/A    # System options
2522292SN/A    parser.add_option("--kernel", action="store", type="string")
2533795Sgblack@eecs.umich.edu    parser.add_option("--os-type", action="store", type="choice",
2544636Sgblack@eecs.umich.edu            choices=os_types[buildEnv['TARGET_ISA']], default="linux",
2556221Snate@binkert.org            help="Specifies type of OS to boot")
2562292SN/A    parser.add_option("--script", action="store", type="string")
2572292SN/A    parser.add_option("--frame-capture", action="store_true",
2586221Snate@binkert.org            help="Stores changed frame buffers from the VNC server to compressed "\
2592292SN/A            "files in the gem5 output directory")
2602292SN/A
2612292SN/A    if buildEnv['TARGET_ISA'] == "arm":
2622292SN/A        parser.add_option("--bare-metal", action="store_true",
2631684SN/A                   help="Provide the raw system without the linux specific bits")
2641684SN/A        parser.add_option("--machine-type", action="store", type="choice",
2652292SN/A                choices=ArmMachineType.map.keys(), default="VExpress_EMM")
2662292SN/A        parser.add_option("--dtb-filename", action="store", type="string",
2672292SN/A              help="Specifies device tree blob file to use with device-tree-"\
2682292SN/A              "enabled kernels")
2693795Sgblack@eecs.umich.edu        parser.add_option("--enable-context-switch-stats-dump", \
2704636Sgblack@eecs.umich.edu                action="store_true", help="Enable stats dump at context "\
2716221Snate@binkert.org                "switches and dump tasks file (required for Streamline)")
2721684SN/A
2732292SN/A    # Benchmark options
2742292SN/A    parser.add_option("--dual", action="store_true",
2752292SN/A                      help="Simulate two systems attached with an ethernet link")
2761684SN/A    parser.add_option("-b", "--benchmark", action="store", type="string",
2771684SN/A                      dest="benchmark",
2782292SN/A                      help="Specify the benchmark to run. Available benchmarks: %s"\
2792292SN/A                      % DefinedBenchmarks)
2802292SN/A
2816221Snate@binkert.org    # Metafile options
2821684SN/A    parser.add_option("--etherdump", action="store", type="string", dest="etherdump",
2832292SN/A                      help="Specify the filename to dump a pcap capture of the" \
2842292SN/A                      "ethernet traffic")
2852292SN/A
2862292SN/A    # Disk Image Options
2872292SN/A    parser.add_option("--disk-image", action="store", type="string", default=None,
2882292SN/A                      help="Path to the disk image to use.")
2892292SN/A    parser.add_option("--root-device", action="store", type="string", default=None,
2902292SN/A                      help="OS device name for root partition")
2911062SN/A
2921062SN/A    # Command line options
2932107SN/A    parser.add_option("--command-line", action="store", type="string",
2941062SN/A                      default=None,
2951062SN/A                      help="Template for the kernel command line.")
2961061SN/A    parser.add_option("--command-line-file", action="store",
2971060SN/A                      default=None, type="string",
2982698Sktlim@umich.edu                      help="File with a template for the kernel command line")
2992696Sktlim@umich.edu