sim: Remove broken AutoSerialize support from the event queue
Event auto-serialization no longer in use and has been broken ever since the introduction of PDES support almost two years ago. Additionally, serializing the individual event queues is undesirable since it exposes the thread structure of the simulator. What this means in practice is that the number of threads in the simulator must be the same when taking a checkpoint and when loading the checkpoint. This changeset removes support for the AutoSerialize event flag and the associated serialization code.
This commit is contained in:
parent
53001e6e09
commit
05852e698a
4 changed files with 8 additions and 174 deletions
|
@ -282,55 +282,6 @@ Event::unserialize(CheckpointIn &cp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
EventQueue::serialize(CheckpointOut &cp) const
|
|
||||||
{
|
|
||||||
std::list<Event *> eventPtrs;
|
|
||||||
|
|
||||||
int numEvents = 0;
|
|
||||||
Event *nextBin = head;
|
|
||||||
while (nextBin) {
|
|
||||||
Event *nextInBin = nextBin;
|
|
||||||
|
|
||||||
while (nextInBin) {
|
|
||||||
if (nextInBin->flags.isSet(Event::AutoSerialize)) {
|
|
||||||
eventPtrs.push_back(nextInBin);
|
|
||||||
paramOut(cp, csprintf("event%d", numEvents++),
|
|
||||||
nextInBin->name());
|
|
||||||
}
|
|
||||||
nextInBin = nextInBin->nextInBin;
|
|
||||||
}
|
|
||||||
|
|
||||||
nextBin = nextBin->nextBin;
|
|
||||||
}
|
|
||||||
|
|
||||||
SERIALIZE_SCALAR(numEvents);
|
|
||||||
|
|
||||||
for (Event *ev : eventPtrs)
|
|
||||||
ev->serializeSection(cp, ev->name());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
EventQueue::unserialize(CheckpointIn &cp)
|
|
||||||
{
|
|
||||||
int numEvents;
|
|
||||||
UNSERIALIZE_SCALAR(numEvents);
|
|
||||||
|
|
||||||
std::string eventName;
|
|
||||||
for (int i = 0; i < numEvents; i++) {
|
|
||||||
// get the pointer value associated with the event
|
|
||||||
paramIn(cp, csprintf("event%d", i), eventName);
|
|
||||||
|
|
||||||
// create the event based on its pointer value
|
|
||||||
Serializable *obj(Serializable::create(cp, eventName));
|
|
||||||
Event *event(dynamic_cast<Event *>(obj));
|
|
||||||
fatal_if(!event,
|
|
||||||
"Event queue unserialized something that wasn't an event.\n");
|
|
||||||
|
|
||||||
checkpointReschedule(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EventQueue::checkpointReschedule(Event *event)
|
EventQueue::checkpointReschedule(Event *event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,7 +104,12 @@ class EventBase
|
||||||
static const FlagsType Squashed = 0x0001; // has been squashed
|
static const FlagsType Squashed = 0x0001; // has been squashed
|
||||||
static const FlagsType Scheduled = 0x0002; // has been scheduled
|
static const FlagsType Scheduled = 0x0002; // has been scheduled
|
||||||
static const FlagsType AutoDelete = 0x0004; // delete after dispatch
|
static const FlagsType AutoDelete = 0x0004; // delete after dispatch
|
||||||
static const FlagsType AutoSerialize = 0x0008; // must be serialized
|
/**
|
||||||
|
* This used to be AutoSerialize. This value can't be reused
|
||||||
|
* without changing the checkpoint version since the flag field
|
||||||
|
* gets serialized.
|
||||||
|
*/
|
||||||
|
static const FlagsType Reserved0 = 0x0008;
|
||||||
static const FlagsType IsExitEvent = 0x0010; // special exit event
|
static const FlagsType IsExitEvent = 0x0010; // special exit event
|
||||||
static const FlagsType IsMainQueue = 0x0020; // on main event queue
|
static const FlagsType IsMainQueue = 0x0020; // on main event queue
|
||||||
static const FlagsType Initialized = 0x7a40; // somewhat random bits
|
static const FlagsType Initialized = 0x7a40; // somewhat random bits
|
||||||
|
@ -437,7 +442,7 @@ operator!=(const Event &l, const Event &r)
|
||||||
* otherwise they risk being scheduled in the past by
|
* otherwise they risk being scheduled in the past by
|
||||||
* handleAsyncInsertions().
|
* handleAsyncInsertions().
|
||||||
*/
|
*/
|
||||||
class EventQueue : public Serializable
|
class EventQueue
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string objName;
|
std::string objName;
|
||||||
|
@ -643,11 +648,6 @@ class EventQueue : public Serializable
|
||||||
void unlock() { service_mutex.unlock(); }
|
void unlock() { service_mutex.unlock(); }
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
#ifndef SWIG
|
|
||||||
void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
|
|
||||||
void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reschedule an event after a checkpoint.
|
* Reschedule an event after a checkpoint.
|
||||||
*
|
*
|
||||||
|
|
|
@ -445,15 +445,12 @@ void
|
||||||
Globals::serialize(CheckpointOut &cp) const
|
Globals::serialize(CheckpointOut &cp) const
|
||||||
{
|
{
|
||||||
paramOut(cp, "curTick", curTick());
|
paramOut(cp, "curTick", curTick());
|
||||||
paramOut(cp, "numMainEventQueues", numMainEventQueues);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Globals::unserialize(CheckpointIn &cp)
|
Globals::unserialize(CheckpointIn &cp)
|
||||||
{
|
{
|
||||||
paramIn(cp, "curTick", unserializedCurTick);
|
paramIn(cp, "curTick", unserializedCurTick);
|
||||||
paramIn(cp, "numMainEventQueues", numMainEventQueues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Serializable::Serializable()
|
Serializable::Serializable()
|
||||||
|
@ -500,8 +497,6 @@ Serializable::serializeAll(const string &cpt_dir)
|
||||||
outstream << "## checkpoint generated: " << ctime(&t);
|
outstream << "## checkpoint generated: " << ctime(&t);
|
||||||
|
|
||||||
globals.serializeSection(outstream, "Globals");
|
globals.serializeSection(outstream, "Globals");
|
||||||
for (uint32_t i = 0; i < numMainEventQueues; ++i)
|
|
||||||
mainEventQueue[i]->serializeSection(outstream, "MainEventQueue");
|
|
||||||
|
|
||||||
SimObject::serializeAll(outstream);
|
SimObject::serializeAll(outstream);
|
||||||
}
|
}
|
||||||
|
@ -511,10 +506,8 @@ Serializable::unserializeGlobals(CheckpointIn &cp)
|
||||||
{
|
{
|
||||||
globals.unserializeSection(cp, "Globals");
|
globals.unserializeSection(cp, "Globals");
|
||||||
|
|
||||||
for (uint32_t i = 0; i < numMainEventQueues; ++i) {
|
for (uint32_t i = 0; i < numMainEventQueues; ++i)
|
||||||
mainEventQueue[i]->setCurTick(globals.unserializedCurTick);
|
mainEventQueue[i]->setCurTick(globals.unserializedCurTick);
|
||||||
mainEventQueue[i]->unserializeSection(cp, "MainEventQueue");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Serializable::ScopedCheckpointSection::~ScopedCheckpointSection()
|
Serializable::ScopedCheckpointSection::~ScopedCheckpointSection()
|
||||||
|
@ -549,59 +542,6 @@ debug_serialize(const string &cpt_dir)
|
||||||
Serializable::serializeAll(cpt_dir);
|
Serializable::serializeAll(cpt_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SerializableClass member definitions
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Map of class names to SerializableBuilder creation functions.
|
|
||||||
// Need to make this a pointer so we can force initialization on the
|
|
||||||
// first reference; otherwise, some SerializableClass constructors
|
|
||||||
// may be invoked before the classMap constructor.
|
|
||||||
map<string, SerializableClass::CreateFunc> *SerializableClass::classMap = 0;
|
|
||||||
|
|
||||||
// SerializableClass constructor: add mapping to classMap
|
|
||||||
SerializableClass::SerializableClass(const string &className,
|
|
||||||
CreateFunc createFunc)
|
|
||||||
{
|
|
||||||
if (classMap == NULL)
|
|
||||||
classMap = new map<string, SerializableClass::CreateFunc>();
|
|
||||||
|
|
||||||
if ((*classMap)[className])
|
|
||||||
fatal("Error: simulation object class %s redefined\n", className);
|
|
||||||
|
|
||||||
// add className --> createFunc to class map
|
|
||||||
(*classMap)[className] = createFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
Serializable *
|
|
||||||
SerializableClass::createObject(CheckpointIn &cp, const string §ion)
|
|
||||||
{
|
|
||||||
string className;
|
|
||||||
|
|
||||||
if (!cp.find(section, "type", className)) {
|
|
||||||
fatal("Serializable::create: no 'type' entry in section '%s'.\n",
|
|
||||||
section);
|
|
||||||
}
|
|
||||||
|
|
||||||
CreateFunc createFunc = (*classMap)[className];
|
|
||||||
|
|
||||||
if (createFunc == NULL) {
|
|
||||||
fatal("Serializable::create: no create function for class '%s'.\n",
|
|
||||||
className);
|
|
||||||
}
|
|
||||||
|
|
||||||
Serializable *object = createFunc(cp, section);
|
|
||||||
|
|
||||||
assert(object != NULL);
|
|
||||||
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &
|
const std::string &
|
||||||
Serializable::currentSection()
|
Serializable::currentSection()
|
||||||
{
|
{
|
||||||
|
@ -610,15 +550,6 @@ Serializable::currentSection()
|
||||||
return path.top();
|
return path.top();
|
||||||
}
|
}
|
||||||
|
|
||||||
Serializable *
|
|
||||||
Serializable::create(CheckpointIn &cp, const string §ion)
|
|
||||||
{
|
|
||||||
Serializable *object = SerializableClass::createObject(cp, section);
|
|
||||||
object->unserializeSection(cp, section);
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char *CheckpointIn::baseFilename = "m5.cpt";
|
const char *CheckpointIn::baseFilename = "m5.cpt";
|
||||||
|
|
||||||
string CheckpointIn::currentDirectory;
|
string CheckpointIn::currentDirectory;
|
||||||
|
|
|
@ -350,8 +350,6 @@ class Serializable
|
||||||
/** Get the fully-qualified name of the active section */
|
/** Get the fully-qualified name of the active section */
|
||||||
static const std::string ¤tSection();
|
static const std::string ¤tSection();
|
||||||
|
|
||||||
static Serializable *create(CheckpointIn &cp, const std::string §ion);
|
|
||||||
|
|
||||||
static int ckptCount;
|
static int ckptCount;
|
||||||
static int ckptMaxCount;
|
static int ckptMaxCount;
|
||||||
static int ckptPrevCount;
|
static int ckptPrevCount;
|
||||||
|
@ -364,52 +362,6 @@ class Serializable
|
||||||
|
|
||||||
void debug_serialize(const std::string &cpt_dir);
|
void debug_serialize(const std::string &cpt_dir);
|
||||||
|
|
||||||
//
|
|
||||||
// An instance of SerializableClass corresponds to a class derived from
|
|
||||||
// Serializable. The SerializableClass instance serves to bind the string
|
|
||||||
// name (found in the config file) to a function that creates an
|
|
||||||
// instance of the appropriate derived class.
|
|
||||||
//
|
|
||||||
// This would be much cleaner in Smalltalk or Objective-C, where types
|
|
||||||
// are first-class objects themselves.
|
|
||||||
//
|
|
||||||
class SerializableClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Type CreateFunc is a pointer to a function that creates a new
|
|
||||||
// simulation object builder based on a .ini-file parameter
|
|
||||||
// section (specified by the first string argument), a unique name
|
|
||||||
// for the object (specified by the second string argument), and
|
|
||||||
// an optional config hierarchy node (specified by the third
|
|
||||||
// argument). A pointer to the new SerializableBuilder is returned.
|
|
||||||
typedef Serializable *(*CreateFunc)(CheckpointIn &cp,
|
|
||||||
const std::string §ion);
|
|
||||||
|
|
||||||
static std::map<std::string,CreateFunc> *classMap;
|
|
||||||
|
|
||||||
// Constructor. For example:
|
|
||||||
//
|
|
||||||
// SerializableClass baseCacheSerializableClass("BaseCacheSerializable",
|
|
||||||
// newBaseCacheSerializableBuilder);
|
|
||||||
//
|
|
||||||
SerializableClass(const std::string &className, CreateFunc createFunc);
|
|
||||||
|
|
||||||
// create Serializable given name of class and pointer to
|
|
||||||
// configuration hierarchy node
|
|
||||||
static Serializable *createObject(CheckpointIn &cp,
|
|
||||||
const std::string §ion);
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Macros to encapsulate the magic of declaring & defining
|
|
||||||
// SerializableBuilder and SerializableClass objects
|
|
||||||
//
|
|
||||||
|
|
||||||
#define REGISTER_SERIALIZEABLE(CLASS_NAME, OBJ_CLASS) \
|
|
||||||
SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \
|
|
||||||
OBJ_CLASS::createForUnserialize);
|
|
||||||
|
|
||||||
|
|
||||||
class CheckpointIn
|
class CheckpointIn
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue