diff options
author | Nathan Binkert <binkertn@umich.edu> | 2005-06-22 09:59:13 -0400 |
---|---|---|
committer | Nathan Binkert <binkertn@umich.edu> | 2005-06-22 09:59:13 -0400 |
commit | 91f5736fd3fe989a7d5f3db10070fdedea36e1b4 (patch) | |
tree | fd62e362e7024addd0ec893d4fc9a6d19a12e2f8 | |
parent | 1331a723c3113497deb63d0503ab49709d64b0c2 (diff) | |
download | gem5-91f5736fd3fe989a7d5f3db10070fdedea36e1b4.tar.xz |
Move max_time and progress_interval parameters to the Root
object and get rid of the ParamContext that each used to have.
python/m5/objects/Root.py:
Add max_time and progress_interval to the Root object
sim/root.cc:
Add max_time and progress_interval to the Root object. These
parameters used to be in their own contexts in sim_events.cc
sim/sim_events.cc:
Get rid of the ParamContext for max cycles and the progress
event. Move the functionality to the Root object
sim/sim_events.hh:
Move ProgressEvent declaration to the header so that it can
be used in other files.
--HG--
extra : convert_revision : ff664b806855e8eb9201b8a25392aa53204464f0
-rw-r--r-- | python/m5/objects/Root.py | 3 | ||||
-rw-r--r-- | sim/root.cc | 27 | ||||
-rw-r--r-- | sim/sim_events.cc | 82 | ||||
-rw-r--r-- | sim/sim_events.hh | 29 |
4 files changed, 52 insertions, 89 deletions
diff --git a/python/m5/objects/Root.py b/python/m5/objects/Root.py index 79e3721fc..a5aaadd8c 100644 --- a/python/m5/objects/Root.py +++ b/python/m5/objects/Root.py @@ -7,6 +7,9 @@ from Trace import Trace class Root(SimObject): type = 'Root' clock = Param.RootClock('200MHz', "tick frequency") + max_time = Param.Latency('0ns', "maximum simulation time (0 = infinite)") + progress_interval = Param.Latency('0ns', + "print a progress message at a regular interval (0 = never)") output_file = Param.String('cout', "file to dump simulator output to") checkpoint = Param.String('', "checkpoint file to load") # hier = Param.HierParams(HierParams(do_data = False, do_events = True), diff --git a/sim/root.cc b/sim/root.cc index fcfde20d1..17438cf2c 100644 --- a/sim/root.cc +++ b/sim/root.cc @@ -36,6 +36,7 @@ #include "base/output.hh" #include "sim/builder.hh" #include "sim/host.hh" +#include "sim/sim_events.hh" #include "sim/sim_object.hh" #include "sim/root.hh" @@ -79,13 +80,33 @@ Tick ps; // Dummy Object class Root : public SimObject { + private: + Tick max_time; + Tick progress_interval; + public: - Root(const std::string &name) : SimObject(name) {} + Root(const std::string &name, Tick maxtime, Tick pi) + : SimObject(name), max_time(maxtime), progress_interval(pi) + {} + + virtual void startup(); }; +void +Root::startup() +{ + if (max_time != 0) + new SimExitEvent(curTick + max_time, "reached maximum cycle count"); + + if (progress_interval != 0) + new ProgressEvent(&mainEventQueue, progress_interval); +} + BEGIN_DECLARE_SIM_OBJECT_PARAMS(Root) Param<Tick> clock; + Param<Tick> max_time; + Param<Tick> progress_interval; Param<string> output_file; END_DECLARE_SIM_OBJECT_PARAMS(Root) @@ -93,6 +114,8 @@ END_DECLARE_SIM_OBJECT_PARAMS(Root) BEGIN_INIT_SIM_OBJECT_PARAMS(Root) INIT_PARAM(clock, "tick frequency"), + INIT_PARAM(max_time, "maximum simulation time"), + INIT_PARAM(progress_interval, "print a progress message"), INIT_PARAM(output_file, "file to dump simulator output to") END_INIT_SIM_OBJECT_PARAMS(Root) @@ -106,7 +129,7 @@ CREATE_SIM_OBJECT(Root) created = true; outputStream = simout.find(output_file); - Root *root = new Root(getInstanceName()); + Root *root = new Root(getInstanceName(), max_time, progress_interval); using namespace Clock; Frequency = clock; diff --git a/sim/sim_events.cc b/sim/sim_events.cc index 55bb3c305..c2bdca9df 100644 --- a/sim/sim_events.cc +++ b/sim/sim_events.cc @@ -129,60 +129,6 @@ CheckSwapEvent::description() return "check swap"; } - -/////////////////////////////////////////////////// -// -// Simulation termination parameters -// -/////////////////////////////////////////////////// - -class TermParamContext : public ParamContext -{ - public: - TermParamContext(const string &_iniSection) - : ParamContext(_iniSection) {} - void checkParams(); -}; - -TermParamContext simTerminationParams("max"); - -Param<Tick> max_cycle(&simTerminationParams, "cycle", - "maximum number of cycles to execute"); - -void -TermParamContext::checkParams() -{ - // if a max cycle count was specified, put a termination event on - // the event queue at that point - if (max_cycle.isValid()) - new SimExitEvent(max_cycle, "reached maximum cycle count"); -} - -// -// Progress event: print out cycle every so often so we know we're -// making forward progress. -// -class ProgressEvent : public Event -{ - protected: - Tick interval; - - public: - ProgressEvent(EventQueue *q, Tick interval); - - void process(); // process event - virtual const char *description(); -}; - -// -// constructor: schedule at specified time -// -ProgressEvent::ProgressEvent(EventQueue *q, Tick _interval) - : Event(q), interval(_interval) -{ - schedule(curTick + interval); -} - // // handle progress event: print message and reschedule // @@ -200,31 +146,3 @@ ProgressEvent::description() { return "progress message"; } - -///////// -// -// Periodic progress message support: print out a message every n -// cycles so we know we're making forward progress. -// -///////// - -// Parameter space for execution address tracing options. Derive -// from ParamContext so we can override checkParams() function. -struct ProgressParamContext : public ParamContext -{ - ProgressParamContext(const string &_iniSection) - : ParamContext(_iniSection) {} - void startup(); -}; - -ProgressParamContext progessMessageParams("progress"); - -Param<Tick> progress_interval(&progessMessageParams, "cycle", - "cycle interval for progress messages"); - -void -ProgressParamContext::startup() -{ - if (progress_interval.isValid()) - new ProgressEvent(&mainEventQueue, progress_interval); -} diff --git a/sim/sim_events.hh b/sim/sim_events.hh index 091d4db61..c93914457 100644 --- a/sim/sim_events.hh +++ b/sim/sim_events.hh @@ -26,8 +26,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __SIM_EVENTS_HH__ -#define __SIM_EVENTS_HH__ +#ifndef __SIM_SIM_EVENTS_HH__ +#define __SIM_SIM_EVENTS_HH__ #include "sim/eventq.hh" @@ -87,7 +87,7 @@ class CountedExitEvent : public Event }; // -// Event to cause a statistics dump +// Event to check swap usage // class CheckSwapEvent : public Event { @@ -97,11 +97,30 @@ class CheckSwapEvent : public Event public: CheckSwapEvent(EventQueue *q, int ival) : Event(q), interval(ival) - { schedule(interval); } + { schedule(curTick + interval); } void process(); // process event virtual const char *description(); }; -#endif // __SIM_EVENTS_HH__ +// +// Progress event: print out cycle every so often so we know we're +// making forward progress. +// +class ProgressEvent : public Event +{ + protected: + Tick interval; + + public: + ProgressEvent(EventQueue *q, Tick ival) + : Event(q), interval(ival) + { schedule(curTick + interval); } + + void process(); // process event + + virtual const char *description(); +}; + +#endif // __SIM_SIM_EVENTS_HH__ |