summaryrefslogtreecommitdiff
path: root/src/mem/ruby/structures
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2015-07-04 10:43:46 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2015-07-04 10:43:46 -0500
commitb4efb48a71c42085134e57840aa9562884404d11 (patch)
tree0626bf3d54745737f3553fcf0a6a931813e441e6 /src/mem/ruby/structures
parent25e1b1c1f5f4e0ad3976c88998161700135f4aae (diff)
downloadgem5-b4efb48a71c42085134e57840aa9562884404d11.tar.xz
ruby: remove message buffer node
This structure's only purpose was to provide a comparison function for ordering messages in the MessageBuffer. The comparison function is now being moved to the Message class itself. So we no longer require this structure.
Diffstat (limited to 'src/mem/ruby/structures')
-rw-r--r--src/mem/ruby/structures/WireBuffer.cc33
-rw-r--r--src/mem/ruby/structures/WireBuffer.hh5
2 files changed, 14 insertions, 24 deletions
diff --git a/src/mem/ruby/structures/WireBuffer.cc b/src/mem/ruby/structures/WireBuffer.cc
index 702a53f16..3308dbe8e 100644
--- a/src/mem/ruby/structures/WireBuffer.cc
+++ b/src/mem/ruby/structures/WireBuffer.cc
@@ -77,8 +77,9 @@ WireBuffer::enqueue(MsgPtr message, Cycles latency)
Cycles arrival_time = current_time + latency;
assert(arrival_time > current_time);
- MessageBufferNode thisNode(arrival_time, m_msg_counter, message);
- m_message_queue.push_back(thisNode);
+ Message* msg_ptr = message.get();
+ msg_ptr->setLastEnqueueTime(arrival_time);
+ m_message_queue.push_back(message);
if (m_consumer_ptr != NULL) {
m_consumer_ptr->
scheduleEventAbsolute(g_system_ptr->clockPeriod() * arrival_time);
@@ -92,27 +93,18 @@ WireBuffer::dequeue()
{
assert(isReady());
pop_heap(m_message_queue.begin(), m_message_queue.end(),
- greater<MessageBufferNode>());
+ greater<MsgPtr>());
m_message_queue.pop_back();
}
const Message*
WireBuffer::peek()
{
- MessageBufferNode node = peekNode();
- Message* msg_ptr = node.m_msgptr.get();
+ Message* msg_ptr = m_message_queue.front().get();
assert(msg_ptr != NULL);
return msg_ptr;
}
-MessageBufferNode
-WireBuffer::peekNode()
-{
- assert(isReady());
- MessageBufferNode req = m_message_queue.front();
- return req;
-}
-
void
WireBuffer::recycle()
{
@@ -121,23 +113,23 @@ WireBuffer::recycle()
// Wire-like situations because you don't want to deadlock as a result of
// being stuck behind something if you're not actually supposed to.
assert(isReady());
- MessageBufferNode node = m_message_queue.front();
- pop_heap(m_message_queue.begin(), m_message_queue.end(),
- greater<MessageBufferNode>());
+ MsgPtr node = m_message_queue.front();
+ pop_heap(m_message_queue.begin(), m_message_queue.end(), greater<MsgPtr>());
- node.m_time = g_system_ptr->curCycle() + Cycles(1);
+ node->setLastEnqueueTime(g_system_ptr->curCycle() + Cycles(1));
m_message_queue.back() = node;
push_heap(m_message_queue.begin(), m_message_queue.end(),
- greater<MessageBufferNode>());
+ greater<MsgPtr>());
m_consumer_ptr->
- scheduleEventAbsolute(g_system_ptr->clockPeriod() * node.m_time);
+ scheduleEventAbsolute(g_system_ptr->curCycle() + Cycles(1));
}
bool
WireBuffer::isReady()
{
return ((!m_message_queue.empty()) &&
- (m_message_queue.front().m_time <= g_system_ptr->curCycle()));
+ (m_message_queue.front()->getLastEnqueueTime() <=
+ g_system_ptr->curCycle()));
}
void
@@ -155,4 +147,3 @@ RubyWireBufferParams::create()
{
return new WireBuffer(this);
}
-
diff --git a/src/mem/ruby/structures/WireBuffer.hh b/src/mem/ruby/structures/WireBuffer.hh
index a362d524e..a724f1381 100644
--- a/src/mem/ruby/structures/WireBuffer.hh
+++ b/src/mem/ruby/structures/WireBuffer.hh
@@ -37,7 +37,7 @@
#include <vector>
#include "mem/ruby/common/Consumer.hh"
-#include "mem/ruby/network/MessageBufferNode.hh"
+#include "mem/ruby/slicc_interface/Message.hh"
#include "params/RubyWireBuffer.hh"
#include "sim/sim_object.hh"
@@ -75,7 +75,6 @@ class WireBuffer : public SimObject
void enqueue(MsgPtr message, Cycles latency);
void dequeue();
const Message* peek();
- MessageBufferNode peekNode();
void recycle();
bool isReady();
bool areNSlotsAvailable(int n) { return true; }; // infinite queue length
@@ -93,7 +92,7 @@ class WireBuffer : public SimObject
std::string m_description;
// queues where memory requests live
- std::vector<MessageBufferNode> m_message_queue;
+ std::vector<MsgPtr> m_message_queue;
};