__init__.py (2797:b5f26b4eacef) __init__.py (2839:d5dd8a3cdea0)
1# Copyright (c) 2005 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

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

208# register our C++ exit callback function with Python
209atexit.register(cc_main.doExitCleanup)
210
211# This import allows user scripts to reference 'm5.objects.Foo' after
212# just doing an 'import m5' (without an 'import m5.objects'). May not
213# matter since most scripts will probably 'from m5.objects import *'.
214import objects
215
1# Copyright (c) 2005 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

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

208# register our C++ exit callback function with Python
209atexit.register(cc_main.doExitCleanup)
210
211# This import allows user scripts to reference 'm5.objects.Foo' after
212# just doing an 'import m5' (without an 'import m5.objects'). May not
213# matter since most scripts will probably 'from m5.objects import *'.
214import objects
215
216def doQuiesce(root):
217 quiesce = cc_main.createCountedQuiesce()
218 unready_objects = root.startQuiesce(quiesce, True)
219 # If we've got some objects that can't quiesce immediately, then simulate
216def doDrain(root):
217 drain_event = cc_main.createCountedDrain()
218 unready_objects = root.startDrain(drain_event, True)
219 # If we've got some objects that can't drain immediately, then simulate
220 if unready_objects > 0:
220 if unready_objects > 0:
221 quiesce.setCount(unready_objects)
221 drain_event.setCount(unready_objects)
222 simulate()
222 simulate()
223 cc_main.cleanupCountedQuiesce(quiesce)
223 cc_main.cleanupCountedDrain(drain_event)
224
225def resume(root):
226 root.resume()
227
228def checkpoint(root):
229 if not isinstance(root, objects.Root):
230 raise TypeError, "Object is not a root object. Checkpoint must be called on a root object."
224
225def resume(root):
226 root.resume()
227
228def checkpoint(root):
229 if not isinstance(root, objects.Root):
230 raise TypeError, "Object is not a root object. Checkpoint must be called on a root object."
231 doQuiesce(root)
231 doDrain(root)
232 print "Writing checkpoint"
233 cc_main.serializeAll()
234 resume(root)
235
236def restoreCheckpoint(root):
237 print "Restoring from checkpoint"
238 cc_main.unserializeAll()
239
240def changeToAtomic(system):
241 if not isinstance(system, objects.Root) and not isinstance(system, System):
242 raise TypeError, "Object is not a root or system object. Checkpoint must be "
243 "called on a root object."
232 print "Writing checkpoint"
233 cc_main.serializeAll()
234 resume(root)
235
236def restoreCheckpoint(root):
237 print "Restoring from checkpoint"
238 cc_main.unserializeAll()
239
240def changeToAtomic(system):
241 if not isinstance(system, objects.Root) and not isinstance(system, System):
242 raise TypeError, "Object is not a root or system object. Checkpoint must be "
243 "called on a root object."
244 doQuiesce(system)
244 doDrain(system)
245 print "Changing memory mode to atomic"
246 system.changeTiming(cc_main.SimObject.Atomic)
247 resume(system)
248
249def changeToTiming(system):
250 if not isinstance(system, objects.Root) and not isinstance(system, System):
251 raise TypeError, "Object is not a root or system object. Checkpoint must be "
252 "called on a root object."
245 print "Changing memory mode to atomic"
246 system.changeTiming(cc_main.SimObject.Atomic)
247 resume(system)
248
249def changeToTiming(system):
250 if not isinstance(system, objects.Root) and not isinstance(system, System):
251 raise TypeError, "Object is not a root or system object. Checkpoint must be "
252 "called on a root object."
253 doQuiesce(system)
253 doDrain(system)
254 print "Changing memory mode to timing"
255 system.changeTiming(cc_main.SimObject.Timing)
256 resume(system)
257
258def switchCpus(cpuList):
259 if not isinstance(cpuList, list):
260 raise RuntimeError, "Must pass a list to this function"
261 for i in cpuList:

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

266
267 for cpu in old_cpus:
268 if not isinstance(cpu, objects.BaseCPU):
269 raise TypeError, "%s is not of type BaseCPU", cpu
270 for cpu in new_cpus:
271 if not isinstance(cpu, objects.BaseCPU):
272 raise TypeError, "%s is not of type BaseCPU", cpu
273
254 print "Changing memory mode to timing"
255 system.changeTiming(cc_main.SimObject.Timing)
256 resume(system)
257
258def switchCpus(cpuList):
259 if not isinstance(cpuList, list):
260 raise RuntimeError, "Must pass a list to this function"
261 for i in cpuList:

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

266
267 for cpu in old_cpus:
268 if not isinstance(cpu, objects.BaseCPU):
269 raise TypeError, "%s is not of type BaseCPU", cpu
270 for cpu in new_cpus:
271 if not isinstance(cpu, objects.BaseCPU):
272 raise TypeError, "%s is not of type BaseCPU", cpu
273
274 # Quiesce all of the individual CPUs
275 quiesce = cc_main.createCountedQuiesce()
274 # Drain all of the individual CPUs
275 drain_event = cc_main.createCountedDrain()
276 unready_cpus = 0
277 for old_cpu in old_cpus:
276 unready_cpus = 0
277 for old_cpu in old_cpus:
278 unready_cpus += old_cpu.startQuiesce(quiesce, False)
279 # If we've got some objects that can't quiesce immediately, then simulate
278 unready_cpus += old_cpu.startDrain(drain_event, False)
279 # If we've got some objects that can't drain immediately, then simulate
280 if unready_cpus > 0:
280 if unready_cpus > 0:
281 quiesce.setCount(unready_cpus)
281 drain_event.setCount(unready_cpus)
282 simulate()
282 simulate()
283 cc_main.cleanupCountedQuiesce(quiesce)
283 cc_main.cleanupCountedDrain(drain_event)
284 # Now all of the CPUs are ready to be switched out
285 for old_cpu in old_cpus:
286 old_cpu._ccObject.switchOut()
287 index = 0
288 print "Switching CPUs"
289 for new_cpu in new_cpus:
290 new_cpu.takeOverFrom(old_cpus[index])
291 new_cpu._ccObject.resume()
292 index += 1
284 # Now all of the CPUs are ready to be switched out
285 for old_cpu in old_cpus:
286 old_cpu._ccObject.switchOut()
287 index = 0
288 print "Switching CPUs"
289 for new_cpu in new_cpus:
290 new_cpu.takeOverFrom(old_cpus[index])
291 new_cpu._ccObject.resume()
292 index += 1