diff --git a/src/mem/ruby/system/CacheRecorder.cc b/src/mem/ruby/system/CacheRecorder.cc index e87b3f20b2..20a8a30ebc 100644 --- a/src/mem/ruby/system/CacheRecorder.cc +++ b/src/mem/ruby/system/CacheRecorder.cc @@ -207,5 +207,11 @@ CacheRecorder::aggregateRecords(uint8_t **buf, uint64_t total_size) 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 8dbd67f3ff..be95590313 100644 --- a/src/mem/ruby/system/CacheRecorder.hh +++ b/src/mem/ruby/system/CacheRecorder.hh @@ -85,6 +85,8 @@ class CacheRecorder 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 5a81513720..b38c903b09 100644 --- a/src/mem/ruby/system/RubySystem.cc +++ b/src/mem/ruby/system/RubySystem.cc @@ -218,6 +218,13 @@ RubySystem::memWriteback() } DPRINTF(RubyCacheTrace, "Cache Trace Complete\n"); + // If there is no dirty block, we don't need to flush the cache + if (m_cache_recorder->getNumRecords() == 0) + { + m_cooldown_enabled = false; + return; + } + // save the current tick value Tick curtick_original = curTick(); DPRINTF(RubyCacheTrace, "Recording current tick %ld\n", curtick_original);