diff options
-rw-r--r-- | src/base/stats/group.cc | 10 | ||||
-rw-r--r-- | src/base/stats/group.hh | 7 | ||||
-rw-r--r-- | src/python/m5/stats/__init__.py | 4 | ||||
-rw-r--r-- | src/python/pybind11/stats.cc | 1 |
4 files changed, 22 insertions, 0 deletions
diff --git a/src/base/stats/group.cc b/src/base/stats/group.cc index b1504275a..d7c244225 100644 --- a/src/base/stats/group.cc +++ b/src/base/stats/group.cc @@ -94,6 +94,16 @@ Group::resetStats() } void +Group::preDumpStats() +{ + for (auto &g : mergedStatGroups) + g->preDumpStats(); + + for (auto &g : statGroups) + g.second->preDumpStats(); +} + +void Group::addStat(Stats::Info *info) { stats.push_back(info); diff --git a/src/base/stats/group.hh b/src/base/stats/group.hh index f65e46448..96743a811 100644 --- a/src/base/stats/group.hh +++ b/src/base/stats/group.hh @@ -128,6 +128,13 @@ class Group virtual void resetStats(); /** + * Callback before stats are dumped. This can be overridden by + * objects that need to perform calculations in addition to the + * capabiltiies implemented in the stat framework. + */ + virtual void preDumpStats(); + + /** * Register a stat with this group. This method is normally called * automatically when a stat is instantiated. */ diff --git a/src/python/m5/stats/__init__.py b/src/python/m5/stats/__init__.py index e2e1909f7..6a7c14d00 100644 --- a/src/python/m5/stats/__init__.py +++ b/src/python/m5/stats/__init__.py @@ -371,6 +371,10 @@ def dump(root=None): # Only prepare stats the first time we dump them in the same tick. if new_dump: _m5.stats.processDumpQueue() + # Notify new-style stats group that we are about to dump stats. + sim_root = Root.getInstance() + if sim_root: + sim_root.preDumpStats(); prepare() for output in outputList: diff --git a/src/python/pybind11/stats.cc b/src/python/pybind11/stats.cc index 190c78d52..b1f420978 100644 --- a/src/python/pybind11/stats.cc +++ b/src/python/pybind11/stats.cc @@ -127,6 +127,7 @@ pybind_init_stats(py::module &m_native) m, "Group") .def("regStats", &Stats::Group::regStats) .def("resetStats", &Stats::Group::resetStats) + .def("preDumpStats", &Stats::Group::preDumpStats) .def("getStats", &Stats::Group::getStats) .def("getStatGroups", &Stats::Group::getStatGroups) .def("addStatGroup", &Stats::Group::addStatGroup) |