PerfectSwitch.cc (11093:8049ffff6d68) | PerfectSwitch.cc (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; --- 130 unchanged lines hidden (view full) --- 139 int vnet) 140{ 141 MsgPtr msg_ptr; 142 Message *net_msg_ptr = NULL; 143 144 // temporary vectors to store the routing results 145 vector<LinkID> output_links; 146 vector<NetDest> output_link_destinations; | 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; --- 130 unchanged lines hidden (view full) --- 139 int vnet) 140{ 141 MsgPtr msg_ptr; 142 Message *net_msg_ptr = NULL; 143 144 // temporary vectors to store the routing results 145 vector<LinkID> output_links; 146 vector<NetDest> output_link_destinations; |
147 Tick current_time = m_switch->clockEdge(); |
|
147 | 148 |
148 while (buffer->isReady()) { | 149 while (buffer->isReady(current_time)) { |
149 DPRINTF(RubyNetwork, "incoming: %d\n", incoming); 150 151 // Peek at message 152 msg_ptr = buffer->peekMsgPtr(); 153 net_msg_ptr = msg_ptr.get(); 154 DPRINTF(RubyNetwork, "Message: %s\n", (*net_msg_ptr)); 155 156 output_links.clear(); --- 14 unchanged lines hidden (view full) --- 171 m_link_order[out].m_link = out; 172 m_link_order[out].m_value = 0; 173 } 174 } else { 175 // Find how clogged each link is 176 for (int out = 0; out < m_out.size(); out++) { 177 int out_queue_length = 0; 178 for (int v = 0; v < m_virtual_networks; v++) { | 150 DPRINTF(RubyNetwork, "incoming: %d\n", incoming); 151 152 // Peek at message 153 msg_ptr = buffer->peekMsgPtr(); 154 net_msg_ptr = msg_ptr.get(); 155 DPRINTF(RubyNetwork, "Message: %s\n", (*net_msg_ptr)); 156 157 output_links.clear(); --- 14 unchanged lines hidden (view full) --- 172 m_link_order[out].m_link = out; 173 m_link_order[out].m_value = 0; 174 } 175 } else { 176 // Find how clogged each link is 177 for (int out = 0; out < m_out.size(); out++) { 178 int out_queue_length = 0; 179 for (int v = 0; v < m_virtual_networks; v++) { |
179 out_queue_length += m_out[out][v]->getSize(); | 180 out_queue_length += m_out[out][v]->getSize(current_time); |
180 } 181 int value = 182 (out_queue_length << 8) | 183 random_mt.random(0, 0xff); 184 m_link_order[out].m_link = out; 185 m_link_order[out].m_value = value; 186 } 187 --- 27 unchanged lines hidden (view full) --- 215 216 assert(msg_dsts.count() == 0); 217 218 // Check for resources - for all outgoing queues 219 bool enough = true; 220 for (int i = 0; i < output_links.size(); i++) { 221 int outgoing = output_links[i]; 222 | 181 } 182 int value = 183 (out_queue_length << 8) | 184 random_mt.random(0, 0xff); 185 m_link_order[out].m_link = out; 186 m_link_order[out].m_value = value; 187 } 188 --- 27 unchanged lines hidden (view full) --- 216 217 assert(msg_dsts.count() == 0); 218 219 // Check for resources - for all outgoing queues 220 bool enough = true; 221 for (int i = 0; i < output_links.size(); i++) { 222 int outgoing = output_links[i]; 223 |
223 if (!m_out[outgoing][vnet]->areNSlotsAvailable(1)) | 224 if (!m_out[outgoing][vnet]->areNSlotsAvailable(1, current_time)) |
224 enough = false; 225 226 DPRINTF(RubyNetwork, "Checking if node is blocked ..." 227 "outgoing: %d, vnet: %d, enough: %d\n", 228 outgoing, vnet, enough); 229 } 230 231 // There were not enough resources --- 14 unchanged lines hidden (view full) --- 246 // to create an unmodified MsgPtr because the MessageBuffer 247 // enqueue func will modify the message 248 249 // This magic line creates a private copy of the message 250 unmodified_msg_ptr = msg_ptr->clone(); 251 } 252 253 // Dequeue msg | 225 enough = false; 226 227 DPRINTF(RubyNetwork, "Checking if node is blocked ..." 228 "outgoing: %d, vnet: %d, enough: %d\n", 229 outgoing, vnet, enough); 230 } 231 232 // There were not enough resources --- 14 unchanged lines hidden (view full) --- 247 // to create an unmodified MsgPtr because the MessageBuffer 248 // enqueue func will modify the message 249 250 // This magic line creates a private copy of the message 251 unmodified_msg_ptr = msg_ptr->clone(); 252 } 253 254 // Dequeue msg |
254 buffer->dequeue(); | 255 buffer->dequeue(current_time); |
255 m_pending_message_count[vnet]--; 256 257 // Enqueue it - for all outgoing queues 258 for (int i=0; i<output_links.size(); i++) { 259 int outgoing = output_links[i]; 260 261 if (i > 0) { 262 // create a private copy of the unmodified message --- 5 unchanged lines hidden (view full) --- 268 net_msg_ptr = msg_ptr.get(); 269 net_msg_ptr->getDestination() = output_link_destinations[i]; 270 271 // Enqeue msg 272 DPRINTF(RubyNetwork, "Enqueuing net msg from " 273 "inport[%d][%d] to outport [%d][%d].\n", 274 incoming, vnet, outgoing, vnet); 275 | 256 m_pending_message_count[vnet]--; 257 258 // Enqueue it - for all outgoing queues 259 for (int i=0; i<output_links.size(); i++) { 260 int outgoing = output_links[i]; 261 262 if (i > 0) { 263 // create a private copy of the unmodified message --- 5 unchanged lines hidden (view full) --- 269 net_msg_ptr = msg_ptr.get(); 270 net_msg_ptr->getDestination() = output_link_destinations[i]; 271 272 // Enqeue msg 273 DPRINTF(RubyNetwork, "Enqueuing net msg from " 274 "inport[%d][%d] to outport [%d][%d].\n", 275 incoming, vnet, outgoing, vnet); 276 |
276 m_out[outgoing][vnet]->enqueue(msg_ptr); | 277 m_out[outgoing][vnet]->enqueue(msg_ptr, current_time, 278 m_switch->cyclesToTicks(Cycles(1))); |
277 } 278 } 279} 280 281void 282PerfectSwitch::wakeup() 283{ 284 // Give the highest numbered link priority most of the time --- 42 unchanged lines hidden --- | 279 } 280 } 281} 282 283void 284PerfectSwitch::wakeup() 285{ 286 // Give the highest numbered link priority most of the time --- 42 unchanged lines hidden --- |