/*
- * Copyright (c) 2002-2004 The Regents of The University of Michigan
+ * Copyright (c) 2002-2005 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include "base/inifile.hh"
#include "base/misc.hh"
+#include "base/output.hh"
#include "base/str.hh"
#include "base/trace.hh"
#include "sim/config_node.hh"
#include "sim/param.hh"
#include "sim/serialize.hh"
#include "sim/sim_events.hh"
+#include "sim/sim_exit.hh"
#include "sim/sim_object.hh"
using namespace std;
+int Serializable::maxCount = 0;
+int Serializable::count = 0;
+
void
Serializable::nameOut(ostream &os)
{
arrayParamIn(Checkpoint *cp, const std::string §ion, \
const std::string &name, type *param, int size);
-
-INSTANTIATE_PARAM_TEMPLATES(int8_t)
-INSTANTIATE_PARAM_TEMPLATES(uint8_t)
-INSTANTIATE_PARAM_TEMPLATES(int16_t)
-INSTANTIATE_PARAM_TEMPLATES(uint16_t)
-INSTANTIATE_PARAM_TEMPLATES(int32_t)
-INSTANTIATE_PARAM_TEMPLATES(uint32_t)
-INSTANTIATE_PARAM_TEMPLATES(int64_t)
-INSTANTIATE_PARAM_TEMPLATES(uint64_t)
+INSTANTIATE_PARAM_TEMPLATES(signed char)
+INSTANTIATE_PARAM_TEMPLATES(unsigned char)
+INSTANTIATE_PARAM_TEMPLATES(signed short)
+INSTANTIATE_PARAM_TEMPLATES(unsigned short)
+INSTANTIATE_PARAM_TEMPLATES(signed int)
+INSTANTIATE_PARAM_TEMPLATES(unsigned int)
+INSTANTIATE_PARAM_TEMPLATES(signed long)
+INSTANTIATE_PARAM_TEMPLATES(unsigned long)
+INSTANTIATE_PARAM_TEMPLATES(signed long long)
+INSTANTIATE_PARAM_TEMPLATES(unsigned long long)
INSTANTIATE_PARAM_TEMPLATES(bool)
INSTANTIATE_PARAM_TEMPLATES(string)
globals.serialize(outstream);
SimObject::serializeAll(outstream);
+
+ if (maxCount && ++count >= maxCount)
+ SimExit(curTick + 1, "Maximum number of checkpoints dropped");
}
"period to repeat serializations",
0);
-
+Param<int> serialize_count(&serialParams, "count",
+ "maximum number of checkpoints to drop");
SerializeParamContext::SerializeParamContext(const string §ion)
: ParamContext(section), event(NULL)
void
SerializeParamContext::checkParams()
{
- if (serialize_dir.isValid()) {
- checkpointDirBase = serialize_dir;
- } else {
- checkpointDirBase = outputDirectory + "cpt.%012d";
- }
+ checkpointDirBase = simout.resolve(serialize_dir);
// guarantee that directory ends with a '/'
if (checkpointDirBase[checkpointDirBase.size() - 1] != '/')
if (serialize_cycle > 0)
Checkpoint::setup(serialize_cycle, serialize_period);
+
+ Serializable::maxCount = serialize_count;
}
void