35 #include "debug/RubyNetwork.hh"
54 : m_nodes(MachineType_base_number(MachineType_NUM)),
55 m_number_of_switches(num_routers), m_vnets(num_vnets),
56 m_ext_link_vector(ext_links), m_int_link_vector(int_links)
70 i != ext_links.end(); ++
i) {
75 int machine_base_idx = MachineType_base_number(abs_cntrl->
getType());
76 int ext_idx1 = machine_base_idx + abs_cntrl->
getVersion();
77 int ext_idx2 = ext_idx1 +
m_nodes;
82 addLink(ext_idx1, int_idx, ext_link);
84 addLink(int_idx, ext_idx2, ext_link);
89 i != int_links.end(); ++
i) {
104 addLink(src, dst, int_link, src_outport, dst_inport);
113 for (LinkMap::const_iterator
i =
m_link_map.begin();
116 max_switch_id = std::max(max_switch_id, src_dest.first);
117 max_switch_id = std::max(max_switch_id, src_dest.second);
121 int num_switches = max_switch_id+1;
125 Matrix component_latencies(num_switches,
128 Matrix component_inter_switches(num_switches,
133 for (
int i = 0;
i < topology_weights[0].size();
i++) {
135 topology_weights[
v][
i][
i] = 0;
143 int src = src_dest.first;
144 int dst = src_dest.second;
148 for (
int l = 0;
l < link_entries.size();
l++) {
150 if (link->
mVnets.size() == 0) {
154 fatal_if(vnet_done[
v],
"Two links connecting same src"
155 " and destination cannot support same vnets");
157 component_latencies[src][dst][
v] = link->
m_latency;
158 topology_weights[
v][src][dst] = link->
m_weight;
162 for (
int v = 0;
v < link->
mVnets.size();
v++) {
165 "(setting latency and weight for vnet %d)", vnet);
168 fatal_if(vnet_done[vnet],
"Two links connecting same src"
169 " and destination cannot support same vnets");
171 component_latencies[src][dst][vnet] = link->
m_latency;
172 topology_weights[vnet][src][dst] = link->
m_weight;
173 vnet_done[vnet] =
true;
181 component_inter_switches);
183 for (
int i = 0;
i < topology_weights[0].size();
i++) {
184 for (
int j = 0;
j < topology_weights[0][
i].size();
j++) {
191 bool realLink =
false;
194 int weight = topology_weights[
v][
i][
j];
220 src_dest_pair.first = src;
221 src_dest_pair.second = dest;
224 link_entry.
link = link;
235 lit->second.push_back(link_entry);
238 links.push_back(link_entry);
255 src_dest.first = src;
256 src_dest.second = dest;
258 for (
int l = 0;
l < links.size();
l++) {
259 link_entry = links[
l];
263 if (link->
mVnets.size() == 0) {
265 routing_table_entry);
267 for (
int v = 0;
v< link->
mVnets.size();
v++) {
269 linkRoute[vnet] = routing_table_entry[vnet];
278 src_dest.first = src;
279 src_dest.second = dest;
281 for (
int l = 0;
l < links.size();
l++) {
282 link_entry = links[
l];
286 if (link->
mVnets.size() == 0) {
288 routing_table_entry);
290 for (
int v = 0;
v< link->
mVnets.size();
v++) {
292 linkRoute[vnet] = routing_table_entry[vnet];
300 src_dest.first = src;
301 src_dest.second = dest;
303 for (
int l = 0;
l < links.size();
l++) {
304 link_entry = links[
l];
308 if (link->
mVnets.size() == 0) {
310 dest - (2 *
m_nodes), link, routing_table_entry,
314 for (
int v = 0;
v< link->
mVnets.size();
v++) {
316 linkRoute[vnet] = routing_table_entry[vnet];
319 dest - (2 *
m_nodes), link, linkRoute,
333 int nodes = current_dist[0].size();
345 for (
int i = 0;
i < nodes;
i++) {
346 for (
int j = 0;
j < nodes;
j++) {
358 int minimum = current_dist[
v][
i][
j];
359 int previous_minimum = minimum;
360 int intermediate_switch = -1;
361 for (
int k = 0;
k < nodes;
k++) {
362 minimum = std::min(minimum,
363 current_dist[
v][
i][
k] + current_dist[
v][
k][
j]);
364 if (previous_minimum != minimum) {
365 intermediate_switch =
k;
366 inter_switches[
i][
j][
v] =
367 inter_switches[
i][
k][
v] +
368 inter_switches[
k][
j][
v] + 1;
370 previous_minimum = minimum;
372 if (current_dist[
v][
i][
j] != minimum) {
374 current_dist[
v][
i][
j] = minimum;
375 assert(intermediate_switch >= 0);
376 assert(intermediate_switch < latencies[
i].size());
378 latencies[
i][intermediate_switch][
v] +
379 latencies[intermediate_switch][
j][
v];
401 return weights[vnet][src][next] +
dist[vnet][next][
final] ==
402 dist[vnet][src][
final];
415 machines = MachineType_NUM;
416 max_machines = MachineType_base_number(MachineType_NUM);
418 for (
int m = 0;
m < machines;
m++) {
419 for (
NodeID i = 0;
i < MachineType_base_count((MachineType)
m);
i++) {
426 weights,
dist, vnet)) {
434 DPRINTF(RubyNetwork,
"Returning shortest path\n"
435 "(src-(2*max_machines)): %d, (next-(2*max_machines)): %d, "
436 "src: %d, next: %d, vnet:%d result: %s\n",
437 (src-(2*max_machines)), (next-(2*max_machines)),
438 src, next, vnet, result);