Options.py revision 13357
112839Sgabeblack@google.com# Copyright (c) 2013 ARM Limited 212839Sgabeblack@google.com# All rights reserved. 312839Sgabeblack@google.com# 412839Sgabeblack@google.com# The license below extends only to copyright in the software and shall 512839Sgabeblack@google.com# not be construed as granting a license to any other intellectual 612839Sgabeblack@google.com# property including but not limited to intellectual property relating 712839Sgabeblack@google.com# to a hardware implementation of the functionality of the software 812839Sgabeblack@google.com# licensed hereunder. You may use the software subject to the license 912839Sgabeblack@google.com# terms below provided that you ensure that this notice is replicated 1012839Sgabeblack@google.com# unmodified and in its entirety in all distributions of the software, 1112839Sgabeblack@google.com# modified or unmodified, in source code or in binary form. 1212839Sgabeblack@google.com# 1312839Sgabeblack@google.com# Copyright (c) 2006-2008 The Regents of The University of Michigan 1412839Sgabeblack@google.com# All rights reserved. 1512839Sgabeblack@google.com# 1612839Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 1712839Sgabeblack@google.com# modification, are permitted provided that the following conditions are 1812839Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 1912839Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 2012839Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 2112839Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 2212839Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 2312839Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 2412839Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 2512839Sgabeblack@google.com# this software without specific prior written permission. 2612839Sgabeblack@google.com# 2712839Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2812839Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2912839Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3012839Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3112839Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3212839Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3312993Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3412993Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3512839Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3612839Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3712839Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3812839Sgabeblack@google.com# 3912839Sgabeblack@google.com# Authors: Lisa Hsu 4012993Sgabeblack@google.com 4112993Sgabeblack@google.comimport m5 4212993Sgabeblack@google.comfrom m5.defines import buildEnv 4312993Sgabeblack@google.comfrom m5.objects import * 4412993Sgabeblack@google.comfrom common.Benchmarks import * 4512993Sgabeblack@google.com 4612993Sgabeblack@google.comfrom common import CpuConfig 4712993Sgabeblack@google.comfrom common import MemConfig 4812993Sgabeblack@google.comfrom common import PlatformConfig 4912993Sgabeblack@google.com 5012993Sgabeblack@google.comdef _listCpuTypes(option, opt, value, parser): 5112993Sgabeblack@google.com CpuConfig.print_cpu_list() 5212993Sgabeblack@google.com sys.exit(0) 5312993Sgabeblack@google.com 5412993Sgabeblack@google.comdef _listMemTypes(option, opt, value, parser): 5512993Sgabeblack@google.com MemConfig.print_mem_list() 5612993Sgabeblack@google.com sys.exit(0) 5712993Sgabeblack@google.com 5812993Sgabeblack@google.comdef _listPlatformTypes(option, opt, value, parser): 5912993Sgabeblack@google.com PlatformConfig.print_platform_list() 6012993Sgabeblack@google.com sys.exit(0) 6112993Sgabeblack@google.com 6212993Sgabeblack@google.com# Add the very basic options that work also in the case of the no ISA 6312993Sgabeblack@google.com# being used, and consequently no CPUs, but rather various types of 6412993Sgabeblack@google.com# testers and traffic generators. 6512993Sgabeblack@google.comdef addNoISAOptions(parser): 6612993Sgabeblack@google.com parser.add_option("-n", "--num-cpus", type="int", default=1) 6712993Sgabeblack@google.com parser.add_option("--sys-voltage", action="store", type="string", 6812993Sgabeblack@google.com default='1.0V', 6912993Sgabeblack@google.com help = """Top-level voltage for blocks running at system 7012993Sgabeblack@google.com power supply""") 7112993Sgabeblack@google.com parser.add_option("--sys-clock", action="store", type="string", 7212993Sgabeblack@google.com default='1GHz', 7312993Sgabeblack@google.com help = """Top-level clock for blocks running at system 7412993Sgabeblack@google.com speed""") 7512993Sgabeblack@google.com 7612993Sgabeblack@google.com # Memory Options 7712993Sgabeblack@google.com parser.add_option("--list-mem-types", 7812839Sgabeblack@google.com action="callback", callback=_listMemTypes, 7912839Sgabeblack@google.com help="List available memory types") 8012839Sgabeblack@google.com parser.add_option("--mem-type", type="choice", default="DDR3_1600_8x8", 8112839Sgabeblack@google.com choices=MemConfig.mem_names(), 8212839Sgabeblack@google.com help = "type of memory to use") 8312839Sgabeblack@google.com parser.add_option("--mem-channels", type="int", default=1, 8412839Sgabeblack@google.com help = "number of memory channels") 8512839Sgabeblack@google.com parser.add_option("--mem-ranks", type="int", default=None, 8612839Sgabeblack@google.com help = "number of memory ranks per channel") 8712839Sgabeblack@google.com parser.add_option("--mem-size", action="store", type="string", 8812839Sgabeblack@google.com default="512MB", 8912839Sgabeblack@google.com help="Specify the physical memory size (single memory)") 9012839Sgabeblack@google.com 9112839Sgabeblack@google.com 9212839Sgabeblack@google.com parser.add_option("--memchecker", action="store_true") 9312839Sgabeblack@google.com 9412839Sgabeblack@google.com # Cache Options 9512839Sgabeblack@google.com parser.add_option("--external-memory-system", type="string", 9612993Sgabeblack@google.com help="use external ports of this port_type for caches") 9712993Sgabeblack@google.com parser.add_option("--tlm-memory", type="string", 9812993Sgabeblack@google.com help="use external port for SystemC TLM cosimulation") 9912993Sgabeblack@google.com parser.add_option("--caches", action="store_true") 10012839Sgabeblack@google.com parser.add_option("--l2cache", action="store_true") 10112839Sgabeblack@google.com parser.add_option("--num-dirs", type="int", default=1) 10212839Sgabeblack@google.com parser.add_option("--num-l2caches", type="int", default=1) 10312839Sgabeblack@google.com parser.add_option("--num-l3caches", type="int", default=1) 10412839Sgabeblack@google.com parser.add_option("--l1d_size", type="string", default="64kB") 10512839Sgabeblack@google.com parser.add_option("--l1i_size", type="string", default="32kB") 10612839Sgabeblack@google.com parser.add_option("--l2_size", type="string", default="2MB") 10712839Sgabeblack@google.com parser.add_option("--l3_size", type="string", default="16MB") 10812839Sgabeblack@google.com parser.add_option("--l1d_assoc", type="int", default=2) 10912839Sgabeblack@google.com parser.add_option("--l1i_assoc", type="int", default=2) 11012839Sgabeblack@google.com parser.add_option("--l2_assoc", type="int", default=8) 11112839Sgabeblack@google.com parser.add_option("--l3_assoc", type="int", default=16) 11212839Sgabeblack@google.com parser.add_option("--cacheline_size", type="int", default=64) 11312839Sgabeblack@google.com 11412839Sgabeblack@google.com # Enable Ruby 11512839Sgabeblack@google.com parser.add_option("--ruby", action="store_true") 11612839Sgabeblack@google.com 11712839Sgabeblack@google.com # Run duration options 11812839Sgabeblack@google.com parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick, 11912839Sgabeblack@google.com metavar="TICKS", help="Run to absolute simulated tick " 12012839Sgabeblack@google.com "specified including ticks from a restored checkpoint") 12112839Sgabeblack@google.com parser.add_option("--rel-max-tick", type="int", default=None, 12212839Sgabeblack@google.com metavar="TICKS", help="Simulate for specified number of" 12312993Sgabeblack@google.com " ticks relative to the simulation start tick (e.g. if " 12412993Sgabeblack@google.com "restoring a checkpoint)") 12512993Sgabeblack@google.com parser.add_option("--maxtime", type="float", default=None, 12612993Sgabeblack@google.com help="Run to the specified absolute simulated time in " 12712993Sgabeblack@google.com "seconds") 12812993Sgabeblack@google.com parser.add_option("-P", "--param", action="append", default=[], 12912993Sgabeblack@google.com help="Set a SimObject parameter relative to the root node. " 13012993Sgabeblack@google.com "An extended Python multi range slicing syntax can be used " 13112993Sgabeblack@google.com "for arrays. For example: " 13212839Sgabeblack@google.com "'system.cpu[0,1,3:8:2].max_insts_all_threads = 42' " 13312839Sgabeblack@google.com "sets max_insts_all_threads for cpus 0, 1, 3, 5 and 7 " 13412839Sgabeblack@google.com "Direct parameters of the root object are not accessible, " 13512839Sgabeblack@google.com "only parameters of its children.") 13612839Sgabeblack@google.com 13712839Sgabeblack@google.com# Add common options that assume a non-NULL ISA. 13812839Sgabeblack@google.comdef addCommonOptions(parser): 13912839Sgabeblack@google.com # start by adding the base options that do not assume an ISA 14012839Sgabeblack@google.com addNoISAOptions(parser) 14112839Sgabeblack@google.com 14212839Sgabeblack@google.com # system options 14312839Sgabeblack@google.com parser.add_option("--list-cpu-types", 14412993Sgabeblack@google.com action="callback", callback=_listCpuTypes, 14512993Sgabeblack@google.com help="List available CPU types") 14612993Sgabeblack@google.com parser.add_option("--cpu-type", type="choice", default="AtomicSimpleCPU", 14712839Sgabeblack@google.com choices=CpuConfig.cpu_names(), 14812839Sgabeblack@google.com help = "type of cpu to run with") 14912839Sgabeblack@google.com parser.add_option("--checker", action="store_true"); 15012839Sgabeblack@google.com parser.add_option("--cpu-clock", action="store", type="string", 15112839Sgabeblack@google.com default='2GHz', 15212839Sgabeblack@google.com help="Clock for blocks running at CPU speed") 15312839Sgabeblack@google.com parser.add_option("--smt", action="store_true", default=False, 15412993Sgabeblack@google.com help = """ 15512993Sgabeblack@google.com Only used if multiple programs are specified. If true, 15612993Sgabeblack@google.com then the number of threads per cpu is same as the 15712993Sgabeblack@google.com number of programs.""") 15812839Sgabeblack@google.com parser.add_option("--elastic-trace-en", action="store_true", 15912839Sgabeblack@google.com help="""Enable capture of data dependency and instruction 16012839Sgabeblack@google.com fetch traces using elastic trace probe.""") 16112839Sgabeblack@google.com # Trace file paths input to trace probe in a capture simulation and input 16212839Sgabeblack@google.com # to Trace CPU in a replay simulation 16312839Sgabeblack@google.com parser.add_option("--inst-trace-file", action="store", type="string", 16412879Sgabeblack@google.com help="""Instruction fetch trace file input to 16512879Sgabeblack@google.com Elastic Trace probe in a capture simulation and 16612879Sgabeblack@google.com Trace CPU in a replay simulation""", default="") 16712879Sgabeblack@google.com parser.add_option("--data-trace-file", action="store", type="string", 16812879Sgabeblack@google.com help="""Data dependency trace file input to 16912879Sgabeblack@google.com Elastic Trace probe in a capture simulation and 17012879Sgabeblack@google.com Trace CPU in a replay simulation""", default="") 17112879Sgabeblack@google.com 17212879Sgabeblack@google.com parser.add_option("-l", "--lpae", action="store_true") 17312879Sgabeblack@google.com parser.add_option("-V", "--virtualisation", action="store_true") 17412839Sgabeblack@google.com 17512839Sgabeblack@google.com # dist-gem5 options 17612839Sgabeblack@google.com parser.add_option("--dist", action="store_true", 17712839Sgabeblack@google.com help="Parallel distributed gem5 simulation.") 17812839Sgabeblack@google.com parser.add_option("--dist-sync-on-pseudo-op", action="store_true", 17912839Sgabeblack@google.com help="Use a pseudo-op to start dist-gem5 synchronization.") 18012839Sgabeblack@google.com parser.add_option("--is-switch", action="store_true", 18112839Sgabeblack@google.com help="Select the network switch simulator process for a"\ 18212839Sgabeblack@google.com "distributed gem5 run") 18312839Sgabeblack@google.com parser.add_option("--dist-rank", default=0, action="store", type="int", 18412839Sgabeblack@google.com help="Rank of this system within the dist gem5 run.") 18512839Sgabeblack@google.com parser.add_option("--dist-size", default=0, action="store", type="int", 18612839Sgabeblack@google.com help="Number of gem5 processes within the dist gem5 run.") 18712839Sgabeblack@google.com parser.add_option("--dist-server-name", 18812839Sgabeblack@google.com default="127.0.0.1", 18912839Sgabeblack@google.com action="store", type="string", 19012839Sgabeblack@google.com help="Name of the message server host\nDEFAULT: localhost") 19112839Sgabeblack@google.com parser.add_option("--dist-server-port", 19212839Sgabeblack@google.com default=2200, 19312839Sgabeblack@google.com action="store", type="int", 194 help="Message server listen port\nDEFAULT: 2200") 195 parser.add_option("--dist-sync-repeat", 196 default="0us", 197 action="store", type="string", 198 help="Repeat interval for synchronisation barriers among dist-gem5 processes\nDEFAULT: --ethernet-linkdelay") 199 parser.add_option("--dist-sync-start", 200 default="5200000000000t", 201 action="store", type="string", 202 help="Time to schedule the first dist synchronisation barrier\nDEFAULT:5200000000000t") 203 parser.add_option("--ethernet-linkspeed", default="10Gbps", 204 action="store", type="string", 205 help="Link speed in bps\nDEFAULT: 10Gbps") 206 parser.add_option("--ethernet-linkdelay", default="10us", 207 action="store", type="string", 208 help="Link delay in seconds\nDEFAULT: 10us") 209 210 # Run duration options 211 parser.add_option("-I", "--maxinsts", action="store", type="int", 212 default=None, help="""Total number of instructions to 213 simulate (default: run forever)""") 214 parser.add_option("--work-item-id", action="store", type="int", 215 help="the specific work id for exit & checkpointing") 216 parser.add_option("--num-work-ids", action="store", type="int", 217 help="Number of distinct work item types") 218 parser.add_option("--work-begin-cpu-id-exit", action="store", type="int", 219 help="exit when work starts on the specified cpu") 220 parser.add_option("--work-end-exit-count", action="store", type="int", 221 help="exit at specified work end count") 222 parser.add_option("--work-begin-exit-count", action="store", type="int", 223 help="exit at specified work begin count") 224 parser.add_option("--init-param", action="store", type="int", default=0, 225 help="""Parameter available in simulation with m5 226 initparam""") 227 parser.add_option("--initialize-only", action="store_true", default=False, 228 help="""Exit after initialization. Do not simulate time. 229 Useful when gem5 is run as a library.""") 230 231 # Simpoint options 232 parser.add_option("--simpoint-profile", action="store_true", 233 help="Enable basic block profiling for SimPoints") 234 parser.add_option("--simpoint-interval", type="int", default=10000000, 235 help="SimPoint interval in num of instructions") 236 parser.add_option("--take-simpoint-checkpoints", action="store", type="string", 237 help="<simpoint file,weight file,interval-length,warmup-length>") 238 parser.add_option("--restore-simpoint-checkpoint", action="store_true", 239 help="restore from a simpoint checkpoint taken with " + 240 "--take-simpoint-checkpoints") 241 242 # Checkpointing options 243 ###Note that performing checkpointing via python script files will override 244 ###checkpoint instructions built into binaries. 245 parser.add_option("--take-checkpoints", action="store", type="string", 246 help="<M,N> take checkpoints at tick M and every N ticks thereafter") 247 parser.add_option("--max-checkpoints", action="store", type="int", 248 help="the maximum number of checkpoints to drop", default=5) 249 parser.add_option("--checkpoint-dir", action="store", type="string", 250 help="Place all checkpoints in this absolute directory") 251 parser.add_option("-r", "--checkpoint-restore", action="store", type="int", 252 help="restore from checkpoint <N>") 253 parser.add_option("--checkpoint-at-end", action="store_true", 254 help="take a checkpoint at end of run") 255 parser.add_option("--work-begin-checkpoint-count", action="store", type="int", 256 help="checkpoint at specified work begin count") 257 parser.add_option("--work-end-checkpoint-count", action="store", type="int", 258 help="checkpoint at specified work end count") 259 parser.add_option("--work-cpus-checkpoint-count", action="store", type="int", 260 help="checkpoint and exit when active cpu count is reached") 261 parser.add_option("--restore-with-cpu", action="store", type="choice", 262 default="AtomicSimpleCPU", choices=CpuConfig.cpu_names(), 263 help = "cpu type for restoring from a checkpoint") 264 265 266 # CPU Switching - default switch model goes from a checkpoint 267 # to a timing simple CPU with caches to warm up, then to detailed CPU for 268 # data measurement 269 parser.add_option("--repeat-switch", action="store", type="int", 270 default=None, 271 help="switch back and forth between CPUs with period <N>") 272 parser.add_option("-s", "--standard-switch", action="store", type="int", 273 default=None, 274 help="switch from timing to Detailed CPU after warmup period of <N>") 275 parser.add_option("-p", "--prog-interval", type="str", 276 help="CPU Progress Interval") 277 278 # Fastforwarding and simpoint related materials 279 parser.add_option("-W", "--warmup-insts", action="store", type="int", 280 default=None, 281 help="Warmup period in total instructions (requires --standard-switch)") 282 parser.add_option("--bench", action="store", type="string", default=None, 283 help="base names for --take-checkpoint and --checkpoint-restore") 284 parser.add_option("-F", "--fast-forward", action="store", type="string", 285 default=None, 286 help="Number of instructions to fast forward before switching") 287 parser.add_option("-S", "--simpoint", action="store_true", default=False, 288 help="""Use workload simpoints as an instruction offset for 289 --checkpoint-restore or --take-checkpoint.""") 290 parser.add_option("--at-instruction", action="store_true", default=False, 291 help="""Treat value of --checkpoint-restore or --take-checkpoint as a 292 number of instructions.""") 293 parser.add_option("--spec-input", default="ref", type="choice", 294 choices=["ref", "test", "train", "smred", "mdred", 295 "lgred"], 296 help="Input set size for SPEC CPU2000 benchmarks.") 297 parser.add_option("--arm-iset", default="arm", type="choice", 298 choices=["arm", "thumb", "aarch64"], 299 help="ARM instruction set.") 300 301 302def addSEOptions(parser): 303 # Benchmark options 304 parser.add_option("-c", "--cmd", default="", 305 help="The binary to run in syscall emulation mode.") 306 parser.add_option("-o", "--options", default="", 307 help="""The options to pass to the binary, use " " 308 around the entire string""") 309 parser.add_option("-e", "--env", default="", 310 help="Initialize workload environment from text file.") 311 parser.add_option("-i", "--input", default="", 312 help="Read stdin from a file.") 313 parser.add_option("--output", default="", 314 help="Redirect stdout to a file.") 315 parser.add_option("--errout", default="", 316 help="Redirect stderr to a file.") 317 318def addFSOptions(parser): 319 from FSConfig import os_types 320 321 # Simulation options 322 parser.add_option("--timesync", action="store_true", 323 help="Prevent simulated time from getting ahead of real time") 324 325 # System options 326 parser.add_option("--kernel", action="store", type="string") 327 parser.add_option("--os-type", action="store", type="choice", 328 choices=os_types[buildEnv['TARGET_ISA']], default="linux", 329 help="Specifies type of OS to boot") 330 parser.add_option("--script", action="store", type="string") 331 parser.add_option("--frame-capture", action="store_true", 332 help="Stores changed frame buffers from the VNC server to compressed "\ 333 "files in the gem5 output directory") 334 335 if buildEnv['TARGET_ISA'] == "arm": 336 parser.add_option("--bare-metal", action="store_true", 337 help="Provide the raw system without the linux specific bits") 338 parser.add_option("--list-machine-types", 339 action="callback", callback=_listPlatformTypes, 340 help="List available platform types") 341 parser.add_option("--machine-type", action="store", type="choice", 342 choices=PlatformConfig.platform_names(), 343 default="VExpress_EMM") 344 parser.add_option("--dtb-filename", action="store", type="string", 345 help="Specifies device tree blob file to use with device-tree-"\ 346 "enabled kernels") 347 parser.add_option("--enable-security-extensions", action="store_true", 348 help="Turn on the ARM Security Extensions") 349 parser.add_option("--enable-context-switch-stats-dump", \ 350 action="store_true", help="Enable stats dump at context "\ 351 "switches and dump tasks file (required for Streamline)") 352 parser.add_option("--generate-dtb", action="store_true", default=False, 353 help="Automatically generate a dtb file") 354 355 # Benchmark options 356 parser.add_option("--dual", action="store_true", 357 help="Simulate two systems attached with an ethernet link") 358 parser.add_option("-b", "--benchmark", action="store", type="string", 359 dest="benchmark", 360 help="Specify the benchmark to run. Available benchmarks: %s"\ 361 % DefinedBenchmarks) 362 363 # Metafile options 364 parser.add_option("--etherdump", action="store", type="string", dest="etherdump", 365 help="Specify the filename to dump a pcap capture of the" \ 366 "ethernet traffic") 367 368 # Disk Image Options 369 parser.add_option("--disk-image", action="store", type="string", default=None, 370 help="Path to the disk image to use.") 371 parser.add_option("--root-device", action="store", type="string", default=None, 372 help="OS device name for root partition") 373 374 # Command line options 375 parser.add_option("--command-line", action="store", type="string", 376 default=None, 377 help="Template for the kernel command line.") 378 parser.add_option("--command-line-file", action="store", 379 default=None, type="string", 380 help="File with a template for the kernel command line") 381