Topology.cc (9594:219ad5fe8c04) | Topology.cc (9799:5aed42e54180) |
---|---|
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; --- 107 unchanged lines hidden (view full) --- 116 // the first direction is marked: In 117 addLink(a, b, int_link, LinkDirection_In); 118 // the second direction is marked: Out 119 addLink(b, a, int_link, LinkDirection_Out); 120 } 121} 122 123void | 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; --- 107 unchanged lines hidden (view full) --- 116 // the first direction is marked: In 117 addLink(a, b, int_link, LinkDirection_In); 118 // the second direction is marked: Out 119 addLink(b, a, int_link, LinkDirection_Out); 120 } 121} 122 123void |
124Topology::createLinks(Network *net, bool isReconfiguration) | 124Topology::createLinks(Network *net) |
125{ 126 // Find maximum switchID 127 SwitchID max_switch_id = 0; 128 for (LinkMap::const_iterator i = m_link_map.begin(); 129 i != m_link_map.end(); ++i) { 130 std::pair<int, int> src_dest = (*i).first; 131 max_switch_id = max(max_switch_id, src_dest.first); 132 max_switch_id = max(max_switch_id, src_dest.second); --- 41 unchanged lines hidden (view full) --- 174 175 // Walk topology and hookup the links 176 Matrix dist = shortest_path(topology_weights, m_component_latencies, 177 m_component_inter_switches); 178 for (int i = 0; i < topology_weights.size(); i++) { 179 for (int j = 0; j < topology_weights[i].size(); j++) { 180 int weight = topology_weights[i][j]; 181 if (weight > 0 && weight != INFINITE_LATENCY) { | 125{ 126 // Find maximum switchID 127 SwitchID max_switch_id = 0; 128 for (LinkMap::const_iterator i = m_link_map.begin(); 129 i != m_link_map.end(); ++i) { 130 std::pair<int, int> src_dest = (*i).first; 131 max_switch_id = max(max_switch_id, src_dest.first); 132 max_switch_id = max(max_switch_id, src_dest.second); --- 41 unchanged lines hidden (view full) --- 174 175 // Walk topology and hookup the links 176 Matrix dist = shortest_path(topology_weights, m_component_latencies, 177 m_component_inter_switches); 178 for (int i = 0; i < topology_weights.size(); i++) { 179 for (int j = 0; j < topology_weights[i].size(); j++) { 180 int weight = topology_weights[i][j]; 181 if (weight > 0 && weight != INFINITE_LATENCY) { |
182 NetDest destination_set = shortest_path_to_node(i, j, 183 topology_weights, dist); 184 makeLink(net, i, j, destination_set, isReconfiguration); | 182 NetDest destination_set = 183 shortest_path_to_node(i, j, topology_weights, dist); 184 makeLink(net, i, j, destination_set); |
185 } 186 } 187 } 188} 189 190void 191Topology::addLink(SwitchID src, SwitchID dest, BasicLink* link, 192 LinkDirection dir) --- 8 unchanged lines hidden (view full) --- 201 src_dest_pair.second = dest; 202 link_entry.direction = dir; 203 link_entry.link = link; 204 m_link_map[src_dest_pair] = link_entry; 205} 206 207void 208Topology::makeLink(Network *net, SwitchID src, SwitchID dest, | 185 } 186 } 187 } 188} 189 190void 191Topology::addLink(SwitchID src, SwitchID dest, BasicLink* link, 192 LinkDirection dir) --- 8 unchanged lines hidden (view full) --- 201 src_dest_pair.second = dest; 202 link_entry.direction = dir; 203 link_entry.link = link; 204 m_link_map[src_dest_pair] = link_entry; 205} 206 207void 208Topology::makeLink(Network *net, SwitchID src, SwitchID dest, |
209 const NetDest& routing_table_entry, bool isReconfiguration) | 209 const NetDest& routing_table_entry) |
210{ 211 // Make sure we're not trying to connect two end-point nodes 212 // directly together 213 assert(src >= 2 * m_nodes || dest >= 2 * m_nodes); 214 215 std::pair<int, int> src_dest; 216 LinkEntry link_entry; 217 218 if (src < m_nodes) { 219 src_dest.first = src; 220 src_dest.second = dest; 221 link_entry = m_link_map[src_dest]; 222 net->makeInLink(src, dest - (2 * m_nodes), link_entry.link, | 210{ 211 // Make sure we're not trying to connect two end-point nodes 212 // directly together 213 assert(src >= 2 * m_nodes || dest >= 2 * m_nodes); 214 215 std::pair<int, int> src_dest; 216 LinkEntry link_entry; 217 218 if (src < m_nodes) { 219 src_dest.first = src; 220 src_dest.second = dest; 221 link_entry = m_link_map[src_dest]; 222 net->makeInLink(src, dest - (2 * m_nodes), link_entry.link, |
223 link_entry.direction, 224 routing_table_entry, 225 isReconfiguration); | 223 link_entry.direction, routing_table_entry); |
226 } else if (dest < 2*m_nodes) { 227 assert(dest >= m_nodes); 228 NodeID node = dest - m_nodes; 229 src_dest.first = src; 230 src_dest.second = dest; 231 link_entry = m_link_map[src_dest]; 232 net->makeOutLink(src - (2 * m_nodes), node, link_entry.link, | 224 } else if (dest < 2*m_nodes) { 225 assert(dest >= m_nodes); 226 NodeID node = dest - m_nodes; 227 src_dest.first = src; 228 src_dest.second = dest; 229 link_entry = m_link_map[src_dest]; 230 net->makeOutLink(src - (2 * m_nodes), node, link_entry.link, |
233 link_entry.direction, 234 routing_table_entry, 235 isReconfiguration); | 231 link_entry.direction, routing_table_entry); |
236 } else { 237 assert((src >= 2 * m_nodes) && (dest >= 2 * m_nodes)); 238 src_dest.first = src; 239 src_dest.second = dest; 240 link_entry = m_link_map[src_dest]; 241 net->makeInternalLink(src - (2 * m_nodes), dest - (2 * m_nodes), 242 link_entry.link, link_entry.direction, | 232 } else { 233 assert((src >= 2 * m_nodes) && (dest >= 2 * m_nodes)); 234 src_dest.first = src; 235 src_dest.second = dest; 236 link_entry = m_link_map[src_dest]; 237 net->makeInternalLink(src - (2 * m_nodes), dest - (2 * m_nodes), 238 link_entry.link, link_entry.direction, |
243 routing_table_entry, isReconfiguration); | 239 routing_table_entry); |
244 } 245} 246 247// The following all-pairs shortest path algorithm is based on the 248// discussion from Cormen et al., Chapter 26.1. 249void 250extend_shortest_path(Matrix& current_dist, Matrix& latencies, 251 Matrix& inter_switches) --- 86 unchanged lines hidden --- | 240 } 241} 242 243// The following all-pairs shortest path algorithm is based on the 244// discussion from Cormen et al., Chapter 26.1. 245void 246extend_shortest_path(Matrix& current_dist, Matrix& latencies, 247 Matrix& inter_switches) --- 86 unchanged lines hidden --- |