se.py revision 8931
18706Sandreas.hansson@arm.com# Copyright (c) 2012 ARM Limited
28706Sandreas.hansson@arm.com# All rights reserved.
38706Sandreas.hansson@arm.com#
48706Sandreas.hansson@arm.com# The license below extends only to copyright in the software and shall
58706Sandreas.hansson@arm.com# not be construed as granting a license to any other intellectual
68706Sandreas.hansson@arm.com# property including but not limited to intellectual property relating
78706Sandreas.hansson@arm.com# to a hardware implementation of the functionality of the software
88706Sandreas.hansson@arm.com# licensed hereunder.  You may use the software subject to the license
98706Sandreas.hansson@arm.com# terms below provided that you ensure that this notice is replicated
108706Sandreas.hansson@arm.com# unmodified and in its entirety in all distributions of the software,
118706Sandreas.hansson@arm.com# modified or unmodified, in source code or in binary form.
128706Sandreas.hansson@arm.com#
135369Ssaidi@eecs.umich.edu# Copyright (c) 2006-2008 The Regents of The University of Michigan
143005Sstever@eecs.umich.edu# All rights reserved.
153005Sstever@eecs.umich.edu#
163005Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
173005Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are
183005Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright
193005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
203005Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
213005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
223005Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution;
233005Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its
243005Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from
253005Sstever@eecs.umich.edu# this software without specific prior written permission.
263005Sstever@eecs.umich.edu#
273005Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
283005Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
293005Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
303005Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
313005Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
323005Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
333005Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
343005Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
353005Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
363005Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
373005Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
383005Sstever@eecs.umich.edu#
393005Sstever@eecs.umich.edu# Authors: Steve Reinhardt
403005Sstever@eecs.umich.edu
412710SN/A# Simple test script
422710SN/A#
433005Sstever@eecs.umich.edu# "m5 test.py"
442889SN/A
456654Snate@binkert.orgimport optparse
466654Snate@binkert.orgimport sys
476654Snate@binkert.org
482667SN/Aimport m5
496654Snate@binkert.orgfrom m5.defines import buildEnv
506654Snate@binkert.orgfrom m5.objects import *
516654Snate@binkert.orgfrom m5.util import addToPath, fatal
525457Ssaidi@eecs.umich.edu
536654Snate@binkert.orgaddToPath('../common')
548169SLisa.Hsu@amd.comaddToPath('../ruby')
558169SLisa.Hsu@amd.com
568920Snilay@cs.wisc.eduimport Options
578169SLisa.Hsu@amd.comimport Ruby
583395Shsul@eecs.umich.eduimport Simulation
596981SLisa.Hsu@amd.comimport CacheConfig
603448Shsul@eecs.umich.edufrom Caches import *
615369Ssaidi@eecs.umich.edufrom cpu2000 import *
623394Shsul@eecs.umich.edu
632957SN/Aparser = optparse.OptionParser()
648920Snilay@cs.wisc.eduOptions.addCommonOptions(parser)
658920Snilay@cs.wisc.eduOptions.addSEOptions(parser)
662957SN/A
678862Snilay@cs.wisc.eduif '--ruby' in sys.argv:
688862Snilay@cs.wisc.edu    Ruby.define_options(parser)
698467Snilay@cs.wisc.edu
702957SN/A(options, args) = parser.parse_args()
712957SN/A
722957SN/Aif args:
732957SN/A    print "Error: script doesn't take any positional arguments"
742957SN/A    sys.exit(1)
752957SN/A
768167SLisa.Hsu@amd.commultiprocesses = []
778167SLisa.Hsu@amd.comapps = []
788167SLisa.Hsu@amd.com
795369Ssaidi@eecs.umich.eduif options.bench:
808167SLisa.Hsu@amd.com    apps = options.bench.split("-")
818167SLisa.Hsu@amd.com    if len(apps) != options.num_cpus:
828167SLisa.Hsu@amd.com        print "number of benchmarks not equal to set num_cpus!"
838167SLisa.Hsu@amd.com        sys.exit(1)
848167SLisa.Hsu@amd.com
858167SLisa.Hsu@amd.com    for app in apps:
868167SLisa.Hsu@amd.com        try:
878168SLisa.Hsu@amd.com            if buildEnv['TARGET_ISA'] == 'alpha':
888168SLisa.Hsu@amd.com                exec("workload = %s('alpha', 'tru64', 'ref')" % app)
898168SLisa.Hsu@amd.com            else:
908168SLisa.Hsu@amd.com                exec("workload = %s(buildEnv['TARGET_ISA'], 'linux', 'ref')" % app)
918167SLisa.Hsu@amd.com            multiprocesses.append(workload.makeLiveProcess())
928167SLisa.Hsu@amd.com        except:
938168SLisa.Hsu@amd.com            print >>sys.stderr, "Unable to find workload for %s: %s" % (buildEnv['TARGET_ISA'], app)
945369Ssaidi@eecs.umich.edu            sys.exit(1)
958920Snilay@cs.wisc.eduelif options.cmd:
965369Ssaidi@eecs.umich.edu    process = LiveProcess()
975369Ssaidi@eecs.umich.edu    process.executable = options.cmd
985369Ssaidi@eecs.umich.edu    process.cmd = [options.cmd] + options.options.split()
998167SLisa.Hsu@amd.com    multiprocesses.append(process)
1008920Snilay@cs.wisc.eduelse:
1018920Snilay@cs.wisc.edu    print >> sys.stderr, "No workload specified. Exiting!\n"
1028920Snilay@cs.wisc.edu    sys.exit(1)
1035369Ssaidi@eecs.umich.edu
1045369Ssaidi@eecs.umich.edu
1052801SN/Aif options.input != "":
1062801SN/A    process.input = options.input
1075514SMichael.Adler@intel.comif options.output != "":
1085514SMichael.Adler@intel.com    process.output = options.output
1095514SMichael.Adler@intel.comif options.errout != "":
1105514SMichael.Adler@intel.com    process.errout = options.errout
1112418SN/A
1126391Sksewell@umich.edu
1136391Sksewell@umich.edu# By default, set workload to path of user-specified binary
1146391Sksewell@umich.eduworkloads = options.cmd
1156642Sksewell@umich.edunumThreads = 1
1166391Sksewell@umich.edu
1178649Snilay@cs.wisc.eduif options.cpu_type == "detailed" or options.cpu_type == "inorder":
1182833SN/A    #check for SMT workload
1192833SN/A    workloads = options.cmd.split(';')
1202833SN/A    if len(workloads) > 1:
1212833SN/A        process = []
1222833SN/A        smt_idx = 0
1232833SN/A        inputs = []
1245514SMichael.Adler@intel.com        outputs = []
1255514SMichael.Adler@intel.com        errouts = []
1262833SN/A
1272833SN/A        if options.input != "":
1282833SN/A            inputs = options.input.split(';')
1295514SMichael.Adler@intel.com        if options.output != "":
1305514SMichael.Adler@intel.com            outputs = options.output.split(';')
1315514SMichael.Adler@intel.com        if options.errout != "":
1325514SMichael.Adler@intel.com            errouts = options.errout.split(';')
1332833SN/A
1342833SN/A        for wrkld in workloads:
1352833SN/A            smt_process = LiveProcess()
1363005Sstever@eecs.umich.edu            smt_process.executable = wrkld
1372833SN/A            smt_process.cmd = wrkld + " " + options.options
1382833SN/A            if inputs and inputs[smt_idx]:
1392833SN/A                smt_process.input = inputs[smt_idx]
1405514SMichael.Adler@intel.com            if outputs and outputs[smt_idx]:
1415514SMichael.Adler@intel.com                smt_process.output = outputs[smt_idx]
1425514SMichael.Adler@intel.com            if errouts and errouts[smt_idx]:
1435514SMichael.Adler@intel.com                smt_process.errout = errouts[smt_idx]
1442833SN/A            process += [smt_process, ]
1452833SN/A            smt_idx += 1
1466642Sksewell@umich.edu    numThreads = len(workloads)
1478718Snilay@cs.wisc.edu
1488718Snilay@cs.wisc.edu(CPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options)
1493395Shsul@eecs.umich.eduCPUClass.clock = '2GHz'
1506642Sksewell@umich.eduCPUClass.numThreads = numThreads;
1513005Sstever@eecs.umich.edu
1523395Shsul@eecs.umich.edunp = options.num_cpus
1533395Shsul@eecs.umich.edu
1543395Shsul@eecs.umich.edusystem = System(cpu = [CPUClass(cpu_id=i) for i in xrange(np)],
1558931Sandreas.hansson@arm.com                physmem = SimpleMemory(range=AddrRange("512MB")),
1563395Shsul@eecs.umich.edu                membus = Bus(), mem_mode = test_mem_mode)
1573395Shsul@eecs.umich.edu
1588926Sandreas.hansson@arm.com# Sanity check
1598926Sandreas.hansson@arm.comif options.fastmem and (options.caches or options.l2cache):
1608926Sandreas.hansson@arm.com    fatal("You cannot use fastmem in combination with caches!")
1618926Sandreas.hansson@arm.com
1623395Shsul@eecs.umich.edufor i in xrange(np):
1638167SLisa.Hsu@amd.com    system.cpu[i].workload = multiprocesses[i]
1643005Sstever@eecs.umich.edu
1654968Sacolyte@umich.edu    if options.fastmem:
1668926Sandreas.hansson@arm.com        system.cpu[0].fastmem = True
1674968Sacolyte@umich.edu
1688887Sgeoffrey.blake@arm.com    if options.checker:
1698887Sgeoffrey.blake@arm.com        system.cpu[i].addCheckerCpu()
1708887Sgeoffrey.blake@arm.com
1718887Sgeoffrey.blake@arm.comif options.ruby:
1728896Snilay@cs.wisc.edu    if not (options.cpu_type == "detailed" or options.cpu_type == "timing"):
1738896Snilay@cs.wisc.edu        print >> sys.stderr, "Ruby requires TimingSimpleCPU or O3CPU!!"
1748896Snilay@cs.wisc.edu        sys.exit(1)
1758896Snilay@cs.wisc.edu
1768887Sgeoffrey.blake@arm.com    options.use_map = True
1778887Sgeoffrey.blake@arm.com    Ruby.create_system(options, system)
1788887Sgeoffrey.blake@arm.com    assert(options.num_cpus == len(system.ruby._cpu_ruby_ports))
1798896Snilay@cs.wisc.edu
1808896Snilay@cs.wisc.edu    for i in xrange(np):
1818896Snilay@cs.wisc.edu        ruby_port = system.ruby._cpu_ruby_ports[i]
1828896Snilay@cs.wisc.edu
1838896Snilay@cs.wisc.edu        # Create the interrupt controller and connect its ports to Ruby
1848896Snilay@cs.wisc.edu        system.cpu[i].createInterruptController()
1858896Snilay@cs.wisc.edu        system.cpu[i].interrupts.pio = ruby_port.master
1868896Snilay@cs.wisc.edu        system.cpu[i].interrupts.int_master = ruby_port.slave
1878896Snilay@cs.wisc.edu        system.cpu[i].interrupts.int_slave = ruby_port.master
1888896Snilay@cs.wisc.edu
1898896Snilay@cs.wisc.edu        # Connect the cpu's cache ports to Ruby
1908896Snilay@cs.wisc.edu        system.cpu[i].icache_port = ruby_port.slave
1918896Snilay@cs.wisc.edu        system.cpu[i].dcache_port = ruby_port.slave
1928887Sgeoffrey.blake@arm.comelse:
1938887Sgeoffrey.blake@arm.com    system.system_port = system.membus.slave
1948887Sgeoffrey.blake@arm.com    system.physmem.port = system.membus.master
1958887Sgeoffrey.blake@arm.com    CacheConfig.config_cache(options, system)
1968887Sgeoffrey.blake@arm.com
1978801Sgblack@eecs.umich.eduroot = Root(full_system = False, system = system)
1983481Shsul@eecs.umich.eduSimulation.run(options, root, system, FutureClass)
199