34 #include "debug/RubyNetwork.hh"
54 : m_nodes(ext_links.
size()), m_number_of_switches(num_routers),
55 m_ext_link_vector(ext_links), m_int_link_vector(int_links)
69 i != ext_links.end(); ++
i) {
74 int machine_base_idx = MachineType_base_number(abs_cntrl->
getType());
75 int ext_idx1 = machine_base_idx + abs_cntrl->
getVersion();
76 int ext_idx2 = ext_idx1 +
m_nodes;
81 addLink(ext_idx1, int_idx, ext_link);
83 addLink(int_idx, ext_idx2, ext_link);
88 i != int_links.end(); ++
i) {
103 addLink(src, dst, int_link, src_outport, dst_inport);
112 for (LinkMap::const_iterator
i =
m_link_map.begin();
115 max_switch_id = max(max_switch_id, src_dest.first);
116 max_switch_id = max(max_switch_id, src_dest.second);
120 int num_switches = max_switch_id+1;
121 Matrix topology_weights(num_switches,
123 Matrix component_latencies(num_switches,
125 Matrix component_inter_switches(num_switches,
129 for (
int i = 0;
i < topology_weights.size();
i++) {
130 topology_weights[
i][
i] = 0;
134 for (LinkMap::const_iterator
i =
m_link_map.begin();
138 int src = src_dest.first;
139 int dst = src_dest.second;
140 component_latencies[src][dst] = link->
m_latency;
141 topology_weights[src][dst] = link->
m_weight;
146 component_inter_switches);
148 for (
int i = 0;
i < topology_weights.size();
i++) {
149 for (
int j = 0;
j < topology_weights[
i].size();
j++) {
150 int weight = topology_weights[
i][
j];
171 src_dest_pair.first = src;
172 src_dest_pair.second = dest;
173 link_entry.
link = link;
181 const NetDest& routing_table_entry)
191 src_dest.first = src;
192 src_dest.second = dest;
195 routing_table_entry);
199 src_dest.first = src;
200 src_dest.second = dest;
203 routing_table_entry);
206 src_dest.first = src;
207 src_dest.second = dest;
224 int nodes = current_dist.size();
228 for (
int i = 0;
i < nodes;
i++) {
229 for (
int j = 0;
j < nodes;
j++) {
230 int minimum = current_dist[
i][
j];
231 int previous_minimum = minimum;
232 int intermediate_switch = -1;
233 for (
int k = 0;
k < nodes;
k++) {
234 minimum = min(minimum,
235 current_dist[
i][
k] + current_dist[
k][
j]);
236 if (previous_minimum != minimum) {
237 intermediate_switch =
k;
238 inter_switches[
i][
j] =
239 inter_switches[
i][
k] +
240 inter_switches[
k][
j] + 1;
242 previous_minimum = minimum;
244 if (current_dist[
i][
j] != minimum) {
246 current_dist[
i][
j] = minimum;
247 assert(intermediate_switch >= 0);
248 assert(intermediate_switch < latencies[
i].
size());
249 latencies[
i][
j] = latencies[
i][intermediate_switch] +
250 latencies[intermediate_switch][
j];
271 return weights[src][next] + dist[next][
final] == dist[src][
final];
283 machines = MachineType_NUM;
284 max_machines = MachineType_base_number(MachineType_NUM);
286 for (
int m = 0;
m < machines;
m++) {
287 for (
NodeID i = 0;
i < MachineType_base_count((MachineType)
m);
i++) {
302 DPRINTF(RubyNetwork,
"Returning shortest path\n"
303 "(src-(2*max_machines)): %d, (next-(2*max_machines)): %d, "
304 "src: %d, next: %d, result: %s\n",
305 (src-(2*max_machines)), (next-(2*max_machines)),
const int INFINITE_LATENCY
virtual void makeExtInLink(NodeID src, SwitchID dest, BasicLink *link, const NetDest &routing_table_entry)=0
void extend_shortest_path(Matrix ¤t_dist, Matrix &latencies, Matrix &inter_switches)
const Params * params() const
bool link_is_shortest_path_to_node(SwitchID src, SwitchID next, SwitchID final, const Matrix &weights, const Matrix &dist)
PortDirection src_outport_dirn
virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink *link, const NetDest &routing_table_entry)=0
void add(MachineID newElement)
std::vector< std::vector< int > > shortest_path(const Matrix &weights, Matrix &latencies, Matrix &inter_switches)
const Params * params() const
MachineType getType() const
std::string PortDirection
PortDirection dst_inport_dirn
const uint32_t m_number_of_switches
void addLink(SwitchID src, SwitchID dest, BasicLink *link, PortDirection src_outport_dirn="", PortDirection dest_inport_dirn="")
virtual void makeInternalLink(SwitchID src, SwitchID dest, BasicLink *link, const NetDest &routing_table_entry, PortDirection src_outport, PortDirection dst_inport)=0
Topology(uint32_t num_routers, const std::vector< BasicExtLink * > &ext_links, const std::vector< BasicIntLink * > &int_links)
const Params * params() const
std::vector< BasicIntLink * > m_int_link_vector
void createLinks(Network *net)
void makeLink(Network *net, SwitchID src, SwitchID dest, const NetDest &routing_table_entry)
const FlagsType dist
Print the distribution.
NetDest shortest_path_to_node(SwitchID src, SwitchID next, const Matrix &weights, const Matrix &dist)
NodeID getVersion() const