fs.py revision 3005
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: Ali Saidi 283005Sstever@eecs.umich.edu 292889SN/Aimport optparse, os, sys 302889SN/A 312710SN/Aimport m5 322710SN/Afrom m5.objects import * 332934SN/Am5.AddToPath('../common') 342934SN/Afrom FSConfig import * 352549SN/Afrom SysPaths import * 362995SN/Afrom Benchmarks import * 372549SN/A 382889SN/Aparser = optparse.OptionParser() 392710SN/A 402917SN/Aparser.add_option("-d", "--detailed", action="store_true") 412710SN/Aparser.add_option("-t", "--timing", action="store_true") 422917SN/Aparser.add_option("-m", "--maxtick", type="int") 432948SN/Aparser.add_option("--maxtime", type="float") 442995SN/Aparser.add_option("--dual", action="store_true", 452995SN/A help="Simulate two systems attached with an ethernet link") 462995SN/Aparser.add_option("-b", "--benchmark", action="store", type="string", 472995SN/A dest="benchmark", 482995SN/A help="Specify the benchmark to run. Available benchmarks: %s"\ 492995SN/A % DefinedBenchmarks) 502710SN/A 512710SN/A(options, args) = parser.parse_args() 522710SN/A 532710SN/Aif args: 542710SN/A print "Error: script doesn't take any positional arguments" 552710SN/A sys.exit(1) 562710SN/A 572934SN/Aif options.detailed: 582934SN/A cpu = DetailedO3CPU() 592934SN/A cpu2 = DetailedO3CPU() 602953SN/A mem_mode = 'timing' 612934SN/Aelif options.timing: 622934SN/A cpu = TimingSimpleCPU() 632934SN/A cpu2 = TimingSimpleCPU() 642953SN/A mem_mode = 'timing' 652934SN/Aelse: 662934SN/A cpu = AtomicSimpleCPU() 672934SN/A cpu2 = AtomicSimpleCPU() 682953SN/A mem_mode = 'atomic' 692566SN/A 703005Sstever@eecs.umich.educpu.clock = '2GHz' 713005Sstever@eecs.umich.educpu2.clock = '2GHz' 722995SN/A 732995SN/Aif options.benchmark: 742995SN/A if options.benchmark not in Benchmarks: 752995SN/A print "Error benchmark %s has not been defined." % options.benchmark 762995SN/A print "Valid benchmarks are: %s" % DefinedBenchmarks 772995SN/A sys.exit(1) 782995SN/A 792995SN/A bm = Benchmarks[options.benchmark] 802917SN/Aelse: 812995SN/A if options.dual: 823005Sstever@eecs.umich.edu bm = [Machine(), Machine()] 832995SN/A else: 843005Sstever@eecs.umich.edu bm = [Machine()] 853005Sstever@eecs.umich.edu 863005Sstever@eecs.umich.eduif len(bm) == 2: 873005Sstever@eecs.umich.edu s1 = makeLinuxAlphaSystem(mem_mode, bm[0]) 883005Sstever@eecs.umich.edu s1.cpu = cpu 893005Sstever@eecs.umich.edu cpu.connectMemPorts(s1.membus) 903005Sstever@eecs.umich.edu s2 = makeLinuxAlphaSystem(mem_mode, bm[1]) 913005Sstever@eecs.umich.edu s2.cpu = cpu2 923005Sstever@eecs.umich.edu cpu2.connectMemPorts(s2.membus) 933005Sstever@eecs.umich.edu root = makeDualRoot(s1, s2) 943005Sstever@eecs.umich.eduelif len(bm) == 1: 953005Sstever@eecs.umich.edu root = Root(clock = '1THz', 963005Sstever@eecs.umich.edu system = makeLinuxAlphaSystem(mem_mode, bm[0])) 973005Sstever@eecs.umich.edu root.system.cpu = cpu 983005Sstever@eecs.umich.edu cpu.connectMemPorts(root.system.membus) 993005Sstever@eecs.umich.eduelse: 1003005Sstever@eecs.umich.edu print "Error I don't know how to create more than 2 systems." 1013005Sstever@eecs.umich.edu sys.exit(1) 1022566SN/A 1032710SN/Am5.instantiate(root) 1042710SN/A 1052902SN/A#exit_event = m5.simulate(2600000000000) 1062902SN/A#if exit_event.getCause() != "user interrupt received": 1072902SN/A# m5.checkpoint(root, 'cpt') 1082902SN/A# exit_event = m5.simulate(300000000000) 1092902SN/A# if exit_event.getCause() != "user interrupt received": 1102902SN/A# m5.checkpoint(root, 'cptA') 1112902SN/A 1122902SN/A 1132917SN/Aif options.maxtick: 1142917SN/A exit_event = m5.simulate(options.maxtick) 1152948SN/Aelif options.maxtime: 1162948SN/A simtime = int(options.maxtime * root.clock.value) 1172948SN/A print "simulating for: ", simtime 1182948SN/A exit_event = m5.simulate(simtime) 1192917SN/Aelse: 1202917SN/A exit_event = m5.simulate() 1212710SN/A 1222740SN/Aprint 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause() 123