Andreas Sandberg has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/35615 )
Change subject: stats: Make Stats::Group::mergeStatGroup public
......................................................................
stats: Make Stats::Group::mergeStatGroup public
The stat system currently assumes that the decision to merge groups is
done at construction time. This makes it hard to implement global
statistics that live in a single global group.
This change adds some error checking to mergeStatGroup and marks it as
a public method.
Change-Id: I6a42f48545c5ccfcd0672bae66a5bc86bb042f13
Signed-off-by: Andreas Sandberg <[email protected]>
---
M src/base/stats/group.cc
M src/base/stats/group.hh
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/base/stats/group.cc b/src/base/stats/group.cc
index a76ad4f..f1eda1d 100644
--- a/src/base/stats/group.cc
+++ b/src/base/stats/group.cc
@@ -47,7 +47,7 @@
namespace Stats {
Group::Group(Group *parent, const char *name)
- : mergedParent(name ? nullptr : parent)
+ : mergedParent(nullptr)
{
if (parent && name) {
parent->addStatGroup(name, this);
@@ -152,7 +152,22 @@
void
Group::mergeStatGroup(Group *block)
{
+ panic_if(!block, "No stat block provided");
+ panic_if(block->mergedParent,
+ "Stat group already merged into another group");
+ panic_if(block == this, "Stat group can't merge with itself");
+
+ // Track the new stat group
mergedStatGroups.push_back(block);
+
+ // We might not have seen stats that were associated with the
+ // child group before it was merged, so add them here.
+ for (auto &s : block->stats)
+ addStat(s);
+
+ // Setup the parent pointer so the child know that it needs to
+ // register new stats with the parent.
+ block->mergedParent = this;
}
const std::map<std::string, Group *> &
diff --git a/src/base/stats/group.hh b/src/base/stats/group.hh
index 985bf61..ef223bc 100644
--- a/src/base/stats/group.hh
+++ b/src/base/stats/group.hh
@@ -194,7 +194,6 @@
*/
const Info * resolveStat(std::string name) const;
- private:
/**
* Merge the contents (stats & children) of a block to this block.
*
@@ -205,7 +204,7 @@
private:
/** Parent pointer if merged into parent */
- Group *const mergedParent;
+ Group *mergedParent;
std::map<std::string, Group *> statGroups;
std::vector<Group *> mergedStatGroups;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/35615
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I6a42f48545c5ccfcd0672bae66a5bc86bb042f13
Gerrit-Change-Number: 35615
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s