Topology.cc (11096:efaacec43726) | Topology.cc (11320:42ecb523c64a) |
---|---|
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; --- 43 unchanged lines hidden (view full) --- 52 : m_nodes(ext_links.size()), m_number_of_switches(num_routers), 53 m_ext_link_vector(ext_links), m_int_link_vector(int_links) 54{ 55 // Total nodes/controllers in network 56 assert(m_nodes > 1); 57 58 // analyze both the internal and external links, create data structures 59 // Note that the python created links are bi-directional, but that the | 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; --- 43 unchanged lines hidden (view full) --- 52 : m_nodes(ext_links.size()), m_number_of_switches(num_routers), 53 m_ext_link_vector(ext_links), m_int_link_vector(int_links) 54{ 55 // Total nodes/controllers in network 56 assert(m_nodes > 1); 57 58 // analyze both the internal and external links, create data structures 59 // Note that the python created links are bi-directional, but that the |
60 // topology and networks utilize uni-directional links. Thus each | 60 // topology and networks utilize uni-directional links. Thus each |
61 // BasicLink is converted to two calls to add link, on for each direction 62 for (vector<BasicExtLink*>::const_iterator i = ext_links.begin(); 63 i != ext_links.end(); ++i) { 64 BasicExtLink *ext_link = (*i); 65 AbstractController *abs_cntrl = ext_link->params()->ext_node; 66 BasicRouter *router = ext_link->params()->int_node; 67 68 int machine_base_idx = MachineType_base_number(abs_cntrl->getType()); --- 32 unchanged lines hidden (view full) --- 101Topology::createLinks(Network *net) 102{ 103 // Find maximum switchID 104 SwitchID max_switch_id = 0; 105 for (LinkMap::const_iterator i = m_link_map.begin(); 106 i != m_link_map.end(); ++i) { 107 std::pair<SwitchID, SwitchID> src_dest = (*i).first; 108 max_switch_id = max(max_switch_id, src_dest.first); | 61 // BasicLink is converted to two calls to add link, on for each direction 62 for (vector<BasicExtLink*>::const_iterator i = ext_links.begin(); 63 i != ext_links.end(); ++i) { 64 BasicExtLink *ext_link = (*i); 65 AbstractController *abs_cntrl = ext_link->params()->ext_node; 66 BasicRouter *router = ext_link->params()->int_node; 67 68 int machine_base_idx = MachineType_base_number(abs_cntrl->getType()); --- 32 unchanged lines hidden (view full) --- 101Topology::createLinks(Network *net) 102{ 103 // Find maximum switchID 104 SwitchID max_switch_id = 0; 105 for (LinkMap::const_iterator i = m_link_map.begin(); 106 i != m_link_map.end(); ++i) { 107 std::pair<SwitchID, SwitchID> src_dest = (*i).first; 108 max_switch_id = max(max_switch_id, src_dest.first); |
109 max_switch_id = max(max_switch_id, src_dest.second); | 109 max_switch_id = max(max_switch_id, src_dest.second); |
110 } 111 112 // Initialize weight, latency, and inter switched vectors 113 int num_switches = max_switch_id+1; 114 Matrix topology_weights(num_switches, 115 vector<int>(num_switches, INFINITE_LATENCY)); 116 Matrix component_latencies(num_switches, 117 vector<int>(num_switches, -1)); --- 10 unchanged lines hidden (view full) --- 128 i != m_link_map.end(); ++i) { 129 std::pair<int, int> src_dest = (*i).first; 130 BasicLink* link = (*i).second.link; 131 int src = src_dest.first; 132 int dst = src_dest.second; 133 component_latencies[src][dst] = link->m_latency; 134 topology_weights[src][dst] = link->m_weight; 135 } | 110 } 111 112 // Initialize weight, latency, and inter switched vectors 113 int num_switches = max_switch_id+1; 114 Matrix topology_weights(num_switches, 115 vector<int>(num_switches, INFINITE_LATENCY)); 116 Matrix component_latencies(num_switches, 117 vector<int>(num_switches, -1)); --- 10 unchanged lines hidden (view full) --- 128 i != m_link_map.end(); ++i) { 129 std::pair<int, int> src_dest = (*i).first; 130 BasicLink* link = (*i).second.link; 131 int src = src_dest.first; 132 int dst = src_dest.second; 133 component_latencies[src][dst] = link->m_latency; 134 topology_weights[src][dst] = link->m_weight; 135 } |
136 | 136 |
137 // Walk topology and hookup the links 138 Matrix dist = shortest_path(topology_weights, component_latencies, 139 component_inter_switches); 140 141 for (int i = 0; i < topology_weights.size(); i++) { 142 for (int j = 0; j < topology_weights[i].size(); j++) { 143 int weight = topology_weights[i][j]; 144 if (weight > 0 && weight != INFINITE_LATENCY) { 145 NetDest destination_set = 146 shortest_path_to_node(i, j, topology_weights, dist); 147 makeLink(net, i, j, destination_set); 148 } 149 } 150 } 151} 152 153void | 137 // Walk topology and hookup the links 138 Matrix dist = shortest_path(topology_weights, component_latencies, 139 component_inter_switches); 140 141 for (int i = 0; i < topology_weights.size(); i++) { 142 for (int j = 0; j < topology_weights[i].size(); j++) { 143 int weight = topology_weights[i][j]; 144 if (weight > 0 && weight != INFINITE_LATENCY) { 145 NetDest destination_set = 146 shortest_path_to_node(i, j, topology_weights, dist); 147 makeLink(net, i, j, destination_set); 148 } 149 } 150 } 151} 152 153void |
154Topology::addLink(SwitchID src, SwitchID dest, BasicLink* link, | 154Topology::addLink(SwitchID src, SwitchID dest, BasicLink* link, |
155 LinkDirection dir) 156{ 157 assert(src <= m_number_of_switches+m_nodes+m_nodes); 158 assert(dest <= m_number_of_switches+m_nodes+m_nodes); | 155 LinkDirection dir) 156{ 157 assert(src <= m_number_of_switches+m_nodes+m_nodes); 158 assert(dest <= m_number_of_switches+m_nodes+m_nodes); |
159 | 159 |
160 std::pair<int, int> src_dest_pair; 161 LinkEntry link_entry; 162 163 src_dest_pair.first = src; 164 src_dest_pair.second = dest; 165 link_entry.direction = dir; 166 link_entry.link = link; 167 m_link_map[src_dest_pair] = link_entry; 168} 169 170void 171Topology::makeLink(Network *net, SwitchID src, SwitchID dest, 172 const NetDest& routing_table_entry) 173{ 174 // Make sure we're not trying to connect two end-point nodes 175 // directly together 176 assert(src >= 2 * m_nodes || dest >= 2 * m_nodes); 177 178 std::pair<int, int> src_dest; | 160 std::pair<int, int> src_dest_pair; 161 LinkEntry link_entry; 162 163 src_dest_pair.first = src; 164 src_dest_pair.second = dest; 165 link_entry.direction = dir; 166 link_entry.link = link; 167 m_link_map[src_dest_pair] = link_entry; 168} 169 170void 171Topology::makeLink(Network *net, SwitchID src, SwitchID dest, 172 const NetDest& routing_table_entry) 173{ 174 // Make sure we're not trying to connect two end-point nodes 175 // directly together 176 assert(src >= 2 * m_nodes || dest >= 2 * m_nodes); 177 178 std::pair<int, int> src_dest; |
179 LinkEntry link_entry; | 179 LinkEntry link_entry; |
180 181 if (src < m_nodes) { 182 src_dest.first = src; 183 src_dest.second = dest; 184 link_entry = m_link_map[src_dest]; 185 net->makeInLink(src, dest - (2 * m_nodes), link_entry.link, 186 link_entry.direction, routing_table_entry); 187 } else if (dest < 2*m_nodes) { --- 111 unchanged lines hidden --- | 180 181 if (src < m_nodes) { 182 src_dest.first = src; 183 src_dest.second = dest; 184 link_entry = m_link_map[src_dest]; 185 net->makeInLink(src, dest - (2 * m_nodes), link_entry.link, 186 link_entry.direction, routing_table_entry); 187 } else if (dest < 2*m_nodes) { --- 111 unchanged lines hidden --- |