35 #include "debug/RubyNetwork.hh"
56 : m_nodes(MachineType_base_number(MachineType_NUM)),
57 m_number_of_switches(num_routers), m_vnets(num_vnets),
58 m_ext_link_vector(ext_links), m_int_link_vector(int_links)
72 i != ext_links.end(); ++
i) {
77 int machine_base_idx = MachineType_base_number(abs_cntrl->
getType());
78 int ext_idx1 = machine_base_idx + abs_cntrl->
getVersion();
79 int ext_idx2 = ext_idx1 +
m_nodes;
84 addLink(ext_idx1, int_idx, ext_link);
86 addLink(int_idx, ext_idx2, ext_link);
91 i != int_links.end(); ++
i) {
106 addLink(src, dst, int_link, src_outport, dst_inport);
115 for (LinkMap::const_iterator
i =
m_link_map.begin();
118 max_switch_id = max(max_switch_id, src_dest.first);
119 max_switch_id = max(max_switch_id, src_dest.second);
123 int num_switches = max_switch_id+1;
127 Matrix component_latencies(num_switches,
130 Matrix component_inter_switches(num_switches,
135 for (
int i = 0;
i < topology_weights[0].size();
i++) {
137 topology_weights[
v][
i][
i] = 0;
145 int src = src_dest.first;
146 int dst = src_dest.second;
150 for (
int l = 0;
l < link_entries.size();
l++) {
152 if (link->
mVnets.size() == 0) {
156 fatal_if(vnet_done[
v],
"Two links connecting same src"
157 " and destination cannot support same vnets");
159 component_latencies[src][dst][
v] = link->
m_latency;
160 topology_weights[
v][src][dst] = link->
m_weight;
164 for (
int v = 0;
v < link->
mVnets.size();
v++) {
167 "(setting latency and weight for vnet %d)", vnet);
170 fatal_if(vnet_done[vnet],
"Two links connecting same src"
171 " and destination cannot support same vnets");
173 component_latencies[src][dst][vnet] = link->
m_latency;
174 topology_weights[vnet][src][dst] = link->
m_weight;
175 vnet_done[vnet] =
true;
183 component_inter_switches);
185 for (
int i = 0;
i < topology_weights[0].size();
i++) {
186 for (
int j = 0;
j < topology_weights[0][
i].size();
j++) {
193 bool realLink =
false;
196 int weight = topology_weights[
v][
i][
j];
222 src_dest_pair.first = src;
223 src_dest_pair.second = dest;
226 link_entry.
link = link;
237 lit->second.push_back(link_entry);
240 links.push_back(link_entry);
257 src_dest.first = src;
258 src_dest.second = dest;
260 for (
int l = 0;
l < links.size();
l++) {
261 link_entry = links[
l];
265 if (link->
mVnets.size() == 0) {
267 routing_table_entry);
269 for (
int v = 0;
v< link->
mVnets.size();
v++) {
271 linkRoute[vnet] = routing_table_entry[vnet];
280 src_dest.first = src;
281 src_dest.second = dest;
283 for (
int l = 0;
l < links.size();
l++) {
284 link_entry = links[
l];
288 if (link->
mVnets.size() == 0) {
290 routing_table_entry);
292 for (
int v = 0;
v< link->
mVnets.size();
v++) {
294 linkRoute[vnet] = routing_table_entry[vnet];
302 src_dest.first = src;
303 src_dest.second = dest;
305 for (
int l = 0;
l < links.size();
l++) {
306 link_entry = links[
l];
310 if (link->
mVnets.size() == 0) {
312 dest - (2 *
m_nodes), link, routing_table_entry,
316 for (
int v = 0;
v< link->
mVnets.size();
v++) {
318 linkRoute[vnet] = routing_table_entry[vnet];
321 dest - (2 *
m_nodes), link, linkRoute,
335 int nodes = current_dist[0].size();
347 for (
int i = 0;
i < nodes;
i++) {
348 for (
int j = 0;
j < nodes;
j++) {
360 int minimum = current_dist[
v][
i][
j];
361 int previous_minimum = minimum;
362 int intermediate_switch = -1;
363 for (
int k = 0;
k < nodes;
k++) {
364 minimum = min(minimum,
365 current_dist[
v][
i][
k] + current_dist[
v][
k][
j]);
366 if (previous_minimum != minimum) {
367 intermediate_switch =
k;
368 inter_switches[
i][
j][
v] =
369 inter_switches[
i][
k][
v] +
370 inter_switches[
k][
j][
v] + 1;
372 previous_minimum = minimum;
374 if (current_dist[
v][
i][
j] != minimum) {
376 current_dist[
v][
i][
j] = minimum;
377 assert(intermediate_switch >= 0);
378 assert(intermediate_switch < latencies[
i].size());
380 latencies[
i][intermediate_switch][
v] +
381 latencies[intermediate_switch][
j][
v];
403 return weights[vnet][src][next] +
dist[vnet][next][
final] ==
404 dist[vnet][src][
final];
417 machines = MachineType_NUM;
418 max_machines = MachineType_base_number(MachineType_NUM);
420 for (
int m = 0;
m < machines;
m++) {
421 for (
NodeID i = 0;
i < MachineType_base_count((MachineType)
m);
i++) {
428 weights,
dist, vnet)) {
436 DPRINTF(RubyNetwork,
"Returning shortest path\n"
437 "(src-(2*max_machines)): %d, (next-(2*max_machines)): %d, "
438 "src: %d, next: %d, vnet:%d result: %s\n",
439 (src-(2*max_machines)), (next-(2*max_machines)),
440 src, next, vnet, result);