fs.py revision 3668:bacb0a392e78
1# Copyright (c) 2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright 9# notice, this list of conditions and the following disclaimer in the 10# documentation and/or other materials provided with the distribution; 11# neither the name of the copyright holders nor the names of its 12# contributors may be used to endorse or promote products derived from 13# this software without specific prior written permission. 14# 15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26# 27# Authors: Ali Saidi 28 29import optparse, os, sys 30 31import m5 32from m5.objects import * 33m5.AddToPath('../common') 34from FSConfig import * 35from SysPaths import * 36from Benchmarks import * 37import Simulation 38from Caches import * 39 40if not m5.build_env['FULL_SYSTEM']: 41 m5.panic("This script requires full-system mode (ALPHA_FS).") 42 43# Get paths we might need. It's expected this file is in m5/configs/example. 44config_path = os.path.dirname(os.path.abspath(__file__)) 45config_root = os.path.dirname(config_path) 46 47parser = optparse.OptionParser() 48 49# Benchmark options 50parser.add_option("--l2cache", action="store_true") 51parser.add_option("--dual", action="store_true", 52 help="Simulate two systems attached with an ethernet link") 53parser.add_option("-b", "--benchmark", action="store", type="string", 54 dest="benchmark", 55 help="Specify the benchmark to run. Available benchmarks: %s"\ 56 % DefinedBenchmarks) 57 58# Metafile options 59parser.add_option("--etherdump", action="store", type="string", dest="etherdump", 60 help="Specify the filename to dump a pcap capture of the" \ 61 "ethernet traffic") 62 63execfile(os.path.join(config_root, "common", "Options.py")) 64 65(options, args) = parser.parse_args() 66 67if args: 68 print "Error: script doesn't take any positional arguments" 69 sys.exit(1) 70 71# driver system CPU is always simple... note this is an assignment of 72# a class, not an instance. 73DriveCPUClass = AtomicSimpleCPU 74drive_mem_mode = 'atomic' 75 76# system under test can be any CPU 77(TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options) 78 79TestCPUClass.clock = '2GHz' 80DriveCPUClass.clock = '2GHz' 81 82if options.benchmark: 83 try: 84 bm = Benchmarks[options.benchmark] 85 except KeyError: 86 print "Error benchmark %s has not been defined." % options.benchmark 87 print "Valid benchmarks are: %s" % DefinedBenchmarks 88 sys.exit(1) 89else: 90 if options.dual: 91 bm = [SysConfig(), SysConfig()] 92 else: 93 bm = [SysConfig()] 94 95test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0]) 96np = options.num_cpus 97 98if options.l2cache: 99 test_sys.l2 = L2Cache(size = '2MB') 100 test_sys.tol2bus = Bus() 101 test_sys.l2.cpu_side = test_sys.tol2bus.port 102 test_sys.l2.mem_side = test_sys.membus.port 103 104test_sys.cpu = [TestCPUClass(cpu_id=i) for i in xrange(np)] 105for i in xrange(np): 106 if options.caches: 107 test_sys.cpu[i].addPrivateSplitL1Caches(L1Cache(size = '32kB'), 108 L1Cache(size = '64kB')) 109 110 if options.l2cache: 111 test_sys.cpu[i].connectMemPorts(test_sys.tol2bus) 112 else: 113 test_sys.cpu[i].connectMemPorts(test_sys.membus) 114 115if len(bm) == 2: 116 drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1]) 117 drive_sys.cpu = DriveCPUClass(cpu_id=0) 118 drive_sys.cpu.connectMemPorts(drive_sys.membus) 119 root = makeDualRoot(test_sys, drive_sys, options.etherdump) 120elif len(bm) == 1: 121 root = Root(clock = '1THz', system = test_sys) 122else: 123 print "Error I don't know how to create more than 2 systems." 124 sys.exit(1) 125 126Simulation.run(options, root, test_sys, FutureClass) 127