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; |
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++; |
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 |
215MessageBuffer::dequeue(Tick current_time, bool decrement_messages) |
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 |
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 } |
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 |
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); |
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++; |
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 } |
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 --- |