Options.py revision 13876:1643f200987c
1# Copyright (c) 2013 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated 10# unmodified and in its entirety in all distributions of the software, 11# modified or unmodified, in source code or in binary form. 12# 13# Copyright (c) 2006-2008 The Regents of The University of Michigan 14# All rights reserved. 15# 16# Redistribution and use in source and binary forms, with or without 17# modification, are permitted provided that the following conditions are 18# met: redistributions of source code must retain the above copyright 19# notice, this list of conditions and the following disclaimer; 20# redistributions in binary form must reproduce the above copyright 21# notice, this list of conditions and the following disclaimer in the 22# documentation and/or other materials provided with the distribution; 23# neither the name of the copyright holders nor the names of its 24# contributors may be used to endorse or promote products derived from 25# this software without specific prior written permission. 26# 27# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38# 39# Authors: Lisa Hsu 40 41from __future__ import print_function 42from __future__ import absolute_import 43 44import m5 45from m5.defines import buildEnv 46from m5.objects import * 47 48from .Benchmarks import * 49from . import CpuConfig 50from . import BPConfig 51from . import HWPConfig 52from . import MemConfig 53from . import PlatformConfig 54 55def _listCpuTypes(option, opt, value, parser): 56 CpuConfig.print_cpu_list() 57 sys.exit(0) 58 59def _listBPTypes(option, opt, value, parser): 60 BPConfig.print_bp_list() 61 sys.exit(0) 62 63def _listHWPTypes(option, opt, value, parser): 64 HWPConfig.print_hwp_list() 65 sys.exit(0) 66 67def _listMemTypes(option, opt, value, parser): 68 MemConfig.print_mem_list() 69 sys.exit(0) 70 71def _listPlatformTypes(option, opt, value, parser): 72 PlatformConfig.print_platform_list() 73 sys.exit(0) 74 75# Add the very basic options that work also in the case of the no ISA 76# being used, and consequently no CPUs, but rather various types of 77# testers and traffic generators. 78def addNoISAOptions(parser): 79 parser.add_option("-n", "--num-cpus", type="int", default=1) 80 parser.add_option("--sys-voltage", action="store", type="string", 81 default='1.0V', 82 help = """Top-level voltage for blocks running at system 83 power supply""") 84 parser.add_option("--sys-clock", action="store", type="string", 85 default='1GHz', 86 help = """Top-level clock for blocks running at system 87 speed""") 88 89 # Memory Options 90 parser.add_option("--list-mem-types", 91 action="callback", callback=_listMemTypes, 92 help="List available memory types") 93 parser.add_option("--mem-type", type="choice", default="DDR3_1600_8x8", 94 choices=MemConfig.mem_names(), 95 help = "type of memory to use") 96 parser.add_option("--mem-channels", type="int", default=1, 97 help = "number of memory channels") 98 parser.add_option("--mem-ranks", type="int", default=None, 99 help = "number of memory ranks per channel") 100 parser.add_option("--mem-size", action="store", type="string", 101 default="512MB", 102 help="Specify the physical memory size (single memory)") 103 104 105 parser.add_option("--memchecker", action="store_true") 106 107 # Cache Options 108 parser.add_option("--external-memory-system", type="string", 109 help="use external ports of this port_type for caches") 110 parser.add_option("--tlm-memory", type="string", 111 help="use external port for SystemC TLM cosimulation") 112 parser.add_option("--caches", action="store_true") 113 parser.add_option("--l2cache", action="store_true") 114 parser.add_option("--num-dirs", type="int", default=1) 115 parser.add_option("--num-l2caches", type="int", default=1) 116 parser.add_option("--num-l3caches", type="int", default=1) 117 parser.add_option("--l1d_size", type="string", default="64kB") 118 parser.add_option("--l1i_size", type="string", default="32kB") 119 parser.add_option("--l2_size", type="string", default="2MB") 120 parser.add_option("--l3_size", type="string", default="16MB") 121 parser.add_option("--l1d_assoc", type="int", default=2) 122 parser.add_option("--l1i_assoc", type="int", default=2) 123 parser.add_option("--l2_assoc", type="int", default=8) 124 parser.add_option("--l3_assoc", type="int", default=16) 125 parser.add_option("--cacheline_size", type="int", default=64) 126 127 # Enable Ruby 128 parser.add_option("--ruby", action="store_true") 129 130 # Run duration options 131 parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick, 132 metavar="TICKS", help="Run to absolute simulated tick " 133 "specified including ticks from a restored checkpoint") 134 parser.add_option("--rel-max-tick", type="int", default=None, 135 metavar="TICKS", help="Simulate for specified number of" 136 " ticks relative to the simulation start tick (e.g. if " 137 "restoring a checkpoint)") 138 parser.add_option("--maxtime", type="float", default=None, 139 help="Run to the specified absolute simulated time in " 140 "seconds") 141 parser.add_option("-P", "--param", action="append", default=[], 142 help="Set a SimObject parameter relative to the root node. " 143 "An extended Python multi range slicing syntax can be used " 144 "for arrays. For example: " 145 "'system.cpu[0,1,3:8:2].max_insts_all_threads = 42' " 146 "sets max_insts_all_threads for cpus 0, 1, 3, 5 and 7 " 147 "Direct parameters of the root object are not accessible, " 148 "only parameters of its children.") 149 150# Add common options that assume a non-NULL ISA. 151def addCommonOptions(parser): 152 # start by adding the base options that do not assume an ISA 153 addNoISAOptions(parser) 154 155 # system options 156 parser.add_option("--list-cpu-types", 157 action="callback", callback=_listCpuTypes, 158 help="List available CPU types") 159 parser.add_option("--cpu-type", type="choice", default="AtomicSimpleCPU", 160 choices=CpuConfig.cpu_names(), 161 help = "type of cpu to run with") 162 parser.add_option("--list-bp-types", 163 action="callback", callback=_listBPTypes, 164 help="List available branch predictor types") 165 parser.add_option("--bp-type", type="choice", default=None, 166 choices=BPConfig.bp_names(), 167 help = """ 168 type of branch predictor to run with 169 (if not set, use the default branch predictor of 170 the selected CPU)""") 171 parser.add_option("--list-hwp-types", 172 action="callback", callback=_listHWPTypes, 173 help="List available hardware prefetcher types") 174 parser.add_option("--l1i-hwp-type", type="choice", default=None, 175 choices=HWPConfig.hwp_names(), 176 help = """ 177 type of hardware prefetcher to use with the L1 178 instruction cache. 179 (if not set, use the default prefetcher of 180 the selected cache)""") 181 parser.add_option("--l1d-hwp-type", type="choice", default=None, 182 choices=HWPConfig.hwp_names(), 183 help = """ 184 type of hardware prefetcher to use with the L1 185 data cache. 186 (if not set, use the default prefetcher of 187 the selected cache)""") 188 parser.add_option("--l2-hwp-type", type="choice", default=None, 189 choices=HWPConfig.hwp_names(), 190 help = """ 191 type of hardware prefetcher to use with the L2 cache. 192 (if not set, use the default prefetcher of 193 the selected cache)""") 194 parser.add_option("--checker", action="store_true"); 195 parser.add_option("--cpu-clock", action="store", type="string", 196 default='2GHz', 197 help="Clock for blocks running at CPU speed") 198 parser.add_option("--smt", action="store_true", default=False, 199 help = """ 200 Only used if multiple programs are specified. If true, 201 then the number of threads per cpu is same as the 202 number of programs.""") 203 parser.add_option("--elastic-trace-en", action="store_true", 204 help="""Enable capture of data dependency and instruction 205 fetch traces using elastic trace probe.""") 206 # Trace file paths input to trace probe in a capture simulation and input 207 # to Trace CPU in a replay simulation 208 parser.add_option("--inst-trace-file", action="store", type="string", 209 help="""Instruction fetch trace file input to 210 Elastic Trace probe in a capture simulation and 211 Trace CPU in a replay simulation""", default="") 212 parser.add_option("--data-trace-file", action="store", type="string", 213 help="""Data dependency trace file input to 214 Elastic Trace probe in a capture simulation and 215 Trace CPU in a replay simulation""", default="") 216 217 parser.add_option("-l", "--lpae", action="store_true") 218 parser.add_option("-V", "--virtualisation", action="store_true") 219 220 # dist-gem5 options 221 parser.add_option("--dist", action="store_true", 222 help="Parallel distributed gem5 simulation.") 223 parser.add_option("--dist-sync-on-pseudo-op", action="store_true", 224 help="Use a pseudo-op to start dist-gem5 synchronization.") 225 parser.add_option("--is-switch", action="store_true", 226 help="Select the network switch simulator process for a"\ 227 "distributed gem5 run") 228 parser.add_option("--dist-rank", default=0, action="store", type="int", 229 help="Rank of this system within the dist gem5 run.") 230 parser.add_option("--dist-size", default=0, action="store", type="int", 231 help="Number of gem5 processes within the dist gem5 run.") 232 parser.add_option("--dist-server-name", 233 default="127.0.0.1", 234 action="store", type="string", 235 help="Name of the message server host\nDEFAULT: localhost") 236 parser.add_option("--dist-server-port", 237 default=2200, 238 action="store", type="int", 239 help="Message server listen port\nDEFAULT: 2200") 240 parser.add_option("--dist-sync-repeat", 241 default="0us", 242 action="store", type="string", 243 help="Repeat interval for synchronisation barriers among dist-gem5 processes\nDEFAULT: --ethernet-linkdelay") 244 parser.add_option("--dist-sync-start", 245 default="5200000000000t", 246 action="store", type="string", 247 help="Time to schedule the first dist synchronisation barrier\nDEFAULT:5200000000000t") 248 parser.add_option("--ethernet-linkspeed", default="10Gbps", 249 action="store", type="string", 250 help="Link speed in bps\nDEFAULT: 10Gbps") 251 parser.add_option("--ethernet-linkdelay", default="10us", 252 action="store", type="string", 253 help="Link delay in seconds\nDEFAULT: 10us") 254 255 # Run duration options 256 parser.add_option("-I", "--maxinsts", action="store", type="int", 257 default=None, help="""Total number of instructions to 258 simulate (default: run forever)""") 259 parser.add_option("--work-item-id", action="store", type="int", 260 help="the specific work id for exit & checkpointing") 261 parser.add_option("--num-work-ids", action="store", type="int", 262 help="Number of distinct work item types") 263 parser.add_option("--work-begin-cpu-id-exit", action="store", type="int", 264 help="exit when work starts on the specified cpu") 265 parser.add_option("--work-end-exit-count", action="store", type="int", 266 help="exit at specified work end count") 267 parser.add_option("--work-begin-exit-count", action="store", type="int", 268 help="exit at specified work begin count") 269 parser.add_option("--init-param", action="store", type="int", default=0, 270 help="""Parameter available in simulation with m5 271 initparam""") 272 parser.add_option("--initialize-only", action="store_true", default=False, 273 help="""Exit after initialization. Do not simulate time. 274 Useful when gem5 is run as a library.""") 275 276 # Simpoint options 277 parser.add_option("--simpoint-profile", action="store_true", 278 help="Enable basic block profiling for SimPoints") 279 parser.add_option("--simpoint-interval", type="int", default=10000000, 280 help="SimPoint interval in num of instructions") 281 parser.add_option("--take-simpoint-checkpoints", action="store", type="string", 282 help="<simpoint file,weight file,interval-length,warmup-length>") 283 parser.add_option("--restore-simpoint-checkpoint", action="store_true", 284 help="restore from a simpoint checkpoint taken with " + 285 "--take-simpoint-checkpoints") 286 287 # Checkpointing options 288 ###Note that performing checkpointing via python script files will override 289 ###checkpoint instructions built into binaries. 290 parser.add_option("--take-checkpoints", action="store", type="string", 291 help="<M,N> take checkpoints at tick M and every N ticks thereafter") 292 parser.add_option("--max-checkpoints", action="store", type="int", 293 help="the maximum number of checkpoints to drop", default=5) 294 parser.add_option("--checkpoint-dir", action="store", type="string", 295 help="Place all checkpoints in this absolute directory") 296 parser.add_option("-r", "--checkpoint-restore", action="store", type="int", 297 help="restore from checkpoint <N>") 298 parser.add_option("--checkpoint-at-end", action="store_true", 299 help="take a checkpoint at end of run") 300 parser.add_option("--work-begin-checkpoint-count", action="store", type="int", 301 help="checkpoint at specified work begin count") 302 parser.add_option("--work-end-checkpoint-count", action="store", type="int", 303 help="checkpoint at specified work end count") 304 parser.add_option("--work-cpus-checkpoint-count", action="store", type="int", 305 help="checkpoint and exit when active cpu count is reached") 306 parser.add_option("--restore-with-cpu", action="store", type="choice", 307 default="AtomicSimpleCPU", choices=CpuConfig.cpu_names(), 308 help = "cpu type for restoring from a checkpoint") 309 310 311 # CPU Switching - default switch model goes from a checkpoint 312 # to a timing simple CPU with caches to warm up, then to detailed CPU for 313 # data measurement 314 parser.add_option("--repeat-switch", action="store", type="int", 315 default=None, 316 help="switch back and forth between CPUs with period <N>") 317 parser.add_option("-s", "--standard-switch", action="store", type="int", 318 default=None, 319 help="switch from timing to Detailed CPU after warmup period of <N>") 320 parser.add_option("-p", "--prog-interval", type="str", 321 help="CPU Progress Interval") 322 323 # Fastforwarding and simpoint related materials 324 parser.add_option("-W", "--warmup-insts", action="store", type="int", 325 default=None, 326 help="Warmup period in total instructions (requires --standard-switch)") 327 parser.add_option("--bench", action="store", type="string", default=None, 328 help="base names for --take-checkpoint and --checkpoint-restore") 329 parser.add_option("-F", "--fast-forward", action="store", type="string", 330 default=None, 331 help="Number of instructions to fast forward before switching") 332 parser.add_option("-S", "--simpoint", action="store_true", default=False, 333 help="""Use workload simpoints as an instruction offset for 334 --checkpoint-restore or --take-checkpoint.""") 335 parser.add_option("--at-instruction", action="store_true", default=False, 336 help="""Treat value of --checkpoint-restore or --take-checkpoint as a 337 number of instructions.""") 338 parser.add_option("--spec-input", default="ref", type="choice", 339 choices=["ref", "test", "train", "smred", "mdred", 340 "lgred"], 341 help="Input set size for SPEC CPU2000 benchmarks.") 342 parser.add_option("--arm-iset", default="arm", type="choice", 343 choices=["arm", "thumb", "aarch64"], 344 help="ARM instruction set.") 345 346 347def addSEOptions(parser): 348 # Benchmark options 349 parser.add_option("-c", "--cmd", default="", 350 help="The binary to run in syscall emulation mode.") 351 parser.add_option("-o", "--options", default="", 352 help="""The options to pass to the binary, use " " 353 around the entire string""") 354 parser.add_option("-e", "--env", default="", 355 help="Initialize workload environment from text file.") 356 parser.add_option("-i", "--input", default="", 357 help="Read stdin from a file.") 358 parser.add_option("--output", default="", 359 help="Redirect stdout to a file.") 360 parser.add_option("--errout", default="", 361 help="Redirect stderr to a file.") 362 363def addFSOptions(parser): 364 from .FSConfig import os_types 365 366 # Simulation options 367 parser.add_option("--timesync", action="store_true", 368 help="Prevent simulated time from getting ahead of real time") 369 370 # System options 371 parser.add_option("--kernel", action="store", type="string") 372 parser.add_option("--os-type", action="store", type="choice", 373 choices=os_types[str(buildEnv['TARGET_ISA'])], 374 default="linux", 375 help="Specifies type of OS to boot") 376 parser.add_option("--script", action="store", type="string") 377 parser.add_option("--frame-capture", action="store_true", 378 help="Stores changed frame buffers from the VNC server to compressed "\ 379 "files in the gem5 output directory") 380 381 if buildEnv['TARGET_ISA'] == "arm": 382 parser.add_option("--bare-metal", action="store_true", 383 help="Provide the raw system without the linux specific bits") 384 parser.add_option("--list-machine-types", 385 action="callback", callback=_listPlatformTypes, 386 help="List available platform types") 387 parser.add_option("--machine-type", action="store", type="choice", 388 choices=PlatformConfig.platform_names(), 389 default="VExpress_EMM") 390 parser.add_option("--dtb-filename", action="store", type="string", 391 help="Specifies device tree blob file to use with device-tree-"\ 392 "enabled kernels") 393 parser.add_option("--enable-security-extensions", action="store_true", 394 help="Turn on the ARM Security Extensions") 395 parser.add_option("--enable-context-switch-stats-dump", \ 396 action="store_true", help="Enable stats dump at context "\ 397 "switches and dump tasks file (required for Streamline)") 398 399 # Benchmark options 400 parser.add_option("--dual", action="store_true", 401 help="Simulate two systems attached with an ethernet link") 402 parser.add_option("-b", "--benchmark", action="store", type="string", 403 dest="benchmark", 404 help="Specify the benchmark to run. Available benchmarks: %s"\ 405 % DefinedBenchmarks) 406 407 # Metafile options 408 parser.add_option("--etherdump", action="store", type="string", dest="etherdump", 409 help="Specify the filename to dump a pcap capture of the" \ 410 "ethernet traffic") 411 412 # Disk Image Options 413 parser.add_option("--disk-image", action="store", type="string", default=None, 414 help="Path to the disk image to use.") 415 parser.add_option("--root-device", action="store", type="string", default=None, 416 help="OS device name for root partition") 417 418 # Command line options 419 parser.add_option("--command-line", action="store", type="string", 420 default=None, 421 help="Template for the kernel command line.") 422 parser.add_option("--command-line-file", action="store", 423 default=None, type="string", 424 help="File with a template for the kernel command line") 425