37 #include "debug/RubyQueue.hh" 41 using m5::stl_helpers::operator<<;
45 m_max_size(p->buffer_size), m_time_last_time_size_checked(0),
46 m_time_last_time_enqueue(0), m_time_last_time_pop(0),
47 m_last_arrival_time(0), m_strict_fifo(p->ordered),
48 m_randomization(p->randomization)
92 unsigned int current_size = 0;
93 unsigned int current_stall_size = 0;
114 if (current_size + current_stall_size + n <=
m_max_size) {
117 DPRINTF(RubyQueue,
"n: %d, current_size: %d, heap size: %d, " 119 n, current_size + current_stall_size,
129 DPRINTF(RubyQueue,
"Peeking at head of queue.\n");
133 DPRINTF(RubyQueue,
"Message: %s\n", (*msg_ptr));
164 Tick arrival_time = 0;
170 arrival_time = current_time + delta;
184 assert(arrival_time > current_time);
187 panic(
"FIFO ordering violated: %s name: %s current time: %d " 188 "delta: %d arrival_time: %d last arrival_time: %d\n",
189 *
this,
name(), current_time, delta, arrival_time,
200 Message* msg_ptr = message.get();
201 assert(msg_ptr != NULL);
204 "ensure we aren't dequeued early");
216 DPRINTF(RubyQueue,
"Enqueue arrival_time: %lld, Message: %s\n",
217 arrival_time, *(message.get()));
228 DPRINTF(RubyQueue,
"Popping\n");
235 message->updateDelayedTicks(current_time);
236 Tick delay = message->getDelayedTicks();
250 if (decrement_messages) {
292 DPRINTF(RubyQueue,
"Recycling.\n");
297 Tick future_time = current_time + recycle_latency;
298 node->setLastEnqueueTime(future_time);
308 while (!lt.empty()) {
310 assert(m->getLastEnqueueTime() <= schdTick);
318 DPRINTF(RubyQueue,
"Requeue arrival_time: %lld, Message: %s\n",
319 schdTick, *(m.get()));
328 DPRINTF(RubyQueue,
"ReanalyzeMessages %#x\n", addr);
338 assert(m_stall_map_size >= 0);
346 DPRINTF(RubyQueue,
"ReanalyzeAllMessages\n");
366 DPRINTF(RubyQueue,
"Stalling due to %#x\n", addr);
394 sort_heap(copy.begin(), copy.end(), greater<MsgPtr>());
402 (
m_prio_heap.front()->getLastEnqueueTime() <= current_time));
410 .
desc(
"Number of times this buffer did not have N slots available")
415 .
desc(
"Average number of messages in buffer")
420 .
desc(
"Number of times messages were stalled")
425 .
desc(
"Average occupancy of buffer capacity")
430 .
desc(
"Average number of cycles messages are stalled in this MB")
443 uint32_t num_functional_writes = 0;
450 num_functional_writes++;
461 it != (map_iter->second).end(); ++it) {
465 num_functional_writes++;
470 return num_functional_writes;
474 MessageBufferParams::create()
#define panic(...)
This implements a cprintf based panic() function.
bool isReady(Tick current_time) const
void ccprintf(cp::Print &print)
const Message * peek() const
Function for extracting the message at the head of the message queue.
unsigned int m_stalled_at_cycle_start
Tick m_time_last_time_size_checked
std::shared_ptr< Message > MsgPtr
const bool m_randomization
MessageBuffer(const Params *p)
StallMsgMapType m_stall_msg_map
A map from line addresses to lists of stalled messages for that line.
void recycle(Tick current_time, Tick recycle_latency)
void reanalyzeMessages(Addr addr, Tick current_time)
void stallMessage(Addr addr, Tick current_time)
Stats::Average m_stall_time
Overload hash function for BasicBlockRange type.
virtual void storeEventInfo(int info)
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
unsigned int m_size_last_time_size_checked
uint32_t functionalWrite(Packet *pkt)
Stats::Average m_buf_msgs
std::enable_if< std::is_integral< T >::value, T >::type random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
void scheduleEventAbsolute(Tick timeAbs)
unsigned int getSize(Tick curTime)
static bool getWarmupEnabled()
bool areNSlotsAvailable(unsigned int n, Tick curTime)
Tick curTick()
The current simulated tick.
void setMsgCounter(uint64_t c)
virtual bool functionalWrite(Packet *pkt)=0
uint64_t Tick
Tick count type.
Stats::Scalar m_not_avail_count
int m_stall_map_size
Current size of the stall map.
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...
void unregisterDequeueCallback()
Addr getOffset(Addr addr)
unsigned int m_msgs_this_cycle
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual const std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
unsigned int m_size_at_cycle_start
Stats::Formula m_occupancy
void print(std::ostream &out) const
Tick getLastEnqueueTime() const
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Consumer * m_consumer
Consumer to signal a wakeup(), can be NULL.
void reanalyzeList(std::list< MsgPtr > &, Tick)
void regStats() override
Callback to set stat parameters.
Tick m_time_last_time_pop
Stats::Scalar m_stall_count
Tick m_time_last_time_enqueue
void reanalyzeAllMessages(Tick current_time)
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
const unsigned int m_max_size
The maximum capacity.
void updateDelayedTicks(Tick curTime)
Update the delay this message has experienced so far.
std::function< void()> m_dequeue_callback
const FlagsType nozero
Don't print if this is zero.
std::vector< MsgPtr > m_prio_heap
void enqueue(MsgPtr message, Tick curTime, Tick delta)
void registerDequeueCallback(std::function< void()> callback)
MessageBufferParams Params
Abstract superclass for simulation objects.
void setLastEnqueueTime(const Tick &time)
static int getRandomization()