1# Copyright (c) 2012 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 143 unchanged lines hidden (view full) --- 152 return internal.core.curTick() 153 154# Python exit handlers happen in reverse order. We want to dump stats last. 155atexit.register(stats.dump) 156 157# register our C++ exit callback function with Python 158atexit.register(internal.core.doExitCleanup) 159 |
160# Drain the system in preparation of a checkpoint or memory mode 161# switch. |
162def drain(root): |
163 # Try to drain all objects. Draining might not be completed unless 164 # all objects return that they are drained on the first call. This 165 # is because as objects drain they may cause other objects to no 166 # longer be drained. 167 def _drain(): 168 all_drained = False 169 dm = internal.drain.createDrainManager() 170 unready_objs = sum(obj.drain(dm) for obj in root.descendants()) 171 # If we've got some objects that can't drain immediately, then simulate 172 if unready_objs > 0: 173 dm.setCount(unready_objs) 174 simulate() 175 else: 176 all_drained = True 177 internal.drain.cleanupDrainManager(dm) 178 return all_drained |
179 |
180 all_drained = _drain() 181 while (not all_drained): 182 all_drained = _drain() 183 |
184def resume(root): 185 for obj in root.descendants(): obj.drainResume() 186 187def checkpoint(dir): 188 root = objects.Root.getInstance() 189 if not isinstance(root, objects.Root): 190 raise TypeError, "Checkpoint must be called on a root object." |
191 drain(root) |
192 print "Writing checkpoint" 193 internal.core.serializeAll(dir) 194 resume(root) 195 196def changeMemoryMode(system, mode): 197 if not isinstance(system, (objects.Root, objects.System)): 198 raise TypeError, "Parameter of type '%s'. Must be type %s or %s." % \ 199 (type(system), objects.Root, objects.System) 200 if system.getMemoryMode() != mode: |
201 drain(system) |
202 system.setMemoryMode(mode) 203 else: 204 print "System already in target mode. Memory mode unchanged." 205 206def changeToAtomic(system, **kwargs): 207 print "Changing memory mode to atomic" 208 changeMemoryMode(system, objects.params.atomic, **kwargs) 209 --- 26 unchanged lines hidden --- |