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 * 37 38if not m5.build_env['FULL_SYSTEM']: 39 m5.panic("This script requires full-system mode (ALPHA_FS).") 40 41parser = optparse.OptionParser() 42 43parser.add_option("-d", "--detailed", action="store_true") 44parser.add_option("-t", "--timing", action="store_true") 45parser.add_option("-n", "--num_cpus", type="int", default=1)
| 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 * 37 38if not m5.build_env['FULL_SYSTEM']: 39 m5.panic("This script requires full-system mode (ALPHA_FS).") 40 41parser = optparse.OptionParser() 42 43parser.add_option("-d", "--detailed", action="store_true") 44parser.add_option("-t", "--timing", action="store_true") 45parser.add_option("-n", "--num_cpus", type="int", default=1)
|
| 46parser.add_option("--caches", action="store_true")
|
46parser.add_option("-m", "--maxtick", type="int") 47parser.add_option("--maxtime", type="float") 48parser.add_option("--dual", action="store_true", 49 help="Simulate two systems attached with an ethernet link") 50parser.add_option("-b", "--benchmark", action="store", type="string", 51 dest="benchmark", 52 help="Specify the benchmark to run. Available benchmarks: %s"\ 53 % DefinedBenchmarks) 54parser.add_option("--etherdump", action="store", type="string", dest="etherdump", 55 help="Specify the filename to dump a pcap capture of the" \ 56 "ethernet traffic") 57parser.add_option("--checkpoint_dir", action="store", type="string", 58 help="Place all checkpoints in this absolute directory") 59parser.add_option("-c", "--checkpoint", action="store", type="int", 60 help="restore from checkpoint <N>") 61 62(options, args) = parser.parse_args() 63 64if args: 65 print "Error: script doesn't take any positional arguments" 66 sys.exit(1) 67
| 47parser.add_option("-m", "--maxtick", type="int") 48parser.add_option("--maxtime", type="float") 49parser.add_option("--dual", action="store_true", 50 help="Simulate two systems attached with an ethernet link") 51parser.add_option("-b", "--benchmark", action="store", type="string", 52 dest="benchmark", 53 help="Specify the benchmark to run. Available benchmarks: %s"\ 54 % DefinedBenchmarks) 55parser.add_option("--etherdump", action="store", type="string", dest="etherdump", 56 help="Specify the filename to dump a pcap capture of the" \ 57 "ethernet traffic") 58parser.add_option("--checkpoint_dir", action="store", type="string", 59 help="Place all checkpoints in this absolute directory") 60parser.add_option("-c", "--checkpoint", action="store", type="int", 61 help="restore from checkpoint <N>") 62 63(options, args) = parser.parse_args() 64 65if args: 66 print "Error: script doesn't take any positional arguments" 67 sys.exit(1) 68
|
| 69class MyCache(BaseCache): 70 assoc = 2 71 block_size = 64 72 latency = 1 73 mshrs = 10 74 tgts_per_mshr = 5 75
|
68# client system CPU is always simple... note this is an assignment of 69# a class, not an instance. 70ClientCPUClass = AtomicSimpleCPU 71client_mem_mode = 'atomic' 72 73if options.detailed: 74 ServerCPUClass = DerivO3CPU 75 server_mem_mode = 'timing' 76elif options.timing: 77 ServerCPUClass = TimingSimpleCPU 78 server_mem_mode = 'timing' 79else: 80 ServerCPUClass = AtomicSimpleCPU 81 server_mem_mode = 'atomic' 82 83ServerCPUClass.clock = '2GHz' 84ClientCPUClass.clock = '2GHz' 85 86if options.benchmark: 87 try: 88 bm = Benchmarks[options.benchmark] 89 except KeyError: 90 print "Error benchmark %s has not been defined." % options.benchmark 91 print "Valid benchmarks are: %s" % DefinedBenchmarks 92 sys.exit(1) 93else: 94 if options.dual: 95 bm = [SysConfig(), SysConfig()] 96 else: 97 bm = [SysConfig()] 98 99server_sys = makeLinuxAlphaSystem(server_mem_mode, bm[0]) 100np = options.num_cpus 101server_sys.cpu = [ServerCPUClass(cpu_id=i) for i in xrange(np)] 102for i in xrange(np):
| 76# client system CPU is always simple... note this is an assignment of 77# a class, not an instance. 78ClientCPUClass = AtomicSimpleCPU 79client_mem_mode = 'atomic' 80 81if options.detailed: 82 ServerCPUClass = DerivO3CPU 83 server_mem_mode = 'timing' 84elif options.timing: 85 ServerCPUClass = TimingSimpleCPU 86 server_mem_mode = 'timing' 87else: 88 ServerCPUClass = AtomicSimpleCPU 89 server_mem_mode = 'atomic' 90 91ServerCPUClass.clock = '2GHz' 92ClientCPUClass.clock = '2GHz' 93 94if options.benchmark: 95 try: 96 bm = Benchmarks[options.benchmark] 97 except KeyError: 98 print "Error benchmark %s has not been defined." % options.benchmark 99 print "Valid benchmarks are: %s" % DefinedBenchmarks 100 sys.exit(1) 101else: 102 if options.dual: 103 bm = [SysConfig(), SysConfig()] 104 else: 105 bm = [SysConfig()] 106 107server_sys = makeLinuxAlphaSystem(server_mem_mode, bm[0]) 108np = options.num_cpus 109server_sys.cpu = [ServerCPUClass(cpu_id=i) for i in xrange(np)] 110for i in xrange(np):
|
| 111 if options.caches: 112 server_sys.cpu[i].addPrivateSplitL1Caches(MyCache(size = '32kB'), 113 MyCache(size = '64kB'))
|
103 server_sys.cpu[i].connectMemPorts(server_sys.membus) 104 server_sys.cpu[i].mem = server_sys.physmem 105 106if len(bm) == 2: 107 client_sys = makeLinuxAlphaSystem(client_mem_mode, bm[1]) 108 client_sys.cpu = ClientCPUClass(cpu_id=0) 109 client_sys.cpu.connectMemPorts(client_sys.membus) 110 client_sys.cpu.mem = client_sys.physmem 111 root = makeDualRoot(server_sys, client_sys, options.etherdump) 112elif len(bm) == 1: 113 root = Root(clock = '1THz', system = server_sys) 114else: 115 print "Error I don't know how to create more than 2 systems." 116 sys.exit(1) 117 118m5.instantiate(root) 119 120if options.checkpoint: 121 from os.path import isdir 122 from os import listdir, getcwd 123 import re 124 if options.checkpoint_dir: 125 cptdir = options.checkpoint_dir 126 else: 127 cptdir = getcwd() 128 129 if not isdir(cptdir): 130 m5.panic("checkpoint dir %s does not exist!" % cptdir) 131 132 dirs = listdir(cptdir) 133 expr = re.compile('cpt.([0-9]*)') 134 cpts = [] 135 for dir in dirs: 136 match = expr.match(dir) 137 if match: 138 cpts.append(match.group(1)) 139 140 if options.checkpoint > len(cpts): 141 m5.panic('Checkpoint %d not found' % options.checkpoint) 142 143 m5.restoreCheckpoint(root, "/".join([cptdir, "cpt.%s" % cpts[options.checkpoint - 1]])) 144 145if options.maxtick: 146 maxtick = options.maxtick 147elif options.maxtime: 148 simtime = int(options.maxtime * root.clock.value) 149 print "simulating for: ", simtime 150 maxtick = simtime 151else: 152 maxtick = -1 153 154exit_event = m5.simulate(maxtick) 155 156while exit_event.getCause() == "checkpoint": 157 if options.checkpoint_dir: 158 m5.checkpoint(root, "/".join([options.checkpoint_dir, "cpt.%d"])) 159 else: 160 m5.checkpoint(root, "cpt.%d") 161 162 if maxtick == -1: 163 exit_event = m5.simulate(maxtick) 164 else: 165 exit_event = m5.simulate(maxtick - m5.curTick()) 166 167print 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause()
| 114 server_sys.cpu[i].connectMemPorts(server_sys.membus) 115 server_sys.cpu[i].mem = server_sys.physmem 116 117if len(bm) == 2: 118 client_sys = makeLinuxAlphaSystem(client_mem_mode, bm[1]) 119 client_sys.cpu = ClientCPUClass(cpu_id=0) 120 client_sys.cpu.connectMemPorts(client_sys.membus) 121 client_sys.cpu.mem = client_sys.physmem 122 root = makeDualRoot(server_sys, client_sys, options.etherdump) 123elif len(bm) == 1: 124 root = Root(clock = '1THz', system = server_sys) 125else: 126 print "Error I don't know how to create more than 2 systems." 127 sys.exit(1) 128 129m5.instantiate(root) 130 131if options.checkpoint: 132 from os.path import isdir 133 from os import listdir, getcwd 134 import re 135 if options.checkpoint_dir: 136 cptdir = options.checkpoint_dir 137 else: 138 cptdir = getcwd() 139 140 if not isdir(cptdir): 141 m5.panic("checkpoint dir %s does not exist!" % cptdir) 142 143 dirs = listdir(cptdir) 144 expr = re.compile('cpt.([0-9]*)') 145 cpts = [] 146 for dir in dirs: 147 match = expr.match(dir) 148 if match: 149 cpts.append(match.group(1)) 150 151 if options.checkpoint > len(cpts): 152 m5.panic('Checkpoint %d not found' % options.checkpoint) 153 154 m5.restoreCheckpoint(root, "/".join([cptdir, "cpt.%s" % cpts[options.checkpoint - 1]])) 155 156if options.maxtick: 157 maxtick = options.maxtick 158elif options.maxtime: 159 simtime = int(options.maxtime * root.clock.value) 160 print "simulating for: ", simtime 161 maxtick = simtime 162else: 163 maxtick = -1 164 165exit_event = m5.simulate(maxtick) 166 167while exit_event.getCause() == "checkpoint": 168 if options.checkpoint_dir: 169 m5.checkpoint(root, "/".join([options.checkpoint_dir, "cpt.%d"])) 170 else: 171 m5.checkpoint(root, "cpt.%d") 172 173 if maxtick == -1: 174 exit_event = m5.simulate(maxtick) 175 else: 176 exit_event = m5.simulate(maxtick - m5.curTick()) 177 178print 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause()
|