diff -r 8a50ef5b803e -r fc6a443e8899 src/mem/ruby/system/CacheRecorder.cc --- a/src/mem/ruby/system/CacheRecorder.cc Tue Jun 23 13:54:46 2015 +0100 +++ b/src/mem/ruby/system/CacheRecorder.cc Tue Jun 23 14:24:34 2015 +0100 @@ -95,6 +95,8 @@ m_sequencer_ptr->makeRequest(pkt); DPRINTF(RubyCacheTrace, "Flushing %s\n", *rec); + } else { + DPRINTF(RubyCacheTrace, "Flushed all %d records\n", m_records_flushed); } } @@ -137,6 +139,8 @@ m_bytes_read += (sizeof(TraceRecord) + m_block_size_bytes); m_records_read++; + } else { + DPRINTF(RubyCacheTrace, "Fetched all %d records\n", m_records_read); } } diff -r 8a50ef5b803e -r fc6a443e8899 src/mem/ruby/system/System.cc --- a/src/mem/ruby/system/System.cc Tue Jun 23 13:54:46 2015 +0100 +++ b/src/mem/ruby/system/System.cc Tue Jun 23 14:24:34 2015 +0100 @@ -81,6 +81,9 @@ // Create the profiler m_profiler = new Profiler(p); m_phys_mem = p->phys_mem; + + // Should be serialized first (to flush memory). + serializePriority(1); } void @@ -171,6 +174,14 @@ } DPRINTF(RubyCacheTrace, "Cache Trace Complete\n"); + + // Deschedule the simulate limit event. We're going to remove events from + // the event queue temporarily in a moment with a call to replaceHead() and + // once we do that the simulate limit event will not be on any queue, but + // will think that it is. When we call simulate() this will cause problems + // as it tries to be rescheduled and the event queue can't find it. + simulate_limit_event->deschedule(); + // save the current tick value Tick curtick_original = curTick(); // save the event queue head @@ -184,6 +195,8 @@ simulate(); DPRINTF(RubyCacheTrace, "Cache flush complete\n"); + // Deschedule the simulate limit event again. + simulate_limit_event->deschedule(); // Restore eventq head eventq_head = eventq->replaceHead(eventq_head); // Restore curTick @@ -296,6 +309,7 @@ // state was checkpointed. if (m_warmup_enabled) { + DPRINTF(RubyCacheTrace, "Starting ruby cache warmup\n"); // save the current tick value Tick curtick_original = curTick(); // save the event queue head diff -r 8a50ef5b803e -r fc6a443e8899 src/sim/sim_object.hh --- a/src/sim/sim_object.hh Tue Jun 23 13:54:46 2015 +0100 +++ b/src/sim/sim_object.hh Tue Jun 23 14:24:34 2015 +0100 @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -90,6 +91,9 @@ /** List of all instantiated simulation objects. */ static SimObjectList simObjectList; + /** To order serialization, keep a set of priorities requested. */ + static std::set serializePriorities; + /** Manager coordinates hooking up probe points with listeners. */ ProbeManager *probeManager; @@ -97,6 +101,15 @@ /** Cached copy of the object parameters. */ const SimObjectParams *_params; + /** Priority for serializing, higher is earlier. */ + int _serializePriority; + + /** Set the serialization priority. */ + void serializePriority(int priority); + + /** Get the serialization priority. */ + int serializePriority() const { return _serializePriority; } + public: typedef SimObjectParams Params; const Params *params() const { return _params; } diff -r 8a50ef5b803e -r fc6a443e8899 src/sim/sim_object.cc --- a/src/sim/sim_object.cc Tue Jun 23 13:54:46 2015 +0100 +++ b/src/sim/sim_object.cc Tue Jun 23 14:24:34 2015 +0100 @@ -30,7 +30,11 @@ * Nathan Binkert */ +#include "sim/sim_object.hh" + #include +#include +#include #include "base/callback.hh" #include "base/inifile.hh" @@ -40,7 +44,6 @@ #include "base/types.hh" #include "debug/Checkpoint.hh" #include "sim/probe/probe.hh" -#include "sim/sim_object.hh" #include "sim/stats.hh" using namespace std; @@ -58,6 +61,11 @@ SimObject::SimObjectList SimObject::simObjectList; // +// Static set of all serialize priorities seen +// +set SimObject::serializePriorities; + +// // SimObject constructor: used to maintain static simObjectList // SimObject::SimObject(const Params *p) @@ -68,6 +76,7 @@ #endif simObjectList.push_back(this); probeManager = new ProbeManager(this); + serializePriority(0); } SimObject::~SimObject() @@ -142,14 +151,31 @@ void SimObject::serializeAll(std::ostream &os) { + // Map priorities to lists of objects with that priority. + map priorityMap; SimObjectList::reverse_iterator ri = simObjectList.rbegin(); SimObjectList::reverse_iterator rend = simObjectList.rend(); - for (; ri != rend; ++ri) { SimObject *obj = *ri; - obj->nameOut(os); - obj->serialize(os); - } + priorityMap[obj->serializePriority()].push_back(obj); + } + + // Serialize based on priority. + int numSerialized = 0; + set::reverse_iterator pi = serializePriorities.rbegin(); + set::reverse_iterator pend = serializePriorities.rend(); + for (; pi != pend; ++pi) { + int priority = *pi; + SimObjectList::iterator si = priorityMap[priority].begin(); + SimObjectList::iterator send = priorityMap[priority].end(); + for (; si != send; ++si) { + SimObject *obj = *si; + obj->nameOut(os); + obj->serialize(os); + numSerialized += 1; + } + } + assert(numSerialized == simObjectList.size()); } @@ -199,3 +225,10 @@ return NULL; } + +void +SimObject::serializePriority(int priority) +{ + _serializePriority = priority; + serializePriorities.insert(priority); +}