SimpleNetwork.cc (9799:5aed42e54180) | SimpleNetwork.cc (9858:f2417ecf5cc9) |
---|---|
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; --- 69 unchanged lines hidden (view full) --- 78 new MessageBuffer(csprintf("fromNet node %d j %d", node, j)); 79 } 80 } 81 82 // record the routers 83 for (vector<BasicRouter*>::const_iterator i = p->routers.begin(); 84 i != p->routers.end(); ++i) { 85 Switch* s = safe_cast<Switch*>(*i); | 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; --- 69 unchanged lines hidden (view full) --- 78 new MessageBuffer(csprintf("fromNet node %d j %d", node, j)); 79 } 80 } 81 82 // record the routers 83 for (vector<BasicRouter*>::const_iterator i = p->routers.begin(); 84 i != p->routers.end(); ++i) { 85 Switch* s = safe_cast<Switch*>(*i); |
86 m_switch_ptr_vector.push_back(s); | 86 m_switches.push_back(s); |
87 s->init_net_ptr(this); 88 } 89} 90 91void 92SimpleNetwork::init() 93{ 94 Network::init(); --- 9 unchanged lines hidden (view full) --- 104{ 105 for (int node = 0; node < m_nodes; node++) { 106 for (int j = 0; j < m_virtual_networks; j++) { 107 m_toNetQueues[node][j]->clear(); 108 m_fromNetQueues[node][j]->clear(); 109 } 110 } 111 | 87 s->init_net_ptr(this); 88 } 89} 90 91void 92SimpleNetwork::init() 93{ 94 Network::init(); --- 9 unchanged lines hidden (view full) --- 104{ 105 for (int node = 0; node < m_nodes; node++) { 106 for (int j = 0; j < m_virtual_networks; j++) { 107 m_toNetQueues[node][j]->clear(); 108 m_fromNetQueues[node][j]->clear(); 109 } 110 } 111 |
112 for(int i = 0; i < m_switch_ptr_vector.size(); i++){ 113 m_switch_ptr_vector[i]->clearBuffers(); | 112 for(int i = 0; i < m_switches.size(); i++){ 113 m_switches[i]->clearBuffers(); |
114 } 115} 116 117SimpleNetwork::~SimpleNetwork() 118{ 119 for (int i = 0; i < m_nodes; i++) { 120 deletePointers(m_toNetQueues[i]); 121 deletePointers(m_fromNetQueues[i]); 122 } | 114 } 115} 116 117SimpleNetwork::~SimpleNetwork() 118{ 119 for (int i = 0; i < m_nodes; i++) { 120 deletePointers(m_toNetQueues[i]); 121 deletePointers(m_fromNetQueues[i]); 122 } |
123 deletePointers(m_switch_ptr_vector); | 123 deletePointers(m_switches); |
124 deletePointers(m_buffers_to_free); 125 // delete m_topology_ptr; 126} 127 128// From a switch to an endpoint node 129void 130SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, BasicLink* link, 131 LinkDirection direction, 132 const NetDest& routing_table_entry) 133{ 134 assert(dest < m_nodes); | 124 deletePointers(m_buffers_to_free); 125 // delete m_topology_ptr; 126} 127 128// From a switch to an endpoint node 129void 130SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, BasicLink* link, 131 LinkDirection direction, 132 const NetDest& routing_table_entry) 133{ 134 assert(dest < m_nodes); |
135 assert(src < m_switch_ptr_vector.size()); 136 assert(m_switch_ptr_vector[src] != NULL); | 135 assert(src < m_switches.size()); 136 assert(m_switches[src] != NULL); |
137 138 SimpleExtLink *simple_link = safe_cast<SimpleExtLink*>(link); 139 | 137 138 SimpleExtLink *simple_link = safe_cast<SimpleExtLink*>(link); 139 |
140 m_switch_ptr_vector[src]->addOutPort(m_fromNetQueues[dest], | 140 m_switches[src]->addOutPort(m_fromNetQueues[dest], |
141 routing_table_entry, 142 simple_link->m_latency, 143 simple_link->m_bw_multiplier); 144 | 141 routing_table_entry, 142 simple_link->m_latency, 143 simple_link->m_bw_multiplier); 144 |
145 m_endpoint_switches[dest] = m_switch_ptr_vector[src]; | 145 m_endpoint_switches[dest] = m_switches[src]; |
146} 147 148// From an endpoint node to a switch 149void 150SimpleNetwork::makeInLink(NodeID src, SwitchID dest, BasicLink* link, 151 LinkDirection direction, 152 const NetDest& routing_table_entry) 153{ 154 assert(src < m_nodes); | 146} 147 148// From an endpoint node to a switch 149void 150SimpleNetwork::makeInLink(NodeID src, SwitchID dest, BasicLink* link, 151 LinkDirection direction, 152 const NetDest& routing_table_entry) 153{ 154 assert(src < m_nodes); |
155 m_switch_ptr_vector[dest]->addInPort(m_toNetQueues[src]); | 155 m_switches[dest]->addInPort(m_toNetQueues[src]); |
156} 157 158// From a switch to a switch 159void 160SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link, 161 LinkDirection direction, 162 const NetDest& routing_table_entry) 163{ --- 8 unchanged lines hidden (view full) --- 172 } 173 queues.push_back(buffer_ptr); 174 // remember to deallocate it 175 m_buffers_to_free.push_back(buffer_ptr); 176 } 177 // Connect it to the two switches 178 SimpleIntLink *simple_link = safe_cast<SimpleIntLink*>(link); 179 | 156} 157 158// From a switch to a switch 159void 160SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link, 161 LinkDirection direction, 162 const NetDest& routing_table_entry) 163{ --- 8 unchanged lines hidden (view full) --- 172 } 173 queues.push_back(buffer_ptr); 174 // remember to deallocate it 175 m_buffers_to_free.push_back(buffer_ptr); 176 } 177 // Connect it to the two switches 178 SimpleIntLink *simple_link = safe_cast<SimpleIntLink*>(link); 179 |
180 m_switch_ptr_vector[dest]->addInPort(queues); 181 m_switch_ptr_vector[src]->addOutPort(queues, routing_table_entry, | 180 m_switches[dest]->addInPort(queues); 181 m_switches[src]->addOutPort(queues, routing_table_entry, |
182 simple_link->m_latency, 183 simple_link->m_bw_multiplier); 184} 185 186void 187SimpleNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num) 188{ 189 assert(id < m_nodes); --- 44 unchanged lines hidden (view full) --- 234 std::vector<uint64> total_msg_counts; 235 total_msg_counts.resize(MessageSizeType_NUM); 236 for (MessageSizeType type = MessageSizeType_FIRST; 237 type < MessageSizeType_NUM; 238 ++type) { 239 total_msg_counts[type] = 0; 240 } 241 | 182 simple_link->m_latency, 183 simple_link->m_bw_multiplier); 184} 185 186void 187SimpleNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num) 188{ 189 assert(id < m_nodes); --- 44 unchanged lines hidden (view full) --- 234 std::vector<uint64> total_msg_counts; 235 total_msg_counts.resize(MessageSizeType_NUM); 236 for (MessageSizeType type = MessageSizeType_FIRST; 237 type < MessageSizeType_NUM; 238 ++type) { 239 total_msg_counts[type] = 0; 240 } 241 |
242 for (int i = 0; i < m_switch_ptr_vector.size(); i++) { | 242 for (int i = 0; i < m_switches.size(); i++) { |
243 const std::vector<Throttle*>* throttles = | 243 const std::vector<Throttle*>* throttles = |
244 m_switch_ptr_vector[i]->getThrottles(); | 244 m_switches[i]->getThrottles(); |
245 246 for (int p = 0; p < throttles->size(); p++) { 247 248 const std::vector<std::vector<int> >& message_counts = 249 ((*throttles)[p])->getCounters(); 250 251 for (MessageSizeType type = MessageSizeType_FIRST; 252 type < MessageSizeType_NUM; --- 23 unchanged lines hidden (view full) --- 276 uint64(MessageSizeType_to_int(type)); 277 } 278 } 279 280 out << "total_msgs: " << total_msgs 281 << " total_bytes: " << total_bytes << endl; 282 283 out << endl; | 245 246 for (int p = 0; p < throttles->size(); p++) { 247 248 const std::vector<std::vector<int> >& message_counts = 249 ((*throttles)[p])->getCounters(); 250 251 for (MessageSizeType type = MessageSizeType_FIRST; 252 type < MessageSizeType_NUM; --- 23 unchanged lines hidden (view full) --- 276 uint64(MessageSizeType_to_int(type)); 277 } 278 } 279 280 out << "total_msgs: " << total_msgs 281 << " total_bytes: " << total_bytes << endl; 282 283 out << endl; |
284 for (int i = 0; i < m_switch_ptr_vector.size(); i++) { 285 m_switch_ptr_vector[i]->printStats(out); | 284 for (int i = 0; i < m_switches.size(); i++) { 285 m_switches[i]->printStats(out); |
286 } 287} 288 289void 290SimpleNetwork::clearStats() 291{ | 286 } 287} 288 289void 290SimpleNetwork::clearStats() 291{ |
292 for (int i = 0; i < m_switch_ptr_vector.size(); i++) { 293 m_switch_ptr_vector[i]->clearStats(); | 292 for (int i = 0; i < m_switches.size(); i++) { 293 m_switches[i]->clearStats(); |
294 } 295} 296 297void 298SimpleNetwork::print(ostream& out) const 299{ 300 out << "[SimpleNetwork]"; 301} --- 7 unchanged lines hidden (view full) --- 309/* 310 * The simple network has an array of switches. These switches have buffers 311 * that need to be accessed for functional reads and writes. Also the links 312 * between different switches have buffers that need to be accessed. 313 */ 314bool 315SimpleNetwork::functionalRead(Packet *pkt) 316{ | 294 } 295} 296 297void 298SimpleNetwork::print(ostream& out) const 299{ 300 out << "[SimpleNetwork]"; 301} --- 7 unchanged lines hidden (view full) --- 309/* 310 * The simple network has an array of switches. These switches have buffers 311 * that need to be accessed for functional reads and writes. Also the links 312 * between different switches have buffers that need to be accessed. 313 */ 314bool 315SimpleNetwork::functionalRead(Packet *pkt) 316{ |
317 for (unsigned int i = 0; i < m_switch_ptr_vector.size(); i++) { 318 if (m_switch_ptr_vector[i]->functionalRead(pkt)) { | 317 for (unsigned int i = 0; i < m_switches.size(); i++) { 318 if (m_switches[i]->functionalRead(pkt)) { |
319 return true; 320 } 321 } 322 323 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) { 324 if (m_buffers_to_free[i]->functionalRead(pkt)) { 325 return true; 326 } 327 } 328 329 return false; 330} 331 332uint32_t 333SimpleNetwork::functionalWrite(Packet *pkt) 334{ 335 uint32_t num_functional_writes = 0; 336 | 319 return true; 320 } 321 } 322 323 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) { 324 if (m_buffers_to_free[i]->functionalRead(pkt)) { 325 return true; 326 } 327 } 328 329 return false; 330} 331 332uint32_t 333SimpleNetwork::functionalWrite(Packet *pkt) 334{ 335 uint32_t num_functional_writes = 0; 336 |
337 for (unsigned int i = 0; i < m_switch_ptr_vector.size(); i++) { 338 num_functional_writes += m_switch_ptr_vector[i]->functionalWrite(pkt); | 337 for (unsigned int i = 0; i < m_switches.size(); i++) { 338 num_functional_writes += m_switches[i]->functionalWrite(pkt); |
339 } 340 341 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) { 342 num_functional_writes += m_buffers_to_free[i]->functionalWrite(pkt); 343 } 344 return num_functional_writes; 345} | 339 } 340 341 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) { 342 num_functional_writes += m_buffers_to_free[i]->functionalWrite(pkt); 343 } 344 return num_functional_writes; 345} |