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 --- 26 unchanged lines hidden (view full) --- 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") |
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 protocol = CoherenceProtocol(protocol='moesi') |
76 |
77# client system CPU is always simple... note this is an assignment of |
78# a class, not an instance. |
79ClientCPUClass = AtomicSimpleCPU 80client_mem_mode = 'atomic' |
81 |
82if options.detailed: |
83 ServerCPUClass = DerivO3CPU 84 server_mem_mode = 'timing' |
85elif options.timing: |
86 ServerCPUClass = TimingSimpleCPU 87 server_mem_mode = 'timing' |
88else: |
89 ServerCPUClass = AtomicSimpleCPU 90 server_mem_mode = 'atomic' |
91 |
92ServerCPUClass.clock = '2GHz' 93ClientCPUClass.clock = '2GHz' |
94 95if options.benchmark: 96 try: 97 bm = Benchmarks[options.benchmark] 98 except KeyError: 99 print "Error benchmark %s has not been defined." % options.benchmark 100 print "Valid benchmarks are: %s" % DefinedBenchmarks 101 sys.exit(1) 102else: 103 if options.dual: 104 bm = [SysConfig(), SysConfig()] 105 else: 106 bm = [SysConfig()] 107 |
108server_sys = makeLinuxAlphaSystem(server_mem_mode, bm[0]) |
109np = options.num_cpus |
110server_sys.cpu = [ServerCPUClass(cpu_id=i) for i in xrange(np)] |
111for i in xrange(np): |
112 if options.caches: 113 server_sys.cpu[i].addPrivateSplitL1Caches(MyCache(size = '32kB'), |
114 MyCache(size = '64kB')) |
115 server_sys.cpu[i].connectMemPorts(server_sys.membus) 116 server_sys.cpu[i].mem = server_sys.physmem |
117 118if len(bm) == 2: |
119 client_sys = makeLinuxAlphaSystem(client_mem_mode, bm[1]) 120 client_sys.cpu = ClientCPUClass(cpu_id=0) 121 client_sys.cpu.connectMemPorts(client_sys.membus) 122 client_sys.cpu.mem = client_sys.physmem 123 root = makeDualRoot(server_sys, client_sys, options.etherdump) |
124elif len(bm) == 1: |
125 root = Root(clock = '1THz', system = server_sys) |
126else: 127 print "Error I don't know how to create more than 2 systems." 128 sys.exit(1) 129 |
130m5.instantiate(root) 131 |
132if options.checkpoint: |
133 from os.path import isdir 134 from os import listdir, getcwd 135 import re |
136 if options.checkpoint_dir: 137 cptdir = options.checkpoint_dir 138 else: 139 cptdir = getcwd() |
140 141 if not isdir(cptdir): 142 m5.panic("checkpoint dir %s does not exist!" % cptdir) 143 144 dirs = listdir(cptdir) 145 expr = re.compile('cpt.([0-9]*)') 146 cpts = [] 147 for dir in dirs: 148 match = expr.match(dir) 149 if match: 150 cpts.append(match.group(1)) 151 |
152 if options.checkpoint > len(cpts): 153 m5.panic('Checkpoint %d not found' % options.checkpoint) |
154 |
155 m5.restoreCheckpoint(root, "/".join([cptdir, "cpt.%s" % cpts[options.checkpoint - 1]])) |
156 |
157if options.maxtick: 158 maxtick = options.maxtick 159elif options.maxtime: 160 simtime = int(options.maxtime * root.clock.value) 161 print "simulating for: ", simtime 162 maxtick = simtime 163else: 164 maxtick = -1 165 |
166exit_event = m5.simulate(maxtick) |
167 |
168while exit_event.getCause() == "checkpoint": 169 if options.checkpoint_dir: 170 m5.checkpoint(root, "/".join([options.checkpoint_dir, "cpt.%d"])) 171 else: 172 m5.checkpoint(root, "cpt.%d") |
173 |
174 if maxtick == -1: 175 exit_event = m5.simulate(maxtick) 176 else: 177 exit_event = m5.simulate(maxtick - m5.curTick()) |
178 |
179print 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause() |