Update the Memtester, commit a config file/test for it.
[gem5.git] / src / sim / serialize.cc
index 7450d7b7e0e79e4370a35354dedd1231c74ee6af..941f0b1c6f9ef9737990e9b5efc196b3ef87b7cb 100644 (file)
@@ -52,6 +52,9 @@
 #include "sim/sim_exit.hh"
 #include "sim/sim_object.hh"
 
+// For stat reset hack
+#include "sim/stat_control.hh"
+
 using namespace std;
 
 int Serializable::ckptMaxCount = 0;
@@ -231,8 +234,9 @@ Globals::unserialize(Checkpoint *cp)
 }
 
 void
-Serializable::serializeAll()
+Serializable::serializeAll(const std::string &cpt_dir)
 {
+    setCheckpointDir(cpt_dir);
     string dir = Checkpoint::dir();
     if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
             fatal("couldn't mkdir %s\n", dir);
@@ -247,8 +251,9 @@ Serializable::serializeAll()
 }
 
 void
-Serializable::unserializeAll()
+Serializable::unserializeAll(const std::string &cpt_dir)
 {
+    setCheckpointDir(cpt_dir);
     string dir = Checkpoint::dir();
     string cpt_file = dir + Checkpoint::baseFilename;
     string section = "";
@@ -289,9 +294,9 @@ Checkpoint::dir()
 }
 
 void
-debug_serialize()
+debug_serialize(const std::string &cpt_dir)
 {
-    Serializable::serializeAll();
+    Serializable::serializeAll(cpt_dir);
 }
 
 
@@ -402,3 +407,36 @@ Checkpoint::sectionExists(const std::string &section)
 {
     return db->sectionExists(section);
 }
+
+/** Hacked stat reset event */
+
+class StatresetParamContext : public ParamContext
+{
+  public:
+    StatresetParamContext(const string &section);
+    ~StatresetParamContext();
+    void startup();
+};
+
+StatresetParamContext statParams("statsreset");
+
+Param<Tick> reset_cycle(&statParams, "reset_cycle",
+                        "Cycle to reset stats on", 0);
+
+StatresetParamContext::StatresetParamContext(const string &section)
+    : ParamContext(section)
+{ }
+
+StatresetParamContext::~StatresetParamContext()
+{
+}
+
+void
+StatresetParamContext::startup()
+{
+    if (reset_cycle > 0) {
+        Stats::SetupEvent(Stats::Reset, curTick + reset_cycle, 0);
+        cprintf("Stats reset event scheduled for %lli\n",
+                curTick + reset_cycle);
+    }
+}