diff options
author | Lisa Hsu <hsul@eecs.umich.edu> | 2004-03-11 18:52:29 -0500 |
---|---|---|
committer | Lisa Hsu <hsul@eecs.umich.edu> | 2004-03-11 18:52:29 -0500 |
commit | 3bc8cffc75c2e03a6a8fe5f4425940a16405f672 (patch) | |
tree | 1d44dba1a7dbd4aef6fad45753b7607928d3414a /sim | |
parent | 1039028d408d5a374a67d8d3ecc640a0e6559fbb (diff) | |
parent | 2c60d7aa9e4b48f30ab8c48436ff2dfec8e390f2 (diff) | |
download | gem5-3bc8cffc75c2e03a6a8fe5f4425940a16405f672.tar.xz |
merge with m5 head
--HG--
extra : convert_revision : c90339248d1ee74df1c6b90a77ec9ea41f646311
Diffstat (limited to 'sim')
-rw-r--r-- | sim/eventq.hh | 19 | ||||
-rw-r--r-- | sim/sim_events.cc | 24 | ||||
-rw-r--r-- | sim/sim_object.cc | 8 | ||||
-rw-r--r-- | sim/system.cc | 80 | ||||
-rw-r--r-- | sim/system.hh | 54 | ||||
-rw-r--r-- | sim/universe.cc | 2 |
6 files changed, 143 insertions, 44 deletions
diff --git a/sim/eventq.hh b/sim/eventq.hh index 31bf9d652..ed37fd4f4 100644 --- a/sim/eventq.hh +++ b/sim/eventq.hh @@ -236,6 +236,23 @@ DelayFunction(Tick when, T *object) new DelayEvent(when, object); } +template <class T, void (T::* F)()> +class EventWrapper : public Event +{ + private: + T *object; + + public: + EventWrapper(T *obj, bool del = false, EventQueue *q = &mainEventQueue, + Priority p = Default_Pri) + : Event(q, p), object(obj) + { + if (del) + setFlags(AutoDelete); + } + void process() { (object->*F)(); } +}; + /* * Queue of events sorted in time order */ @@ -310,6 +327,8 @@ inline void Event::schedule(Tick t) { assert(!scheduled()); + assert(t >= curTick); + setFlags(Scheduled); #if TRACING_ON when_scheduled = curTick; diff --git a/sim/sim_events.cc b/sim/sim_events.cc index a31da18dd..f7b07359c 100644 --- a/sim/sim_events.cc +++ b/sim/sim_events.cc @@ -28,11 +28,13 @@ #include <string> -#include "sim/param.hh" -#include "sim/eventq.hh" +#include "base/callback.hh" #include "base/hostinfo.hh" +#include "sim/eventq.hh" +#include "sim/param.hh" #include "sim/sim_events.hh" #include "sim/sim_exit.hh" +#include "sim/sim_init.hh" #include "sim/sim_stats.hh" using namespace std; @@ -178,7 +180,7 @@ class ProgressEvent : public Event ProgressEvent::ProgressEvent(EventQueue *q, Tick _interval) : Event(q), interval(_interval) { - schedule(interval); + schedule(curTick + interval); } // @@ -221,10 +223,24 @@ ProgressParamContext progessMessageParams("progress"); Param<Tick> progress_interval(&progessMessageParams, "cycle", "cycle interval for progress messages"); +namespace { + struct SetupProgress : public Callback + { + Tick interval; + SetupProgress(Tick tick) : interval(tick) {} + + virtual void process() + { + new ProgressEvent(&mainEventQueue, interval); + delete this; + } + }; +} + /* check execute options */ void ProgressParamContext::checkParams() { if (progress_interval.isValid()) - new ProgressEvent(&mainEventQueue, progress_interval); + registerInitCallback(new SetupProgress(progress_interval)); } diff --git a/sim/sim_object.cc b/sim/sim_object.cc index b3ac2c7a4..c55021e41 100644 --- a/sim/sim_object.cc +++ b/sim/sim_object.cc @@ -182,11 +182,11 @@ SimObject::printAllExtraOutput(ostream &os) void SimObject::serializeAll(ostream &os) { - SimObjectList::iterator i = simObjectList.begin(); - SimObjectList::iterator end = simObjectList.end(); + SimObjectList::reverse_iterator ri = simObjectList.rbegin(); + SimObjectList::reverse_iterator rend = simObjectList.rend(); - for (; i != end; ++i) { - SimObject *obj = *i; + for (; ri != rend; ++ri) { + SimObject *obj = *ri; obj->nameOut(os); obj->serialize(os); } diff --git a/sim/system.cc b/sim/system.cc index db93250ee..43f43baec 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -50,13 +50,12 @@ System::System(const std::string _name, { // add self to global system list systemList.push_back(this); -#ifdef FS_MEASURE if (bin == true) { - nonPath = new Statistics::MainBin("non TCPIP path stats"); - nonPath->activate(); + Kernel = new Statistics::MainBin("non TCPIP Kernel stats"); + Kernel->activate(); + User = new Statistics::MainBin("User stats"); } else - nonPath = NULL; -#endif + Kernel = NULL; } @@ -104,14 +103,13 @@ printSystems() System::printSystems(); } -#ifdef FS_MEASURE Statistics::MainBin * System::getBin(const std::string &name) { std::map<const std::string, Statistics::MainBin *>::const_iterator i; i = fnBins.find(name); if (i == fnBins.end()) - panic("trying to getBin that is not on system map!"); + panic("trying to getBin %s that is not on system map!", name); return (*i).second; } @@ -127,7 +125,73 @@ System::findContext(Addr pcb) } else return NULL; } -#endif //FS_MEASURE + +void +System::serialize(std::ostream &os) +{ + if (bin == true) { + map<const Addr, SWContext *>::const_iterator iter, end; + iter = swCtxMap.begin(); + end = swCtxMap.end(); + + int numCtxs = swCtxMap.size(); + SERIALIZE_SCALAR(numCtxs); + SWContext *ctx; + for (int i = 0; iter != end; ++i, ++iter) { + paramOut(os, csprintf("Addr[%d]",i), (*iter).first); + ctx = (*iter).second; + paramOut(os, csprintf("calls[%d]",i), ctx->calls); + + stack<fnCall *> *stack = &(ctx->callStack); + fnCall *top; + int size = stack->size(); + paramOut(os, csprintf("stacksize[%d]",i), size); + for (int j=0; j<size; ++j) { + top = stack->top(); + paramOut(os, csprintf("ctx[%d].stackpos[%d]",i,j), + top->name); + delete top; + stack->pop(); + } + } + } +} + +void +System::unserialize(Checkpoint *cp, const std::string §ion) +{ + if (bin == true) { + int numCtxs; + UNSERIALIZE_SCALAR(numCtxs); + + SWContext *ctx; + Addr addr; + int size; + for(int i = 0; i < numCtxs; ++i) { + ctx = new SWContext; + paramIn(cp, section, csprintf("Addr[%d]",i), addr); + paramIn(cp, section, csprintf("calls[%d]",i), ctx->calls); + + paramIn(cp, section, csprintf("stacksize[%d]",i), size); + + vector<fnCall *> calls; + fnCall *call; + for (int j = 0; j < size; ++j) { + call = new fnCall; + paramIn(cp, section, csprintf("ctx[%d].stackpos[%d]",i,j), + call->name); + call->myBin = getBin(call->name); + calls.push_back(call); + } + + for (int j=size-1; j>=0; --j) { + ctx->callStack.push(calls[j]); + } + + addContext(addr, ctx); + } + } +} DEFINE_SIM_OBJECT_CLASS_NAME("System", System) diff --git a/sim/system.hh b/sim/system.hh index e5d990e86..7b011aa8f 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -32,14 +32,11 @@ #include <string> #include <vector> -#include "sim/sim_object.hh" -#include "cpu/pc_event.hh" #include "base/loader/symtab.hh" - -#ifdef FS_MEASURE #include "base/statistics.hh" +#include "cpu/pc_event.hh" +#include "sim/sim_object.hh" #include "sim/sw_context.hh" -#endif class MemoryController; class PhysicalMemory; @@ -51,11 +48,33 @@ class ExecContext; class System : public SimObject { -#ifdef FS_MEASURE + // lisa's binning stuff protected: std::map<const std::string, Statistics::MainBin *> fnBins; std::map<const Addr, SWContext *> swCtxMap; -#endif //FS_MEASURE + + public: + Statistics::Scalar<Counter> fnCalls; + Statistics::MainBin *Kernel; + Statistics::MainBin *User; + + Statistics::MainBin * getBin(const std::string &name); + virtual bool findCaller(std::string, std::string) const = 0; + + SWContext *findContext(Addr pcb); + bool addContext(Addr pcb, SWContext *ctx) { + return (swCtxMap.insert(make_pair(pcb, ctx))).second; + } + void remContext(Addr pcb) { + swCtxMap.erase(pcb); + return; + } + + virtual void dumpState(ExecContext *xc) const = 0; + + virtual void serialize(std::ostream &os); + virtual void unserialize(Checkpoint *cp, const std::string §ion); + // public: const uint64_t init_param; @@ -71,11 +90,6 @@ class System : public SimObject virtual int registerExecContext(ExecContext *xc); virtual void replaceExecContext(int xcIndex, ExecContext *xc); -#ifdef FS_MEASURE - Statistics::Scalar<Counter, Statistics::MainBin> fnCalls; - Statistics::MainBin *nonPath; -#endif //FS_MEASURE - public: System(const std::string _name, const uint64_t _init_param, MemoryController *, PhysicalMemory *, const bool); @@ -86,22 +100,6 @@ class System : public SimObject virtual Addr getKernelEntry() const = 0; virtual bool breakpoint() = 0; -#ifdef FS_MEASURE - Statistics::MainBin * getBin(const std::string &name); - virtual bool findCaller(std::string, std::string) const = 0; - - SWContext *findContext(Addr pcb); - bool addContext(Addr pcb, SWContext *ctx) { - return (swCtxMap.insert(make_pair(pcb, ctx))).second; - } - void remContext(Addr pcb) { - swCtxMap.erase(pcb); - return; - } - - virtual void dumpState(ExecContext *xc) const = 0; -#endif //FS_MEASURE - public: //////////////////////////////////////////// // diff --git a/sim/universe.cc b/sim/universe.cc index feede514e..d6c849ac7 100644 --- a/sim/universe.cc +++ b/sim/universe.cc @@ -47,6 +47,7 @@ Tick ticksPerSecond; double __ticksPerMS; double __ticksPerUS; double __ticksPerNS; +double __ticksPerPS; string outputDirectory; ostream *outputStream; @@ -79,6 +80,7 @@ UniverseParamContext::checkParams() __ticksPerMS = freq / 1.0e3; __ticksPerUS = freq / 1.0e6; __ticksPerNS = freq / 1.0e9; + __ticksPerPS = freq / 1.0e12; if (universe_output_dir.isValid()) { outputDirectory = universe_output_dir; |