LSQ Unit: After deleting part of a split request, set it to NULL so that it
[gem5.git] / src / sim / stat_control.cc
index dfed2a0c8c7caa4bac4f4e65fe06d40b5358bc9c..373a3f2973f2eb7df47620f5ebdb2e466aee846d 100644 (file)
 #include "base/callback.hh"
 #include "base/hostinfo.hh"
 #include "base/statistics.hh"
-#include "base/str.hh"
 #include "base/time.hh"
-#include "base/stats/output.hh"
 #include "cpu/base.hh"
 #include "sim/eventq.hh"
-#include "sim/sim_object.hh"
-#include "sim/stat_control.hh"
-#include "sim/root.hh"
 
 using namespace std;
 
-Stats::Formula hostInstRate;
-Stats::Formula hostTickRate;
-Stats::Value hostMemory;
-Stats::Value hostSeconds;
-
+Stats::Formula simSeconds;
 Stats::Value simTicks;
-Stats::Value simInsts;
 Stats::Value simFreq;
-Stats::Formula simSeconds;
 
 namespace Stats {
 
 Time statTime(true);
 Tick startTick;
-Tick lastDump(0);
 
-class SimTicksReset : public Callback
+struct SimTicksReset : public Callback
 {
-  public:
     void process()
     {
         statTime.set();
@@ -91,8 +78,19 @@ statElapsedTicks()
 
 SimTicksReset simTicksReset;
 
-void
-InitSimStats()
+struct Global
+{
+    Stats::Formula hostInstRate;
+    Stats::Formula hostTickRate;
+    Stats::Value hostMemory;
+    Stats::Value hostSeconds;
+
+    Stats::Value simInsts;
+
+    Global();
+};
+
+Global::Global()
 {
     simInsts
         .functor(BaseCPU::numSimulatedInstructions)
@@ -108,7 +106,7 @@ InitSimStats()
         ;
 
     simFreq
-        .scalar(Clock::Frequency)
+        .scalar(SimClock::Frequency)
         .name("sim_freq")
         .desc("Frequency of simulated ticks")
         ;
@@ -153,81 +151,47 @@ InitSimStats()
     registerResetCallback(&simTicksReset);
 }
 
-class StatEvent : public Event
-{
-  protected:
-    int flags;
-    Tick repeat;
-
-  public:
-    StatEvent(EventQueue *queue, int _flags, Tick _when, Tick _repeat);
-    virtual void process();
-    virtual const char *description();
-};
-
-StatEvent::StatEvent(EventQueue *queue, int _flags, Tick _when, Tick _repeat)
-    : Event(queue, Stat_Event_Pri),
-      flags(_flags), repeat(_repeat)
-{
-    setFlags(AutoDelete);
-    schedule(_when);
-}
-
-const char *
-StatEvent::description()
+void
+initSimStats()
 {
-    return "Statistics dump and/or reset";
+    static Global global;
 }
 
-void
-StatEvent::process()
+class _StatEvent : public Event
 {
-    if (flags & Stats::Dump)
-        DumpNow();
+  private:
+    bool dump;
+    bool reset;
+    Tick repeat;
 
-    if (flags & Stats::Reset) {
-        cprintf("Resetting stats!\n");
-        reset();
+  public:
+    _StatEvent(bool _dump, bool _reset, Tick _repeat)
+        : Event(Stat_Event_Pri), dump(_dump), reset(_reset), repeat(_repeat)
+    {
+        setFlags(AutoDelete);
     }
 
-    if (repeat)
-        schedule(curTick + repeat);
-}
+    virtual void
+    process()
+    {
+        if (dump)
+            Stats::dump();
 
-list<Output *> OutputList;
+        if (reset)
+            Stats::reset();
 
-void
-DumpNow()
-{
-    assert(lastDump <= curTick);
-    if (lastDump == curTick)
-        return;
-    lastDump = curTick;
-
-    list<Output *>::iterator i = OutputList.begin();
-    list<Output *>::iterator end = OutputList.end();
-    for (; i != end; ++i) {
-        Output *output = *i;
-        if (!output->valid())
-            continue;
-
-        output->output();
+        if (repeat) {
+            Event *event = new _StatEvent(dump, reset, repeat);
+            mainEventQueue.schedule(event, curTick + repeat);
+        }
     }
-}
+};
 
 void
-SetupEvent(int flags, Tick when, Tick repeat, EventQueue *queue)
+StatEvent(bool dump, bool reset, Tick when, Tick repeat)
 {
-    if (queue == NULL)
-        queue = &mainEventQueue;
-
-    new StatEvent(queue, flags, when, repeat);
+    Event *event = new _StatEvent(dump, reset, repeat);
+    mainEventQueue.schedule(event, when);
 }
 
 /* namespace Stats */ }
-
-void debugDumpStats()
-{
-    Stats::DumpNow();
-}
-