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 <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35615 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -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 @@ Group::resolveStat(std::string name) const
|
||||
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 *> &
|
||||
|
||||
@@ -194,7 +194,6 @@ class Group
|
||||
*/
|
||||
const Info * resolveStat(std::string name) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Merge the contents (stats & children) of a block to this block.
|
||||
*
|
||||
@@ -205,7 +204,7 @@ class Group
|
||||
|
||||
private:
|
||||
/** Parent pointer if merged into parent */
|
||||
Group *const mergedParent;
|
||||
Group *mergedParent;
|
||||
|
||||
std::map<std::string, Group *> statGroups;
|
||||
std::vector<Group *> mergedStatGroups;
|
||||
|
||||
Reference in New Issue
Block a user