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(visitor, root=None): 162 if root is None: 163 root = Root.getInstance() |
164 for group in root.getStatGroups().values(): 165 visitor(group) |
166 _visit_groups(visitor, root=group) |
167 |
168def _visit_stats(visitor, root=None): |
169 def for_each_stat(g): 170 for stat in g.getStats(): 171 visitor(g, stat) |
172 _visit_groups(for_each_stat, root=root) |
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 |
217 _visit_stats(check_stat) 218 _visit_stats(lambda g, s: s.enable()) |
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 |
231 _visit_stats(lambda g, s: s.prepare()) |
232 |
233def _dump_to_visitor(visitor, root=None): |
234 # Legacy stats |
235 if root is None: 236 for stat in stats_list: 237 stat.visit(visitor) |
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 |
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() |
256 |
257lastDump = 0 |
258 |
259def dump(root=None): |
260 '''Dump all statistics data to the registered outputs''' 261 |
262 now = m5.curTick() |
263 global lastDump |
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: |
271 return |
272 |
273 # Only prepare stats the first time we dump them in the same tick. 274 if new_dump: 275 _m5.stats.processDumpQueue() 276 prepare() |
277 |
278 for output in outputList: 279 if output.valid(): 280 output.begin() |
281 _dump_to_visitor(output, root=root) |
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 --- |