Simulation.py (9457:a4739b6f799d) Simulation.py (9460:5532a1642108)
1# Copyright (c) 2006-2008 The Regents of The University of Michigan
2# Copyright (c) 2010 Advanced Micro Devices, Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 217 unchanged lines hidden (view full) ---

226 num_checkpoints += 1
227 if num_checkpoints == max_checkpoints:
228 exit_cause = "maximum %d checkpoints dropped" % max_checkpoints
229 break
230
231 exit_event = m5.simulate(maxtick - m5.curTick())
232 exit_cause = exit_event.getCause()
233
1# Copyright (c) 2006-2008 The Regents of The University of Michigan
2# Copyright (c) 2010 Advanced Micro Devices, Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 217 unchanged lines hidden (view full) ---

226 num_checkpoints += 1
227 if num_checkpoints == max_checkpoints:
228 exit_cause = "maximum %d checkpoints dropped" % max_checkpoints
229 break
230
231 exit_event = m5.simulate(maxtick - m5.curTick())
232 exit_cause = exit_event.getCause()
233
234 return exit_cause
234 return exit_event
235
236def repeatSwitch(testsys, repeat_switch_cpu_list, maxtick, switch_freq):
237 print "starting switch loop"
238 while True:
239 exit_event = m5.simulate(switch_freq)
240 exit_cause = exit_event.getCause()
241
242 if exit_cause != "simulate() limit reached":
235
236def repeatSwitch(testsys, repeat_switch_cpu_list, maxtick, switch_freq):
237 print "starting switch loop"
238 while True:
239 exit_event = m5.simulate(switch_freq)
240 exit_cause = exit_event.getCause()
241
242 if exit_cause != "simulate() limit reached":
243 return exit_cause
243 return exit_event
244
245 print "draining the system"
246 m5.drain(testsys)
247 m5.switchCpus(repeat_switch_cpu_list)
248 m5.resume(testsys)
249
250 tmp_cpu_list = []
251 for old_cpu, new_cpu in repeat_switch_cpu_list:
252 tmp_cpu_list.append((new_cpu, old_cpu))
253 repeat_switch_cpu_list = tmp_cpu_list
254
255 if (maxtick - m5.curTick()) <= switch_freq:
256 exit_event = m5.simulate(maxtick - m5.curTick())
244
245 print "draining the system"
246 m5.drain(testsys)
247 m5.switchCpus(repeat_switch_cpu_list)
248 m5.resume(testsys)
249
250 tmp_cpu_list = []
251 for old_cpu, new_cpu in repeat_switch_cpu_list:
252 tmp_cpu_list.append((new_cpu, old_cpu))
253 repeat_switch_cpu_list = tmp_cpu_list
254
255 if (maxtick - m5.curTick()) <= switch_freq:
256 exit_event = m5.simulate(maxtick - m5.curTick())
257 return exit_event.getCause()
257 return exit_event
258
259def run(options, root, testsys, cpu_class):
260 if options.maxtick:
261 maxtick = options.maxtick
262 elif options.maxtime:
263 simtime = m5.ticks.seconds(simtime)
264 print "simulating for: ", simtime
265 maxtick = simtime

--- 227 unchanged lines hidden (view full) ---

493 else:
494 if options.fast_forward:
495 m5.stats.reset()
496 print "**** REAL SIMULATION ****"
497
498 # If checkpoints are being taken, then the checkpoint instruction
499 # will occur in the benchmark code it self.
500 if options.repeat_switch and maxtick > options.repeat_switch:
258
259def run(options, root, testsys, cpu_class):
260 if options.maxtick:
261 maxtick = options.maxtick
262 elif options.maxtime:
263 simtime = m5.ticks.seconds(simtime)
264 print "simulating for: ", simtime
265 maxtick = simtime

--- 227 unchanged lines hidden (view full) ---

493 else:
494 if options.fast_forward:
495 m5.stats.reset()
496 print "**** REAL SIMULATION ****"
497
498 # If checkpoints are being taken, then the checkpoint instruction
499 # will occur in the benchmark code it self.
500 if options.repeat_switch and maxtick > options.repeat_switch:
501 exit_cause = repeatSwitch(testsys, repeat_switch_cpu_list,
501 exit_event = repeatSwitch(testsys, repeat_switch_cpu_list,
502 maxtick, options.repeat_switch)
503 else:
502 maxtick, options.repeat_switch)
503 else:
504 exit_cause = benchCheckpoints(options, maxtick, cptdir)
504 exit_event = benchCheckpoints(options, maxtick, cptdir)
505
505
506 print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_cause)
506 print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause())
507 if options.checkpoint_at_end:
508 m5.checkpoint(joinpath(cptdir, "cpt.%d"))
509
510 sys.exit(exit_event.getCode())
507 if options.checkpoint_at_end:
508 m5.checkpoint(joinpath(cptdir, "cpt.%d"))
509
510 sys.exit(exit_event.getCode())