Hoa Nguyen has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/69897?usp=email )

Change subject: mem-ruby: Not draining cache without drainable actions
......................................................................

mem-ruby: Not draining cache without drainable actions

Currently, taking a checkpoint with a ruby cache involves moving all
the cache blocks that are in transient states to stable states. This
is done by keeping **only** simulating the cache still all blocks are
in the stable states before taking the checkpoint.

However, when all blocks are in stable states, it is a problem if we
keep simulating the cache. E.g., calling checkpoint caused the gem5
"empty event queue" assertion fault when running the ruby cache in
atomic_noncaching mode. Since the mode bypasses the cache, all blocks
in the cache are in a stable state. Subsequently, there is no event
placed to the event queue when we keep **only** simulating the cache
before taking the checkpoint.

This patch fixes this problem by checking if there is any actionable
item when trying to moving all cache blocks to stable states. If
there is no block needed to be transitioned to a stable state, we
simply choose not to continue simulating the cache before taking the
checkpoint.

Change-Id: Idfa09be51274c7fc8a340e9e33167f5b32d1b866
Signed-off-by: Hoa Nguyen <hoangu...@ucdavis.edu>
---
M src/mem/ruby/system/CacheRecorder.cc
M src/mem/ruby/system/CacheRecorder.hh
M src/mem/ruby/system/RubySystem.cc
3 files changed, 46 insertions(+), 34 deletions(-)



diff --git a/src/mem/ruby/system/CacheRecorder.cc b/src/mem/ruby/system/CacheRecorder.cc
index e87b3f2..20a8a30 100644
--- a/src/mem/ruby/system/CacheRecorder.cc
+++ b/src/mem/ruby/system/CacheRecorder.cc
@@ -207,5 +207,11 @@
     return current_size;
 }

+uint64_t
+CacheRecorder::getNumRecords() const
+{
+    return m_records.size();
+}
+
 } // namespace ruby
 } // namespace gem5
diff --git a/src/mem/ruby/system/CacheRecorder.hh b/src/mem/ruby/system/CacheRecorder.hh
index 8dbd67f..be95590 100644
--- a/src/mem/ruby/system/CacheRecorder.hh
+++ b/src/mem/ruby/system/CacheRecorder.hh
@@ -85,6 +85,8 @@

     uint64_t aggregateRecords(uint8_t **data, uint64_t size);

+    uint64_t getNumRecords() const;
+
     /*!
      * Function for flushing the memory contents of the caches to the
      * main memory. It goes through the recorded contents of the caches,
diff --git a/src/mem/ruby/system/RubySystem.cc b/src/mem/ruby/system/RubySystem.cc
index 5a81513..4a01c20 100644
--- a/src/mem/ruby/system/RubySystem.cc
+++ b/src/mem/ruby/system/RubySystem.cc
@@ -218,46 +218,50 @@
     }
     DPRINTF(RubyCacheTrace, "Cache Trace Complete\n");

-    // save the current tick value
-    Tick curtick_original = curTick();
- DPRINTF(RubyCacheTrace, "Recording current tick %ld\n", curtick_original);
+    if (m_cache_recorder->getNumRecords() != 0)
+    {
+        // save the current tick value
+        Tick curtick_original = curTick();
+        DPRINTF(RubyCacheTrace, "Recording current tick %ld\n",
+                curtick_original);

- // Deschedule all prior events on the event queue, but record the tick they
-    // were scheduled at so they can be restored correctly later.
-    std::list<std::pair<Event*, Tick> > original_events;
-    while (!eventq->empty()) {
-        Event *curr_head = eventq->getHead();
-        if (curr_head->isAutoDelete()) {
- DPRINTF(RubyCacheTrace, "Event %s auto-deletes when descheduled,"
-                    " not recording\n", curr_head->name());
-        } else {
-            original_events.push_back(
-                    std::make_pair(curr_head, curr_head->when()));
+ // Deschedule all prior events on the event queue, but record the tick
+        // they were scheduled at so they can be restored correctly later.
+        std::list<std::pair<Event*, Tick> > original_events;
+        while (!eventq->empty()) {
+            Event *curr_head = eventq->getHead();
+            if (curr_head->isAutoDelete()) {
+                DPRINTF(RubyCacheTrace, "Event %s auto-deletes when
+                        "descheduled, not recording\n", curr_head->name());
+            } else {
+                original_events.push_back(
+                        std::make_pair(curr_head, curr_head->when()));
+            }
+            eventq->deschedule(curr_head);
         }
-        eventq->deschedule(curr_head);
-    }

-    // Schedule an event to start cache cooldown
-    DPRINTF(RubyCacheTrace, "Starting cache flush\n");
-    enqueueRubyEvent(curTick());
-    simulate();
-    DPRINTF(RubyCacheTrace, "Cache flush complete\n");
+        // Schedule an event to start cache cooldown
+        DPRINTF(RubyCacheTrace, "Starting cache flush\n");
+        enqueueRubyEvent(curTick());
+        simulate();
+        DPRINTF(RubyCacheTrace, "Cache flush complete\n");

-    // Deschedule any events left on the event queue.
-    while (!eventq->empty()) {
-        eventq->deschedule(eventq->getHead());
-    }
+        // Deschedule any events left on the event queue.
+        while (!eventq->empty()) {
+            eventq->deschedule(eventq->getHead());
+        }

-    // Restore curTick
-    setCurTick(curtick_original);
+        // Restore curTick
+        setCurTick(curtick_original);

-    // Restore all events that were originally on the event queue.  This is
- // done after setting curTick back to its original value so that events do
-    // not seem to be scheduled in the past.
-    while (!original_events.empty()) {
-        std::pair<Event*, Tick> event = original_events.back();
-        eventq->schedule(event.first, event.second);
-        original_events.pop_back();
+ // Restore all events that were originally on the event queue. This is + // done after setting curTick back to its original value so that events
+        // do not seem to be scheduled in the past.
+        while (!original_events.empty()) {
+            std::pair<Event*, Tick> event = original_events.back();
+            eventq->schedule(event.first, event.second);
+            original_events.pop_back();
+        }
     }

     // No longer flushing back to memory.

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/69897?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Idfa09be51274c7fc8a340e9e33167f5b32d1b866
Gerrit-Change-Number: 69897
Gerrit-PatchSet: 1
Gerrit-Owner: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to