ruby: message buffer: removes some unecessary functions.

This commit is contained in:
Nilay Vaish 2014-02-20 17:26:41 -06:00
parent 0d6009e8dc
commit b312a41f21
8 changed files with 33 additions and 80 deletions

View file

@ -75,7 +75,7 @@ MessageBuffer::getSize()
} }
bool bool
MessageBuffer::areNSlotsAvailable(int n) MessageBuffer::areNSlotsAvailable(unsigned int n)
{ {
// fast path when message buffers have infinite size // fast path when message buffers have infinite size
@ -124,7 +124,7 @@ MessageBuffer::getMsgPtrCopy() const
} }
const Message* const Message*
MessageBuffer::peekAtHeadOfQueue() const MessageBuffer::peek() const
{ {
DPRINTF(RubyQueue, "Peeking at head of queue.\n"); DPRINTF(RubyQueue, "Peeking at head of queue.\n");
assert(isReady()); assert(isReady());
@ -160,9 +160,7 @@ MessageBuffer::enqueue(MsgPtr message, Cycles delta)
} }
m_msgs_this_cycle++; m_msgs_this_cycle++;
if (!m_ordering_set) { assert(m_ordering_set);
panic("Ordering property of %s has not been set", m_name);
}
// Calculate the arrival time of the message, that is, the first // Calculate the arrival time of the message, that is, the first
// cycle the message can be dequeued. // cycle the message can be dequeued.
@ -211,9 +209,7 @@ MessageBuffer::enqueue(MsgPtr message, Cycles delta)
assert(m_sender->clockEdge() >= msg_ptr->getLastEnqueueTime() && assert(m_sender->clockEdge() >= msg_ptr->getLastEnqueueTime() &&
"ensure we aren't dequeued early"); "ensure we aren't dequeued early");
msg_ptr->setDelayedTicks(m_sender->clockEdge() - msg_ptr->updateDelayedTicks(m_sender->clockEdge());
msg_ptr->getLastEnqueueTime() +
msg_ptr->getDelayedTicks());
msg_ptr->setLastEnqueueTime(arrival_time); msg_ptr->setLastEnqueueTime(arrival_time);
// Insert the message into the priority heap // Insert the message into the priority heap
@ -226,29 +222,9 @@ MessageBuffer::enqueue(MsgPtr message, Cycles delta)
arrival_time, *(message.get())); arrival_time, *(message.get()));
// Schedule the wakeup // Schedule the wakeup
if (m_consumer != NULL) { assert(m_consumer != NULL);
m_consumer->scheduleEventAbsolute(arrival_time); m_consumer->scheduleEventAbsolute(arrival_time);
m_consumer->storeEventInfo(m_vnet_id); m_consumer->storeEventInfo(m_vnet_id);
} else {
panic("No consumer: %s name: %s\n", *this, m_name);
}
}
Cycles
MessageBuffer::dequeue_getDelayCycles(MsgPtr& message)
{
dequeue(message);
return setAndReturnDelayCycles(message);
}
void
MessageBuffer::dequeue(MsgPtr& message)
{
DPRINTF(RubyQueue, "Dequeueing\n");
message = m_prio_heap.front().m_msgptr;
pop();
DPRINTF(RubyQueue, "Enqueue message is %s\n", (*(message.get())));
} }
Cycles Cycles
@ -258,14 +234,16 @@ MessageBuffer::dequeue_getDelayCycles()
MsgPtr message = m_prio_heap.front().m_msgptr; MsgPtr message = m_prio_heap.front().m_msgptr;
// get the delay cycles // get the delay cycles
Cycles delayCycles = setAndReturnDelayCycles(message); message->updateDelayedTicks(m_receiver->clockEdge());
Cycles delayCycles =
m_receiver->ticksToCycles(message->getDelayedTicks());
dequeue(); dequeue();
return delayCycles; return delayCycles;
} }
void void
MessageBuffer::pop() MessageBuffer::dequeue()
{ {
DPRINTF(RubyQueue, "Popping\n"); DPRINTF(RubyQueue, "Popping\n");
assert(isReady()); assert(isReady());
@ -375,7 +353,7 @@ MessageBuffer::stallMessage(const Address& addr)
assert(addr.getOffset() == 0); assert(addr.getOffset() == 0);
MsgPtr message = m_prio_heap.front().m_msgptr; MsgPtr message = m_prio_heap.front().m_msgptr;
pop(); dequeue();
// //
// Note: no event is scheduled to analyze the map at a later time. // Note: no event is scheduled to analyze the map at a later time.
@ -385,22 +363,6 @@ MessageBuffer::stallMessage(const Address& addr)
(m_stall_msg_map[addr]).push_back(message); (m_stall_msg_map[addr]).push_back(message);
} }
Cycles
MessageBuffer::setAndReturnDelayCycles(MsgPtr msg_ptr)
{
// get the delay cycles of the message at the top of the queue
// this function should only be called on dequeue
// ensure the msg hasn't been enqueued
assert(msg_ptr->getLastEnqueueTime() <= m_receiver->clockEdge());
msg_ptr->setDelayedTicks(m_receiver->clockEdge() -
msg_ptr->getLastEnqueueTime() +
msg_ptr->getDelayedTicks());
return m_receiver->ticksToCycles(msg_ptr->getDelayedTicks());
}
void void
MessageBuffer::print(ostream& out) const MessageBuffer::print(ostream& out) const
{ {

View file

@ -74,7 +74,7 @@ class MessageBuffer
enqueue(node.m_msgptr, Cycles(1)); enqueue(node.m_msgptr, Cycles(1));
} }
bool areNSlotsAvailable(int n); bool areNSlotsAvailable(unsigned int n);
int getPriority() { return m_priority_rank; } int getPriority() { return m_priority_rank; }
void setPriority(int rank) { m_priority_rank = rank; } void setPriority(int rank) { m_priority_rank = rank; }
void setConsumer(Consumer* consumer) void setConsumer(Consumer* consumer)
@ -104,8 +104,9 @@ class MessageBuffer
Consumer* getConsumer() { return m_consumer; } Consumer* getConsumer() { return m_consumer; }
const Message* peekAtHeadOfQueue() const; //! Function for extracting the message at the head of the
const Message* peek() const { return peekAtHeadOfQueue(); } //! message queue. The function assumes that the queue is nonempty.
const Message* peek() const;
const MsgPtr getMsgPtrCopy() const; const MsgPtr getMsgPtrCopy() const;
const MsgPtr& const MsgPtr&
@ -115,23 +116,15 @@ class MessageBuffer
return m_prio_heap.front().m_msgptr; return m_prio_heap.front().m_msgptr;
} }
const MsgPtr&
peekMsgPtrEvenIfNotReady() const
{
return m_prio_heap.front().m_msgptr;
}
void enqueue(MsgPtr message) { enqueue(message, Cycles(1)); } void enqueue(MsgPtr message) { enqueue(message, Cycles(1)); }
void enqueue(MsgPtr message, Cycles delta); void enqueue(MsgPtr message, Cycles delta);
//! returns delay ticks of the message. //! Updates the delay cycles of the message at the of the queue,
Cycles dequeue_getDelayCycles(MsgPtr& message); //! removes it from the queue and returns its total delay.
void dequeue(MsgPtr& message);
//! returns delay cycles of the message
Cycles dequeue_getDelayCycles(); Cycles dequeue_getDelayCycles();
void dequeue() { pop(); }
void pop(); void dequeue();
void recycle(); void recycle();
bool isEmpty() const { return m_prio_heap.size() == 0; } bool isEmpty() const { return m_prio_heap.size() == 0; }
@ -141,12 +134,12 @@ class MessageBuffer
m_strict_fifo = order; m_strict_fifo = order;
m_ordering_set = true; m_ordering_set = true;
} }
void resize(int size) { m_max_size = size; } void resize(int size) { m_max_size = size; }
int getSize(); int getSize();
void setRandomization(bool random_flag) { m_randomization = random_flag; } void setRandomization(bool random_flag) { m_randomization = random_flag; }
void clear(); void clear();
void print(std::ostream& out) const; void print(std::ostream& out) const;
void clearStats() { m_not_avail_count = 0; m_msg_counter = 0; } void clearStats() { m_not_avail_count = 0; m_msg_counter = 0; }
@ -168,13 +161,6 @@ class MessageBuffer
//added by SS //added by SS
Cycles m_recycle_latency; Cycles m_recycle_latency;
// Private Methods
Cycles setAndReturnDelayCycles(MsgPtr message);
// Private copy constructor and assignment operator
MessageBuffer(const MessageBuffer& obj);
MessageBuffer& operator=(const MessageBuffer& obj);
// Data Members (m_ prefix) // Data Members (m_ prefix)
//! The two ends of the buffer. //! The two ends of the buffer.
ClockedObject* m_sender; ClockedObject* m_sender;

