Options.py revision 9790
16906SBrad.Beckmann@amd.com# Copyright (c) 2013 ARM Limited 26906SBrad.Beckmann@amd.com# All rights reserved. 36906SBrad.Beckmann@amd.com# 46906SBrad.Beckmann@amd.com# The license below extends only to copyright in the software and shall 56906SBrad.Beckmann@amd.com# not be construed as granting a license to any other intellectual 66906SBrad.Beckmann@amd.com# property including but not limited to intellectual property relating 76906SBrad.Beckmann@amd.com# to a hardware implementation of the functionality of the software 86906SBrad.Beckmann@amd.com# licensed hereunder. You may use the software subject to the license 96906SBrad.Beckmann@amd.com# terms below provided that you ensure that this notice is replicated 106906SBrad.Beckmann@amd.com# unmodified and in its entirety in all distributions of the software, 116906SBrad.Beckmann@amd.com# modified or unmodified, in source code or in binary form. 126906SBrad.Beckmann@amd.com# 136906SBrad.Beckmann@amd.com# Copyright (c) 2006-2008 The Regents of The University of Michigan 146906SBrad.Beckmann@amd.com# All rights reserved. 156906SBrad.Beckmann@amd.com# 166906SBrad.Beckmann@amd.com# Redistribution and use in source and binary forms, with or without 176906SBrad.Beckmann@amd.com# modification, are permitted provided that the following conditions are 186906SBrad.Beckmann@amd.com# met: redistributions of source code must retain the above copyright 196906SBrad.Beckmann@amd.com# notice, this list of conditions and the following disclaimer; 206906SBrad.Beckmann@amd.com# redistributions in binary form must reproduce the above copyright 216906SBrad.Beckmann@amd.com# notice, this list of conditions and the following disclaimer in the 226906SBrad.Beckmann@amd.com# documentation and/or other materials provided with the distribution; 236906SBrad.Beckmann@amd.com# neither the name of the copyright holders nor the names of its 246906SBrad.Beckmann@amd.com# contributors may be used to endorse or promote products derived from 256906SBrad.Beckmann@amd.com# this software without specific prior written permission. 266906SBrad.Beckmann@amd.com# 276906SBrad.Beckmann@amd.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 286906SBrad.Beckmann@amd.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 296906SBrad.Beckmann@amd.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 306906SBrad.Beckmann@amd.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 316906SBrad.Beckmann@amd.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 326906SBrad.Beckmann@amd.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 336906SBrad.Beckmann@amd.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 346906SBrad.Beckmann@amd.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 356906SBrad.Beckmann@amd.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 366906SBrad.Beckmann@amd.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 376906SBrad.Beckmann@amd.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 386906SBrad.Beckmann@amd.com# 396906SBrad.Beckmann@amd.com# Authors: Lisa Hsu 407538SBrad.Beckmann@amd.com 417538SBrad.Beckmann@amd.comimport m5 427538SBrad.Beckmann@amd.comfrom m5.defines import buildEnv 437541SBrad.Beckmann@amd.comfrom m5.objects import * 446906SBrad.Beckmann@amd.comfrom Benchmarks import * 456906SBrad.Beckmann@amd.com 466906SBrad.Beckmann@amd.comimport CpuConfig 476906SBrad.Beckmann@amd.comimport MemConfig 486906SBrad.Beckmann@amd.com 496906SBrad.Beckmann@amd.comdef _listCpuTypes(option, opt, value, parser): 506906SBrad.Beckmann@amd.com CpuConfig.print_cpu_list() 516906SBrad.Beckmann@amd.com sys.exit(0) 526906SBrad.Beckmann@amd.com 536906SBrad.Beckmann@amd.comdef _listMemTypes(option, opt, value, parser): 546906SBrad.Beckmann@amd.com MemConfig.print_mem_list() 556906SBrad.Beckmann@amd.com sys.exit(0) 566906SBrad.Beckmann@amd.com 576906SBrad.Beckmann@amd.comdef addCommonOptions(parser): 586906SBrad.Beckmann@amd.com # system options 596906SBrad.Beckmann@amd.com parser.add_option("--list-cpu-types", 606906SBrad.Beckmann@amd.com action="callback", callback=_listCpuTypes, 616906SBrad.Beckmann@amd.com help="List available CPU types") 626906SBrad.Beckmann@amd.com parser.add_option("--cpu-type", type="choice", default="atomic", 636906SBrad.Beckmann@amd.com choices=CpuConfig.cpu_names(), 646906SBrad.Beckmann@amd.com help = "type of cpu to run with") 656906SBrad.Beckmann@amd.com parser.add_option("--list-mem-types", 666906SBrad.Beckmann@amd.com action="callback", callback=_listMemTypes, 676906SBrad.Beckmann@amd.com help="List available memory types") 686906SBrad.Beckmann@amd.com parser.add_option("--mem-type", type="choice", default="simple_mem", 696906SBrad.Beckmann@amd.com choices=MemConfig.mem_names(), 706906SBrad.Beckmann@amd.com help = "type of memory to use") 716906SBrad.Beckmann@amd.com parser.add_option("--checker", action="store_true"); 726906SBrad.Beckmann@amd.com parser.add_option("-n", "--num-cpus", type="int", default=1) 736906SBrad.Beckmann@amd.com parser.add_option("--caches", action="store_true") 746906SBrad.Beckmann@amd.com parser.add_option("--l2cache", action="store_true") 756906SBrad.Beckmann@amd.com parser.add_option("--fastmem", action="store_true") 767015SBrad.Beckmann@amd.com parser.add_option("--simpoint-profile", action="store_true", 777015SBrad.Beckmann@amd.com help="Enable basic block profiling for SimPoints") 786906SBrad.Beckmann@amd.com parser.add_option("--simpoint-interval", type="int", default=10000000, 797541SBrad.Beckmann@amd.com help="SimPoint interval in num of instructions") 807541SBrad.Beckmann@amd.com parser.add_option("--clock", action="store", type="string", default='2GHz') 816906SBrad.Beckmann@amd.com parser.add_option("--sys-clock", action="store", type="string", 826906SBrad.Beckmann@amd.com default='1GHz', 836906SBrad.Beckmann@amd.com help = """Top-level clock for blocks running at system 846906SBrad.Beckmann@amd.com speed""") 856906SBrad.Beckmann@amd.com parser.add_option("--cpu-clock", action="store", type="string", 866906SBrad.Beckmann@amd.com default='2GHz', 876906SBrad.Beckmann@amd.com help="Clock for blocks running at CPU speed") 887541SBrad.Beckmann@amd.com parser.add_option("--num-dirs", type="int", default=1) 897541SBrad.Beckmann@amd.com parser.add_option("--num-l2caches", type="int", default=1) 906906SBrad.Beckmann@amd.com parser.add_option("--num-l3caches", type="int", default=1) 916906SBrad.Beckmann@amd.com parser.add_option("--l1d_size", type="string", default="64kB") 926906SBrad.Beckmann@amd.com parser.add_option("--l1i_size", type="string", default="32kB") 936906SBrad.Beckmann@amd.com parser.add_option("--l2_size", type="string", default="2MB") 946906SBrad.Beckmann@amd.com parser.add_option("--l3_size", type="string", default="16MB") 956906SBrad.Beckmann@amd.com parser.add_option("--l1d_assoc", type="int", default=2) 967541SBrad.Beckmann@amd.com parser.add_option("--l1i_assoc", type="int", default=2) 977541SBrad.Beckmann@amd.com parser.add_option("--l2_assoc", type="int", default=8) 986906SBrad.Beckmann@amd.com parser.add_option("--l3_assoc", type="int", default=16) 996906SBrad.Beckmann@amd.com parser.add_option("--cacheline_size", type="int", default=64) 1006906SBrad.Beckmann@amd.com parser.add_option("--ruby", action="store_true") 1016906SBrad.Beckmann@amd.com parser.add_option("--smt", action="store_true", default=False, 1026906SBrad.Beckmann@amd.com help = """ 1036906SBrad.Beckmann@amd.com Only used if multiple programs are specified. If true, 1046906SBrad.Beckmann@amd.com then the number of threads per cpu is same as the 1056906SBrad.Beckmann@amd.com number of programs.""") 1066906SBrad.Beckmann@amd.com 1076906SBrad.Beckmann@amd.com # Run duration options 1086906SBrad.Beckmann@amd.com parser.add_option("-m", "--maxtick", type="int", default=m5.MaxTick, 1096906SBrad.Beckmann@amd.com metavar="T", help="Stop after T ticks") 1106906SBrad.Beckmann@amd.com parser.add_option("--maxtime", type="float") 1116906SBrad.Beckmann@amd.com parser.add_option("-I", "--maxinsts", action="store", type="int", 1127541SBrad.Beckmann@amd.com default=None, help="""Total number of instructions to 1137541SBrad.Beckmann@amd.com simulate (default: run forever)""") 1147541SBrad.Beckmann@amd.com parser.add_option("--work-item-id", action="store", type="int", 1157541SBrad.Beckmann@amd.com help="the specific work id for exit & checkpointing") 1167541SBrad.Beckmann@amd.com parser.add_option("--work-begin-cpu-id-exit", action="store", type="int", 1177541SBrad.Beckmann@amd.com help="exit when work starts on the specified cpu") 1186906SBrad.Beckmann@amd.com parser.add_option("--work-end-exit-count", action="store", type="int", 1196906SBrad.Beckmann@amd.com help="exit at specified work end count") 1207541SBrad.Beckmann@amd.com parser.add_option("--work-begin-exit-count", action="store", type="int", 1216906SBrad.Beckmann@amd.com help="exit at specified work begin count") 1226906SBrad.Beckmann@amd.com parser.add_option("--init-param", action="store", type="int", default=0, 1236906SBrad.Beckmann@amd.com help="""Parameter available in simulation with m5 1246906SBrad.Beckmann@amd.com initparam""") 1256906SBrad.Beckmann@amd.com 1266906SBrad.Beckmann@amd.com # Checkpointing options 1276906SBrad.Beckmann@amd.com ###Note that performing checkpointing via python script files will override 1287541SBrad.Beckmann@amd.com ###checkpoint instructions built into binaries. 1297541SBrad.Beckmann@amd.com parser.add_option("--take-checkpoints", action="store", type="string", 1306906SBrad.Beckmann@amd.com help="<M,N> take checkpoints at tick M and every N ticks thereafter") 1316906SBrad.Beckmann@amd.com parser.add_option("--max-checkpoints", action="store", type="int", 1326906SBrad.Beckmann@amd.com help="the maximum number of checkpoints to drop", default=5) 1336906SBrad.Beckmann@amd.com parser.add_option("--checkpoint-dir", action="store", type="string", 1347541SBrad.Beckmann@amd.com help="Place all checkpoints in this absolute directory") 1356906SBrad.Beckmann@amd.com parser.add_option("-r", "--checkpoint-restore", action="store", type="int", 1366906SBrad.Beckmann@amd.com help="restore from checkpoint <N>") 1376906SBrad.Beckmann@amd.com parser.add_option("--checkpoint-at-end", action="store_true", 1386906SBrad.Beckmann@amd.com help="take a checkpoint at end of run") 1396906SBrad.Beckmann@amd.com parser.add_option("--work-begin-checkpoint-count", action="store", type="int", 1406906SBrad.Beckmann@amd.com help="checkpoint at specified work begin count") 141 parser.add_option("--work-end-checkpoint-count", action="store", type="int", 142 help="checkpoint at specified work end count") 143 parser.add_option("--work-cpus-checkpoint-count", action="store", type="int", 144 help="checkpoint and exit when active cpu count is reached") 145 parser.add_option("--restore-with-cpu", action="store", type="choice", 146 default="atomic", choices=CpuConfig.cpu_names(), 147 help = "cpu type for restoring from a checkpoint") 148 149 150 # CPU Switching - default switch model goes from a checkpoint 151 # to a timing simple CPU with caches to warm up, then to detailed CPU for 152 # data measurement 153 parser.add_option("--repeat-switch", action="store", type="int", 154 default=None, 155 help="switch back and forth between CPUs with period <N>") 156 parser.add_option("-s", "--standard-switch", action="store", type="int", 157 default=None, 158 help="switch from timing to Detailed CPU after warmup period of <N>") 159 parser.add_option("-p", "--prog-interval", type="str", 160 help="CPU Progress Interval") 161 162 # Fastforwarding and simpoint related materials 163 parser.add_option("-W", "--warmup-insts", action="store", type="int", 164 default=None, 165 help="Warmup period in total instructions (requires --standard-switch)") 166 parser.add_option("--bench", action="store", type="string", default=None, 167 help="base names for --take-checkpoint and --checkpoint-restore") 168 parser.add_option("-F", "--fast-forward", action="store", type="string", 169 default=None, 170 help="Number of instructions to fast forward before switching") 171 parser.add_option("-S", "--simpoint", action="store_true", default=False, 172 help="""Use workload simpoints as an instruction offset for 173 --checkpoint-restore or --take-checkpoint.""") 174 parser.add_option("--at-instruction", action="store_true", default=False, 175 help="""Treat value of --checkpoint-restore or --take-checkpoint as a 176 number of instructions.""") 177 178def addSEOptions(parser): 179 # Benchmark options 180 parser.add_option("-c", "--cmd", default="", 181 help="The binary to run in syscall emulation mode.") 182 parser.add_option("-o", "--options", default="", 183 help="""The options to pass to the binary, use " " 184 around the entire string""") 185 parser.add_option("-i", "--input", default="", 186 help="Read stdin from a file.") 187 parser.add_option("--output", default="", 188 help="Redirect stdout to a file.") 189 parser.add_option("--errout", default="", 190 help="Redirect stderr to a file.") 191 192def addFSOptions(parser): 193 # Simulation options 194 parser.add_option("--timesync", action="store_true", 195 help="Prevent simulated time from getting ahead of real time") 196 197 # System options 198 parser.add_option("--kernel", action="store", type="string") 199 parser.add_option("--script", action="store", type="string") 200 parser.add_option("--frame-capture", action="store_true", 201 help="Stores changed frame buffers from the VNC server to compressed "\ 202 "files in the gem5 output directory") 203 204 if buildEnv['TARGET_ISA'] == "arm": 205 parser.add_option("--bare-metal", action="store_true", 206 help="Provide the raw system without the linux specific bits") 207 parser.add_option("--machine-type", action="store", type="choice", 208 choices=ArmMachineType.map.keys(), default="RealView_PBX") 209 parser.add_option("--dtb-filename", action="store", type="string", 210 help="Specifies device tree blob file to use with device-tree-"\ 211 "enabled kernels") 212 # Benchmark options 213 parser.add_option("--dual", action="store_true", 214 help="Simulate two systems attached with an ethernet link") 215 parser.add_option("-b", "--benchmark", action="store", type="string", 216 dest="benchmark", 217 help="Specify the benchmark to run. Available benchmarks: %s"\ 218 % DefinedBenchmarks) 219 220 # Metafile options 221 parser.add_option("--etherdump", action="store", type="string", dest="etherdump", 222 help="Specify the filename to dump a pcap capture of the" \ 223 "ethernet traffic") 224 225 # Disk Image Options 226 parser.add_option("--disk-image", action="store", type="string", default=None, 227 help="Path to the disk image to use.") 228 229 # Memory Size Options 230 parser.add_option("--mem-size", action="store", type="string", default=None, 231 help="Specify the physical memory size (single memory)") 232