Go to the documentation of this file.
49 #include "debug/RubyQueue.hh"
52 using m5::stl_helpers::operator<<;
56 m_max_size(
p.buffer_size), m_time_last_time_size_checked(0),
57 m_time_last_time_enqueue(0), m_time_last_time_pop(0),
58 m_last_arrival_time(0), m_strict_fifo(
p.ordered),
59 m_randomization(
p.randomization),
60 m_allow_zero_latency(
p.allow_zero_latency),
61 ADD_STAT(m_not_avail_count,
"Number of times this buffer did not have "
63 ADD_STAT(m_buf_msgs,
"Average number of messages in buffer"),
64 ADD_STAT(m_stall_time,
"Average number of cycles messages are stalled in "
66 ADD_STAT(m_stall_count,
"Number of times messages were stalled"),
67 ADD_STAT(m_occupancy,
"Average occupancy of buffer capacity")
133 unsigned int current_size = 0;
134 unsigned int current_stall_size = 0;
155 if (current_size + current_stall_size +
n <=
m_max_size) {
158 DPRINTF(RubyQueue,
"n: %d, current_size: %d, heap size: %d, "
160 n, current_size + current_stall_size,
170 DPRINTF(RubyQueue,
"Peeking at head of queue.\n");
174 DPRINTF(RubyQueue,
"Message: %s\n", (*msg_ptr));
205 "Delta equals zero and allow_zero_latency is false during enqueue");
206 Tick arrival_time = 0;
214 arrival_time = current_time + delta;
228 assert(arrival_time >= current_time);
231 panic(
"FIFO ordering violated: %s name: %s current time: %d "
232 "delta: %d arrival_time: %d last arrival_time: %d\n",
233 *
this,
name(), current_time, delta, arrival_time,
244 Message* msg_ptr = message.get();
245 assert(msg_ptr != NULL);
248 "ensure we aren't dequeued early");
263 DPRINTF(RubyQueue,
"Enqueue arrival_time: %lld, Message: %s\n",
264 arrival_time, *(message.get()));
275 DPRINTF(RubyQueue,
"Popping\n");
282 message->updateDelayedTicks(current_time);
283 Tick delay = message->getDelayedTicks();
297 if (decrement_messages) {
339 DPRINTF(RubyQueue,
"Recycling.\n");
344 Tick future_time = current_time + recycle_latency;
345 node->setLastEnqueueTime(future_time);
355 while (!
lt.empty()) {
357 assert(
m->getLastEnqueueTime() <= schdTick);
361 std::greater<MsgPtr>());
365 DPRINTF(RubyQueue,
"Requeue arrival_time: %lld, Message: %s\n",
366 schdTick, *(
m.get()));
375 DPRINTF(RubyQueue,
"ReanalyzeMessages %#x\n",
addr);
393 DPRINTF(RubyQueue,
"ReanalyzeAllMessages\n");
441 DPRINTF(RubyQueue,
"Deferring enqueueing message: %s, Address %#x\n",
442 *(message.get()),
addr);
451 assert(msg_vec.size() > 0);
477 std::sort_heap(copy.begin(), copy.end(), std::greater<MsgPtr>());
485 (
m_prio_heap.front()->getLastEnqueueTime() <= current_time));
491 DPRINTF(RubyQueue,
"functional %s for %#x\n",
492 is_read ?
"read" :
"write", pkt->
getAddr());
494 uint32_t num_functional_accesses = 0;
503 num_functional_accesses++;
505 num_functional_accesses++;
515 it != (map_iter->second).end(); ++it) {
521 num_functional_accesses++;
523 num_functional_accesses++;
527 return num_functional_accesses;
virtual bool functionalRead(Packet *pkt)
The two functions below are used for reading / writing the message functionally.
unsigned int m_msgs_this_cycle
Tick dequeue(Tick current_time, bool decrement_messages=true)
Updates the delay cycles of the message at the head of the queue, removes it from the queue and retur...
Tick getLastEnqueueTime() const
Stats::Average m_stall_time
const Message * peek() const
Function for extracting the message at the head of the message queue.
unsigned int m_size_at_cycle_start
std::function< void()> m_dequeue_callback
DeferredMsgMapType m_deferred_msg_map
uint64_t Tick
Tick count type.
unsigned int getSize(Tick curTime)
virtual bool functionalWrite(Packet *pkt)
void reanalyzeMessages(Addr addr, Tick current_time)
Tick m_time_last_time_pop
void stallMessage(Addr addr, Tick current_time)
void enqueue(MsgPtr message, Tick curTime, Tick delta)
std::enable_if_t< std::is_integral< T >::value, T > random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
void updateDelayedTicks(Tick curTime)
Update the delay this message has experienced so far.
std::vector< MsgPtr > m_prio_heap
const unsigned int m_max_size
The maximum capacity.
void deferEnqueueingMessage(Addr addr, MsgPtr message)
Tick m_time_last_time_enqueue
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
uint32_t functionalAccess(Packet *pkt, bool is_read, WriteMask *mask)
unsigned int m_stalled_at_cycle_start
bool isReady(Tick current_time) const
bool isDeferredMsgMapEmpty(Addr addr) const
void reanalyzeAllMessages(Tick current_time)
bool hasStalledMsg(Addr addr) const
Stats::Scalar m_not_avail_count
unsigned int m_size_last_time_size_checked
Consumer * m_consumer
Consumer to signal a wakeup(), can be NULL.
const MessageRandomization m_randomization
void unregisterDequeueCallback()
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
const bool m_allow_zero_latency
int m_stall_map_size
Current size of the stall map.
MessageBufferParams Params
std::shared_ptr< Message > MsgPtr
bool areNSlotsAvailable(unsigned int n, Tick curTime)
const FlagsType nozero
Don't print if this is zero.
void recycle(Tick current_time, Tick recycle_latency)
void registerDequeueCallback(std::function< void()> callback)
virtual const std::string name() const
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
void print(std::ostream &out) const
void setLastEnqueueTime(const Tick &time)
void scheduleEventAbsolute(Tick timeAbs)
static bool getWarmupEnabled()
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Addr getOffset(Addr addr)
void reanalyzeList(std::list< MsgPtr > &, Tick)
MessageBuffer(const Params &p)
void ccprintf(cp::Print &print)
Stats::Formula m_occupancy
void enqueueDeferredMessages(Addr addr, Tick curTime, Tick delay)
static int getRandomization()
Tick curTick()
The universal simulation clock.
Stats::Average m_buf_msgs
Tick m_time_last_time_size_checked
virtual void storeEventInfo(int info)
Stats::Scalar m_stall_count
StallMsgMapType m_stall_msg_map
A map from line addresses to lists of stalled messages for that line.
void setMsgCounter(uint64_t c)
#define panic(...)
This implements a cprintf based panic() function.
Abstract superclass for simulation objects.
Generated on Tue Jun 22 2021 15:28:30 for gem5 by doxygen 1.8.17