MessageBuffer.hh (11061:25b53a7195f7) | MessageBuffer.hh (11111:6da33e720481) |
---|---|
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; --- 41 unchanged lines hidden (view full) --- 50#include "sim/sim_object.hh" 51 52class MessageBuffer : public SimObject 53{ 54 public: 55 typedef MessageBufferParams Params; 56 MessageBuffer(const Params *p); 57 | 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; --- 41 unchanged lines hidden (view full) --- 50#include "sim/sim_object.hh" 51 52class MessageBuffer : public SimObject 53{ 54 public: 55 typedef MessageBufferParams Params; 56 MessageBuffer(const Params *p); 57 |
58 void reanalyzeMessages(Addr addr); 59 void reanalyzeAllMessages(); 60 void stallMessage(Addr addr); | 58 void reanalyzeMessages(Addr addr, Tick current_time); 59 void reanalyzeAllMessages(Tick current_time); 60 void stallMessage(Addr addr, Tick current_time); |
61 62 // TRUE if head of queue timestamp <= SystemTime | 61 62 // TRUE if head of queue timestamp <= SystemTime |
63 bool isReady() const; | 63 bool isReady(Tick current_time) const; |
64 65 void | 64 65 void |
66 delayHead() | 66 delayHead(Tick current_time, Tick delta) |
67 { 68 MsgPtr m = m_prio_heap.front(); 69 std::pop_heap(m_prio_heap.begin(), m_prio_heap.end(), 70 std::greater<MsgPtr>()); 71 m_prio_heap.pop_back(); | 67 { 68 MsgPtr m = m_prio_heap.front(); 69 std::pop_heap(m_prio_heap.begin(), m_prio_heap.end(), 70 std::greater<MsgPtr>()); 71 m_prio_heap.pop_back(); |
72 enqueue(m, Cycles(1)); | 72 enqueue(m, current_time, delta); |
73 } 74 | 73 } 74 |
75 bool areNSlotsAvailable(unsigned int n); | 75 bool areNSlotsAvailable(unsigned int n, Tick curTime); |
76 int getPriority() { return m_priority_rank; } 77 void setPriority(int rank) { m_priority_rank = rank; } 78 void setConsumer(Consumer* consumer) 79 { 80 DPRINTF(RubyQueue, "Setting consumer: %s\n", *consumer); 81 if (m_consumer != NULL) { 82 fatal("Trying to connect %s to MessageBuffer %s. \ 83 \n%s already connected. Check the cntrl_id's.\n", 84 *consumer, *this, *m_consumer); 85 } 86 m_consumer = consumer; 87 } 88 | 76 int getPriority() { return m_priority_rank; } 77 void setPriority(int rank) { m_priority_rank = rank; } 78 void setConsumer(Consumer* consumer) 79 { 80 DPRINTF(RubyQueue, "Setting consumer: %s\n", *consumer); 81 if (m_consumer != NULL) { 82 fatal("Trying to connect %s to MessageBuffer %s. \ 83 \n%s already connected. Check the cntrl_id's.\n", 84 *consumer, *this, *m_consumer); 85 } 86 m_consumer = consumer; 87 } 88 |
89 void setSender(ClockedObject* obj) 90 { 91 DPRINTF(RubyQueue, "Setting sender: %s\n", obj->name()); 92 assert(m_sender == NULL || m_sender == obj); 93 m_sender = obj; 94 } 95 96 void setReceiver(ClockedObject* obj) 97 { 98 DPRINTF(RubyQueue, "Setting receiver: %s\n", obj->name()); 99 assert(m_receiver == NULL || m_receiver == obj); 100 m_receiver = obj; 101 } 102 | |
103 Consumer* getConsumer() { return m_consumer; } 104 105 bool getOrdered() { return m_strict_fifo; } 106 107 //! Function for extracting the message at the head of the 108 //! message queue. The function assumes that the queue is nonempty. 109 const Message* peek() const; 110 | 89 Consumer* getConsumer() { return m_consumer; } 90 91 bool getOrdered() { return m_strict_fifo; } 92 93 //! Function for extracting the message at the head of the 94 //! message queue. The function assumes that the queue is nonempty. 95 const Message* peek() const; 96 |
111 const MsgPtr& 112 peekMsgPtr() const 113 { 114 assert(isReady()); 115 return m_prio_heap.front(); 116 } | 97 const MsgPtr &peekMsgPtr() const { return m_prio_heap.front(); } |
117 | 98 |
118 void enqueue(MsgPtr message) { enqueue(message, Cycles(1)); } 119 void enqueue(MsgPtr message, Cycles delta); | 99 void enqueue(MsgPtr message, Tick curTime, Tick delta); |
120 121 //! Updates the delay cycles of the message at the head of the queue, 122 //! removes it from the queue and returns its total delay. | 100 101 //! Updates the delay cycles of the message at the head of the queue, 102 //! removes it from the queue and returns its total delay. |
123 Cycles dequeue(); | 103 Tick dequeue(Tick current_time); |
124 | 104 |
125 void recycle(); | 105 void recycle(Tick current_time, Tick recycle_latency); |
126 bool isEmpty() const { return m_prio_heap.size() == 0; } 127 bool isStallMapEmpty() { return m_stall_msg_map.size() == 0; } 128 unsigned int getStallMapSize() { return m_stall_msg_map.size(); } 129 | 106 bool isEmpty() const { return m_prio_heap.size() == 0; } 107 bool isStallMapEmpty() { return m_stall_msg_map.size() == 0; } 108 unsigned int getStallMapSize() { return m_stall_msg_map.size(); } 109 |
130 unsigned int getSize(); | 110 unsigned int getSize(Tick curTime); |
131 132 void clear(); 133 void print(std::ostream& out) const; 134 void clearStats() { m_not_avail_count = 0; m_msg_counter = 0; } 135 136 void setIncomingLink(int link_id) { m_input_link_id = link_id; } 137 void setVnet(int net) { m_vnet_id = net; } 138 --- 4 unchanged lines hidden (view full) --- 143 144 // Function for figuring out if any of the messages in the buffer need 145 // to be updated with the data from the packet. 146 // Return value indicates the number of messages that were updated. 147 // This required for debugging the code. 148 uint32_t functionalWrite(Packet *pkt); 149 150 private: | 111 112 void clear(); 113 void print(std::ostream& out) const; 114 void clearStats() { m_not_avail_count = 0; m_msg_counter = 0; } 115 116 void setIncomingLink(int link_id) { m_input_link_id = link_id; } 117 void setVnet(int net) { m_vnet_id = net; } 118 --- 4 unchanged lines hidden (view full) --- 123 124 // Function for figuring out if any of the messages in the buffer need 125 // to be updated with the data from the packet. 126 // Return value indicates the number of messages that were updated. 127 // This required for debugging the code. 128 uint32_t functionalWrite(Packet *pkt); 129 130 private: |
151 //added by SS 152 const Cycles m_recycle_latency; 153 | |
154 void reanalyzeList(std::list<MsgPtr> &, Tick); 155 156 private: 157 // Data Members (m_ prefix) | 131 void reanalyzeList(std::list<MsgPtr> &, Tick); 132 133 private: 134 // Data Members (m_ prefix) |
158 //! The two ends of the buffer. 159 ClockedObject* m_sender; 160 ClockedObject* m_receiver; 161 | |
162 //! Consumer to signal a wakeup(), can be NULL 163 Consumer* m_consumer; 164 std::vector<MsgPtr> m_prio_heap; 165 166 // use a std::map for the stalled messages as this container is 167 // sorted and ensures a well-defined iteration order 168 typedef std::map<Addr, std::list<MsgPtr> > StallMsgMapType; 169 170 StallMsgMapType m_stall_msg_map; 171 172 const unsigned int m_max_size; | 135 //! Consumer to signal a wakeup(), can be NULL 136 Consumer* m_consumer; 137 std::vector<MsgPtr> m_prio_heap; 138 139 // use a std::map for the stalled messages as this container is 140 // sorted and ensures a well-defined iteration order 141 typedef std::map<Addr, std::list<MsgPtr> > StallMsgMapType; 142 143 StallMsgMapType m_stall_msg_map; 144 145 const unsigned int m_max_size; |
173 Cycles m_time_last_time_size_checked; | 146 Tick m_time_last_time_size_checked; |
174 unsigned int m_size_last_time_size_checked; 175 176 // variables used so enqueues appear to happen immediately, while 177 // pop happen the next cycle | 147 unsigned int m_size_last_time_size_checked; 148 149 // variables used so enqueues appear to happen immediately, while 150 // pop happen the next cycle |
178 Cycles m_time_last_time_enqueue; | 151 Tick m_time_last_time_enqueue; |
179 Tick m_time_last_time_pop; 180 Tick m_last_arrival_time; 181 182 unsigned int m_size_at_cycle_start; 183 unsigned int m_msgs_this_cycle; 184 185 int m_not_avail_count; // count the # of times I didn't have N 186 // slots available 187 uint64_t m_msg_counter; 188 int m_priority_rank; 189 const bool m_strict_fifo; 190 const bool m_randomization; 191 192 int m_input_link_id; 193 int m_vnet_id; 194}; 195 | 152 Tick m_time_last_time_pop; 153 Tick m_last_arrival_time; 154 155 unsigned int m_size_at_cycle_start; 156 unsigned int m_msgs_this_cycle; 157 158 int m_not_avail_count; // count the # of times I didn't have N 159 // slots available 160 uint64_t m_msg_counter; 161 int m_priority_rank; 162 const bool m_strict_fifo; 163 const bool m_randomization; 164 165 int m_input_link_id; 166 int m_vnet_id; 167}; 168 |
196Cycles random_time(); | 169Tick random_time(); |
197 198inline std::ostream& 199operator<<(std::ostream& out, const MessageBuffer& obj) 200{ 201 obj.print(out); 202 out << std::flush; 203 return out; 204} 205 206#endif // __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__ | 170 171inline std::ostream& 172operator<<(std::ostream& out, const MessageBuffer& obj) 173{ 174 obj.print(out); 175 out << std::flush; 176 return out; 177} 178 179#endif // __MEM_RUBY_BUFFERS_MESSAGEBUFFER_HH__ |