diff options
author | Andreas Sandberg <Andreas.Sandberg@arm.com> | 2012-11-02 11:32:01 -0500 |
---|---|---|
committer | Andreas Sandberg <Andreas.Sandberg@arm.com> | 2012-11-02 11:32:01 -0500 |
commit | b81a977e6ab7dbfd122cb778cfe3d40ca7451198 (patch) | |
tree | 09804c27367de8cf93623ec4644bf47abf316bf9 /src/mem/ruby/system | |
parent | eb703a4b4e167e4d45f92203a1e0849f19cdba6d (diff) | |
download | gem5-b81a977e6ab7dbfd122cb778cfe3d40ca7451198.tar.xz |
sim: Move the draining interface into a separate base class
This patch moves the draining interface from SimObject to a separate
class that can be used by any object needing draining. However,
objects not visible to the Python code (i.e., objects not deriving
from SimObject) still depend on their parents informing them when to
drain. This patch also gets rid of the CountedDrainEvent (which isn't
really an event) and replaces it with a DrainManager.
Diffstat (limited to 'src/mem/ruby/system')
-rw-r--r-- | src/mem/ruby/system/MemoryControl.hh | 2 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyMemoryControl.cc | 2 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyMemoryControl.hh | 2 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyPort.cc | 36 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyPort.hh | 6 | ||||
-rw-r--r-- | src/mem/ruby/system/Sequencer.cc | 5 |
6 files changed, 26 insertions, 27 deletions
diff --git a/src/mem/ruby/system/MemoryControl.hh b/src/mem/ruby/system/MemoryControl.hh index 8d15b8dec..5c6adb0ab 100644 --- a/src/mem/ruby/system/MemoryControl.hh +++ b/src/mem/ruby/system/MemoryControl.hh @@ -56,8 +56,6 @@ class MemoryControl : public ClockedObject, public Consumer ~MemoryControl(); - unsigned int drain(Event *de) = 0; - virtual void wakeup() = 0; virtual void setConsumer(Consumer* consumer_ptr) = 0; diff --git a/src/mem/ruby/system/RubyMemoryControl.cc b/src/mem/ruby/system/RubyMemoryControl.cc index c0e91c28b..620113719 100644 --- a/src/mem/ruby/system/RubyMemoryControl.cc +++ b/src/mem/ruby/system/RubyMemoryControl.cc @@ -684,7 +684,7 @@ RubyMemoryControl::executeCycle() } unsigned int -RubyMemoryControl::drain(Event *de) +RubyMemoryControl::drain(DrainManager *dm) { DPRINTF(RubyMemory, "MemoryController drain\n"); if(m_event.scheduled()) { diff --git a/src/mem/ruby/system/RubyMemoryControl.hh b/src/mem/ruby/system/RubyMemoryControl.hh index 1f3a8acf5..53e8fabef 100644 --- a/src/mem/ruby/system/RubyMemoryControl.hh +++ b/src/mem/ruby/system/RubyMemoryControl.hh @@ -62,7 +62,7 @@ class RubyMemoryControl : public MemoryControl ~RubyMemoryControl(); - unsigned int drain(Event *de); + unsigned int drain(DrainManager *dm); void wakeup(); diff --git a/src/mem/ruby/system/RubyPort.cc b/src/mem/ruby/system/RubyPort.cc index 1259f0f15..dd9e9676e 100644 --- a/src/mem/ruby/system/RubyPort.cc +++ b/src/mem/ruby/system/RubyPort.cc @@ -53,7 +53,7 @@ RubyPort::RubyPort(const Params *p) m_mandatory_q_ptr(NULL), pio_port(csprintf("%s-pio-port", name()), this), m_usingRubyTester(p->using_ruby_tester), m_request_cnt(0), - drainEvent(NULL), ruby_system(p->ruby_system), system(p->system), + drainManager(NULL), ruby_system(p->ruby_system), system(p->system), waitingOnSequencer(false), access_phys_mem(p->access_phys_mem) { assert(m_version != -1); @@ -343,36 +343,36 @@ void RubyPort::testDrainComplete() { //If we weren't able to drain before, we might be able to now. - if (drainEvent != NULL) { + if (drainManager != NULL) { unsigned int drainCount = outstandingCount(); DPRINTF(Drain, "Drain count: %u\n", drainCount); if (drainCount == 0) { - DPRINTF(Drain, "RubyPort done draining, processing drain event\n"); - drainEvent->process(); - // Clear the drain event once we're done with it. - drainEvent = NULL; + DPRINTF(Drain, "RubyPort done draining, signaling drain done\n"); + drainManager->signalDrainDone(); + // Clear the drain manager once we're done with it. + drainManager = NULL; } } } unsigned int -RubyPort::getChildDrainCount(Event *de) +RubyPort::getChildDrainCount(DrainManager *dm) { int count = 0; if (pio_port.isConnected()) { - count += pio_port.drain(de); + count += pio_port.drain(dm); DPRINTF(Config, "count after pio check %d\n", count); } for (CpuPortIter p = slave_ports.begin(); p != slave_ports.end(); ++p) { - count += (*p)->drain(de); + count += (*p)->drain(dm); DPRINTF(Config, "count after slave port check %d\n", count); } for (std::vector<PioPort*>::iterator p = master_ports.begin(); p != master_ports.end(); ++p) { - count += (*p)->drain(de); + count += (*p)->drain(dm); DPRINTF(Config, "count after master port check %d\n", count); } @@ -382,7 +382,7 @@ RubyPort::getChildDrainCount(Event *de) } unsigned int -RubyPort::drain(Event *de) +RubyPort::drain(DrainManager *dm) { if (isDeadlockEventScheduled()) { descheduleDeadlockEvent(); @@ -390,28 +390,28 @@ RubyPort::drain(Event *de) // // If the RubyPort is not empty, then it needs to clear all outstanding - // requests before it should call drainEvent->process() + // requests before it should call drainManager->signalDrainDone() // DPRINTF(Config, "outstanding count %d\n", outstandingCount()); bool need_drain = outstandingCount() > 0; // // Also, get the number of child ports that will also need to clear - // their buffered requests before they call drainEvent->process() + // their buffered requests before they call drainManager->signalDrainDone() // - unsigned int child_drain_count = getChildDrainCount(de); + unsigned int child_drain_count = getChildDrainCount(dm); // Set status if (need_drain) { - drainEvent = de; + drainManager = dm; DPRINTF(Drain, "RubyPort not drained\n"); - changeState(SimObject::Draining); + setDrainState(Drainable::Draining); return child_drain_count + 1; } - drainEvent = NULL; - changeState(SimObject::Drained); + drainManager = NULL; + setDrainState(Drainable::Drained); return child_drain_count; } diff --git a/src/mem/ruby/system/RubyPort.hh b/src/mem/ruby/system/RubyPort.hh index ab09bd90a..98bcede44 100644 --- a/src/mem/ruby/system/RubyPort.hh +++ b/src/mem/ruby/system/RubyPort.hh @@ -142,7 +142,7 @@ class RubyPort : public MemObject // void setController(AbstractController* _cntrl) { m_controller = _cntrl; } int getId() { return m_version; } - unsigned int drain(Event *de); + unsigned int drain(DrainManager *dm); protected: const std::string m_name; @@ -166,7 +166,7 @@ class RubyPort : public MemObject } } - unsigned int getChildDrainCount(Event *de); + unsigned int getChildDrainCount(DrainManager *dm); uint16_t m_port_id; uint64_t m_request_cnt; @@ -176,7 +176,7 @@ class RubyPort : public MemObject std::vector<M5Port*> slave_ports; std::vector<PioPort*> master_ports; - Event *drainEvent; + DrainManager *drainManager; RubySystem* ruby_system; System* system; diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc index 9b6ef35cd..a45dfc98d 100644 --- a/src/mem/ruby/system/Sequencer.cc +++ b/src/mem/ruby/system/Sequencer.cc @@ -85,7 +85,7 @@ Sequencer::~Sequencer() void Sequencer::wakeup() { - assert(getState() != SimObject::Draining); + assert(getDrainState() != Drainable::Draining); // Check for deadlock of any of the requests Time current_time = g_system_ptr->getTime(); @@ -209,7 +209,8 @@ Sequencer::insertRequest(PacketPtr pkt, RubyRequestType request_type) (m_writeRequestTable.size() + m_readRequestTable.size())); // See if we should schedule a deadlock check - if (!deadlockCheckEvent.scheduled() && getState() != SimObject::Draining) { + if (!deadlockCheckEvent.scheduled() && + getDrainState() != Drainable::Draining) { schedule(deadlockCheckEvent, g_system_ptr->clockPeriod() * m_deadlock_threshold + curTick()); } |