se.py revision 3395
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 392957SN/Aparser = optparse.OptionParser() 402957SN/A 413323Shsul@eecs.umich.edu# Benchmark options 423005Sstever@eecs.umich.eduparser.add_option("-c", "--cmd", 433005Sstever@eecs.umich.edu default="../../tests/test-progs/hello/bin/alpha/linux/hello", 442957SN/A help="The binary to run in syscall emulation mode.") 452957SN/Aparser.add_option("-o", "--options", default="", 462957SN/A help="The options to pass to the binary, use \" \" around the entire\ 472957SN/A string.") 482957SN/Aparser.add_option("-i", "--input", default="", 492957SN/A help="A file of input to give to the binary.") 503323Shsul@eecs.umich.edu 513395Shsul@eecs.umich.eduexecfile("Options.py") 522957SN/A 532957SN/A(options, args) = parser.parse_args() 542957SN/A 552957SN/Aif args: 562957SN/A print "Error: script doesn't take any positional arguments" 572957SN/A sys.exit(1) 582957SN/A 592715SN/Aprocess = LiveProcess() 603005Sstever@eecs.umich.eduprocess.executable = options.cmd 612801SN/Aprocess.cmd = options.cmd + " " + options.options 622801SN/Aif options.input != "": 632801SN/A process.input = options.input 642418SN/A 652917SN/Aif options.detailed: 662833SN/A #check for SMT workload 672833SN/A workloads = options.cmd.split(';') 682833SN/A if len(workloads) > 1: 692833SN/A process = [] 702833SN/A smt_idx = 0 712833SN/A inputs = [] 722833SN/A 732833SN/A if options.input != "": 742833SN/A inputs = options.input.split(';') 752833SN/A 762833SN/A for wrkld in workloads: 772833SN/A smt_process = LiveProcess() 783005Sstever@eecs.umich.edu smt_process.executable = wrkld 792833SN/A smt_process.cmd = wrkld + " " + options.options 802833SN/A if inputs and inputs[smt_idx]: 812833SN/A smt_process.input = inputs[smt_idx] 822833SN/A process += [smt_process, ] 832833SN/A smt_idx += 1 842833SN/A 852957SN/A 862957SN/Aif options.timing: 873395Shsul@eecs.umich.edu CPUClass = TimingSimpleCPU 883395Shsul@eecs.umich.edu test_mem_mode = 'timing' 892957SN/Aelif options.detailed: 903395Shsul@eecs.umich.edu CPUClass = DerivO3CPU 913395Shsul@eecs.umich.edu test_mem_mode = 'timing' 922957SN/Aelse: 933395Shsul@eecs.umich.edu CPUClass = AtomicSimpleCPU 943395Shsul@eecs.umich.edu test_mem_mode = 'atomic' 952957SN/A 963395Shsul@eecs.umich.eduCPUClass.clock = '2GHz' 973005Sstever@eecs.umich.edu 983395Shsul@eecs.umich.edunp = options.num_cpus 993395Shsul@eecs.umich.edu 1003395Shsul@eecs.umich.edusystem = System(cpu = [CPUClass(cpu_id=i) for i in xrange(np)], 1013323Shsul@eecs.umich.edu physmem = PhysicalMemory(range=AddrRange("512MB")), 1023395Shsul@eecs.umich.edu membus = Bus(), mem_mode = test_mem_mode) 1033395Shsul@eecs.umich.edu 1043005Sstever@eecs.umich.edusystem.physmem.port = system.membus.port 1053395Shsul@eecs.umich.edu 1063395Shsul@eecs.umich.edufor i in xrange(np): 1073395Shsul@eecs.umich.edu if options.caches and not options.standard_switch: 1083395Shsul@eecs.umich.edu system.cpu[i].addPrivateSplitL1Caches(L1Cache(size = '32kB'), 1093395Shsul@eecs.umich.edu L2Cache(size = '64kB')) 1103395Shsul@eecs.umich.edu system.cpu[i].connectMemPorts(system.membus) 1113395Shsul@eecs.umich.edu system.cpu[i].mem = system.physmem 1123395Shsul@eecs.umich.edu system.cpu[i].workload = process 1133005Sstever@eecs.umich.edu 1143005Sstever@eecs.umich.eduroot = Root(system = system) 1152902SN/A 1163395Shsul@eecs.umich.eduSimulation.run(options, root, system) 117