simulate.py (7492:acc1fbbef239) simulate.py (7525:722f2ad014a7)
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

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

34# import the SWIG-wrapped main C++ functions
35import internal
36import core
37import stats
38from main import options
39import SimObject
40import ticks
41import objects
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

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

34# import the SWIG-wrapped main C++ functions
35import internal
36import core
37import stats
38from main import options
39import SimObject
40import ticks
41import objects
42from util import fatal
42
43# define a MaxTick parameter
44MaxTick = 2**63 - 1
45
46# The final hook to generate .ini files. Called from the user script
47# once the config is built.
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.
48def instantiate(root):
49def instantiate():
50 root = objects.Root.getInstance()
51
52 if not root:
53 fatal("Need to instantiate Root() before calling instantiate()")
54
49 # we need to fix the global frequency
50 ticks.fixGlobalFrequency()
51
52 root.unproxy_all()
53
54 if options.dump_config:
55 ini_file = file(os.path.join(options.outdir, options.dump_config), 'w')
56 root.print_ini(ini_file)

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

131 else:
132 all_drained = True
133 internal.event.cleanupCountedDrain(drain_event)
134 return all_drained
135
136def resume(root):
137 root.resume()
138
55 # we need to fix the global frequency
56 ticks.fixGlobalFrequency()
57
58 root.unproxy_all()
59
60 if options.dump_config:
61 ini_file = file(os.path.join(options.outdir, options.dump_config), 'w')
62 root.print_ini(ini_file)

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

137 else:
138 all_drained = True
139 internal.event.cleanupCountedDrain(drain_event)
140 return all_drained
141
142def resume(root):
143 root.resume()
144
139def checkpoint(root, dir):
145def checkpoint(dir):
146 root = objects.Root.getInstance()
140 if not isinstance(root, objects.Root):
141 raise TypeError, "Checkpoint must be called on a root object."
142 doDrain(root)
143 print "Writing checkpoint"
144 internal.core.serializeAll(dir)
145 resume(root)
146
147 if not isinstance(root, objects.Root):
148 raise TypeError, "Checkpoint must be called on a root object."
149 doDrain(root)
150 print "Writing checkpoint"
151 internal.core.serializeAll(dir)
152 resume(root)
153
147def restoreCheckpoint(root, dir):
154def restoreCheckpoint(dir):
155 root = objects.Root.getInstance()
148 print "Restoring from checkpoint"
149 internal.core.unserializeAll(dir)
150 need_resume.append(root)
151 stats.reset()
152
153def changeToAtomic(system):
154 if not isinstance(system, (objects.Root, objects.System)):
155 raise TypeError, "Parameter of type '%s'. Must be type %s or %s." % \

--- 38 unchanged lines hidden ---
156 print "Restoring from checkpoint"
157 internal.core.unserializeAll(dir)
158 need_resume.append(root)
159 stats.reset()
160
161def changeToAtomic(system):
162 if not isinstance(system, (objects.Root, objects.System)):
163 raise TypeError, "Parameter of type '%s'. Must be type %s or %s." % \

--- 38 unchanged lines hidden ---