Deleted Added
sdiff udiff text old ( 10837:ecbab2522757 ) new ( 10893:f567e80c0714 )
full compact
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;

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

117}
118
119const Message*
120MessageBuffer::peek() const
121{
122 DPRINTF(RubyQueue, "Peeking at head of queue.\n");
123 assert(isReady());
124
125 const Message* msg_ptr = m_prio_heap.front().get();
126 assert(msg_ptr);
127
128 DPRINTF(RubyQueue, "Message: %s\n", (*msg_ptr));
129 return msg_ptr;
130}
131
132// FIXME - move me somewhere else
133Cycles

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

199 Message* msg_ptr = message.get();
200 assert(msg_ptr != NULL);
201
202 assert(m_sender->clockEdge() >= msg_ptr->getLastEnqueueTime() &&
203 "ensure we aren't dequeued early");
204
205 msg_ptr->updateDelayedTicks(m_sender->clockEdge());
206 msg_ptr->setLastEnqueueTime(arrival_time);
207 msg_ptr->setMsgCounter(m_msg_counter);
208
209 // Insert the message into the priority heap
210 m_prio_heap.push_back(message);
211 push_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
212
213 DPRINTF(RubyQueue, "Enqueue arrival_time: %lld, Message: %s\n",
214 arrival_time, *(message.get()));
215
216 // Schedule the wakeup
217 assert(m_consumer != NULL);
218 m_consumer->scheduleEventAbsolute(arrival_time);
219 m_consumer->storeEventInfo(m_vnet_id);
220}
221
222Cycles
223MessageBuffer::dequeue()
224{
225 DPRINTF(RubyQueue, "Popping\n");
226 assert(isReady());
227
228 // get MsgPtr of the message about to be dequeued
229 MsgPtr message = m_prio_heap.front();
230
231 // get the delay cycles
232 message->updateDelayedTicks(m_receiver->clockEdge());
233 Cycles delayCycles =
234 m_receiver->ticksToCycles(message->getDelayedTicks());
235
236 // record previous size and time so the current buffer size isn't
237 // adjusted until next cycle
238 if (m_time_last_time_pop < m_receiver->clockEdge()) {
239 m_size_at_cycle_start = m_prio_heap.size();
240 m_time_last_time_pop = m_receiver->clockEdge();
241 }
242
243 pop_heap(m_prio_heap.begin(), m_prio_heap.end(),
244 greater<MsgPtr>());
245 m_prio_heap.pop_back();
246
247 return delayCycles;
248}
249
250void
251MessageBuffer::clear()
252{

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

259 m_msgs_this_cycle = 0;
260}
261
262void
263MessageBuffer::recycle()
264{
265 DPRINTF(RubyQueue, "Recycling.\n");
266 assert(isReady());
267 MsgPtr node = m_prio_heap.front();
268 pop_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
269
270 node->setLastEnqueueTime(m_receiver->clockEdge(m_recycle_latency));
271 m_prio_heap.back() = node;
272 push_heap(m_prio_heap.begin(), m_prio_heap.end(), greater<MsgPtr>());
273 m_consumer->
274 scheduleEventAbsolute(m_receiver->clockEdge(m_recycle_latency));
275}
276
277void
278MessageBuffer::reanalyzeList(list<MsgPtr> &lt, Tick nextTick)
279{
280 while(!lt.empty()) {
281 m_msg_counter++;
282 MsgPtr m = lt.front();
283 m->setLastEnqueueTime(nextTick);
284 m->setMsgCounter(m_msg_counter);
285
286 m_prio_heap.push_back(m);
287 push_heap(m_prio_heap.begin(), m_prio_heap.end(),
288 greater<MsgPtr>());
289
290 m_consumer->scheduleEventAbsolute(nextTick);
291 lt.pop_front();
292 }
293}
294
295void
296MessageBuffer::reanalyzeMessages(const Address& addr)

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

325}
326
327void
328MessageBuffer::stallMessage(const Address& addr)
329{
330 DPRINTF(RubyQueue, "Stalling due to %s\n", addr);
331 assert(isReady());
332 assert(addr.getOffset() == 0);
333 MsgPtr message = m_prio_heap.front();
334
335 dequeue();
336
337 //
338 // Note: no event is scheduled to analyze the map at a later time.
339 // Instead the controller is responsible to call reanalyzeMessages when
340 // these addresses change state.
341 //
342 (m_stall_msg_map[addr]).push_back(message);
343}
344
345void
346MessageBuffer::print(ostream& out) const
347{
348 ccprintf(out, "[MessageBuffer: ");
349 if (m_consumer != NULL) {
350 ccprintf(out, " consumer-yes ");
351 }
352
353 vector<MsgPtr> copy(m_prio_heap);
354 sort_heap(copy.begin(), copy.end(), greater<MsgPtr>());
355 ccprintf(out, "%s] %s", copy, m_name);
356}
357
358bool
359MessageBuffer::isReady() const
360{
361 return ((m_prio_heap.size() > 0) &&
362 (m_prio_heap.front()->getLastEnqueueTime() <= m_receiver->clockEdge()));
363}
364
365bool
366MessageBuffer::functionalRead(Packet *pkt)
367{
368 // Check the priority heap and read any messages that may
369 // correspond to the address in the packet.
370 for (unsigned int i = 0; i < m_prio_heap.size(); ++i) {
371 Message *msg = m_prio_heap[i].get();
372 if (msg->functionalRead(pkt)) return true;
373 }
374
375 // Read the messages in the stall queue that correspond
376 // to the address in the packet.
377 for (StallMsgMapType::iterator map_iter = m_stall_msg_map.begin();
378 map_iter != m_stall_msg_map.end();
379 ++map_iter) {

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

391uint32_t
392MessageBuffer::functionalWrite(Packet *pkt)
393{
394 uint32_t num_functional_writes = 0;
395
396 // Check the priority heap and write any messages that may
397 // correspond to the address in the packet.
398 for (unsigned int i = 0; i < m_prio_heap.size(); ++i) {
399 Message *msg = m_prio_heap[i].get();
400 if (msg->functionalWrite(pkt)) {
401 num_functional_writes++;
402 }
403 }
404
405 // Check the stall queue and write any messages that may
406 // correspond to the address in the packet.
407 for (StallMsgMapType::iterator map_iter = m_stall_msg_map.begin();

--- 15 unchanged lines hidden ---