From 0479569f6748202f1704d70aad3b03b3d17f6092 Mon Sep 17 00:00:00 2001 From: Joel Hestness Date: Tue, 19 May 2015 10:56:51 -0500 Subject: ruby: Fix RubySystem warm-up and cool-down scope The processes of warming up and cooling down Ruby caches are simulation-wide processes, not just RubySystem instance-specific processes. Thus, the warm-up and cool-down variables should be globally visible to any Ruby components participating in either process. Make these variables static members and track the warm-up and cool-down processes as appropriate. This patch also has two side benefits: 1) It removes references to the RubySystem g_system_ptr, which are problematic for allowing multiple RubySystem instances in a single simulation. Warmup and cooldown variables being static (global) reduces the need for instance-specific dereferences through the RubySystem. 2) From the AbstractController, it removes local RubySystem pointers, which are used inconsistently with other uses of the RubySystem: 11 other uses reference the RubySystem with the g_system_ptr. Only sequencers have local pointers. --- src/mem/ruby/network/MessageBuffer.cc | 2 +- src/mem/ruby/slicc_interface/AbstractController.cc | 7 +++---- src/mem/ruby/slicc_interface/AbstractController.hh | 3 --- src/mem/ruby/system/Sequencer.cc | 6 +++--- src/mem/ruby/system/System.cc | 18 ++++++++++++------ src/mem/ruby/system/System.hh | 7 +++++-- 6 files changed, 24 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/mem/ruby/network/MessageBuffer.cc b/src/mem/ruby/network/MessageBuffer.cc index 57a8d5519..99879a1b6 100644 --- a/src/mem/ruby/network/MessageBuffer.cc +++ b/src/mem/ruby/network/MessageBuffer.cc @@ -191,7 +191,7 @@ MessageBuffer::enqueue(MsgPtr message, Cycles delta) } // If running a cache trace, don't worry about the last arrival checks - if (!g_system_ptr->m_warmup_enabled) { + if (!RubySystem::getWarmupEnabled()) { m_last_arrival_time = arrival_time; } diff --git a/src/mem/ruby/slicc_interface/AbstractController.cc b/src/mem/ruby/slicc_interface/AbstractController.cc index 4290c63fa..a6d05fd3a 100644 --- a/src/mem/ruby/slicc_interface/AbstractController.cc +++ b/src/mem/ruby/slicc_interface/AbstractController.cc @@ -40,8 +40,7 @@ AbstractController::AbstractController(const Params *p) m_transitions_per_cycle(p->transitions_per_cycle), m_buffer_size(p->buffer_size), m_recycle_latency(p->recycle_latency), memoryPort(csprintf("%s.memory", name()), this, ""), - m_responseFromMemory_ptr(new MessageBuffer()), - m_rubySystem(p->ruby_system) + m_responseFromMemory_ptr(new MessageBuffer()) { // Set the sender pointer of the response message buffer from the // memory controller. @@ -219,7 +218,7 @@ AbstractController::queueMemoryRead(const MachineID &id, Address addr, pkt->pushSenderState(s); // Use functional rather than timing accesses during warmup - if (m_rubySystem->m_warmup_enabled) { + if (RubySystem::getWarmupEnabled()) { memoryPort.sendFunctional(pkt); recvTimingResp(pkt); return; @@ -246,7 +245,7 @@ AbstractController::queueMemoryWrite(const MachineID &id, Address addr, pkt->pushSenderState(s); // Use functional rather than timing accesses during warmup - if (m_rubySystem->m_warmup_enabled) { + if (RubySystem::getWarmupEnabled()) { memoryPort.sendFunctional(pkt); recvTimingResp(pkt); return; diff --git a/src/mem/ruby/slicc_interface/AbstractController.hh b/src/mem/ruby/slicc_interface/AbstractController.hh index 01859397a..f8970fb59 100644 --- a/src/mem/ruby/slicc_interface/AbstractController.hh +++ b/src/mem/ruby/slicc_interface/AbstractController.hh @@ -205,9 +205,6 @@ class AbstractController : public MemObject, public Consumer // memory controller. MessageBuffer *m_responseFromMemory_ptr; - // Needed so we know if we are warming up - RubySystem *m_rubySystem; - // State that is stored in packets sent to the memory controller. struct SenderState : public Packet::SenderState { diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc index 98649dcd5..b1d22b549 100644 --- a/src/mem/ruby/system/Sequencer.cc +++ b/src/mem/ruby/system/Sequencer.cc @@ -525,7 +525,7 @@ Sequencer::hitCallback(SequencerRequest* srequest, DataBlock& data, request_address, total_latency); // update the data unless it is a non-data-carrying flush - if (g_system_ptr->m_warmup_enabled) { + if (RubySystem::getWarmupEnabled()) { data.setData(pkt->getConstPtr(), request_address.getOffset(), pkt->getSize()); } else if (!pkt->isFlush()) { @@ -557,12 +557,12 @@ Sequencer::hitCallback(SequencerRequest* srequest, DataBlock& data, delete srequest; - if (g_system_ptr->m_warmup_enabled) { + if (RubySystem::getWarmupEnabled()) { assert(pkt->req); delete pkt->req; delete pkt; g_system_ptr->m_cache_recorder->enqueueNextFetchRequest(); - } else if (g_system_ptr->m_cooldown_enabled) { + } else if (RubySystem::getCooldownEnabled()) { delete pkt; g_system_ptr->m_cache_recorder->enqueueNextFlushRequest(); } else { diff --git a/src/mem/ruby/system/System.cc b/src/mem/ruby/system/System.cc index b93dacdfc..75ebc8caf 100644 --- a/src/mem/ruby/system/System.cc +++ b/src/mem/ruby/system/System.cc @@ -49,6 +49,11 @@ bool RubySystem::m_randomization; uint32_t RubySystem::m_block_size_bytes; uint32_t RubySystem::m_block_size_bits; uint32_t RubySystem::m_memory_size_bits; +bool RubySystem::m_warmup_enabled = false; +// To look forward to allowing multiple RubySystem instances, track the number +// of RubySystems that need to be warmed up on checkpoint restore. +unsigned RubySystem::m_systems_to_warmup = 0; +bool RubySystem::m_cooldown_enabled = false; RubySystem::RubySystem(const Params *p) : ClockedObject(p), m_access_backing_store(p->access_backing_store) @@ -65,9 +70,6 @@ RubySystem::RubySystem(const Params *p) m_block_size_bits = floorLog2(m_block_size_bytes); m_memory_size_bits = p->memory_size_bits; - m_warmup_enabled = false; - m_cooldown_enabled = false; - // Setup the global variables used in Ruby g_system_ptr = this; @@ -252,6 +254,7 @@ RubySystem::unserialize(Checkpoint *cp, const string §ion) readCompressedTrace(cache_trace_file, uncompressed_trace, cache_trace_size); m_warmup_enabled = true; + m_systems_to_warmup++; vector sequencer_map; Sequencer* t = NULL; @@ -307,7 +310,10 @@ RubySystem::startup() delete m_cache_recorder; m_cache_recorder = NULL; - m_warmup_enabled = false; + m_systems_to_warmup--; + if (m_systems_to_warmup == 0) { + m_warmup_enabled = false; + } // Restore eventq head eventq_head = eventq->replaceHead(eventq_head); @@ -322,9 +328,9 @@ RubySystem::startup() void RubySystem::RubyEvent::process() { - if (ruby_system->m_warmup_enabled) { + if (RubySystem::getWarmupEnabled()) { ruby_system->m_cache_recorder->enqueueNextFetchRequest(); - } else if (ruby_system->m_cooldown_enabled) { + } else if (RubySystem::getCooldownEnabled()) { ruby_system->m_cache_recorder->enqueueNextFlushRequest(); } } diff --git a/src/mem/ruby/system/System.hh b/src/mem/ruby/system/System.hh index 72de74702..45e8aa8b4 100644 --- a/src/mem/ruby/system/System.hh +++ b/src/mem/ruby/system/System.hh @@ -74,6 +74,8 @@ class RubySystem : public ClockedObject static uint32_t getBlockSizeBytes() { return m_block_size_bytes; } static uint32_t getBlockSizeBits() { return m_block_size_bits; } static uint32_t getMemorySizeBits() { return m_memory_size_bits; } + static bool getWarmupEnabled() { return m_warmup_enabled; } + static bool getCooldownEnabled() { return m_cooldown_enabled; } SimpleMemory *getPhysMem() { return m_phys_mem; } const bool getAccessBackingStore() { return m_access_backing_store; } @@ -125,6 +127,9 @@ class RubySystem : public ClockedObject static uint32_t m_block_size_bytes; static uint32_t m_block_size_bits; static uint32_t m_memory_size_bits; + static bool m_warmup_enabled; + static unsigned m_systems_to_warmup; + static bool m_cooldown_enabled; SimpleMemory *m_phys_mem; const bool m_access_backing_store; @@ -133,8 +138,6 @@ class RubySystem : public ClockedObject public: Profiler* m_profiler; - bool m_warmup_enabled; - bool m_cooldown_enabled; CacheRecorder* m_cache_recorder; }; -- cgit v1.2.3