X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsim%2Fstat_control.cc;h=eb5fe13072497089f7b5cf504e3bab62a87b08ab;hb=bd55c9e2af7fd6c06af48a020c29cb33ba1ca3fc;hp=f7fc03d7409b6b9f4d142dd066ce5e6b235c9a72;hpb=3c95f5958fd1a90cf83d85e1b24fb700c07bae91;p=gem5.git diff --git a/src/sim/stat_control.cc b/src/sim/stat_control.cc index f7fc03d74..eb5fe1307 100644 --- a/src/sim/stat_control.cc +++ b/src/sim/stat_control.cc @@ -38,61 +38,75 @@ #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 "config/the_isa.hh" +#if THE_ISA == NO_ISA +#include "arch/noisa/cpu_dummy.hh" +#else #include "cpu/base.hh" +#endif + #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 finalTick; 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(); - startTick = curTick; + statTime.setTimer(); + startTick = curTick(); } }; double statElapsedTime() { - Time now(true); + Time now; + now.setTimer(); + Time elapsed = now - statTime; - return elapsed(); + return elapsed; } Tick statElapsedTicks() { - return curTick - startTick; + return curTick() - startTick; +} + +Tick +statFinalTick() +{ + return curTick(); } 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 +122,7 @@ InitSimStats() ; simFreq - .scalar(Clock::Frequency) + .scalar(SimClock::Frequency) .name("sim_freq") .desc("Frequency of simulated ticks") ; @@ -119,6 +133,13 @@ InitSimStats() .desc("Number of ticks simulated") ; + finalTick + .functor(statFinalTick) + .name("final_tick") + .desc("Number of ticks from beginning of simulation \ +(restored from checkpoints and never reset)") + ; + hostInstRate .name("host_inst_rate") .desc("Simulator instruction rate (inst/s)") @@ -153,77 +174,46 @@ InitSimStats() registerResetCallback(&simTicksReset); } -class StatEvent : public Event -{ - protected: - int flags; - Tick repeat; - - public: - StatEvent(int _flags, Tick _when, Tick _repeat); - virtual void process(); - virtual const char *description(); -}; - -StatEvent::StatEvent(int _flags, Tick _when, Tick _repeat) - : Event(&mainEventQueue, 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) - reset(); + public: + StatEvent(bool _dump, bool _reset, Tick _repeat) + : Event(Stat_Event_Pri, AutoDelete), + dump(_dump), reset(_reset), repeat(_repeat) + { + } - if (repeat) - schedule(curTick + repeat); -} + virtual void + process() + { + if (dump) + Stats::dump(); -list OutputList; + if (reset) + Stats::reset(); -void -DumpNow() -{ - assert(lastDump <= curTick); - if (lastDump == curTick) - return; - lastDump = curTick; - - list::iterator i = OutputList.begin(); - list::iterator end = OutputList.end(); - for (; i != end; ++i) { - Output *output = *i; - if (!output->valid()) - continue; - - output->output(); + if (repeat) { + Stats::schedStatEvent(dump, reset, curTick() + repeat, repeat); + } } -} +}; void -SetupEvent(int flags, Tick when, Tick repeat) -{ - new StatEvent(flags, when, repeat); -} - -/* namespace Stats */ } - -extern "C" void -debugDumpStats() +schedStatEvent(bool dump, bool reset, Tick when, Tick repeat) { - Stats::DumpNow(); + Event *event = new StatEvent(dump, reset, repeat); + mainEventQueue.schedule(event, when); } +} // namespace Stats