stats: add --stats-root option to dump only under some SimObjects
This commit makes it possible to make invocations such as: gem5.opt se.py --stats-root 'system.cpu[:].dtb' --stats-root 'system.membus' When --stats-root is given, only stats that are under any of the root SimObjects get dumped. E.g. the above invocation would dump stats such as: system.cpu0.dtb.walker.pwrStateResidencyTicks::UNDEFINED system.cpu1.dtb.walker.pwrStateResidencyTicks::UNDEFINED system.membus.pwrStateResidencyTicks::UNDEFINED system.membus.trans_dist::ReadReq but not for example `system.clk_domain.clock`. If the --stats-root is given, only new stats as defined at: Idc8ff448b9f70a796427b4a5231e7371485130b4 get dumped, and old ones are ignored. The commits following that one have done some initial conversion work, but many stats are still in the old format. Change-Id: Iadaef26edf9a678b39f774515600884fbaeec497 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28628 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -326,35 +326,45 @@ def prepare():
|
||||
# New stats
|
||||
_visit_stats(lambda g, s: s.prepare())
|
||||
|
||||
def _dump_to_visitor(visitor, root=None):
|
||||
# Legacy stats
|
||||
if root is None:
|
||||
for stat in stats_list:
|
||||
stat.visit(visitor)
|
||||
|
||||
def _dump_to_visitor(visitor, roots=None):
|
||||
# New stats
|
||||
def dump_group(group):
|
||||
for stat in group.getStats():
|
||||
stat.visit(visitor)
|
||||
|
||||
for n, g in group.getStatGroups().items():
|
||||
visitor.beginGroup(n)
|
||||
dump_group(g)
|
||||
visitor.endGroup()
|
||||
|
||||
if root is not None:
|
||||
for p in root.path_list():
|
||||
visitor.beginGroup(p)
|
||||
dump_group(root if root is not None else Root.getInstance())
|
||||
if root is not None:
|
||||
for p in reversed(root.path_list()):
|
||||
visitor.endGroup()
|
||||
if roots:
|
||||
# New stats from selected subroots.
|
||||
for root in roots:
|
||||
for p in root.path_list():
|
||||
visitor.beginGroup(p)
|
||||
dump_group(root)
|
||||
for p in reversed(root.path_list()):
|
||||
visitor.endGroup()
|
||||
else:
|
||||
# Legacy stats
|
||||
for stat in stats_list:
|
||||
stat.visit(visitor)
|
||||
|
||||
# New stats starting from root.
|
||||
dump_group(Root.getInstance())
|
||||
|
||||
lastDump = 0
|
||||
# List[SimObject].
|
||||
global_dump_roots = []
|
||||
|
||||
def dump(root=None):
|
||||
def dump(roots=None):
|
||||
'''Dump all statistics data to the registered outputs'''
|
||||
|
||||
all_roots = []
|
||||
if roots is not None:
|
||||
all_roots.extend(roots)
|
||||
global global_dump_roots
|
||||
all_roots.extend(global_dump_roots)
|
||||
|
||||
now = m5.curTick()
|
||||
global lastDump
|
||||
assert lastDump <= now
|
||||
@@ -363,7 +373,7 @@ def dump(root=None):
|
||||
|
||||
# Don't allow multiple global stat dumps in the same tick. It's
|
||||
# still possible to dump a multiple sub-trees.
|
||||
if not new_dump and root is None:
|
||||
if not new_dump and not all_roots:
|
||||
return
|
||||
|
||||
# Only prepare stats the first time we dump them in the same tick.
|
||||
@@ -378,7 +388,7 @@ def dump(root=None):
|
||||
for output in outputList:
|
||||
if output.valid():
|
||||
output.begin()
|
||||
_dump_to_visitor(output, root=root)
|
||||
_dump_to_visitor(output, roots=all_roots)
|
||||
output.end()
|
||||
|
||||
def reset():
|
||||
|
||||
Reference in New Issue
Block a user