1# Copyright (c) 2006-2008 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 --- 176 unchanged lines hidden (view full) --- 185 options.take_checkpoints = checkpoint_inst 186 else: 187 options.take_checkpoints = offset 188 # Set all test cpus with the right number of instructions 189 # for the upcoming simulation 190 for i in xrange(np): 191 testsys.cpu[i].max_insts_any_thread = offset 192 |
193 m5.instantiate() |
194 195 if options.checkpoint_restore != None: 196 from os.path import isdir, exists 197 from os import listdir 198 import re 199 200 if not isdir(cptdir): 201 fatal("checkpoint dir %s does not exist!", cptdir) 202 203 if options.at_instruction: 204 checkpoint_dir = joinpath(cptdir, "cpt.%s.%s" % \ 205 (options.bench, options.checkpoint_restore)) 206 if not exists(checkpoint_dir): 207 fatal("Unable to find checkpoint directory %s", checkpoint_dir) 208 209 print "Restoring checkpoint ..." |
210 m5.restoreCheckpoint(checkpoint_dir) |
211 print "Done." 212 elif options.simpoint: 213 # assume workload 0 has the simpoint 214 if testsys.cpu[0].workload[0].simpoint == 0: 215 fatal('Unable to find simpoint') 216 217 options.checkpoint_restore += \ 218 int(testsys.cpu[0].workload[0].simpoint) 219 220 checkpoint_dir = joinpath(cptdir, "cpt.%s.%d" % \ 221 (options.bench, options.checkpoint_restore)) 222 if not exists(checkpoint_dir): 223 fatal("Unable to find checkpoint directory %s.%s", 224 options.bench, options.checkpoint_restore) 225 226 print "Restoring checkpoint ..." |
227 m5.restoreCheckpoint(checkpoint_dir) |
228 print "Done." 229 else: 230 dirs = listdir(cptdir) 231 expr = re.compile('cpt\.([0-9]*)') 232 cpts = [] 233 for dir in dirs: 234 match = expr.match(dir) 235 if match: --- 5 unchanged lines hidden (view full) --- 241 242 if cpt_num > len(cpts): 243 fatal('Checkpoint %d not found', cpt_num) 244 245 ## Adjust max tick based on our starting tick 246 maxtick = maxtick - int(cpts[cpt_num - 1]) 247 248 ## Restore the checkpoint |
249 m5.restoreCheckpoint(joinpath(cptdir, 250 "cpt.%s" % cpts[cpt_num - 1])) |
251 252 if options.standard_switch or cpu_class: 253 if options.standard_switch: 254 print "Switch at instruction count:%s" % \ 255 str(testsys.cpu[0].max_insts_any_thread) 256 exit_event = m5.simulate() 257 elif cpu_class and options.fast_forward: 258 print "Switch at instruction count:%s" % \ --- 60 unchanged lines hidden (view full) --- 319 print "exit cause = %s" % (exit_event.getCause()) 320 321 # skip checkpoint instructions should they exist 322 while exit_event.getCause() == "checkpoint": 323 exit_event = m5.simulate() 324 325 if exit_event.getCause() == \ 326 "a thread reached the max instruction count": |
327 m5.checkpoint(joinpath(cptdir, "cpt.%s.%d" % \ |
328 (options.bench, checkpoint_inst))) 329 print "Checkpoint written." 330 num_checkpoints += 1 331 332 if exit_event.getCause() == "user interrupt received": 333 exit_cause = exit_event.getCause(); 334 else: 335 when, period = options.take_checkpoints.split(",", 1) 336 when = int(when) 337 period = int(period) 338 339 exit_event = m5.simulate(when) 340 while exit_event.getCause() == "checkpoint": 341 exit_event = m5.simulate(when - m5.curTick()) 342 343 if exit_event.getCause() == "simulate() limit reached": |
344 m5.checkpoint(joinpath(cptdir, "cpt.%d")) |
345 num_checkpoints += 1 346 347 sim_ticks = when 348 exit_cause = "maximum %d checkpoints dropped" % max_checkpoints 349 while num_checkpoints < max_checkpoints and \ 350 exit_event.getCause() == "simulate() limit reached": 351 if (sim_ticks + period) > maxtick: 352 exit_event = m5.simulate(maxtick - sim_ticks) 353 exit_cause = exit_event.getCause() 354 break 355 else: 356 exit_event = m5.simulate(period) 357 sim_ticks += period 358 while exit_event.getCause() == "checkpoint": 359 exit_event = m5.simulate(sim_ticks - m5.curTick()) 360 if exit_event.getCause() == "simulate() limit reached": |
361 m5.checkpoint(joinpath(cptdir, "cpt.%d")) |
362 num_checkpoints += 1 363 364 if exit_event.getCause() != "simulate() limit reached": 365 exit_cause = exit_event.getCause(); 366 367 else: # no checkpoints being taken via this script 368 if options.fast_forward: 369 m5.stats.reset() 370 print "**** REAL SIMULATION ****" 371 exit_event = m5.simulate(maxtick) 372 373 while exit_event.getCause() == "checkpoint": |
374 m5.checkpoint(joinpath(cptdir, "cpt.%d")) |
375 num_checkpoints += 1 376 if num_checkpoints == max_checkpoints: 377 exit_cause = "maximum %d checkpoints dropped" % max_checkpoints 378 break 379 380 exit_event = m5.simulate(maxtick - m5.curTick()) 381 exit_cause = exit_event.getCause() 382 383 if exit_cause == '': 384 exit_cause = exit_event.getCause() 385 print 'Exiting @ cycle %i because %s' % (m5.curTick(), exit_cause) 386 387 if options.checkpoint_at_end: |
388 m5.checkpoint(joinpath(cptdir, "cpt.%d")) |
389 |