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 --- 130 unchanged lines hidden (view full) --- 139 resume(root) 140 141def restoreCheckpoint(root, dir): 142 print "Restoring from checkpoint" 143 cc_main.unserializeAll(dir) 144 resume(root) 145 146def changeToAtomic(system): |
147 if not isinstance(system, objects.Root) and not isinstance(system, objects.System): |
148 raise TypeError, "Object is not a root or system object. Checkpoint must be " 149 "called on a root object." 150 doDrain(system) 151 print "Changing memory mode to atomic" 152 system.changeTiming(cc_main.SimObject.Atomic) 153 resume(system) 154 155def changeToTiming(system): |
156 if not isinstance(system, objects.Root) and not isinstance(system, objects.System): |
157 raise TypeError, "Object is not a root or system object. Checkpoint must be " 158 "called on a root object." 159 doDrain(system) 160 print "Changing memory mode to timing" 161 system.changeTiming(cc_main.SimObject.Timing) 162 resume(system) 163 164def switchCpus(cpuList): |
165 print "switching cpus" |
166 if not isinstance(cpuList, list): 167 raise RuntimeError, "Must pass a list to this function" 168 for i in cpuList: 169 if not isinstance(i, tuple): 170 raise RuntimeError, "List must have tuples of (oldCPU,newCPU)" 171 172 [old_cpus, new_cpus] = zip(*cpuList) 173 --- 11 unchanged lines hidden (view full) --- 185 unready_cpus += old_cpu.startDrain(drain_event, False) 186 # If we've got some objects that can't drain immediately, then simulate 187 if unready_cpus > 0: 188 drain_event.setCount(unready_cpus) 189 simulate() 190 cc_main.cleanupCountedDrain(drain_event) 191 # Now all of the CPUs are ready to be switched out 192 for old_cpu in old_cpus: |
193 print "switching" |
194 old_cpu._ccObject.switchOut() 195 index = 0 |
196 for new_cpu in new_cpus: 197 new_cpu.takeOverFrom(old_cpus[index]) 198 new_cpu._ccObject.resume() 199 index += 1 200 201# Since we have so many mutual imports in this package, we should: 202# 1. Put all intra-package imports at the *bottom* of the file, unless 203# they're absolutely needed before that (for top-level statements 204# or class attributes). Imports of "trivial" packages that don't 205# import other packages (e.g., 'smartdict') can be at the top. 206# 2. Never use 'from foo import *' on an intra-package import since 207# you can get the wrong result if foo is only partially imported 208# at the point you do that (i.e., because foo is in the middle of 209# importing *you*). 210from main import options 211import objects 212import params 213from SimObject import resolveSimObject |