ruby: Use the const serialize interface in RubySystem
authorAndreas Sandberg <andreas.sandberg@arm.com>
Fri, 28 Aug 2015 09:58:44 +0000 (10:58 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Fri, 28 Aug 2015 09:58:44 +0000 (10:58 +0100)
The new serialization code (kudos to Tim Jones) moves all of the state
mangling in RubySystem to memWriteback. This makes it possible to use
the new const serialization interface.

This changeset moves the cache recorder cleanup from the checkpoint()
method to drainResume() to make checkpointing truly constant and
updates the checkpointing code to use the new interface.

src/mem/ruby/system/System.cc
src/mem/ruby/system/System.hh

index c0008201030e53d61fb48f86556979ebd8540396..fd712a47a3e4024f0815b8a3b82882d1c5e0d0b4 100644 (file)
@@ -235,7 +235,7 @@ RubySystem::writeCompressedTrace(uint8_t *raw_data, string filename,
 }
 
 void
-RubySystem::serializeOld(CheckpointOut &cp)
+RubySystem::serialize(CheckpointOut &cp) const
 {
     // Store the cache-block size, so we are able to restore on systems with a
     // different cache-block size. CacheRecorder depends on the correct
@@ -259,10 +259,17 @@ RubySystem::serializeOld(CheckpointOut &cp)
 
     SERIALIZE_SCALAR(cache_trace_file);
     SERIALIZE_SCALAR(cache_trace_size);
+}
 
-    // Now finished with the cache recorder.
-    delete m_cache_recorder;
-    m_cache_recorder = NULL;
+void
+RubySystem::drainResume()
+{
+    // Delete the cache recorder if it was created in memWriteback()
+    // to checkpoint the current cache state.
+    if (m_cache_recorder) {
+        delete m_cache_recorder;
+        m_cache_recorder = NULL;
+    }
 }
 
 void
index 787e4f4ae5eef8ca3a76fade2e0b09db626c0aa1..a7afac45cb724db157471dec13a2e78aa3f815b9 100644 (file)
@@ -95,8 +95,9 @@ class RubySystem : public ClockedObject
     void resetStats();
 
     void memWriteback();
-    void serializeOld(CheckpointOut &cp) M5_ATTR_OVERRIDE;
+    void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
     void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
+    void drainResume() M5_ATTR_OVERRIDE;
     void process();
     void startup();
     bool functionalRead(Packet *ptr);
@@ -121,11 +122,11 @@ class RubySystem : public ClockedObject
                            uint64 cache_trace_size,
                            uint64 block_size_bytes);
 
-    void readCompressedTrace(std::string filename,
-                             uint8_t *&raw_data,
-                             uint64& uncompressed_trace_size);
-    void writeCompressedTrace(uint8_t *raw_data, std::string file,
-                              uint64 uncompressed_trace_size);
+    static void readCompressedTrace(std::string filename,
+                                    uint8_t *&raw_data,
+                                    uint64& uncompressed_trace_size);
+    static void writeCompressedTrace(uint8_t *raw_data, std::string file,
+                                     uint64 uncompressed_trace_size);
 
   private:
     // configuration parameters