summaryrefslogtreecommitdiff
path: root/sim/serialize.cc
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2003-11-02 18:02:58 -0500
committerNathan Binkert <binkertn@umich.edu>2003-11-02 18:02:58 -0500
commit667cbb6690b1f4af68ab7dad8caed8cdf107a090 (patch)
tree69f9843c46d0b6f3d6831311f0eec28719726b3f /sim/serialize.cc
parent3e87070209b5c4003ac643b5ba6c3081ff0454fe (diff)
downloadgem5-667cbb6690b1f4af68ab7dad8caed8cdf107a090.tar.xz
Implement more m5 pseduo opcodes:
resetstats dumpstats dumpresetstats m5checkpoint Lots of cleanup of serialization and stats dumping/resetting to work with these new instructions arch/alpha/isa_desc: Implement more m5 pseduo opcodes: resetstats dumpstats dumpresetstats m5checkpoint All of these functions take two optional parameters, the first is a delay, and the second is a period. The delay tells the simulator to wait the specified number of nanoseconds before triggering the event, the period tells the simulator to repeat the event with a specified frequency base/statistics.cc: base/statistics.hh: regReset RegResetCallback dev/disk_image.cc: serializeFilename -> CheckpointFile() sim/debug.cc: Move this debugging statement to sim_stats.cc sim/eventq.cc: Don't AutoDelete an event if it is scheduled since the process() function could potentially schedule the event again. sim/main.cc: DumpStatsEvent is now Statistics::SetupEvent(Dump, curTick) sim/serialize.cc: Change the serialize event so that it's possible to cause the event to repeat. Also make the priority such that the event happens just before the simulator would exit if both events were scheduled for the same cycle. get rid of the serializeFilename variable and provide a CheckpointFile() function. This function takes a basename that is set in the configuration, and appends the current cycle to the name so that multiple checkpoints can be dumped from the same simulation. Also, don't exit the simulation when a checkpoint file is dumped. sim/serialize.hh: serializeFilename -> CheckpointFile() SetupCheckpoint function to tell the simulator to prepare to checkpoint at a certain time with a certain period sim/sim_events.cc: DumpStatsEvent stuff gets move to sim_stats.(cc|hh) The context stuff gets moved into the already existing stats context in stat_context.cc sim/sim_events.hh: DumpStatsEvent stuff gets move to sim_stats.(cc|hh) sim/universe.cc: Provide some simple functions for converting times into ticks. These use floating point math to get as close as possible to the real values. Multipliers are set up ahead of time --HG-- extra : convert_revision : d06ef26a9237529a1e5060cb1ac2dcc04d4ec252
Diffstat (limited to 'sim/serialize.cc')
-rw-r--r--sim/serialize.cc79
1 files changed, 47 insertions, 32 deletions
diff --git a/sim/serialize.cc b/sim/serialize.cc
index 84d400e16..bd528c678 100644
--- a/sim/serialize.cc
+++ b/sim/serialize.cc
@@ -245,14 +245,14 @@ Serializer::add_objects()
}
void
-Serializer::serialize(const string &f)
+Serializer::serialize()
{
if (Serializeable::serializer != NULL)
panic("in process of serializing!");
Serializeable::serializer = this;
- file = f;
+ file = CheckpointFile();
string cpt_file = file + ".cpt";
output = new ofstream(cpt_file.c_str());
time_t t = time(NULL);
@@ -286,38 +286,49 @@ class SerializeEvent : public Event
{
protected:
string file;
+ Tick repeat;
public:
- SerializeEvent(EventQueue *q, Tick when, const string &file);
- ~SerializeEvent();
-
+ SerializeEvent(Tick _when, Tick _repeat);
virtual void process();
- virtual void serialize(std::ostream &os);
+ virtual void serialize(std::ostream &os)
+ {
+ panic("Cannot serialize the SerializeEvent");
+ }
+
};
-SerializeEvent::SerializeEvent(EventQueue *q, Tick when, const string &f)
- : Event(q), file(f)
+SerializeEvent::SerializeEvent(Tick _when, Tick _repeat)
+ : Event(&mainEventQueue, 990), repeat(_repeat)
{
setFlags(AutoDelete);
- schedule(when);
-}
-
-SerializeEvent::~SerializeEvent()
-{
+ schedule(_when);
}
void
SerializeEvent::process()
{
Serializer serial;
- serial.serialize(file);
- new SimExitEvent("Serialization caused exit");
+ serial.serialize();
+ if (repeat)
+ schedule(curTick + repeat);
+}
+
+string __CheckpointFileBase;
+
+string
+CheckpointFile()
+{
+ if (__CheckpointFileBase.empty())
+ return __CheckpointFileBase;
+
+ return csprintf("%s.%d", __CheckpointFileBase, curTick);
}
void
-SerializeEvent::serialize(ostream &os)
+SetupCheckpoint(Tick when, Tick period)
{
- panic("Cannot serialize the SerializeEvent");
+ new SerializeEvent(when, period);
}
class SerializeParamContext : public ParamContext
@@ -333,18 +344,21 @@ class SerializeParamContext : public ParamContext
SerializeParamContext serialParams("serialize");
+Param<string> serialize_file(&serialParams,
+ "file",
+ "file to write to", "m5");
+
Param<Counter> serialize_cycle(&serialParams,
"cycle",
"cycle to serialize",
0);
-Param<string> serialize_file(&serialParams,
- "file",
- "file to write to", "");
+Param<Counter> serialize_period(&serialParams,
+ "period",
+ "period to repeat serializations",
+ 0);
+
-// Copy filename into regular string so we can export it without
-// having to include param.hh all over the place.
-string serializeFilename;
SerializeParamContext::SerializeParamContext(const string &section)
: ParamContext(section), event(NULL)
@@ -357,22 +371,23 @@ SerializeParamContext::~SerializeParamContext()
void
SerializeParamContext::checkParams()
{
- serializeFilename = serialize_file;
- if (!serializeFilename.empty() && serialize_cycle > 0)
- event = new SerializeEvent(&mainEventQueue, serialize_cycle,
- serializeFilename);
+ __CheckpointFileBase = serialize_file;
+ if (serialize_cycle > 0)
+ SetupCheckpoint(serialize_cycle, serialize_period);
}
void
-debug_serialize(const char *file)
+debug_serialize()
{
Serializer serial;
- serial.serialize(file);
- new SimExitEvent("Serialization caused exit");
+ serial.serialize();
}
-
-
+void
+debug_serialize(Tick when)
+{
+ new SerializeEvent(when, 0);
+}
////////////////////////////////////////////////////////////////////////
//