changeset 6a447a3138ef in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=6a447a3138ef
description:
        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.

diffstat:

 src/sim/eventq.cc    |  49 -----------------------------------
 src/sim/eventq.hh    |  14 +++++-----
 src/sim/serialize.cc |  71 +---------------------------------------------------
 src/sim/serialize.hh |  48 -----------------------------------
 4 files changed, 8 insertions(+), 174 deletions(-)

diffs (278 lines):

diff -r 6fc2465b202e -r 6a447a3138ef src/sim/eventq.cc
--- a/src/sim/eventq.cc Tue Sep 01 15:28:44 2015 +0100
+++ b/src/sim/eventq.cc Tue Sep 01 15:28:45 2015 +0100
@@ -283,55 +283,6 @@
 }
 
 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
 EventQueue::checkpointReschedule(Event *event)
 {
     // It's safe to call insert() directly here since this method
diff -r 6fc2465b202e -r 6a447a3138ef src/sim/eventq.hh
--- a/src/sim/eventq.hh Tue Sep 01 15:28:44 2015 +0100
+++ b/src/sim/eventq.hh Tue Sep 01 15:28:45 2015 +0100
@@ -104,7 +104,12 @@
     static const FlagsType Squashed      = 0x0001; // has been squashed
     static const FlagsType Scheduled     = 0x0002; // has been scheduled
     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 IsMainQueue   = 0x0020; // on main event queue
     static const FlagsType Initialized   = 0x7a40; // somewhat random bits
@@ -437,7 +442,7 @@
  * otherwise they risk being scheduled in the past by
  * handleAsyncInsertions().
  */
-class EventQueue : public Serializable
+class EventQueue
 {
   private:
     std::string objName;
@@ -643,11 +648,6 @@
     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.
      *
diff -r 6fc2465b202e -r 6a447a3138ef src/sim/serialize.cc
--- a/src/sim/serialize.cc      Tue Sep 01 15:28:44 2015 +0100
+++ b/src/sim/serialize.cc      Tue Sep 01 15:28:45 2015 +0100
@@ -445,15 +445,12 @@
 Globals::serialize(CheckpointOut &cp) const
 {
     paramOut(cp, "curTick", curTick());
-    paramOut(cp, "numMainEventQueues", numMainEventQueues);
-
 }
 
 void
 Globals::unserialize(CheckpointIn &cp)
 {
     paramIn(cp, "curTick", unserializedCurTick);
-    paramIn(cp, "numMainEventQueues", numMainEventQueues);
 }
 
 Serializable::Serializable()
@@ -500,8 +497,6 @@
     outstream << "## checkpoint generated: " << ctime(&t);
 
     globals.serializeSection(outstream, "Globals");
-    for (uint32_t i = 0; i < numMainEventQueues; ++i)
-        mainEventQueue[i]->serializeSection(outstream, "MainEventQueue");
 
     SimObject::serializeAll(outstream);
 }
@@ -511,10 +506,8 @@
 {
     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]->unserializeSection(cp, "MainEventQueue");
-    }
 }
 
 Serializable::ScopedCheckpointSection::~ScopedCheckpointSection()
@@ -549,59 +542,6 @@
     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 &section)
-{
-    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 &
 Serializable::currentSection()
 {
@@ -610,15 +550,6 @@
     return path.top();
 }
 
-Serializable *
-Serializable::create(CheckpointIn &cp, const string &section)
-{
-    Serializable *object = SerializableClass::createObject(cp, section);
-    object->unserializeSection(cp, section);
-    return object;
-}
-
-
 const char *CheckpointIn::baseFilename = "m5.cpt";
 
 string CheckpointIn::currentDirectory;
diff -r 6fc2465b202e -r 6a447a3138ef src/sim/serialize.hh
--- a/src/sim/serialize.hh      Tue Sep 01 15:28:44 2015 +0100
+++ b/src/sim/serialize.hh      Tue Sep 01 15:28:45 2015 +0100
@@ -350,8 +350,6 @@
     /** Get the fully-qualified name of the active section */
     static const std::string &currentSection();
 
-    static Serializable *create(CheckpointIn &cp, const std::string &section);
-
     static int ckptCount;
     static int ckptMaxCount;
     static int ckptPrevCount;
@@ -364,52 +362,6 @@
 
 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 &section);
-
-    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 &section);
-};
-
-//
-// 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
 {
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to