Make it so that we create a directory for each checkpoint so that
there aren't so many files littering your directory dev/disk_image.cc: Checkpoints now in a directory sim/serialize.hh: Make it so that we create a directory for each checkpoint so that there aren't so many files littering your directory. Remove unused variable --HG-- extra : convert_revision : 261824eee62f7b68f6ae6e3dbd49ad5128ced148
This commit is contained in:
parent
0bd909277d
commit
123d0294b5
3 changed files with 21 additions and 21 deletions
|
@ -405,7 +405,7 @@ CowDiskImage::write(const uint8_t *data, off_t offset)
|
||||||
void
|
void
|
||||||
CowDiskImage::serialize(ostream &os)
|
CowDiskImage::serialize(ostream &os)
|
||||||
{
|
{
|
||||||
string cowFilename = CheckpointFile() + "." + name() + ".cow";
|
string cowFilename = CheckpointDir() + name() + ".cow";
|
||||||
SERIALIZE_SCALAR(cowFilename);
|
SERIALIZE_SCALAR(cowFilename);
|
||||||
save(cowFilename);
|
save(cowFilename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,23 +27,24 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "base/inifile.hh"
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
#include "base/str.hh"
|
#include "base/str.hh"
|
||||||
|
#include "base/trace.hh"
|
||||||
|
#include "sim/config_node.hh"
|
||||||
#include "sim/eventq.hh"
|
#include "sim/eventq.hh"
|
||||||
#include "sim/param.hh"
|
#include "sim/param.hh"
|
||||||
#include "sim/serialize.hh"
|
#include "sim/serialize.hh"
|
||||||
#include "base/inifile.hh"
|
|
||||||
#include "sim/sim_events.hh"
|
#include "sim/sim_events.hh"
|
||||||
#include "sim/sim_object.hh"
|
#include "sim/sim_object.hh"
|
||||||
#include "base/trace.hh"
|
|
||||||
#include "sim/config_node.hh"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -252,8 +253,11 @@ Serializer::serialize()
|
||||||
|
|
||||||
Serializeable::serializer = this;
|
Serializeable::serializer = this;
|
||||||
|
|
||||||
file = CheckpointFile();
|
string dir = CheckpointDir();
|
||||||
string cpt_file = file + ".cpt";
|
if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
|
||||||
|
warn("could mkdir %s\n", dir);
|
||||||
|
|
||||||
|
string cpt_file = dir + "m5.cpt";
|
||||||
output = new ofstream(cpt_file.c_str());
|
output = new ofstream(cpt_file.c_str());
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
*output << "// checkpoint generated: " << ctime(&t);
|
*output << "// checkpoint generated: " << ctime(&t);
|
||||||
|
@ -279,13 +283,11 @@ Serializer::serialize()
|
||||||
|
|
||||||
delete output;
|
delete output;
|
||||||
output = NULL;
|
output = NULL;
|
||||||
file = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SerializeEvent : public Event
|
class SerializeEvent : public Event
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
string file;
|
|
||||||
Tick repeat;
|
Tick repeat;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -314,15 +316,15 @@ SerializeEvent::process()
|
||||||
schedule(curTick + repeat);
|
schedule(curTick + repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
string __CheckpointFileBase;
|
string __CheckpointDirBase;
|
||||||
|
|
||||||
string
|
string
|
||||||
CheckpointFile()
|
CheckpointDir()
|
||||||
{
|
{
|
||||||
if (__CheckpointFileBase.empty())
|
if (__CheckpointDirBase.empty())
|
||||||
return __CheckpointFileBase;
|
return __CheckpointDirBase;
|
||||||
|
|
||||||
return csprintf("%s.%d", __CheckpointFileBase, curTick);
|
return csprintf("%s/m5.%012d/", __CheckpointDirBase, curTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -344,9 +346,9 @@ class SerializeParamContext : public ParamContext
|
||||||
|
|
||||||
SerializeParamContext serialParams("serialize");
|
SerializeParamContext serialParams("serialize");
|
||||||
|
|
||||||
Param<string> serialize_file(&serialParams,
|
Param<string> serialize_dir(&serialParams,
|
||||||
"file",
|
"dir",
|
||||||
"file to write to", "m5");
|
"dir to stick checkpoint in", ".");
|
||||||
|
|
||||||
Param<Counter> serialize_cycle(&serialParams,
|
Param<Counter> serialize_cycle(&serialParams,
|
||||||
"cycle",
|
"cycle",
|
||||||
|
@ -371,7 +373,7 @@ SerializeParamContext::~SerializeParamContext()
|
||||||
void
|
void
|
||||||
SerializeParamContext::checkParams()
|
SerializeParamContext::checkParams()
|
||||||
{
|
{
|
||||||
__CheckpointFileBase = serialize_file;
|
__CheckpointDirBase = serialize_dir;
|
||||||
if (serialize_cycle > 0)
|
if (serialize_cycle > 0)
|
||||||
SetupCheckpoint(serialize_cycle, serialize_period);
|
SetupCheckpoint(serialize_cycle, serialize_period);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,6 @@ class Serializer
|
||||||
protected:
|
protected:
|
||||||
typedef std::list<Serializeable *> serlist_t;
|
typedef std::list<Serializeable *> serlist_t;
|
||||||
serlist_t objects;
|
serlist_t objects;
|
||||||
std::string file;
|
|
||||||
std::ostream *output;
|
std::ostream *output;
|
||||||
std::ostream &out() const;
|
std::ostream &out() const;
|
||||||
|
|
||||||
|
@ -149,7 +148,6 @@ class Serializer
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void serialize();
|
void serialize();
|
||||||
const std::string &filename() const { return file; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -253,7 +251,7 @@ class Checkpoint
|
||||||
// Export checkpoint filename param so other objects can derive
|
// Export checkpoint filename param so other objects can derive
|
||||||
// filenames from it (e.g., memory).
|
// filenames from it (e.g., memory).
|
||||||
//
|
//
|
||||||
std::string CheckpointFile();
|
std::string CheckpointDir();
|
||||||
void SetupCheckpoint(Tick when, Tick period = 0);
|
void SetupCheckpoint(Tick when, Tick period = 0);
|
||||||
|
|
||||||
#endif // __SERIALIZE_HH__
|
#endif // __SERIALIZE_HH__
|
||||||
|
|
Loading…
Reference in a new issue