View file

@ -227,7 +227,7 @@ NetworkInterface_d::wakeup()
while (inNode_ptr[vnet]->isReady()) { // Is there a message waiting while (inNode_ptr[vnet]->isReady()) { // Is there a message waiting
msg_ptr = inNode_ptr[vnet]->peekMsgPtr(); msg_ptr = inNode_ptr[vnet]->peekMsgPtr();
if (flitisizeMessage(msg_ptr, vnet)) { if (flitisizeMessage(msg_ptr, vnet)) {
inNode_ptr[vnet]->pop(); inNode_ptr[vnet]->dequeue();
} else { } else {
break; break;
} }

View file

@ -253,7 +253,7 @@ NetworkInterface::wakeup()
{ {
msg_ptr = inNode_ptr[vnet]->peekMsgPtr(); msg_ptr = inNode_ptr[vnet]->peekMsgPtr();
if (flitisizeMessage(msg_ptr, vnet)) { if (flitisizeMessage(msg_ptr, vnet)) {
inNode_ptr[vnet]->pop(); inNode_ptr[vnet]->dequeue();
} else { } else {
break; break;
} }

View file

@ -286,7 +286,7 @@ PerfectSwitch::wakeup()
} }
// Dequeue msg // Dequeue msg
m_in[incoming][vnet]->pop(); m_in[incoming][vnet]->dequeue();
m_pending_message_count[vnet]--; m_pending_message_count[vnet]--;
} }
} }

