se.py revision 5457
15369Ssaidi@eecs.umich.edu# Copyright (c) 2006-2008 The Regents of The University of Michigan
23005Sstever@eecs.umich.edu# All rights reserved.
33005Sstever@eecs.umich.edu#
43005Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
53005Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are
63005Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright
73005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
83005Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
93005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
103005Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution;
113005Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its
123005Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from
133005Sstever@eecs.umich.edu# this software without specific prior written permission.
143005Sstever@eecs.umich.edu#
153005Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
163005Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
173005Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
183005Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
193005Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
203005Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
213005Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
223005Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
233005Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
243005Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
253005Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
263005Sstever@eecs.umich.edu#
273005Sstever@eecs.umich.edu# Authors: Steve Reinhardt
283005Sstever@eecs.umich.edu
292710SN/A# Simple test script
302710SN/A#
313005Sstever@eecs.umich.edu# "m5 test.py"
322889SN/A
332667SN/Aimport m5
345457Ssaidi@eecs.umich.edu
355457Ssaidi@eecs.umich.eduif m5.build_env['FULL_SYSTEM']:
365457Ssaidi@eecs.umich.edu    m5.panic("This script requires syscall emulation mode (*_SE).")
375457Ssaidi@eecs.umich.edu
383005Sstever@eecs.umich.edufrom m5.objects import *
392856SN/Aimport os, optparse, sys
402917SN/Am5.AddToPath('../common')
413395Shsul@eecs.umich.eduimport Simulation
423448Shsul@eecs.umich.edufrom Caches import *
435369Ssaidi@eecs.umich.edufrom cpu2000 import *
443394Shsul@eecs.umich.edu
453444Sktlim@umich.edu# Get paths we might need.  It's expected this file is in m5/configs/example.
463444Sktlim@umich.educonfig_path = os.path.dirname(os.path.abspath(__file__))
473444Sktlim@umich.educonfig_root = os.path.dirname(config_path)
483444Sktlim@umich.edum5_root = os.path.dirname(config_root)
492424SN/A
502957SN/Aparser = optparse.OptionParser()
512957SN/A
523323Shsul@eecs.umich.edu# Benchmark options
533005Sstever@eecs.umich.eduparser.add_option("-c", "--cmd",
543444Sktlim@umich.edu                  default=os.path.join(m5_root, "tests/test-progs/hello/bin/alpha/linux/hello"),
552957SN/A                  help="The binary to run in syscall emulation mode.")
562957SN/Aparser.add_option("-o", "--options", default="",
572957SN/A                  help="The options to pass to the binary, use \" \" around the entire\
582957SN/A                        string.")
592957SN/Aparser.add_option("-i", "--input", default="",
602957SN/A                  help="A file of input to give to the binary.")
613323Shsul@eecs.umich.edu
623444Sktlim@umich.eduexecfile(os.path.join(config_root, "common", "Options.py"))
632957SN/A
642957SN/A(options, args) = parser.parse_args()
652957SN/A
662957SN/Aif args:
672957SN/A    print "Error: script doesn't take any positional arguments"
682957SN/A    sys.exit(1)
692957SN/A
705369Ssaidi@eecs.umich.eduif options.bench:
715369Ssaidi@eecs.umich.edu    try:
725369Ssaidi@eecs.umich.edu        if m5.build_env['TARGET_ISA'] != 'alpha':
735369Ssaidi@eecs.umich.edu            print >>sys.stderr, "Simpoints code only works for Alpha ISA at this time"
745369Ssaidi@eecs.umich.edu            sys.exit(1)
755369Ssaidi@eecs.umich.edu        exec("workload = %s('alpha', 'tru64', 'ref')" % options.bench)
765369Ssaidi@eecs.umich.edu        process = workload.makeLiveProcess()
775369Ssaidi@eecs.umich.edu    except:
785369Ssaidi@eecs.umich.edu        print >>sys.stderr, "Unable to find workload for %s" % options.bench
795369Ssaidi@eecs.umich.edu        sys.exit(1)
805369Ssaidi@eecs.umich.eduelse:
815369Ssaidi@eecs.umich.edu    process = LiveProcess()
825369Ssaidi@eecs.umich.edu    process.executable = options.cmd
835369Ssaidi@eecs.umich.edu    process.cmd = [options.cmd] + options.options.split()
845369Ssaidi@eecs.umich.edu
855369Ssaidi@eecs.umich.edu
862801SN/Aif options.input != "":
872801SN/A    process.input = options.input
882418SN/A
892917SN/Aif options.detailed:
902833SN/A    #check for SMT workload
912833SN/A    workloads = options.cmd.split(';')
922833SN/A    if len(workloads) > 1:
932833SN/A        process = []
942833SN/A        smt_idx = 0
952833SN/A        inputs = []
962833SN/A
972833SN/A        if options.input != "":
982833SN/A            inputs = options.input.split(';')
992833SN/A
1002833SN/A        for wrkld in workloads:
1012833SN/A            smt_process = LiveProcess()
1023005Sstever@eecs.umich.edu            smt_process.executable = wrkld
1032833SN/A            smt_process.cmd = wrkld + " " + options.options
1042833SN/A            if inputs and inputs[smt_idx]:
1052833SN/A                smt_process.input = inputs[smt_idx]
1062833SN/A            process += [smt_process, ]
1072833SN/A            smt_idx += 1
1082833SN/A
1093481Shsul@eecs.umich.edu(CPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options)
1102957SN/A
1113395Shsul@eecs.umich.eduCPUClass.clock = '2GHz'
1123005Sstever@eecs.umich.edu
1133395Shsul@eecs.umich.edunp = options.num_cpus
1143395Shsul@eecs.umich.edu
1153395Shsul@eecs.umich.edusystem = System(cpu = [CPUClass(cpu_id=i) for i in xrange(np)],
1163323Shsul@eecs.umich.edu                physmem = PhysicalMemory(range=AddrRange("512MB")),
1173395Shsul@eecs.umich.edu                membus = Bus(), mem_mode = test_mem_mode)
1183395Shsul@eecs.umich.edu
1193005Sstever@eecs.umich.edusystem.physmem.port = system.membus.port
1203395Shsul@eecs.umich.edu
1215056Ssaidi@eecs.umich.eduif options.l2cache:
1225056Ssaidi@eecs.umich.edu    system.l2 = L2Cache(size='2MB')
1235056Ssaidi@eecs.umich.edu    system.tol2bus = Bus()
1245056Ssaidi@eecs.umich.edu    system.l2.cpu_side = system.tol2bus.port
1255056Ssaidi@eecs.umich.edu    system.l2.mem_side = system.membus.port
1265056Ssaidi@eecs.umich.edu
1273395Shsul@eecs.umich.edufor i in xrange(np):
1283514Sktlim@umich.edu    if options.caches:
1293395Shsul@eecs.umich.edu        system.cpu[i].addPrivateSplitL1Caches(L1Cache(size = '32kB'),
1303448Shsul@eecs.umich.edu                                              L1Cache(size = '64kB'))
1314455Ssaidi@eecs.umich.edu    if options.l2cache:
1324455Ssaidi@eecs.umich.edu        system.cpu[i].connectMemPorts(system.tol2bus)
1334455Ssaidi@eecs.umich.edu    else:
1344455Ssaidi@eecs.umich.edu        system.cpu[i].connectMemPorts(system.membus)
1353395Shsul@eecs.umich.edu    system.cpu[i].workload = process
1363005Sstever@eecs.umich.edu
1374968Sacolyte@umich.edu    if options.fastmem:
1384968Sacolyte@umich.edu        system.cpu[0].physmem_port = system.physmem.port
1394968Sacolyte@umich.edu
1403005Sstever@eecs.umich.eduroot = Root(system = system)
1412902SN/A
1423481Shsul@eecs.umich.eduSimulation.run(options, root, system, FutureClass)
143