se.py revision 9006
111308Santhony.gutierrez@amd.com# Copyright (c) 2012 ARM Limited 211308Santhony.gutierrez@amd.com# All rights reserved. 311308Santhony.gutierrez@amd.com# 411308Santhony.gutierrez@amd.com# The license below extends only to copyright in the software and shall 511308Santhony.gutierrez@amd.com# not be construed as granting a license to any other intellectual 611308Santhony.gutierrez@amd.com# property including but not limited to intellectual property relating 711308Santhony.gutierrez@amd.com# to a hardware implementation of the functionality of the software 811308Santhony.gutierrez@amd.com# licensed hereunder. You may use the software subject to the license 911308Santhony.gutierrez@amd.com# terms below provided that you ensure that this notice is replicated 1011308Santhony.gutierrez@amd.com# unmodified and in its entirety in all distributions of the software, 1111308Santhony.gutierrez@amd.com# modified or unmodified, in source code or in binary form. 1211308Santhony.gutierrez@amd.com# 1311308Santhony.gutierrez@amd.com# Copyright (c) 2006-2008 The Regents of The University of Michigan 1411308Santhony.gutierrez@amd.com# All rights reserved. 1511308Santhony.gutierrez@amd.com# 1611308Santhony.gutierrez@amd.com# Redistribution and use in source and binary forms, with or without 1712697Santhony.gutierrez@amd.com# modification, are permitted provided that the following conditions are 1812697Santhony.gutierrez@amd.com# met: redistributions of source code must retain the above copyright 1912697Santhony.gutierrez@amd.com# notice, this list of conditions and the following disclaimer; 2011308Santhony.gutierrez@amd.com# redistributions in binary form must reproduce the above copyright 2111308Santhony.gutierrez@amd.com# notice, this list of conditions and the following disclaimer in the 2211308Santhony.gutierrez@amd.com# documentation and/or other materials provided with the distribution; 2311308Santhony.gutierrez@amd.com# neither the name of the copyright holders nor the names of its 2411308Santhony.gutierrez@amd.com# contributors may be used to endorse or promote products derived from 2511308Santhony.gutierrez@amd.com# this software without specific prior written permission. 2611308Santhony.gutierrez@amd.com# 2711308Santhony.gutierrez@amd.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2811308Santhony.gutierrez@amd.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2911308Santhony.gutierrez@amd.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3011308Santhony.gutierrez@amd.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3111308Santhony.gutierrez@amd.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3211308Santhony.gutierrez@amd.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3312697Santhony.gutierrez@amd.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3412697Santhony.gutierrez@amd.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3511308Santhony.gutierrez@amd.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3611308Santhony.gutierrez@amd.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3711308Santhony.gutierrez@amd.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3811308Santhony.gutierrez@amd.com# 3911308Santhony.gutierrez@amd.com# Authors: Steve Reinhardt 4011308Santhony.gutierrez@amd.com 4111308Santhony.gutierrez@amd.com# Simple test script 4211308Santhony.gutierrez@amd.com# 4311308Santhony.gutierrez@amd.com# "m5 test.py" 4411308Santhony.gutierrez@amd.com 4511308Santhony.gutierrez@amd.comimport optparse 4611308Santhony.gutierrez@amd.comimport sys 4711308Santhony.gutierrez@amd.com 4811308Santhony.gutierrez@amd.comimport m5 4911308Santhony.gutierrez@amd.comfrom m5.defines import buildEnv 5011308Santhony.gutierrez@amd.comfrom m5.objects import * 5111308Santhony.gutierrez@amd.comfrom m5.util import addToPath, fatal 5211308Santhony.gutierrez@amd.com 5311308Santhony.gutierrez@amd.comaddToPath('../common') 5411308Santhony.gutierrez@amd.comaddToPath('../ruby') 5511308Santhony.gutierrez@amd.com 5611308Santhony.gutierrez@amd.comimport Options 5711308Santhony.gutierrez@amd.comimport Ruby 5811308Santhony.gutierrez@amd.comimport Simulation 5911308Santhony.gutierrez@amd.comimport CacheConfig 6011308Santhony.gutierrez@amd.comfrom Caches import * 6111308Santhony.gutierrez@amd.comfrom cpu2000 import * 6211308Santhony.gutierrez@amd.com 6311308Santhony.gutierrez@amd.comparser = optparse.OptionParser() 6411308Santhony.gutierrez@amd.comOptions.addCommonOptions(parser) 6511308Santhony.gutierrez@amd.comOptions.addSEOptions(parser) 6611308Santhony.gutierrez@amd.com 6711308Santhony.gutierrez@amd.comif '--ruby' in sys.argv: 6811308Santhony.gutierrez@amd.com Ruby.define_options(parser) 6911308Santhony.gutierrez@amd.com 7011308Santhony.gutierrez@amd.com(options, args) = parser.parse_args() 7111308Santhony.gutierrez@amd.com 7211308Santhony.gutierrez@amd.comif args: 7311308Santhony.gutierrez@amd.com print "Error: script doesn't take any positional arguments" 7411308Santhony.gutierrez@amd.com sys.exit(1) 7511308Santhony.gutierrez@amd.com 7611308Santhony.gutierrez@amd.commultiprocesses = [] 7711308Santhony.gutierrez@amd.comapps = [] 7811308Santhony.gutierrez@amd.com 7911308Santhony.gutierrez@amd.comif options.bench: 8011308Santhony.gutierrez@amd.com apps = options.bench.split("-") 8111308Santhony.gutierrez@amd.com if len(apps) != options.num_cpus: 8211308Santhony.gutierrez@amd.com print "number of benchmarks not equal to set num_cpus!" 8311308Santhony.gutierrez@amd.com sys.exit(1) 8411308Santhony.gutierrez@amd.com 8511308Santhony.gutierrez@amd.com for app in apps: 8611308Santhony.gutierrez@amd.com try: 8711308Santhony.gutierrez@amd.com if buildEnv['TARGET_ISA'] == 'alpha': 8811308Santhony.gutierrez@amd.com exec("workload = %s('alpha', 'tru64', 'ref')" % app) 8911308Santhony.gutierrez@amd.com else: 9011308Santhony.gutierrez@amd.com exec("workload = %s(buildEnv['TARGET_ISA'], 'linux', 'ref')" % app) 9111308Santhony.gutierrez@amd.com multiprocesses.append(workload.makeLiveProcess()) 9211308Santhony.gutierrez@amd.com except: 9311308Santhony.gutierrez@amd.com print >>sys.stderr, "Unable to find workload for %s: %s" % (buildEnv['TARGET_ISA'], app) 9411308Santhony.gutierrez@amd.com sys.exit(1) 9511308Santhony.gutierrez@amd.comelif options.cmd: 9611308Santhony.gutierrez@amd.com process = LiveProcess() 97 process.executable = options.cmd 98 process.cmd = [options.cmd] + options.options.split() 99 multiprocesses.append(process) 100else: 101 print >> sys.stderr, "No workload specified. Exiting!\n" 102 sys.exit(1) 103 104 105if options.input != "": 106 process.input = options.input 107if options.output != "": 108 process.output = options.output 109if options.errout != "": 110 process.errout = options.errout 111 112 113# By default, set workload to path of user-specified binary 114workloads = options.cmd 115numThreads = 1 116 117if options.cpu_type == "detailed" or options.cpu_type == "inorder": 118 #check for SMT workload 119 workloads = options.cmd.split(';') 120 if len(workloads) > 1: 121 process = [] 122 smt_idx = 0 123 inputs = [] 124 outputs = [] 125 errouts = [] 126 127 if options.input != "": 128 inputs = options.input.split(';') 129 if options.output != "": 130 outputs = options.output.split(';') 131 if options.errout != "": 132 errouts = options.errout.split(';') 133 134 for wrkld in workloads: 135 smt_process = LiveProcess() 136 smt_process.executable = wrkld 137 smt_process.cmd = wrkld + " " + options.options 138 if inputs and inputs[smt_idx]: 139 smt_process.input = inputs[smt_idx] 140 if outputs and outputs[smt_idx]: 141 smt_process.output = outputs[smt_idx] 142 if errouts and errouts[smt_idx]: 143 smt_process.errout = errouts[smt_idx] 144 process += [smt_process, ] 145 smt_idx += 1 146 numThreads = len(workloads) 147 148(CPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options) 149CPUClass.clock = '2GHz' 150CPUClass.numThreads = numThreads; 151 152np = options.num_cpus 153 154system = System(cpu = [CPUClass(cpu_id=i) for i in xrange(np)], 155 physmem = SimpleMemory(range=AddrRange("512MB")), 156 membus = Bus(), mem_mode = test_mem_mode) 157 158# Sanity check 159if options.fastmem and (options.caches or options.l2cache): 160 fatal("You cannot use fastmem in combination with caches!") 161 162for i in xrange(np): 163 if len(multiprocesses) == 1: 164 system.cpu[i].workload = multiprocesses[0] 165 else: 166 system.cpu[i].workload = multiprocesses[i] 167 168 if options.fastmem: 169 system.cpu[i].fastmem = True 170 171 if options.checker: 172 system.cpu[i].addCheckerCpu() 173 174if options.ruby: 175 if not (options.cpu_type == "detailed" or options.cpu_type == "timing"): 176 print >> sys.stderr, "Ruby requires TimingSimpleCPU or O3CPU!!" 177 sys.exit(1) 178 179 options.use_map = True 180 Ruby.create_system(options, system) 181 assert(options.num_cpus == len(system.ruby._cpu_ruby_ports)) 182 183 for i in xrange(np): 184 ruby_port = system.ruby._cpu_ruby_ports[i] 185 186 # Create the interrupt controller and connect its ports to Ruby 187 system.cpu[i].createInterruptController() 188 system.cpu[i].interrupts.pio = ruby_port.master 189 system.cpu[i].interrupts.int_master = ruby_port.slave 190 system.cpu[i].interrupts.int_slave = ruby_port.master 191 192 # Connect the cpu's cache ports to Ruby 193 system.cpu[i].icache_port = ruby_port.slave 194 system.cpu[i].dcache_port = ruby_port.slave 195else: 196 system.system_port = system.membus.slave 197 system.physmem.port = system.membus.master 198 CacheConfig.config_cache(options, system) 199 200root = Root(full_system = False, system = system) 201Simulation.run(options, root, system, FutureClass) 202