simulate.py (7528:6efc3672733b) simulate.py (7531:f5e86115a07a)
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

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

41import objects
42from util import fatal
43
44# define a MaxTick parameter
45MaxTick = 2**63 - 1
46
47# The final hook to generate .ini files. Called from the user script
48# once the config is built.
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

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

41import objects
42from util import fatal
43
44# define a MaxTick parameter
45MaxTick = 2**63 - 1
46
47# The final hook to generate .ini files. Called from the user script
48# once the config is built.
49def instantiate():
49def instantiate(ckpt_dir=None):
50 root = objects.Root.getInstance()
51
52 if not root:
53 fatal("Need to instantiate Root() before calling instantiate()")
54
55 # we need to fix the global frequency
56 ticks.fixGlobalFrequency()
57

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

81
82 # Do a third pass to initialize statistics
83 for obj in root.descendants(): obj.regStats()
84 for obj in root.descendants(): obj.regFormulas()
85
86 # We're done registering statistics. Enable the stats package now.
87 stats.enable()
88
50 root = objects.Root.getInstance()
51
52 if not root:
53 fatal("Need to instantiate Root() before calling instantiate()")
54
55 # we need to fix the global frequency
56 ticks.fixGlobalFrequency()
57

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

81
82 # Do a third pass to initialize statistics
83 for obj in root.descendants(): obj.regStats()
84 for obj in root.descendants(): obj.regFormulas()
85
86 # We're done registering statistics. Enable the stats package now.
87 stats.enable()
88
89 # Restore checkpoint (if any)
90 if ckpt_dir:
91 internal.core.unserializeAll(ckpt_dir)
92 need_resume.append(root)
93
89 # Reset to put the stats in a consistent state.
90 stats.reset()
91
92def doDot(root):
93 dot = pydot.Dot()
94 instance.outputDot(dot)
95 dot.orientation = "portrait"
96 dot.size = "8.5,11"

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

155 root = objects.Root.getInstance()
156 if not isinstance(root, objects.Root):
157 raise TypeError, "Checkpoint must be called on a root object."
158 doDrain(root)
159 print "Writing checkpoint"
160 internal.core.serializeAll(dir)
161 resume(root)
162
94 # Reset to put the stats in a consistent state.
95 stats.reset()
96
97def doDot(root):
98 dot = pydot.Dot()
99 instance.outputDot(dot)
100 dot.orientation = "portrait"
101 dot.size = "8.5,11"

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

160 root = objects.Root.getInstance()
161 if not isinstance(root, objects.Root):
162 raise TypeError, "Checkpoint must be called on a root object."
163 doDrain(root)
164 print "Writing checkpoint"
165 internal.core.serializeAll(dir)
166 resume(root)
167
163def restoreCheckpoint(dir):
164 root = objects.Root.getInstance()
165 print "Restoring from checkpoint"
166 internal.core.unserializeAll(dir)
167 need_resume.append(root)
168 stats.reset()
169
170def changeToAtomic(system):
171 if not isinstance(system, (objects.Root, objects.System)):
172 raise TypeError, "Parameter of type '%s'. Must be type %s or %s." % \
173 (type(system), objects.Root, objects.System)
174 if system.getMemoryMode() != objects.params.atomic:
175 doDrain(system)
176 print "Changing memory mode to atomic"
177 for obj in system.descendants():

--- 35 unchanged lines hidden ---
168def changeToAtomic(system):
169 if not isinstance(system, (objects.Root, objects.System)):
170 raise TypeError, "Parameter of type '%s'. Must be type %s or %s." % \
171 (type(system), objects.Root, objects.System)
172 if system.getMemoryMode() != objects.params.atomic:
173 doDrain(system)
174 print "Changing memory mode to atomic"
175 for obj in system.descendants():

--- 35 unchanged lines hidden ---