MessageBuffer.cc (11793:ef606668d247) MessageBuffer.cc (11796:315e133f45df)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 43 unchanged lines hidden (view full) ---

52 m_size_last_time_size_checked = 0;
53 m_size_at_cycle_start = 0;
54 m_msgs_this_cycle = 0;
55 m_priority_rank = 0;
56
57 m_stall_msg_map.clear();
58 m_input_link_id = 0;
59 m_vnet_id = 0;
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 43 unchanged lines hidden (view full) ---

52 m_size_last_time_size_checked = 0;
53 m_size_at_cycle_start = 0;
54 m_msgs_this_cycle = 0;
55 m_priority_rank = 0;
56
57 m_stall_msg_map.clear();
58 m_input_link_id = 0;
59 m_vnet_id = 0;
60
61 m_buf_msgs = 0;
62 m_stall_time = 0;
60}
61
62unsigned int
63MessageBuffer::getSize(Tick curTime)
64{
65 if (m_time_last_time_size_checked != curTime) {
66 m_time_last_time_size_checked = curTime;
67 m_size_last_time_size_checked = m_prio_heap.size();

--- 123 unchanged lines hidden (view full) ---

191
192 msg_ptr->updateDelayedTicks(current_time);
193 msg_ptr->setLastEnqueueTime(arrival_time);
194 msg_ptr->setMsgCounter(m_msg_counter);
195
196 // Insert the message into the priority heap
197 m_prio_heap.push_back(message);
198 push_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
63}
64
65unsigned int
66MessageBuffer::getSize(Tick curTime)
67{
68 if (m_time_last_time_size_checked != curTime) {
69 m_time_last_time_size_checked = curTime;
70 m_size_last_time_size_checked = m_prio_heap.size();

--- 123 unchanged lines hidden (view full) ---

194
195 msg_ptr->updateDelayedTicks(current_time);
196 msg_ptr->setLastEnqueueTime(arrival_time);
197 msg_ptr->setMsgCounter(m_msg_counter);
198
199 // Insert the message into the priority heap
200 m_prio_heap.push_back(message);
201 push_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
202 // Increment the number of messages statistic
203 m_buf_msgs++;
199
200 DPRINTF(RubyQueue, "Enqueue arrival_time: %lld, Message: %s\n",
201 arrival_time, *(message.get()));
202
203 // Schedule the wakeup
204 assert(m_consumer != NULL);
205 m_consumer->scheduleEventAbsolute(arrival_time);
206 m_consumer->storeEventInfo(m_vnet_id);
207}
208
209Tick
204
205 DPRINTF(RubyQueue, "Enqueue arrival_time: %lld, Message: %s\n",
206 arrival_time, *(message.get()));
207
208 // Schedule the wakeup
209 assert(m_consumer != NULL);
210 m_consumer->scheduleEventAbsolute(arrival_time);
211 m_consumer->storeEventInfo(m_vnet_id);
212}
213
214Tick
210MessageBuffer::dequeue(Tick current_time)
215MessageBuffer::dequeue(Tick current_time, bool decrement_messages)
211{
212 DPRINTF(RubyQueue, "Popping\n");
213 assert(isReady(current_time));
214
215 // get MsgPtr of the message about to be dequeued
216 MsgPtr message = m_prio_heap.front();
217
218 // get the delay cycles
219 message->updateDelayedTicks(current_time);
220 Tick delay = message->getDelayedTicks();
221
216{
217 DPRINTF(RubyQueue, "Popping\n");
218 assert(isReady(current_time));
219
220 // get MsgPtr of the message about to be dequeued
221 MsgPtr message = m_prio_heap.front();
222
223 // get the delay cycles
224 message->updateDelayedTicks(current_time);
225 Tick delay = message->getDelayedTicks();
226
227 m_stall_time = curTick() - message->getTime();
228
222 // record previous size and time so the current buffer size isn't
223 // adjusted until schd cycle
224 if (m_time_last_time_pop < current_time) {
225 m_size_at_cycle_start = m_prio_heap.size();
226 m_time_last_time_pop = current_time;
227 }
228
229 pop_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
230 m_prio_heap.pop_back();
229 // record previous size and time so the current buffer size isn't
230 // adjusted until schd cycle
231 if (m_time_last_time_pop < current_time) {
232 m_size_at_cycle_start = m_prio_heap.size();
233 m_time_last_time_pop = current_time;
234 }
235
236 pop_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
237 m_prio_heap.pop_back();
238 if (decrement_messages) {
239 // If the message will be removed from the queue, decrement the
240 // number of message in the queue.
241 m_buf_msgs--;
242 }
231
232 return delay;
233}
234
235void
236MessageBuffer::clear()
237{
238 m_prio_heap.clear();

--- 80 unchanged lines hidden (view full) ---

319void
320MessageBuffer::stallMessage(Addr addr, Tick current_time)
321{
322 DPRINTF(RubyQueue, "Stalling due to %#x\n", addr);
323 assert(isReady(current_time));
324 assert(getOffset(addr) == 0);
325 MsgPtr message = m_prio_heap.front();
326
243
244 return delay;
245}
246
247void
248MessageBuffer::clear()
249{
250 m_prio_heap.clear();

--- 80 unchanged lines hidden (view full) ---

331void
332MessageBuffer::stallMessage(Addr addr, Tick current_time)
333{
334 DPRINTF(RubyQueue, "Stalling due to %#x\n", addr);
335 assert(isReady(current_time));
336 assert(getOffset(addr) == 0);
337 MsgPtr message = m_prio_heap.front();
338
327 dequeue(current_time);
339 // Since the message will just be moved to stall map, indicate that the
340 // buffer should not decrement the m_buf_msgs statistic
341 dequeue(current_time, false);
328
329 //
330 // Note: no event is scheduled to analyze the map at a later time.
331 // Instead the controller is responsible to call reanalyzeMessages when
332 // these addresses change state.
333 //
334 (m_stall_msg_map[addr]).push_back(message);
335 m_stall_map_size++;
342
343 //
344 // Note: no event is scheduled to analyze the map at a later time.
345 // Instead the controller is responsible to call reanalyzeMessages when
346 // these addresses change state.
347 //
348 (m_stall_msg_map[addr]).push_back(message);
349 m_stall_map_size++;
350 m_stall_count++;
336}
337
338void
339MessageBuffer::print(ostream& out) const
340{
341 ccprintf(out, "[MessageBuffer: ");
342 if (m_consumer != NULL) {
343 ccprintf(out, " consumer-yes ");

--- 13 unchanged lines hidden (view full) ---

357
358void
359MessageBuffer::regStats()
360{
361 m_not_avail_count
362 .name(name() + ".not_avail_count")
363 .desc("Number of times this buffer did not have N slots available")
364 .flags(Stats::nozero);
351}
352
353void
354MessageBuffer::print(ostream& out) const
355{
356 ccprintf(out, "[MessageBuffer: ");
357 if (m_consumer != NULL) {
358 ccprintf(out, " consumer-yes ");

--- 13 unchanged lines hidden (view full) ---

372
373void
374MessageBuffer::regStats()
375{
376 m_not_avail_count
377 .name(name() + ".not_avail_count")
378 .desc("Number of times this buffer did not have N slots available")
379 .flags(Stats::nozero);
380
381 m_buf_msgs
382 .name(name() + ".avg_buf_msgs")
383 .desc("Average number of messages in buffer")
384 .flags(Stats::nozero);
385
386 m_stall_count
387 .name(name() + ".num_msg_stalls")
388 .desc("Number of times messages were stalled")
389 .flags(Stats::nozero);
390
391 m_occupancy
392 .name(name() + ".avg_buf_occ")
393 .desc("Average occupancy of buffer capacity")
394 .flags(Stats::nozero);
395
396 m_stall_time
397 .name(name() + ".avg_stall_time")
398 .desc("Average number of cycles messages are stalled in this MB")
399 .flags(Stats::nozero);
400
401 if (m_max_size > 0) {
402 m_occupancy = m_buf_msgs / m_max_size;
403 } else {
404 m_occupancy = 0;
405 }
365}
366
367uint32_t
368MessageBuffer::functionalWrite(Packet *pkt)
369{
370 uint32_t num_functional_writes = 0;
371
372 // Check the priority heap and write any messages that may

--- 32 unchanged lines hidden ---
406}
407
408uint32_t
409MessageBuffer::functionalWrite(Packet *pkt)
410{
411 uint32_t num_functional_writes = 0;
412
413 // Check the priority heap and write any messages that may

--- 32 unchanged lines hidden ---