se.py revision 3444
13005Sstever@eecs.umich.edu# Copyright (c) 2006 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
343005Sstever@eecs.umich.edufrom m5.objects import *
352856SN/Aimport os, optparse, sys
362917SN/Am5.AddToPath('../common')
373395Shsul@eecs.umich.eduimport Simulation
382424SN/A
393444Sktlim@umich.edu# Get paths we might need.  It's expected this file is in m5/configs/example.
403444Sktlim@umich.educonfig_path = os.path.dirname(os.path.abspath(__file__))
413444Sktlim@umich.educonfig_root = os.path.dirname(config_path)
423444Sktlim@umich.edum5_root = os.path.dirname(config_root)
433444Sktlim@umich.edu
442957SN/Aparser = optparse.OptionParser()
452957SN/A
463323Shsul@eecs.umich.edu# Benchmark options
473005Sstever@eecs.umich.eduparser.add_option("-c", "--cmd",
483444Sktlim@umich.edu                  default=os.path.join(m5_root, "tests/test-progs/hello/bin/alpha/linux/hello"),
492957SN/A                  help="The binary to run in syscall emulation mode.")
502957SN/Aparser.add_option("-o", "--options", default="",
512957SN/A                  help="The options to pass to the binary, use \" \" around the entire\
522957SN/A                        string.")
532957SN/Aparser.add_option("-i", "--input", default="",
542957SN/A                  help="A file of input to give to the binary.")
553323Shsul@eecs.umich.edu
563444Sktlim@umich.eduexecfile(os.path.join(config_root, "common", "Options.py"))
572957SN/A
582957SN/A(options, args) = parser.parse_args()
592957SN/A
602957SN/Aif args:
612957SN/A    print "Error: script doesn't take any positional arguments"
622957SN/A    sys.exit(1)
632957SN/A
642715SN/Aprocess = LiveProcess()
653005Sstever@eecs.umich.eduprocess.executable = options.cmd
662801SN/Aprocess.cmd = options.cmd + " " + options.options
672801SN/Aif options.input != "":
682801SN/A    process.input = options.input
692418SN/A
702917SN/Aif options.detailed:
712833SN/A    #check for SMT workload
722833SN/A    workloads = options.cmd.split(';')
732833SN/A    if len(workloads) > 1:
742833SN/A        process = []
752833SN/A        smt_idx = 0
762833SN/A        inputs = []
772833SN/A
782833SN/A        if options.input != "":
792833SN/A            inputs = options.input.split(';')
802833SN/A
812833SN/A        for wrkld in workloads:
822833SN/A            smt_process = LiveProcess()
833005Sstever@eecs.umich.edu            smt_process.executable = wrkld
842833SN/A            smt_process.cmd = wrkld + " " + options.options
852833SN/A            if inputs and inputs[smt_idx]:
862833SN/A                smt_process.input = inputs[smt_idx]
872833SN/A            process += [smt_process, ]
882833SN/A            smt_idx += 1
892833SN/A
902957SN/A
912957SN/Aif options.timing:
923395Shsul@eecs.umich.edu    CPUClass = TimingSimpleCPU
933395Shsul@eecs.umich.edu    test_mem_mode = 'timing'
942957SN/Aelif options.detailed:
953395Shsul@eecs.umich.edu    CPUClass = DerivO3CPU
963395Shsul@eecs.umich.edu    test_mem_mode = 'timing'
972957SN/Aelse:
983395Shsul@eecs.umich.edu    CPUClass = AtomicSimpleCPU
993395Shsul@eecs.umich.edu    test_mem_mode = 'atomic'
1002957SN/A
1013395Shsul@eecs.umich.eduCPUClass.clock = '2GHz'
1023005Sstever@eecs.umich.edu
1033395Shsul@eecs.umich.edunp = options.num_cpus
1043395Shsul@eecs.umich.edu
1053395Shsul@eecs.umich.edusystem = System(cpu = [CPUClass(cpu_id=i) for i in xrange(np)],
1063323Shsul@eecs.umich.edu                physmem = PhysicalMemory(range=AddrRange("512MB")),
1073395Shsul@eecs.umich.edu                membus = Bus(), mem_mode = test_mem_mode)
1083395Shsul@eecs.umich.edu
1093005Sstever@eecs.umich.edusystem.physmem.port = system.membus.port
1103395Shsul@eecs.umich.edu
1113395Shsul@eecs.umich.edufor i in xrange(np):
1123395Shsul@eecs.umich.edu    if options.caches and not options.standard_switch:
1133395Shsul@eecs.umich.edu        system.cpu[i].addPrivateSplitL1Caches(L1Cache(size = '32kB'),
1143395Shsul@eecs.umich.edu                                              L2Cache(size = '64kB'))
1153395Shsul@eecs.umich.edu    system.cpu[i].connectMemPorts(system.membus)
1163395Shsul@eecs.umich.edu    system.cpu[i].mem = system.physmem
1173395Shsul@eecs.umich.edu    system.cpu[i].workload = process
1183005Sstever@eecs.umich.edu
1193005Sstever@eecs.umich.eduroot = Root(system = system)
1202902SN/A
1213395Shsul@eecs.umich.eduSimulation.run(options, root, system)
122