View file

@ -160,7 +160,7 @@ Throttle::wakeup()
// Move the message // Move the message
m_out[vnet]->enqueue(m_in[vnet]->peekMsgPtr(), m_link_latency); m_out[vnet]->enqueue(m_in[vnet]->peekMsgPtr(), m_link_latency);
m_in[vnet]->pop(); m_in[vnet]->dequeue();
// Count the message // Count the message
m_msg_counts[net_msg_ptr->getMessageSize()][vnet]++; m_msg_counts[net_msg_ptr->getMessageSize()][vnet]++;

View file

@ -71,7 +71,13 @@ class Message : public RefCounted
virtual bool functionalWrite(Packet *pkt) = 0; virtual bool functionalWrite(Packet *pkt) = 0;
//{ fatal("Write functional access not implemented!"); } //{ fatal("Write functional access not implemented!"); }
void setDelayedTicks(const Tick ticks) { m_DelayedTicks = ticks; } //! Update the delay this message has experienced so far.
void updateDelayedTicks(Tick curTime)
{
assert(m_LastEnqueueTime <= curTime);
Tick delta = curTime - m_LastEnqueueTime;
m_DelayedTicks += delta;
}
const Tick getDelayedTicks() const {return m_DelayedTicks;} const Tick getDelayedTicks() const {return m_DelayedTicks;}
void setLastEnqueueTime(const Tick& time) { m_LastEnqueueTime = time; } void setLastEnqueueTime(const Tick& time) { m_LastEnqueueTime = time; }

View file

@ -30,7 +30,6 @@
#include "debug/RubyStats.hh" #include "debug/RubyStats.hh"
#include "mem/protocol/SequencerMsg.hh" #include "mem/protocol/SequencerMsg.hh"
#include "mem/protocol/SequencerRequestType.hh" #include "mem/protocol/SequencerRequestType.hh"
#include "mem/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/system/DMASequencer.hh" #include "mem/ruby/system/DMASequencer.hh"
#include "mem/ruby/system/System.hh" #include "mem/ruby/system/System.hh"