summaryrefslogtreecommitdiff
path: root/src/mem
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2014-02-23 19:16:15 -0600
committerNilay Vaish <nilay@cs.wisc.edu>2014-02-23 19:16:15 -0600
commit7572ab71b56b01e3ee7742dd385af81b49bd753d (patch)
treeb354d130838382c92439fe53d6e15c7bb55eea17 /src/mem
parentcde20fd476a2563bac54bb135fad0dd5e03112db (diff)
downloadgem5-7572ab71b56b01e3ee7742dd385af81b49bd753d.tar.xz
ruby: message buffer: refactor code
Code in two of the functions was exactly the same. This patch moves this code to a new function which is called from the two functions mentioned initially.
Diffstat (limited to 'src/mem')
-rw-r--r--src/mem/ruby/buffers/MessageBuffer.cc46
-rw-r--r--src/mem/ruby/buffers/MessageBuffer.hh4
-rw-r--r--src/mem/ruby/slicc_interface/AbstractController.hh2
3 files changed, 24 insertions, 28 deletions
diff --git a/src/mem/ruby/buffers/MessageBuffer.cc b/src/mem/ruby/buffers/MessageBuffer.cc
index 9475f1514..0a7a78e8d 100644
--- a/src/mem/ruby/buffers/MessageBuffer.cc
+++ b/src/mem/ruby/buffers/MessageBuffer.cc
@@ -282,6 +282,22 @@ MessageBuffer::recycle()
}
void
+MessageBuffer::reanalyzeList(list<MsgPtr> &lt, Tick nextTick)
+{
+ while(!lt.empty()) {
+ m_msg_counter++;
+ MessageBufferNode msgNode(nextTick, m_msg_counter, lt.front());
+
+ m_prio_heap.push_back(msgNode);
+ push_heap(m_prio_heap.begin(), m_prio_heap.end(),
+ greater<MessageBufferNode>());
+
+ m_consumer->scheduleEventAbsolute(nextTick);
+ lt.pop_front();
+ }
+}
+
+void
MessageBuffer::reanalyzeMessages(const Address& addr)
{
DPRINTF(RubyQueue, "ReanalyzeMessages\n");
@@ -292,18 +308,7 @@ MessageBuffer::reanalyzeMessages(const Address& addr)
// Put all stalled messages associated with this address back on the
// prio heap
//
- while(!m_stall_msg_map[addr].empty()) {
- m_msg_counter++;
- MessageBufferNode msgNode(nextTick, m_msg_counter,
- m_stall_msg_map[addr].front());
-
- m_prio_heap.push_back(msgNode);
- push_heap(m_prio_heap.begin(), m_prio_heap.end(),
- greater<MessageBufferNode>());
-
- m_consumer->scheduleEventAbsolute(nextTick);
- m_stall_msg_map[addr].pop_front();
- }
+ reanalyzeList(m_stall_msg_map[addr], nextTick);
m_stall_msg_map.erase(addr);
}
@@ -318,21 +323,8 @@ MessageBuffer::reanalyzeAllMessages()
// prio heap
//
for (StallMsgMapType::iterator map_iter = m_stall_msg_map.begin();
- map_iter != m_stall_msg_map.end();
- ++map_iter) {
-
- while(!(map_iter->second).empty()) {
- m_msg_counter++;
- MessageBufferNode msgNode(nextTick, m_msg_counter,
- (map_iter->second).front());
-
- m_prio_heap.push_back(msgNode);
- push_heap(m_prio_heap.begin(), m_prio_heap.end(),
- greater<MessageBufferNode>());
-
- m_consumer->scheduleEventAbsolute(nextTick);
- (map_iter->second).pop_front();
- }
+ map_iter != m_stall_msg_map.end(); ++map_iter) {
+ reanalyzeList(map_iter->second, nextTick);
}
m_stall_msg_map.clear();
}
diff --git a/src/mem/ruby/buffers/MessageBuffer.hh b/src/mem/ruby/buffers/MessageBuffer.hh
index b1a9f0004..b65717e2d 100644
--- a/src/mem/ruby/buffers/MessageBuffer.hh
+++ b/src/mem/ruby/buffers/MessageBuffer.hh
@@ -157,6 +157,9 @@ class MessageBuffer
uint32_t functionalWrite(Packet *pkt);
private:
+ void reanalyzeList(std::list<MsgPtr> &, Tick);
+
+ private:
//added by SS
Cycles m_recycle_latency;
@@ -172,7 +175,6 @@ class MessageBuffer
// use a std::map for the stalled messages as this container is
// sorted and ensures a well-defined iteration order
typedef std::map< Address, std::list<MsgPtr> > StallMsgMapType;
- typedef std::vector<MsgPtr>::iterator MsgListIter;
StallMsgMapType m_stall_msg_map;
std::string m_name;
diff --git a/src/mem/ruby/slicc_interface/AbstractController.hh b/src/mem/ruby/slicc_interface/AbstractController.hh
index e3584fa8b..d6ba928fd 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.hh
+++ b/src/mem/ruby/slicc_interface/AbstractController.hh
@@ -137,9 +137,11 @@ class AbstractController : public ClockedObject, public Consumer
Network* m_net_ptr;
bool m_is_blocking;
std::map<Address, MessageBuffer*> m_block_map;
+
typedef std::vector<MessageBuffer*> MsgVecType;
typedef std::map< Address, MsgVecType* > WaitingBufType;
WaitingBufType m_waiting_buffers;
+
unsigned int m_in_ports;
unsigned int m_cur_in_port;
int m_number_of_TBEs;