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 41import m5 42from m5.defines import buildEnv 43from m5.objects import * 44from common.Benchmarks import * 45 46from common import CpuConfig 47from common import BPConfig 48from common import MemConfig 49from common import PlatformConfig 50 51def _listCpuTypes(option, opt, value, parser): 52 CpuConfig.print_cpu_list() 53 sys.exit(0) 54 55def _listBPTypes(option, opt, value, parser): 56 BPConfig.print_bp_list() 57 sys.exit(0) 58 59def _listMemTypes(option, opt, value, parser): 60 MemConfig.print_mem_list() 61 sys.exit(0) 62 63def _listPlatformTypes(option, opt, value, parser): 64 PlatformConfig.print_platform_list() 65 sys.exit(0) 66 67# Add the very basic options that work also in the case of the no ISA 68# being used, and consequently no CPUs, but rather various types of 69# testers and traffic generators. 70def addNoISAOptions(parser): 71 parser.add_option("-n", "--num-cpus", type="int", default=1) 72 parser.add_option("--sys-voltage", action="store", type="string", 73 default='1.0V', 74 help = """Top-level voltage for blocks running at system 75 power supply""") 76 parser.add_option("--sys-clock", action="store", type="string", 77 default='1GHz', 78 help = """Top-level clock for blocks running at system 79 speed""") 80 81 # Memory Options 82 parser.add_option("--list-mem-types", 83 action="callback", callback=_listMemTypes, 84 help="List available memory types") 85 parser.add_option("--mem-type", type="choice", default="DDR3_1600_8x8", 86 choices=MemConfig.mem_names(), 87 help = "type of memory to use") 88 parser.add_option("--mem-channels", type="int", default=1, 89 help = "number of memory channels") 90 parser.add_option("--mem-ranks", type="int", default=None, 91 help = "number of memory ranks per channel") 92 parser.add_option("--mem-size", action="store", type="string", 93 default="512MB", 94 help="Specify the physical memory size (single memory)") 95 96 97 parser.add_option("--memchecker", action="store_true") 98 99 # Cache Options 100 parser.add_option("--external-memory-system", type="string", 101 help="use external ports of this port_type for caches") 102 parser.add_option("--tlm-memory", type="string", 103 help="use external port for SystemC TLM cosimulation") 104 parser.add_option("--caches", action="store_true") 105 parser.add_option("--l2cache", action="store_true") 106 parser.add_option("--num-dirs", type="int", default=1) 107 parser.add_option("--num-l2caches", type="int", default=1) 108 parser.add_option("--num-l3caches", type="int", default=1) 109 parser.add_option("--l1d_size", type="string", default="64kB") 110 parser.add_option("--l1i_size", type="string", default="32kB") 111 parser.add_option("--l2_size", type="string", default="2MB") 112 parser.add_option("--l3_size", type="string", default="16MB") 113 parser.add_option("--l1d_assoc", type="int", default=2) 114 parser.add_option("--l1i_assoc", type="int", default=2) 115 parser.add_option("--l2_assoc", type="int", default=8) 116 parser.add_option("--l3_assoc", type="int", default=16) 117 parser.add_option("--cacheline_size", type="int", default=64) 118 119 # Enable Ruby 120 parser.add_option("--ruby", action="store_true") 121 122 # Run duration options 123 parser.add_option("-m", "--abs-max-tick", type="int", default=m5.MaxTick, 124 metavar="TICKS", help="Run to absolute simulated tick " 125 "specified including ticks from a restored checkpoint") 126 parser.add_option("--rel-max-tick", type="int", default=None, 127 metavar="TICKS", help="Simulate for specified number of" 128 " ticks relative to the simulation start tick (e.g. if " 129 "restoring a checkpoint)") 130 parser.add_option("--maxtime", type="float", default=None, 131 help="Run to the specified absolute simulated time in " 132 "seconds") 133 parser.add_option("-P", "--param", action="append", default=[], 134 help="Set a SimObject parameter relative to the root node. " 135 "An extended Python multi range slicing syntax can be used " 136 "for arrays. For example: " 137 "'system.cpu[0,1,3:8:2].max_insts_all_threads = 42' " 138 "sets max_insts_all_threads for cpus 0, 1, 3, 5 and 7 " 139 "Direct parameters of the root object are not accessible, " 140 "only parameters of its children.") 141 142# Add common options that assume a non-NULL ISA. 143def addCommonOptions(parser): 144 # start by adding the base options that do not assume an ISA 145 addNoISAOptions(parser) 146 147 # system options 148 parser.add_option("--list-cpu-types", 149 action="callback", callback=_listCpuTypes, 150 help="List available CPU types") 151 parser.add_option("--cpu-type", type="choice", default="AtomicSimpleCPU", 152 choices=CpuConfig.cpu_names(), 153 help = "type of cpu to run with") 154 parser.add_option("--list-bp-types", 155 action="callback", callback=_listBPTypes, 156 help="List available branch predictor types") 157 parser.add_option("--bp-type", type="choice", default=None, 158 choices=BPConfig.bp_names(), 159 help = """ 160 type of branch predictor to run with 161 (if not set, use the default branch predictor of 162 the selected CPU)""") 163 parser.add_option("--checker", action="store_true"); 164 parser.add_option("--cpu-clock", action="store", type="string", 165 default='2GHz', 166 help="Clock for blocks running at CPU speed") 167 parser.add_option("--smt", action="store_true", default=False, 168 help = """ 169 Only used if multiple programs are specified. If true, 170 then the number of threads per cpu is same as the 171 number of programs.""") 172 parser.add_option("--elastic-trace-en", action="store_true", 173 help="""Enable capture of data dependency and instruction 174 fetch traces using elastic trace probe.""") 175 # Trace file paths input to trace probe in a capture simulation and input 176 # to Trace CPU in a replay simulation 177 parser.add_option("--inst-trace-file", action="store", type="string", 178 help="""Instruction fetch trace file input to 179 Elastic Trace probe in a capture simulation and 180 Trace CPU in a replay simulation""", default="") 181 parser.add_option("--data-trace-file", action="store", type="string", 182 help="""Data dependency trace file input to 183 Elastic Trace probe in a capture simulation and 184 Trace CPU in a replay simulation""", default="") 185 186 parser.add_option("-l", "--lpae", action="store_true") 187 parser.add_option("-V", "--virtualisation", action="store_true") 188 189 # dist-gem5 options 190 parser.add_option("--dist", action="store_true", 191 help="Parallel distributed gem5 simulation.") 192 parser.add_option("--dist-sync-on-pseudo-op", action="store_true", 193 help="Use a pseudo-op to start dist-gem5 synchronization.") 194 parser.add_option("--is-switch", action="store_true", 195 help="Select the network switch simulator process for a"\ 196 "distributed gem5 run") 197 parser.add_option("--dist-rank", default=0, action="store", type="int", 198 help="Rank of this system within the dist gem5 run.") 199 parser.add_option("--dist-size", default=0, action="store", type="int", 200 help="Number of gem5 processes within the dist gem5 run.") 201 parser.add_option("--dist-server-name", 202 default="127.0.0.1", 203 action="store", type="string", 204 help="Name of the message server host\nDEFAULT: localhost") 205 parser.add_option("--dist-server-port", 206 default=2200, 207 action="store", type="int", 208 help="Message server listen port\nDEFAULT: 2200") 209 parser.add_option("--dist-sync-repeat", 210 default="0us", 211 action="store", type="string", 212 help="Repeat interval for synchronisation barriers among dist-gem5 processes\nDEFAULT: --ethernet-linkdelay") 213 parser.add_option("--dist-sync-start", 214 default="5200000000000t", 215 action="store", type="string", 216 help="Time to schedule the first dist synchronisation barrier\nDEFAULT:5200000000000t") 217 parser.add_option("--ethernet-linkspeed", default="10Gbps", 218 action="store", type="string", 219 help="Link speed in bps\nDEFAULT: 10Gbps") 220 parser.add_option("--ethernet-linkdelay", default="10us", 221 action="store", type="string", 222 help="Link delay in seconds\nDEFAULT: 10us") 223 224 # Run duration options 225 parser.add_option("-I", "--maxinsts", action="store", type="int", 226 default=None, help="""Total number of instructions to 227 simulate (default: run forever)""") 228 parser.add_option("--work-item-id", action="store", type="int", 229 help="the specific work id for exit & checkpointing") 230 parser.add_option("--num-work-ids", action="store", type="int", 231 help="Number of distinct work item types") 232 parser.add_option("--work-begin-cpu-id-exit", action="store", type="int", 233 help="exit when work starts on the specified cpu") 234 parser.add_option("--work-end-exit-count", action="store", type="int", 235 help="exit at specified work end count") 236 parser.add_option("--work-begin-exit-count", action="store", type="int", 237 help="exit at specified work begin count") 238 parser.add_option("--init-param", action="store", type="int", default=0, 239 help="""Parameter available in simulation with m5 240 initparam""") 241 parser.add_option("--initialize-only", action="store_true", default=False, 242 help="""Exit after initialization. Do not simulate time. 243 Useful when gem5 is run as a library.""") 244 245 # Simpoint options 246 parser.add_option("--simpoint-profile", action="store_true", 247 help="Enable basic block profiling for SimPoints") 248 parser.add_option("--simpoint-interval", type="int", default=10000000, 249 help="SimPoint interval in num of instructions") 250 parser.add_option("--take-simpoint-checkpoints", action="store", type="string", 251 help="<simpoint file,weight file,interval-length,warmup-length>") 252 parser.add_option("--restore-simpoint-checkpoint", action="store_true", 253 help="restore from a simpoint checkpoint taken with " + 254 "--take-simpoint-checkpoints") 255 256 # Checkpointing options 257 ###Note that performing checkpointing via python script files will override 258 ###checkpoint instructions built into binaries. 259 parser.add_option("--take-checkpoints", action="store", type="string", 260 help="<M,N> take checkpoints at tick M and every N ticks thereafter") 261 parser.add_option("--max-checkpoints", action="store", type="int", 262 help="the maximum number of checkpoints to drop", default=5) 263 parser.add_option("--checkpoint-dir", action="store", type="string", 264 help="Place all checkpoints in this absolute directory") 265 parser.add_option("-r", "--checkpoint-restore", action="store", type="int", 266 help="restore from checkpoint <N>") 267 parser.add_option("--checkpoint-at-end", action="store_true", 268 help="take a checkpoint at end of run") 269 parser.add_option("--work-begin-checkpoint-count", action="store", type="int", 270 help="checkpoint at specified work begin count") 271 parser.add_option("--work-end-checkpoint-count", action="store", type="int", 272 help="checkpoint at specified work end count") 273 parser.add_option("--work-cpus-checkpoint-count", action="store", type="int", 274 help="checkpoint and exit when active cpu count is reached") 275 parser.add_option("--restore-with-cpu", action="store", type="choice", 276 default="AtomicSimpleCPU", choices=CpuConfig.cpu_names(), 277 help = "cpu type for restoring from a checkpoint") 278 279 280 # CPU Switching - default switch model goes from a checkpoint 281 # to a timing simple CPU with caches to warm up, then to detailed CPU for 282 # data measurement 283 parser.add_option("--repeat-switch", action="store", type="int", 284 default=None, 285 help="switch back and forth between CPUs with period <N>") 286 parser.add_option("-s", "--standard-switch", action="store", type="int", 287 default=None, 288 help="switch from timing to Detailed CPU after warmup period of <N>") 289 parser.add_option("-p", "--prog-interval", type="str", 290 help="CPU Progress Interval") 291 292 # Fastforwarding and simpoint related materials 293 parser.add_option("-W", "--warmup-insts", action="store", type="int", 294 default=None, 295 help="Warmup period in total instructions (requires --standard-switch)") 296 parser.add_option("--bench", action="store", type="string", default=None, 297 help="base names for --take-checkpoint and --checkpoint-restore") 298 parser.add_option("-F", "--fast-forward", action="store", type="string", 299 default=None, 300 help="Number of instructions to fast forward before switching") 301 parser.add_option("-S", "--simpoint", action="store_true", default=False, 302 help="""Use workload simpoints as an instruction offset for 303 --checkpoint-restore or --take-checkpoint.""") 304 parser.add_option("--at-instruction", action="store_true", default=False, 305 help="""Treat value of --checkpoint-restore or --take-checkpoint as a 306 number of instructions.""") 307 parser.add_option("--spec-input", default="ref", type="choice", 308 choices=["ref", "test", "train", "smred", "mdred", 309 "lgred"], 310 help="Input set size for SPEC CPU2000 benchmarks.") 311 parser.add_option("--arm-iset", default="arm", type="choice", 312 choices=["arm", "thumb", "aarch64"], 313 help="ARM instruction set.") 314 315 316def addSEOptions(parser): 317 # Benchmark options 318 parser.add_option("-c", "--cmd", default="", 319 help="The binary to run in syscall emulation mode.") 320 parser.add_option("-o", "--options", default="", 321 help="""The options to pass to the binary, use " " 322 around the entire string""") 323 parser.add_option("-e", "--env", default="", 324 help="Initialize workload environment from text file.") 325 parser.add_option("-i", "--input", default="", 326 help="Read stdin from a file.") 327 parser.add_option("--output", default="", 328 help="Redirect stdout to a file.") 329 parser.add_option("--errout", default="", 330 help="Redirect stderr to a file.") 331 332def addFSOptions(parser): 333 from FSConfig import os_types 334 335 # Simulation options 336 parser.add_option("--timesync", action="store_true", 337 help="Prevent simulated time from getting ahead of real time") 338 339 # System options 340 parser.add_option("--kernel", action="store", type="string") 341 parser.add_option("--os-type", action="store", type="choice", 342 choices=os_types[buildEnv['TARGET_ISA']], default="linux", 343 help="Specifies type of OS to boot") 344 parser.add_option("--script", action="store", type="string") 345 parser.add_option("--frame-capture", action="store_true", 346 help="Stores changed frame buffers from the VNC server to compressed "\ 347 "files in the gem5 output directory") 348 349 if buildEnv['TARGET_ISA'] == "arm": 350 parser.add_option("--bare-metal", action="store_true", 351 help="Provide the raw system without the linux specific bits") 352 parser.add_option("--list-machine-types", 353 action="callback", callback=_listPlatformTypes, 354 help="List available platform types") 355 parser.add_option("--machine-type", action="store", type="choice", 356 choices=PlatformConfig.platform_names(), 357 default="VExpress_EMM") 358 parser.add_option("--dtb-filename", action="store", type="string", 359 help="Specifies device tree blob file to use with device-tree-"\ 360 "enabled kernels") 361 parser.add_option("--enable-security-extensions", action="store_true", 362 help="Turn on the ARM Security Extensions") 363 parser.add_option("--enable-context-switch-stats-dump", \ 364 action="store_true", help="Enable stats dump at context "\ 365 "switches and dump tasks file (required for Streamline)") |
366 367 # Benchmark options 368 parser.add_option("--dual", action="store_true", 369 help="Simulate two systems attached with an ethernet link") 370 parser.add_option("-b", "--benchmark", action="store", type="string", 371 dest="benchmark", 372 help="Specify the benchmark to run. Available benchmarks: %s"\ 373 % DefinedBenchmarks) 374 375 # Metafile options 376 parser.add_option("--etherdump", action="store", type="string", dest="etherdump", 377 help="Specify the filename to dump a pcap capture of the" \ 378 "ethernet traffic") 379 380 # Disk Image Options 381 parser.add_option("--disk-image", action="store", type="string", default=None, 382 help="Path to the disk image to use.") 383 parser.add_option("--root-device", action="store", type="string", default=None, 384 help="OS device name for root partition") 385 386 # Command line options 387 parser.add_option("--command-line", action="store", type="string", 388 default=None, 389 help="Template for the kernel command line.") 390 parser.add_option("--command-line-file", action="store", 391 default=None, type="string", 392 help="File with a template for the kernel command line") |