Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/32645 )
Change subject: misc: Make the stats callbacks use CallbackQueue2.
......................................................................
misc: Make the stats callbacks use CallbackQueue2.
Issue-on: https://gem5.atlassian.net/browse/GEM5-698
Change-Id: Idcbe04bdf4299925f321aa0ece263d86ed3fc8df
---
M src/base/statistics.cc
M src/base/statistics.hh
M src/cpu/profile.cc
M src/cpu/profile.hh
M src/mem/probes/mem_footprint.cc
M src/mem/ruby/network/Network.cc
M src/mem/ruby/network/Network.hh
M src/mem/ruby/slicc_interface/AbstractController.cc
M src/mem/ruby/slicc_interface/AbstractController.hh
M src/mem/ruby/system/RubySystem.cc
M src/mem/ruby/system/RubySystem.hh
M src/sim/stat_control.cc
12 files changed, 17 insertions(+), 80 deletions(-)
diff --git a/src/base/statistics.cc b/src/base/statistics.cc
index e4315ba..a00c190 100644
--- a/src/base/statistics.cc
+++ b/src/base/statistics.cc
@@ -518,8 +518,8 @@
dumpHandler = dump_handler;
}
-CallbackQueue dumpQueue;
-CallbackQueue resetQueue;
+CallbackQueue2<> dumpQueue;
+CallbackQueue2<> resetQueue;
void
processResetQueue()
@@ -534,9 +534,9 @@
}
void
-registerResetCallback(Callback *cb)
+registerResetCallback(const std::function<void()> &callback)
{
- resetQueue.add(cb);
+ resetQueue.push_back(callback);
}
bool _enabled = false;
@@ -586,9 +586,9 @@
}
void
-registerDumpCallback(Callback *cb)
+registerDumpCallback(const std::function<void()> &callback)
{
- dumpQueue.add(cb);
+ dumpQueue.push_back(callback);
}
} // namespace Stats
diff --git a/src/base/statistics.hh b/src/base/statistics.hh
index ee541fb..96cd43f 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -82,8 +82,6 @@
#include "base/str.hh"
#include "base/types.hh"
-class Callback;
-
/** The current simulated tick. */
extern Tick curTick();
@@ -3364,13 +3362,13 @@
* Register a callback that should be called whenever statistics are
* reset
*/
-void registerResetCallback(Callback *cb);
+void registerResetCallback(const std::function<void()> &callback);
/**
* Register a callback that should be called whenever statistics are
* about to be dumped
*/
-void registerDumpCallback(Callback *cb);
+void registerDumpCallback(const std::function<void()> &callback);
/**
* Process all the callbacks in the reset callbacks queue
diff --git a/src/cpu/profile.cc b/src/cpu/profile.cc
index 393740b..d132fc1 100644
--- a/src/cpu/profile.cc
+++ b/src/cpu/profile.cc
@@ -97,13 +97,7 @@
const Loader::SymbolTable &_symtab) :
symtab(_symtab), trace(std::move(_trace))
{
- reset = new MakeCallback<FunctionProfile,
&FunctionProfile::clear>(this);
- Stats::registerResetCallback(reset);
-}
-
-FunctionProfile::~FunctionProfile()
-{
- delete reset;
+ Stats::registerResetCallback([this]() { clear(); });
}
ProfileNode *
diff --git a/src/cpu/profile.hh b/src/cpu/profile.hh
index 0f2d8a8..b58447a 100644
--- a/src/cpu/profile.hh
+++ b/src/cpu/profile.hh
@@ -124,13 +124,11 @@
void clear();
};
-class Callback;
class FunctionProfile
{
private:
friend class ProfileNode;
- Callback *reset = nullptr;
const Loader::SymbolTable &symtab;
ProfileNode top;
std::map<Addr, Counter> pc_count;
@@ -139,7 +137,6 @@
public:
FunctionProfile(std::unique_ptr<BaseStackTrace> _trace,
const Loader::SymbolTable &symtab);
- ~FunctionProfile();
ProfileNode *consume(ThreadContext *tc, const StaticInstPtr &inst);
ProfileNode *consume(const std::vector<Addr> &stack);
diff --git a/src/mem/probes/mem_footprint.cc
b/src/mem/probes/mem_footprint.cc
index c907190..9707568 100644
--- a/src/mem/probes/mem_footprint.cc
+++ b/src/mem/probes/mem_footprint.cc
@@ -82,9 +82,7 @@
.flags(nozero | nonan);
// clang-format on
- registerResetCallback(
- new MakeCallback<MemFootprintProbe, &MemFootprintProbe::statReset>(
- this));
+ registerResetCallback([this]() { statReset(); });
}
void
diff --git a/src/mem/ruby/network/Network.cc
b/src/mem/ruby/network/Network.cc
index ba847e5..bf3b637 100644
--- a/src/mem/ruby/network/Network.cc
+++ b/src/mem/ruby/network/Network.cc
@@ -125,7 +125,7 @@
}
// Register a callback function for combining the statistics
- Stats::registerDumpCallback(new StatsCallback(this));
+ Stats::registerDumpCallback([this]() { collateStats(); });
for (auto &it : dynamic_cast<Network *>(this)->params()->ext_links) {
it->params()->ext_node->initNetQueues();
diff --git a/src/mem/ruby/network/Network.hh
b/src/mem/ruby/network/Network.hh
index bba0c5e..6348f6c 100644
--- a/src/mem/ruby/network/Network.hh
+++ b/src/mem/ruby/network/Network.hh
@@ -160,24 +160,6 @@
std::vector<bool> m_ordered;
private:
- //! Callback class used for collating statistics from all the
- //! controller of this type.
- class StatsCallback : public Callback
- {
- private:
- Network *ctr;
-
- public:
- virtual ~StatsCallback() {}
-
- StatsCallback(Network *_ctr)
- : ctr(_ctr)
- {
- }
-
- void process() {ctr->collateStats();}
- };
-
// Global address map
struct AddrMapNode {
NodeID id;
diff --git a/src/mem/ruby/slicc_interface/AbstractController.cc
b/src/mem/ruby/slicc_interface/AbstractController.cc
index d2b3370..599a54b 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.cc
+++ b/src/mem/ruby/slicc_interface/AbstractController.cc
@@ -61,7 +61,7 @@
if (m_version == 0) {
// Combine the statistics from all controllers
// of this particular type.
- Stats::registerDumpCallback(new StatsCallback(this));
+ Stats::registerDumpCallback([this]() { collateStats(); });
}
}
diff --git a/src/mem/ruby/slicc_interface/AbstractController.hh
b/src/mem/ruby/slicc_interface/AbstractController.hh
index 750a620..4820e5c 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.hh
+++ b/src/mem/ruby/slicc_interface/AbstractController.hh
@@ -214,19 +214,6 @@
Stats::Histogram m_delayHistogram;
std::vector<Stats::Histogram *> m_delayVCHistogram;
- //! Callback class used for collating statistics from all the
- //! controller of this type.
- class StatsCallback : public Callback
- {
- private:
- AbstractController *ctr;
-
- public:
- virtual ~StatsCallback() {}
- StatsCallback(AbstractController *_ctr) : ctr(_ctr) {}
- void process() {ctr->collateStats();}
- };
-
/**
* Port that forwards requests and receives responses from the
* memory controller.
diff --git a/src/mem/ruby/system/RubySystem.cc
b/src/mem/ruby/system/RubySystem.cc
index 5babf2d..c35ab02 100644
--- a/src/mem/ruby/system/RubySystem.cc
+++ b/src/mem/ruby/system/RubySystem.cc
@@ -86,7 +86,7 @@
m_abstract_controls.resize(MachineType_NUM);
// Collate the statistics before they are printed.
- Stats::registerDumpCallback(new RubyStatsCallback(this));
+ Stats::registerDumpCallback([this]() { collateStats(); });
// Create the profiler
m_profiler = new Profiler(p, this);
m_phys_mem = p->phys_mem;
diff --git a/src/mem/ruby/system/RubySystem.hh
b/src/mem/ruby/system/RubySystem.hh
index 7ce5ce0..d14b383 100644
--- a/src/mem/ruby/system/RubySystem.hh
+++ b/src/mem/ruby/system/RubySystem.hh
@@ -151,15 +151,4 @@
std::vector<std::map<uint32_t, AbstractController *> >
m_abstract_controls;
};
-class RubyStatsCallback : public Callback
-{
- private:
- RubySystem *m_ruby_system;
-
- public:
- virtual ~RubyStatsCallback() {}
- RubyStatsCallback(RubySystem *system) : m_ruby_system(system) {}
- void process() { m_ruby_system->collateStats(); }
-};
-
#endif //__MEM_RUBY_SYSTEM_RUBYSYSTEM_HH__
diff --git a/src/sim/stat_control.cc b/src/sim/stat_control.cc
index 291698c..9464c0d 100644
--- a/src/sim/stat_control.cc
+++ b/src/sim/stat_control.cc
@@ -70,15 +70,6 @@
GlobalEvent *dumpEvent;
-struct SimTicksReset : public Callback
-{
- void process()
- {
- statTime.setTimer();
- startTick = curTick();
- }
-};
-
double
statElapsedTime()
{
@@ -101,8 +92,6 @@
return curTick();
}
-SimTicksReset simTicksReset;
-
struct Global
{
Stats::Formula hostInstRate;
@@ -198,7 +187,10 @@
hostOpRate = simOps / hostSeconds;
hostTickRate = simTicks / hostSeconds;
- registerResetCallback(&simTicksReset);
+ registerResetCallback([]() {
+ statTime.setTimer();
+ startTick = curTick();
+ });
}
void
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/32645
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: Idcbe04bdf4299925f321aa0ece263d86ed3fc8df
Gerrit-Change-Number: 32645
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[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