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 --- 207 unchanged lines hidden (view full) --- 216 217def memInvalidate(root): 218 for obj in root.descendants(): 219 obj.memInvalidate() 220 221def checkpoint(dir): 222 root = objects.Root.getInstance() 223 if not isinstance(root, objects.Root): |
224 raise TypeError("Checkpoint must be called on a root object.") |
225 226 drain() 227 memWriteback(root) 228 print("Writing checkpoint") 229 _m5.core.serializeAll(dir) 230 231def _changeMemoryMode(system, mode): 232 if not isinstance(system, (objects.Root, objects.System)): |
233 raise TypeError("Parameter of type '%s'. Must be type %s or %s." % \ 234 (type(system), objects.Root, objects.System)) |
235 if system.getMemoryMode() != mode: 236 system.setMemoryMode(mode) 237 else: 238 print("System already in target mode. Memory mode unchanged.") 239 240def switchCpus(system, cpuList, verbose=True): 241 """Switch CPUs in a system. 242 --- 5 unchanged lines hidden (view full) --- 248 system -- Simulated system. 249 cpuList -- (old_cpu, new_cpu) tuples 250 """ 251 252 if verbose: 253 print("switching cpus") 254 255 if not isinstance(cpuList, list): |
256 raise RuntimeError("Must pass a list to this function") |
257 for item in cpuList: 258 if not isinstance(item, tuple) or len(item) != 2: |
259 raise RuntimeError("List must have tuples of (oldCPU,newCPU)") |
260 261 old_cpus = [old_cpu for old_cpu, new_cpu in cpuList] 262 new_cpus = [new_cpu for old_cpu, new_cpu in cpuList] 263 old_cpu_set = set(old_cpus) 264 memory_mode_name = new_cpus[0].memory_mode() 265 for old_cpu, new_cpu in cpuList: 266 if not isinstance(old_cpu, objects.BaseCPU): |
267 raise TypeError("%s is not of type BaseCPU" % old_cpu) |
268 if not isinstance(new_cpu, objects.BaseCPU): |
269 raise TypeError("%s is not of type BaseCPU" % new_cpu) |
270 if new_cpu in old_cpu_set: |
271 raise RuntimeError( 272 "New CPU (%s) is in the list of old CPUs." % (old_cpu,)) |
273 if not new_cpu.switchedOut(): |
274 raise RuntimeError("New CPU (%s) is already active." % (new_cpu,)) |
275 if not new_cpu.support_take_over(): |
276 raise RuntimeError( 277 "New CPU (%s) does not support CPU handover." % (old_cpu,)) |
278 if new_cpu.memory_mode() != memory_mode_name: |
279 raise RuntimeError( |
280 "%s and %s require different memory modes." % (new_cpu, |
281 new_cpus[0])) |
282 if old_cpu.switchedOut(): |
283 raise RuntimeError("Old CPU (%s) is inactive." % (new_cpu,)) |
284 if not old_cpu.support_take_over(): |
285 raise RuntimeError( 286 "Old CPU (%s) does not support CPU handover." % (old_cpu,)) |
287 288 try: 289 memory_mode = _memory_modes[memory_mode_name] 290 except KeyError: |
291 raise RuntimeError("Invalid memory mode (%s)" % memory_mode_name) |
292 293 drain() 294 295 # Now all of the CPUs are ready to be switched out 296 for old_cpu, new_cpu in cpuList: 297 old_cpu.switchOut() 298 299 # Change the memory mode if required. We check if this is needed --- 36 unchanged lines hidden (view full) --- 336 337 Return Value: 338 pid of the child process or 0 if running in the child. 339 """ 340 from m5 import options 341 global fork_count 342 343 if not _m5.core.listenersDisabled(): |
344 raise RuntimeError("Can not fork a simulator with listeners enabled") |
345 346 drain() 347 348 try: 349 pid = os.fork() |
350 except OSError as e: |
351 raise e 352 353 if pid == 0: 354 # In child, notify objects of the fork 355 root = objects.Root.getInstance() 356 notifyFork(root) 357 # Setup a new output directory 358 parent = options.outdir --- 14 unchanged lines hidden --- |