From a1259a4fcf5f1b1c38a7209928a2321cd65daec2 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 20 Feb 2004 15:24:21 -0500 Subject: Add a simple event wrapper class that takes a class pointer and member function and will schedule it for the future. --HG-- extra : convert_revision : f5c5a8df0839e1e10716850c2086862c4a5bc499 --- sim/eventq.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sim') diff --git a/sim/eventq.hh b/sim/eventq.hh index 31bf9d652..60a61fa29 100644 --- a/sim/eventq.hh +++ b/sim/eventq.hh @@ -236,6 +236,20 @@ DelayFunction(Tick when, T *object) new DelayEvent(when, object); } +template +class EventWrapper : public Event +{ + private: + T *object; + + public: + EventWrapper(T *obj, EventQueue *q = &mainEventQueue, + Priority p = Default_Pri) + : Event(q, p), object(obj) + {} + void process() { (object->*F)(); } +}; + /* * Queue of events sorted in time order */ -- cgit v1.2.3 From e067bc751bd13d73dfb0abe31f296140e3e29de9 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Sat, 21 Feb 2004 10:46:31 -0500 Subject: Change order of serialization sim/sim_object.cc: serialize objects in the reverse order of their creation. This causes a SimObject that is dependent on another to be serialized first. For example, the ethernet device writes back some data to physical memory while serializing, so this will cause the physical memory to be serialized after that, preserving the data written back. --HG-- extra : convert_revision : f9a37b63ce777df1cfecefa80f94f8fc69e42448 --- sim/sim_object.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sim') 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); } -- cgit v1.2.3 From 31f82cef41962fb57d343f4a8cd468c87d8204dc Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Sun, 29 Feb 2004 18:49:44 -0500 Subject: Make the progress event work even after restoring from a checkpoint --HG-- extra : convert_revision : 80e31eb26250700ebe3ce5848e570068cc76ef47 --- sim/sim_events.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'sim') 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 -#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 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)); } -- cgit v1.2.3 From ee967995196739b90c0b1c384d7e245d1dffdc80 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Sun, 29 Feb 2004 20:22:32 -0500 Subject: Initial cleanup pass of lisa's function call tracking code. base/statistics.hh: We're getting rid of FS_MEASURE, but for now, we're going to still use a compile time flag to turn on and off binning of statistics. (The flag is STATS_BINNING) cpu/exec_context.cc: cpu/exec_context.hh: kern/tru64/tru64_system.cc: get rid of FS_MEASURE cpu/simple_cpu/simple_cpu.cc: yank the function call tracking code out of the cpu and move it into the software context class itself. kern/tru64/tru64_system.hh: get rid of FS_MEASURE move all of the tacking stuff to the same place. sim/system.hh: cleanup --HG-- extra : convert_revision : 73d3843afe1b3ba0d5445421c39c1148d3f4e7c0 --- sim/system.hh | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) (limited to 'sim') diff --git a/sim/system.hh b/sim/system.hh index 8348a144e..2e0cb3dbf 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -32,14 +32,11 @@ #include #include -#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; @@ -50,11 +47,28 @@ class ExecContext; class System : public SimObject { -#ifdef FS_MEASURE + // lisa's binning stuff protected: std::map fnBins; std::map swCtxMap; -#endif //FS_MEASURE + + public: + Statistics::Scalar fnCalls; + Statistics::MainBin *nonPath; + + 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; public: const uint64_t init_param; @@ -69,11 +83,6 @@ class System : public SimObject virtual int registerExecContext(ExecContext *xc); virtual void replaceExecContext(int xcIndex, ExecContext *xc); -#ifdef FS_MEASURE - Statistics::Scalar fnCalls; - Statistics::MainBin *nonPath; -#endif //FS_MEASURE - public: System(const std::string _name, const uint64_t _init_param, MemoryController *, PhysicalMemory *, const bool); @@ -84,22 +93,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: //////////////////////////////////////////// // -- cgit v1.2.3 From f3861d0cc7d3574f985b3aeb37ddf6038b6c9a11 Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Thu, 4 Mar 2004 21:57:09 -0500 Subject: Overall gist of this is to 'dynamicize' the tracking of functions so you can choose them at the .ini stage rather than at compile time. to do it: in .ini file set binned_fns=foo null bar foo what this says is, track foo when it is called by null (i.e. anything). bin bar only when it is called by foo. essentially, if you have a path of functions to track, the 0th, 2nd, 4th fn listed are the fns to track, and the 1st, 3rd, 5th are their respective callers. base/statistics.hh: turn it back to FS_MEASURE since we already have a build in place kern/tru64/tru64_events.cc: remove FS_MEASURE #defs. add more DPRINTF's. manage an anomaly that happens when tracking idle_thread. kern/tru64/tru64_events.hh: remove FS_MEASURE #defs kern/tru64/tru64_system.cc: make DumpState print all the time, but only with DPRINTF. add a new parameter to tru64System a vector binned_fns, to read in from .ini file. now all this binning stuff is dynamically generated. kern/tru64/tru64_system.hh: remove all static binning stuff, add support for dynamic sim/system.cc: change nonPath bin name to Kernel, remove FS_MEASURE sim/system.hh: change nonPath to Kernel --HG-- extra : convert_revision : 9ee813c0a64273bab4125815b7bc8145c5897ec1 --- sim/system.cc | 10 +++------- sim/system.hh | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'sim') diff --git a/sim/system.cc b/sim/system.cc index db93250ee..36275f400 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -50,13 +50,11 @@ 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(); } else - nonPath = NULL; -#endif + Kernel = NULL; } @@ -104,7 +102,6 @@ printSystems() System::printSystems(); } -#ifdef FS_MEASURE Statistics::MainBin * System::getBin(const std::string &name) { @@ -127,7 +124,6 @@ System::findContext(Addr pcb) } else return NULL; } -#endif //FS_MEASURE DEFINE_SIM_OBJECT_CLASS_NAME("System", System) diff --git a/sim/system.hh b/sim/system.hh index 2e0cb3dbf..aba5f2590 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -54,7 +54,7 @@ class System : public SimObject public: Statistics::Scalar fnCalls; - Statistics::MainBin *nonPath; + Statistics::MainBin *Kernel; Statistics::MainBin * getBin(const std::string &name); virtual bool findCaller(std::string, std::string) const = 0; -- cgit v1.2.3 From 4fa703f2ec733ccb8b5ffaa741db0b8510fbe188 Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Fri, 5 Mar 2004 05:09:05 -0500 Subject: serialization for binning. it is WAAAAAAAY past my bedtime. cpu/exec_context.cc: sim/system.cc: sim/system.hh: serialization for binning --HG-- extra : convert_revision : f8417794a3a5ec7f2addc9c2da0f48e851899112 --- sim/system.cc | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- sim/system.hh | 4 ++++ 2 files changed, 64 insertions(+), 1 deletion(-) (limited to 'sim') diff --git a/sim/system.cc b/sim/system.cc index 36275f400..fa8e8c463 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -108,7 +108,7 @@ System::getBin(const std::string &name) std::map::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; } @@ -125,5 +125,64 @@ System::findContext(Addr pcb) return NULL; } +void +System::serialize(std::ostream &os) +{ + if (bin == true) { + map::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) { + paramOut(os, csprintf("Addr[%d]",i), (*iter).first); + ctx = (*iter).second; + paramOut(os, csprintf("calls[%d]",i), ctx->calls); + + stack *stack = &(ctx->callStack); + fnCall *top; + int size = stack->size(); + paramOut(os, csprintf("stacksize[%d]",i), size); + for (int j=0; jtop(); + paramOut(os, csprintf("ctx[%d].stackpos[%d]",i,j), top->name); + } + } + } +} + +void +System::unserialize(Checkpoint *cp, const std::string §ion) +{ + if (bin == true) { + int numCtxs; + UNSERIALIZE_SCALAR(numCtxs); + + SWContext *ctxs = new SWContext[numCtxs]; + Addr addr; + int size; + for(int i = 0; i < numCtxs; ++i) { + paramIn(cp, section, csprintf("Addr[%d]",i), addr); + paramIn(cp, section, csprintf("calls[%d]",i), ctxs[i].calls); + + paramIn(cp, section, csprintf("stacksize[%d]",i), size); + fnCall *call = new fnCall[size]; + for (int j = 0; j < size; ++j) { + paramIn(cp, section, csprintf("ctx[%d].stackpos[%d]",i,j), + call[j].name); + call[j].myBin = getBin(call[j].name); + } + + for (int j=size-1; j>=0; --j) { + ctxs[i].callStack.push(&(call[j])); + } + + addContext(addr, &(ctxs[i])); + } + } +} + DEFINE_SIM_OBJECT_CLASS_NAME("System", System) diff --git a/sim/system.hh b/sim/system.hh index aba5f2590..3d6d3fc39 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -70,6 +70,10 @@ class System : public SimObject 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; MemoryController *memCtrl; -- cgit v1.2.3 From 1a300ef60da887fd3e90add708af4344e19770cb Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Fri, 5 Mar 2004 05:38:04 -0500 Subject: small bugfix, forgot to increment iter sim/system.cc: oops, forgot to increment iter. --HG-- extra : convert_revision : 95fcd337d00157ccf072f0eb301b76f280480839 --- sim/system.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sim') diff --git a/sim/system.cc b/sim/system.cc index fa8e8c463..40c841ed5 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -53,6 +53,7 @@ System::System(const std::string _name, if (bin == true) { Kernel = new Statistics::MainBin("non TCPIP Kernel stats"); Kernel->activate(); + User = new Statistics::MainBin("User stats"); } else Kernel = NULL; } @@ -136,7 +137,7 @@ System::serialize(std::ostream &os) int numCtxs = swCtxMap.size(); SERIALIZE_SCALAR(numCtxs); SWContext *ctx; - for (int i = 0; iter != end; ++i) { + 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); -- cgit v1.2.3 From 4992680ea28928b165e9fe16d19f4630c66af173 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 5 Mar 2004 05:44:11 -0500 Subject: add ticks per picosecond --HG-- extra : convert_revision : 1585e7f89340b941e699db6b81080af58500a7c2 --- sim/universe.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sim') 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; -- cgit v1.2.3 From ec6265b044b131fbd9b2b8b97788646c29293d1e Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 5 Mar 2004 05:45:45 -0500 Subject: constructor option to make the wrapped event autodelete --HG-- extra : convert_revision : 8663c874c533685adf21eea968b08b40b7d7b665 --- sim/eventq.hh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sim') diff --git a/sim/eventq.hh b/sim/eventq.hh index 60a61fa29..ed37fd4f4 100644 --- a/sim/eventq.hh +++ b/sim/eventq.hh @@ -243,10 +243,13 @@ class EventWrapper : public Event T *object; public: - EventWrapper(T *obj, EventQueue *q = &mainEventQueue, + 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)(); } }; @@ -324,6 +327,8 @@ inline void Event::schedule(Tick t) { assert(!scheduled()); + assert(t >= curTick); + setFlags(Scheduled); #if TRACING_ON when_scheduled = curTick; -- cgit v1.2.3 From 9c4832714523b01b9fc5b0430b1d34251684c045 Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Fri, 5 Mar 2004 05:54:46 -0500 Subject: forgot to check this in --HG-- extra : convert_revision : 3090da3ab1077736bae52519143b44b08dd5ddb9 --- sim/system.hh | 1 + 1 file changed, 1 insertion(+) (limited to 'sim') diff --git a/sim/system.hh b/sim/system.hh index 3d6d3fc39..e5bf9cdac 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -55,6 +55,7 @@ class System : public SimObject 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; -- cgit v1.2.3 From 12662c0b6d765ccfd9ac17ff810560cea62b2e7a Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Fri, 5 Mar 2004 06:14:33 -0500 Subject: nother fix cpu/exec_context.cc: nother little bug...forgot to pop off stack as i read off it sim/system.cc: forgot to pop off stack as i read off it --HG-- extra : convert_revision : d1f691c0a9f0fa22281c717ee465d8a5f1e45c13 --- sim/system.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sim') diff --git a/sim/system.cc b/sim/system.cc index 40c841ed5..951739462 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -148,7 +148,10 @@ System::serialize(std::ostream &os) paramOut(os, csprintf("stacksize[%d]",i), size); for (int j=0; jtop(); - paramOut(os, csprintf("ctx[%d].stackpos[%d]",i,j), top->name); + paramOut(os, csprintf("ctx[%d].stackpos[%d]",i,j), + top->name); + delete top; + stack->pop(); } } } -- cgit v1.2.3 From 34576de15a3c8f8a50437e5d95b1402722cf9e2b Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Fri, 5 Mar 2004 08:16:33 -0500 Subject: changes that affect post checkpoint runs. cpu/exec_context.cc: you can't delete an element of an array that you newed. oops. kern/tru64/tru64_events.cc: changes to reflect .ini changes, and also b/c es_intr and ipintr can happen at ANY point, even within a current calling path being tracked. sim/system.cc: can't delete an element of a newed array. must new them separately. --HG-- extra : convert_revision : 21573327b7b7f20bf9a3fcfb5854526433e17e17 --- sim/system.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'sim') diff --git a/sim/system.cc b/sim/system.cc index 951739462..43f43baec 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -164,26 +164,31 @@ System::unserialize(Checkpoint *cp, const std::string §ion) int numCtxs; UNSERIALIZE_SCALAR(numCtxs); - SWContext *ctxs = new SWContext[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), ctxs[i].calls); + paramIn(cp, section, csprintf("calls[%d]",i), ctx->calls); paramIn(cp, section, csprintf("stacksize[%d]",i), size); - fnCall *call = new fnCall[size]; + + vector calls; + fnCall *call; for (int j = 0; j < size; ++j) { + call = new fnCall; paramIn(cp, section, csprintf("ctx[%d].stackpos[%d]",i,j), - call[j].name); - call[j].myBin = getBin(call[j].name); + call->name); + call->myBin = getBin(call->name); + calls.push_back(call); } for (int j=size-1; j>=0; --j) { - ctxs[i].callStack.push(&(call[j])); + ctx->callStack.push(calls[j]); } - addContext(addr, &(ctxs[i])); + addContext(addr, ctx); } } } -- cgit v1.2.3