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 --- 13 unchanged lines hidden (view full) --- 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: Lisa Hsu 28 29from os import getcwd |
30from os.path import join as joinpath |
31import m5 32from m5.objects import * 33m5.AddToPath('../common') 34from Caches import L1Cache 35 36def setCPUClass(options): 37 38 atomic = False --- 21 unchanged lines hidden (view full) --- 60def run(options, root, testsys, cpu_class): 61 if options.maxtick: 62 maxtick = options.maxtick 63 elif options.maxtime: 64 simtime = int(options.maxtime * root.clock.value) 65 print "simulating for: ", simtime 66 maxtick = simtime 67 else: |
68 maxtick = m5.MaxTick |
69 70 if options.checkpoint_dir: 71 cptdir = options.checkpoint_dir 72 else: 73 cptdir = getcwd() 74 75 np = options.num_cpus 76 max_checkpoints = options.max_checkpoints --- 60 unchanged lines hidden (view full) --- 137 cpts.sort(lambda a,b: cmp(long(a), long(b))) 138 139 cpt_num = options.checkpoint_restore 140 141 if cpt_num > len(cpts): 142 m5.panic('Checkpoint %d not found' % cpt_num) 143 144 m5.restoreCheckpoint(root, |
145 joinpath(cptdir, "cpt.%s" % cpts[cpt_num - 1])) |
146 147 if options.standard_switch or cpu_class: 148 exit_event = m5.simulate(10000) 149 150 ## when you change to Timing (or Atomic), you halt the system given 151 ## as argument. When you are finished with the system changes 152 ## (including switchCpus), you must resume the system manually. 153 ## You DON'T need to resume after just switching CPUs if you haven't --- 18 unchanged lines hidden (view full) --- 172 when = int(when) 173 period = int(period) 174 175 exit_event = m5.simulate(when) 176 while exit_event.getCause() == "checkpoint": 177 exit_event = m5.simulate(when - m5.curTick()) 178 179 if exit_event.getCause() == "simulate() limit reached": |
180 m5.checkpoint(root, joinpath(cptdir, "cpt.%d")) |
181 num_checkpoints += 1 182 183 sim_ticks = when 184 exit_cause = "maximum %d checkpoints dropped" % max_checkpoints 185 while num_checkpoints < max_checkpoints: |
186 if (sim_ticks + period) > maxtick: |
187 exit_event = m5.simulate(maxtick - sim_ticks) 188 exit_cause = exit_event.getCause() 189 break 190 else: 191 exit_event = m5.simulate(period) 192 sim_ticks += period 193 while exit_event.getCause() == "checkpoint": 194 exit_event = m5.simulate(sim_ticks - m5.curTick()) 195 if exit_event.getCause() == "simulate() limit reached": |
196 m5.checkpoint(root, joinpath(cptdir, "cpt.%d")) |
197 num_checkpoints += 1 198 199 else: #no checkpoints being taken via this script 200 exit_event = m5.simulate(maxtick) 201 202 while exit_event.getCause() == "checkpoint": |
203 m5.checkpoint(root, joinpath(cptdir, "cpt.%d")) |
204 num_checkpoints += 1 205 if num_checkpoints == max_checkpoints: 206 exit_cause = "maximum %d checkpoints dropped" % max_checkpoints 207 break 208 |
209 exit_event = m5.simulate(maxtick - m5.curTick()) |
210 exit_cause = exit_event.getCause() 211 212 if exit_cause == '': 213 exit_cause = exit_event.getCause() 214 print 'Exiting @ cycle %i because %s' % (m5.curTick(), exit_cause) 215 |