diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2015-07-07 09:51:05 +0100 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2015-07-07 09:51:05 +0100 |
commit | ed38e3432c732d71cf29dc3fd739f078be7de6b0 (patch) | |
tree | 2c8a307ef7e8188e699d27bb66e942186dc62787 /src/mem/ruby | |
parent | f16c0a4a90ad1050cf7d1140916c35d07b1cb28e (diff) | |
download | gem5-ed38e3432c732d71cf29dc3fd739f078be7de6b0.tar.xz |
sim: Refactor and simplify the drain API
The drain() call currently passes around a DrainManager pointer, which
is now completely pointless since there is only ever one global
DrainManager in the system. It also contains vestiges from the time
when SimObjects had to keep track of their child objects that needed
draining.
This changeset moves all of the DrainState handling to the Drainable
base class and changes the drain() and drainResume() calls to reflect
this. Particularly, the drain() call has been updated to take no
parameters (the DrainManager argument isn't needed) and return a
DrainState instead of an unsigned integer (there is no point returning
anything other than 0 or 1 any more). Drainable objects should return
either DrainState::Draining (equivalent to returning 1 in the old
system) if they need more time to drain or DrainState::Drained
(equivalent to returning 0 in the old system) if they are already in a
consistent state. Returning DrainState::Running is considered an
error.
Drain done signalling is now done through the signalDrainDone() method
in the Drainable class instead of using the DrainManager directly. The
new call checks if the state of the object is DrainState::Draining
before notifying the drain manager. This means that it is safe to call
signalDrainDone() without first checking if the simulator has
requested draining. The intention here is to reduce the code needed to
implement draining in simple objects.
Diffstat (limited to 'src/mem/ruby')
-rw-r--r-- | src/mem/ruby/structures/RubyMemoryControl.cc | 6 | ||||
-rw-r--r-- | src/mem/ruby/structures/RubyMemoryControl.hh | 2 | ||||
-rw-r--r-- | src/mem/ruby/system/DMASequencer.cc | 29 | ||||
-rw-r--r-- | src/mem/ruby/system/DMASequencer.hh | 5 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyPort.cc | 30 | ||||
-rw-r--r-- | src/mem/ruby/system/RubyPort.hh | 4 | ||||
-rw-r--r-- | src/mem/ruby/system/Sequencer.cc | 4 |
7 files changed, 29 insertions, 51 deletions
diff --git a/src/mem/ruby/structures/RubyMemoryControl.cc b/src/mem/ruby/structures/RubyMemoryControl.cc index 7e07a82bc..6e40d415c 100644 --- a/src/mem/ruby/structures/RubyMemoryControl.cc +++ b/src/mem/ruby/structures/RubyMemoryControl.cc @@ -640,14 +640,14 @@ RubyMemoryControl::executeCycle() } } -unsigned int -RubyMemoryControl::drain(DrainManager *dm) +DrainState +RubyMemoryControl::drain() { DPRINTF(RubyMemory, "MemoryController drain\n"); if(m_event.scheduled()) { deschedule(m_event); } - return 0; + return DrainState::Drained; } // wakeup: This function is called once per memory controller clock cycle. diff --git a/src/mem/ruby/structures/RubyMemoryControl.hh b/src/mem/ruby/structures/RubyMemoryControl.hh index 78bc74ad5..d69e8f435 100644 --- a/src/mem/ruby/structures/RubyMemoryControl.hh +++ b/src/mem/ruby/structures/RubyMemoryControl.hh @@ -61,7 +61,7 @@ class RubyMemoryControl : public AbstractMemory, public Consumer virtual BaseSlavePort& getSlavePort(const std::string& if_name, PortID idx = InvalidPortID); - unsigned int drain(DrainManager *dm); + DrainState drain() M5_ATTR_OVERRIDE; void wakeup(); void setDescription(const std::string& name) { m_description = name; }; diff --git a/src/mem/ruby/system/DMASequencer.cc b/src/mem/ruby/system/DMASequencer.cc index 0dd28d91c..05592b231 100644 --- a/src/mem/ruby/system/DMASequencer.cc +++ b/src/mem/ruby/system/DMASequencer.cc @@ -42,7 +42,7 @@ DMASequencer::DMASequencer(const Params *p) m_mandatory_q_ptr(NULL), m_usingRubyTester(p->using_ruby_tester), slave_port(csprintf("%s.slave", name()), this, 0, p->ruby_system, p->ruby_system->getAccessBackingStore()), - drainManager(NULL), system(p->system), retry(false) + system(p->system), retry(false) { assert(m_version != -1); } @@ -148,43 +148,34 @@ void DMASequencer::testDrainComplete() { //If we weren't able to drain before, we might be able to now. - if (drainManager != NULL) { + if (drainState() == DrainState::Draining) { unsigned int drainCount = outstandingCount(); DPRINTF(Drain, "Drain count: %u\n", drainCount); if (drainCount == 0) { DPRINTF(Drain, "DMASequencer done draining, signaling drain done\n"); - drainManager->signalDrainDone(); - // Clear the drain manager once we're done with it. - drainManager = NULL; + signalDrainDone(); } } } -unsigned int -DMASequencer::drain(DrainManager *dm) +DrainState +DMASequencer::drain() { if (isDeadlockEventScheduled()) { descheduleDeadlockEvent(); } // If the DMASequencer is not empty, then it needs to clear all outstanding - // requests before it should call drainManager->signalDrainDone() + // requests before it should call signalDrainDone() DPRINTF(Config, "outstanding count %d\n", outstandingCount()); - bool need_drain = outstandingCount() > 0; - // Set status - if (need_drain) { - drainManager = dm; - + if (outstandingCount() > 0) { DPRINTF(Drain, "DMASequencer not drained\n"); - setDrainState(DrainState::Draining); - return 1; + return DrainState::Draining; + } else { + return DrainState::Drained; } - - drainManager = NULL; - setDrainState(DrainState::Drained); - return 0; } void diff --git a/src/mem/ruby/system/DMASequencer.hh b/src/mem/ruby/system/DMASequencer.hh index bcf586acf..ee5a4b698 100644 --- a/src/mem/ruby/system/DMASequencer.hh +++ b/src/mem/ruby/system/DMASequencer.hh @@ -107,7 +107,7 @@ class DMASequencer : public MemObject // A pointer to the controller is needed for atomic support. void setController(AbstractController* _cntrl) { m_controller = _cntrl; } uint32_t getId() { return m_version; } - unsigned int drain(DrainManager *dm); + DrainState drain() M5_ATTR_OVERRIDE; /* SLICC callback */ void dataCallback(const DataBlock & dblk); @@ -129,7 +129,7 @@ class DMASequencer : public MemObject * @return Whether successfully sent */ bool recvTimingResp(PacketPtr pkt, PortID master_port_id); - unsigned int getChildDrainCount(DrainManager *dm); + unsigned int getChildDrainCount(); private: uint32_t m_version; @@ -139,7 +139,6 @@ class DMASequencer : public MemObject MemSlavePort slave_port; - DrainManager *drainManager; System* system; bool retry; diff --git a/src/mem/ruby/system/RubyPort.cc b/src/mem/ruby/system/RubyPort.cc index 5818056e9..d34cb3c2f 100644 --- a/src/mem/ruby/system/RubyPort.cc +++ b/src/mem/ruby/system/RubyPort.cc @@ -59,7 +59,7 @@ RubyPort::RubyPort(const Params *p) memMasterPort(csprintf("%s.mem-master-port", name()), this), memSlavePort(csprintf("%s-mem-slave-port", name()), this, p->ruby_system, p->ruby_system->getAccessBackingStore(), -1), - gotAddrRanges(p->port_master_connection_count), drainManager(NULL) + gotAddrRanges(p->port_master_connection_count) { assert(m_version != -1); @@ -387,20 +387,18 @@ void RubyPort::testDrainComplete() { //If we weren't able to drain before, we might be able to now. - if (drainManager != NULL) { + if (drainState() == DrainState::Draining) { unsigned int drainCount = outstandingCount(); DPRINTF(Drain, "Drain count: %u\n", drainCount); if (drainCount == 0) { DPRINTF(Drain, "RubyPort done draining, signaling drain done\n"); - drainManager->signalDrainDone(); - // Clear the drain manager once we're done with it. - drainManager = NULL; + signalDrainDone(); } } } -unsigned int -RubyPort::drain(DrainManager *dm) +DrainState +RubyPort::drain() { if (isDeadlockEventScheduled()) { descheduleDeadlockEvent(); @@ -408,23 +406,15 @@ RubyPort::drain(DrainManager *dm) // // If the RubyPort is not empty, then it needs to clear all outstanding - // requests before it should call drainManager->signalDrainDone() + // requests before it should call signalDrainDone() // DPRINTF(Config, "outstanding count %d\n", outstandingCount()); - bool need_drain = outstandingCount() > 0; - - // Set status - if (need_drain) { - drainManager = dm; - + if (outstandingCount() > 0) { DPRINTF(Drain, "RubyPort not drained\n"); - setDrainState(DrainState::Draining); - return 1; + return DrainState::Draining; + } else { + return DrainState::Drained; } - - drainManager = NULL; - setDrainState(DrainState::Drained); - return 0; } void diff --git a/src/mem/ruby/system/RubyPort.hh b/src/mem/ruby/system/RubyPort.hh index ff1b2af04..1fbaeba7b 100644 --- a/src/mem/ruby/system/RubyPort.hh +++ b/src/mem/ruby/system/RubyPort.hh @@ -162,7 +162,7 @@ class RubyPort : public MemObject // void setController(AbstractController* _cntrl) { m_controller = _cntrl; } uint32_t getId() { return m_version; } - unsigned int drain(DrainManager *dm); + DrainState drain() M5_ATTR_OVERRIDE; protected: void ruby_hit_callback(PacketPtr pkt); @@ -204,8 +204,6 @@ class RubyPort : public MemObject std::vector<MemSlavePort *> slave_ports; std::vector<PioMasterPort *> master_ports; - DrainManager *drainManager; - // // Based on similar code in the M5 bus. Stores pointers to those ports // that should be called when the Sequencer becomes available after a stall. diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc index c33f5f819..0a48817ca 100644 --- a/src/mem/ruby/system/Sequencer.cc +++ b/src/mem/ruby/system/Sequencer.cc @@ -77,7 +77,7 @@ Sequencer::~Sequencer() void Sequencer::wakeup() { - assert(getDrainState() != DrainState::Draining); + assert(drainState() != DrainState::Draining); // Check for deadlock of any of the requests Cycles current_time = curCycle(); @@ -215,7 +215,7 @@ Sequencer::insertRequest(PacketPtr pkt, RubyRequestType request_type) // See if we should schedule a deadlock check if (!deadlockCheckEvent.scheduled() && - getDrainState() != DrainState::Draining) { + drainState() != DrainState::Draining) { schedule(deadlockCheckEvent, clockEdge(m_deadlock_threshold)); } |