}
bool
-MessageBuffer::areNSlotsAvailable(int n)
+MessageBuffer::areNSlotsAvailable(unsigned int n)
{
// fast path when message buffers have infinite size
}
const Message*
-MessageBuffer::peekAtHeadOfQueue() const
+MessageBuffer::peek() const
{
DPRINTF(RubyQueue, "Peeking at head of queue.\n");
assert(isReady());
}
m_msgs_this_cycle++;
- if (!m_ordering_set) {
- panic("Ordering property of %s has not been set", m_name);
- }
+ assert(m_ordering_set);
// Calculate the arrival time of the message, that is, the first
// cycle the message can be dequeued.
assert(m_sender->clockEdge() >= msg_ptr->getLastEnqueueTime() &&
"ensure we aren't dequeued early");
- msg_ptr->setDelayedTicks(m_sender->clockEdge() -
- msg_ptr->getLastEnqueueTime() +
- msg_ptr->getDelayedTicks());
+ msg_ptr->updateDelayedTicks(m_sender->clockEdge());
msg_ptr->setLastEnqueueTime(arrival_time);
// Insert the message into the priority heap
arrival_time, *(message.get()));
// Schedule the wakeup
- if (m_consumer != NULL) {
- m_consumer->scheduleEventAbsolute(arrival_time);
- 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())));
+ assert(m_consumer != NULL);
+ m_consumer->scheduleEventAbsolute(arrival_time);
+ m_consumer->storeEventInfo(m_vnet_id);
}
Cycles
MsgPtr message = m_prio_heap.front().m_msgptr;
// get the delay cycles
- Cycles delayCycles = setAndReturnDelayCycles(message);
+ message->updateDelayedTicks(m_receiver->clockEdge());
+ Cycles delayCycles =
+ m_receiver->ticksToCycles(message->getDelayedTicks());
dequeue();
return delayCycles;
}
void
-MessageBuffer::pop()
+MessageBuffer::dequeue()
{
DPRINTF(RubyQueue, "Popping\n");
assert(isReady());
assert(addr.getOffset() == 0);
MsgPtr message = m_prio_heap.front().m_msgptr;
- pop();
+ dequeue();
//
// Note: no event is scheduled to analyze the map at a later time.
(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
MessageBuffer::print(ostream& out) const
{
enqueue(node.m_msgptr, Cycles(1));
}
- bool areNSlotsAvailable(int n);
+ bool areNSlotsAvailable(unsigned int n);
int getPriority() { return m_priority_rank; }
void setPriority(int rank) { m_priority_rank = rank; }
void setConsumer(Consumer* consumer)
Consumer* getConsumer() { return m_consumer; }
- const Message* peekAtHeadOfQueue() const;
- const Message* peek() const { return peekAtHeadOfQueue(); }
+ //! Function for extracting the message at the head of the
+ //! message queue. The function assumes that the queue is nonempty.
+ const Message* peek() const;
const MsgPtr getMsgPtrCopy() const;
const 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, Cycles delta);
- //! returns delay ticks of the message.
- Cycles dequeue_getDelayCycles(MsgPtr& message);
- void dequeue(MsgPtr& message);
-
- //! returns delay cycles of the message
+ //! Updates the delay cycles of the message at the of the queue,
+ //! removes it from the queue and returns its total delay.
Cycles dequeue_getDelayCycles();
- void dequeue() { pop(); }
- void pop();
+
+ void dequeue();
+
void recycle();
bool isEmpty() const { return m_prio_heap.size() == 0; }
m_strict_fifo = order;
m_ordering_set = true;
}
+
void resize(int size) { m_max_size = size; }
int getSize();
void setRandomization(bool random_flag) { m_randomization = random_flag; }
void clear();
-
void print(std::ostream& out) const;
void clearStats() { m_not_avail_count = 0; m_msg_counter = 0; }
//added by SS
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)
//! The two ends of the buffer.
ClockedObject* m_sender;
while (inNode_ptr[vnet]->isReady()) { // Is there a message waiting
msg_ptr = inNode_ptr[vnet]->peekMsgPtr();
if (flitisizeMessage(msg_ptr, vnet)) {
- inNode_ptr[vnet]->pop();
+ inNode_ptr[vnet]->dequeue();
} else {
break;
}
{
msg_ptr = inNode_ptr[vnet]->peekMsgPtr();
if (flitisizeMessage(msg_ptr, vnet)) {
- inNode_ptr[vnet]->pop();
+ inNode_ptr[vnet]->dequeue();
} else {
break;
}
}
// Dequeue msg
- m_in[incoming][vnet]->pop();
+ m_in[incoming][vnet]->dequeue();
m_pending_message_count[vnet]--;
}
}
// Move the message
m_out[vnet]->enqueue(m_in[vnet]->peekMsgPtr(), m_link_latency);
- m_in[vnet]->pop();
+ m_in[vnet]->dequeue();
// Count the message
m_msg_counts[net_msg_ptr->getMessageSize()][vnet]++;
virtual bool functionalWrite(Packet *pkt) = 0;
//{ 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;}
void setLastEnqueueTime(const Tick& time) { m_LastEnqueueTime = time; }
#include "debug/RubyStats.hh"
#include "mem/protocol/SequencerMsg.hh"
#include "mem/protocol/SequencerRequestType.hh"
-#include "mem/ruby/buffers/MessageBuffer.hh"
#include "mem/ruby/system/DMASequencer.hh"
#include "mem/ruby/system/System.hh"