diff options
author | Lisa Hsu <hsul@eecs.umich.edu> | 2004-05-18 01:40:03 -0400 |
---|---|---|
committer | Lisa Hsu <hsul@eecs.umich.edu> | 2004-05-18 01:40:03 -0400 |
commit | a0ccdf8aba8f71c8d66c03f5c6907d0a3c2e091f (patch) | |
tree | 71de26a0139e7db042c79989ae745377d98c3d23 /sim | |
parent | 4d98ab1ca92c2d88d3ee13a7518acc36a6d5bf84 (diff) | |
parent | 02af86f7e813db27b12214ea377948f07f891b69 (diff) | |
download | gem5-a0ccdf8aba8f71c8d66c03f5c6907d0a3c2e091f.tar.xz |
merge m5 with linux for the event and binning lifting
--HG--
extra : convert_revision : 09d3678746c2e9a93a9982dc75d5e1ac309cb2fa
Diffstat (limited to 'sim')
-rw-r--r-- | sim/debug.cc | 2 | ||||
-rw-r--r-- | sim/debug.hh | 4 | ||||
-rw-r--r-- | sim/stat_control.cc | 26 | ||||
-rw-r--r-- | sim/stats.hh | 6 | ||||
-rw-r--r-- | sim/system.cc | 79 | ||||
-rw-r--r-- | sim/system.hh | 22 |
6 files changed, 117 insertions, 22 deletions
diff --git a/sim/debug.cc b/sim/debug.cc index 09c604a95..b73ab4245 100644 --- a/sim/debug.cc +++ b/sim/debug.cc @@ -40,11 +40,13 @@ using namespace std; +#ifdef DEBUG void debug_break() { kill(getpid(), SIGTRAP); } +#endif // // Debug event: place a breakpoint on the process function and diff --git a/sim/debug.hh b/sim/debug.hh index eb0be772e..a4f8b8702 100644 --- a/sim/debug.hh +++ b/sim/debug.hh @@ -29,6 +29,10 @@ #ifndef __DEBUG_HH__ #define __DEBUG_HH__ +#ifdef DEBUG void debug_break(); +#else +inline void debug_break() { } +#endif #endif // __DEBUG_HH__ diff --git a/sim/stat_control.cc b/sim/stat_control.cc index d6d7e2c91..c7d2fdd5b 100644 --- a/sim/stat_control.cc +++ b/sim/stat_control.cc @@ -39,6 +39,7 @@ #include "base/str.hh" #include "base/time.hh" #include "base/stats/output.hh" +#include "cpu/base_cpu.hh" #include "sim/eventq.hh" #include "sim/sim_object.hh" #include "sim/stat_control.hh" @@ -47,13 +48,14 @@ using namespace std; Statistics::Formula hostInstRate; -Statistics::Formula hostMemory; -Statistics::Formula hostSeconds; Statistics::Formula hostTickRate; +Statistics::Value hostMemory; +Statistics::Value hostSeconds; -Statistics::Formula simInsts; +Statistics::Value simTicks; +Statistics::Value simInsts; +Statistics::Value simFreq; Statistics::Formula simSeconds; -Statistics::Formula simTicks; namespace Statistics { @@ -84,6 +86,7 @@ void InitSimStats() { simInsts + .functor(BaseCPU::numSimulatedInstructions) .name("sim_insts") .desc("Number of instructions simulated") .precision(0) @@ -95,7 +98,14 @@ InitSimStats() .desc("Number of seconds simulated") ; + simFreq + .scalar(ticksPerSecond) + .name("sim_freq") + .desc("Frequency of simulated ticks") + ; + simTicks + .scalar(curTick) .name("sim_ticks") .desc("Number of ticks simulated") ; @@ -108,12 +118,14 @@ InitSimStats() ; hostMemory + .functor(memUsage) .name("host_mem_usage") .desc("Number of bytes of host memory used") .prereq(hostMemory) ; hostSeconds + .functor(statElapsedTime) .name("host_seconds") .desc("Real time elapsed on the host") .precision(2) @@ -125,11 +137,7 @@ InitSimStats() .precision(0) ; - simInsts = constant(0); - simTicks = scalar(curTick) - scalar(startTick); - simSeconds = simTicks / scalar(ticksPerSecond); - hostMemory = functor(memUsage); - hostSeconds = functor(statElapsedTime); + simSeconds = simTicks / simFreq; hostInstRate = simInsts / hostSeconds; hostTickRate = simTicks / hostSeconds; diff --git a/sim/stats.hh b/sim/stats.hh index b736850e7..c5e791cfb 100644 --- a/sim/stats.hh +++ b/sim/stats.hh @@ -31,11 +31,7 @@ #include "base/statistics.hh" -extern Statistics::Formula simTicks; extern Statistics::Formula simSeconds; -extern Statistics::Formula simInsts; -extern Statistics::Formula hostSeconds; -extern Statistics::Formula hostTickRate; -extern Statistics::Formula hostInstRate; +extern Statistics::Value simTicks; #endif // __SIM_SIM_STATS_HH__ diff --git a/sim/system.cc b/sim/system.cc index 43f43baec..791a092ac 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -30,6 +30,7 @@ #include "targetarch/vtophys.hh" #include "sim/param.hh" #include "sim/system.hh" +#include "base/trace.hh" using namespace std; @@ -41,12 +42,15 @@ System::System(const std::string _name, const uint64_t _init_param, MemoryController *_memCtrl, PhysicalMemory *_physmem, - const bool _bin) + const bool _bin, + const std::vector<string> &binned_fns) + : SimObject(_name), init_param(_init_param), memCtrl(_memCtrl), physmem(_physmem), - bin(_bin) + bin(_bin), + binned_fns(binned_fns) { // add self to global system list systemList.push_back(this); @@ -54,6 +58,31 @@ System::System(const std::string _name, Kernel = new Statistics::MainBin("non TCPIP Kernel stats"); Kernel->activate(); User = new Statistics::MainBin("User stats"); + + int end = binned_fns.size(); + assert(!(end & 1)); + + Statistics::MainBin *Bin; + + fnEvents.resize(end>>1); + + for (int i = 0; i < end; i +=2) { + Bin = new Statistics::MainBin(binned_fns[i]); + fnBins.insert(make_pair(binned_fns[i], Bin)); + + fnEvents[(i>>1)] = new FnEvent(&pcEventQueue, binned_fns[i], this); + + if (binned_fns[i+1] == "null") + populateMap(binned_fns[i], ""); + else + populateMap(binned_fns[i], binned_fns[i+1]); + } + + fnCalls + .name(name() + ":fnCalls") + .desc("all fn calls being tracked") + ; + } else Kernel = NULL; } @@ -61,6 +90,13 @@ System::System(const std::string _name, System::~System() { + if (bin == true) { + int end = fnEvents.size(); + for (int i = 0; i < end; ++i) { + delete fnEvents[i]; + } + fnEvents.clear(); + } } @@ -103,6 +139,45 @@ printSystems() System::printSystems(); } +void +System::populateMap(std::string callee, std::string caller) +{ + multimap<const string, string>::const_iterator i; + i = callerMap.insert(make_pair(callee, caller)); + assert(i != callerMap.end() && "should not fail populating callerMap"); +} + +bool +System::findCaller(std::string callee, std::string caller) const +{ + typedef multimap<const std::string, std::string>::const_iterator iter; + pair<iter, iter> range; + + range = callerMap.equal_range(callee); + for (iter i = range.first; i != range.second; ++i) { + if ((*i).second == caller) + return true; + } + return false; +} + +void +System::dumpState(ExecContext *xc) const +{ + if (xc->swCtx) { + stack<fnCall *> copy(xc->swCtx->callStack); + if (copy.empty()) + return; + DPRINTF(TCPIP, "xc->swCtx, size: %d:\n", copy.size()); + fnCall *top; + DPRINTF(TCPIP, "|| call : %d\n",xc->swCtx->calls); + for (top = copy.top(); !copy.empty(); copy.pop() ) { + top = copy.top(); + DPRINTF(TCPIP, "|| %13s : %s \n", top->name, top->myBin->name()); + } + } +} + Statistics::MainBin * System::getBin(const std::string &name) { diff --git a/sim/system.hh b/sim/system.hh index 0fcdd77cc..08fcfb784 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -35,6 +35,7 @@ #include "base/loader/symtab.hh" #include "base/statistics.hh" #include "cpu/pc_event.hh" +#include "kern/system_events.hh" #include "sim/sim_object.hh" #include "sim/sw_context.hh" @@ -49,17 +50,20 @@ class ExecContext; class System : public SimObject { // lisa's binning stuff - protected: + private: std::map<const std::string, Statistics::MainBin *> fnBins; std::map<const Addr, SWContext *> swCtxMap; + protected: + std::vector<FnEvent *> fnEvents; + public: Statistics::Scalar<> fnCalls; Statistics::MainBin *Kernel; Statistics::MainBin *User; Statistics::MainBin * getBin(const std::string &name); - virtual bool findCaller(std::string, std::string) const = 0; + bool findCaller(std::string, std::string) const; SWContext *findContext(Addr pcb); bool addContext(Addr pcb, SWContext *ctx) { @@ -69,12 +73,16 @@ class System : public SimObject swCtxMap.erase(pcb); return; } - - virtual void dumpState(ExecContext *xc) const = 0; + void dumpState(ExecContext *xc) const; virtual void serialize(std::ostream &os); virtual void unserialize(Checkpoint *cp, const std::string §ion); - // + + + private: + std::multimap<const std::string, std::string> callerMap; + void populateMap(std::string caller, std::string callee); +// public: const uint64_t init_param; @@ -82,6 +90,7 @@ class System : public SimObject PhysicalMemory *physmem; Platform *platform; bool bin; + std::vector<string> binned_fns; PCEventQueue pcEventQueue; @@ -92,7 +101,8 @@ class System : public SimObject public: System(const std::string _name, const uint64_t _init_param, - MemoryController *, PhysicalMemory *, const bool); + MemoryController *, PhysicalMemory *, const bool, + const std::vector<string> &binned_fns); ~System(); virtual Addr getKernelStart() const = 0; |