__init__.py (14205:197360deaa20) __init__.py (14206:9cd30cd80145)
1# Copyright (c) 2017, 2019 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

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

153 fatal("Illegal stat file type specified.")
154
155 outputList.append(factory(parsed))
156
157def initSimStats():
158 _m5.stats.initSimStats()
159 _m5.stats.registerPythonStatsHandlers()
160
1# Copyright (c) 2017, 2019 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

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

153 fatal("Illegal stat file type specified.")
154
155 outputList.append(factory(parsed))
156
157def initSimStats():
158 _m5.stats.initSimStats()
159 _m5.stats.registerPythonStatsHandlers()
160
161def _visit_groups(root, visitor):
161def _visit_groups(visitor, root=None):
162 if root is None:
163 root = Root.getInstance()
162 for group in root.getStatGroups().values():
163 visitor(group)
164 for group in root.getStatGroups().values():
165 visitor(group)
164 _visit_groups(group, visitor)
166 _visit_groups(visitor, root=group)
165
167
166def _visit_stats(root, visitor):
168def _visit_stats(visitor, root=None):
167 def for_each_stat(g):
168 for stat in g.getStats():
169 visitor(g, stat)
169 def for_each_stat(g):
170 for stat in g.getStats():
171 visitor(g, stat)
170 _visit_groups(root, for_each_stat)
172 _visit_groups(for_each_stat, root=root)
171
172def _bindStatHierarchy(root):
173 def _bind_obj(name, obj):
174 if m5.SimObject.isSimObjectVector(obj):
175 for idx, obj in enumerate(obj):
176 _bind_obj("{}{}".format(name, idx), obj)
177 else:
178 root.addStatGroup(name, obj.getCCObject())

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

207
208 stats_list.sort(key=lambda s: s.name.split('.'))
209 for stat in stats_list:
210 stats_dict[stat.name] = stat
211 stat.enable()
212
213
214 # New stats
173
174def _bindStatHierarchy(root):
175 def _bind_obj(name, obj):
176 if m5.SimObject.isSimObjectVector(obj):
177 for idx, obj in enumerate(obj):
178 _bind_obj("{}{}".format(name, idx), obj)
179 else:
180 root.addStatGroup(name, obj.getCCObject())

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

209
210 stats_list.sort(key=lambda s: s.name.split('.'))
211 for stat in stats_list:
212 stats_dict[stat.name] = stat
213 stat.enable()
214
215
216 # New stats
215 _visit_stats(Root.getInstance(), check_stat)
216 _visit_stats(Root.getInstance(), lambda g, s: s.enable())
217 _visit_stats(check_stat)
218 _visit_stats(lambda g, s: s.enable())
217
218 _m5.stats.enable();
219
220def prepare():
221 '''Prepare all stats for data access. This must be done before
222 dumping and serialization.'''
223
224 # Legacy stats
225 for stat in stats_list:
226 stat.prepare()
227
228 # New stats
219
220 _m5.stats.enable();
221
222def prepare():
223 '''Prepare all stats for data access. This must be done before
224 dumping and serialization.'''
225
226 # Legacy stats
227 for stat in stats_list:
228 stat.prepare()
229
230 # New stats
229 _visit_stats(Root.getInstance(), lambda g, s: s.prepare())
231 _visit_stats(lambda g, s: s.prepare())
230
232
231lastDump = 0
232
233def _dump_to_visitor(visitor):
233def _dump_to_visitor(visitor, root=None):
234 # Legacy stats
234 # Legacy stats
235 for stat in stats_list:
236 stat.visit(visitor)
235 if root is None:
236 for stat in stats_list:
237 stat.visit(visitor)
237
238 # New stats
239 def dump_group(group):
240 for stat in group.getStats():
241 stat.visit(visitor)
242
243 for n, g in group.getStatGroups().items():
244 visitor.beginGroup(n)
245 dump_group(g)
246 visitor.endGroup()
247
238
239 # New stats
240 def dump_group(group):
241 for stat in group.getStats():
242 stat.visit(visitor)
243
244 for n, g in group.getStatGroups().items():
245 visitor.beginGroup(n)
246 dump_group(g)
247 visitor.endGroup()
248
248 dump_group(Root.getInstance())
249 if root is not None:
250 for p in root.path_list():
251 visitor.beginGroup(p)
252 dump_group(root if root is not None else Root.getInstance())
253 if root is not None:
254 for p in reversed(root.path_list()):
255 visitor.endGroup()
249
256
257lastDump = 0
250
258
251def dump():
259def dump(root=None):
252 '''Dump all statistics data to the registered outputs'''
253
260 '''Dump all statistics data to the registered outputs'''
261
254 curTick = m5.curTick()
255
262 now = m5.curTick()
256 global lastDump
263 global lastDump
257 assert lastDump <= curTick
258 if lastDump == curTick:
264 assert lastDump <= now
265 new_dump = lastDump != now
266 lastDump = now
267
268 # Don't allow multiple global stat dumps in the same tick. It's
269 # still possible to dump a multiple sub-trees.
270 if not new_dump and root is None:
259 return
271 return
260 lastDump = curTick
261
272
262 _m5.stats.processDumpQueue()
273 # Only prepare stats the first time we dump them in the same tick.
274 if new_dump:
275 _m5.stats.processDumpQueue()
276 prepare()
263
277
264 prepare()
265
266 for output in outputList:
267 if output.valid():
268 output.begin()
278 for output in outputList:
279 if output.valid():
280 output.begin()
269 _dump_to_visitor(output)
281 _dump_to_visitor(output, root=root)
270 output.end()
271
272def reset():
273 '''Reset all statistics to the base state'''
274
275 # call reset stats on all SimObjects
276 root = Root.getInstance()
277 if root:

--- 19 unchanged lines hidden ---
282 output.end()
283
284def reset():
285 '''Reset all statistics to the base state'''
286
287 # call reset stats on all SimObjects
288 root = Root.getInstance()
289 if root:

--- 19 unchanged lines hidden ---