34 #include "debug/RubyNetwork.hh" 54 : m_nodes(MachineType_base_number(MachineType_NUM)),
55 m_number_of_switches(num_routers),
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 = max(max_switch_id, src_dest.first);
117 max_switch_id = max(max_switch_id, src_dest.second);
121 int num_switches = max_switch_id+1;
122 Matrix topology_weights(num_switches,
124 Matrix component_latencies(num_switches,
126 Matrix component_inter_switches(num_switches,
130 for (
int i = 0;
i < topology_weights.size();
i++) {
131 topology_weights[
i][
i] = 0;
135 for (LinkMap::const_iterator
i =
m_link_map.begin();
139 int src = src_dest.first;
140 int dst = src_dest.second;
141 component_latencies[src][dst] = link->
m_latency;
142 topology_weights[src][dst] = link->
m_weight;
147 component_inter_switches);
149 for (
int i = 0;
i < topology_weights.size();
i++) {
150 for (
int j = 0;
j < topology_weights[
i].size();
j++) {
151 int weight = topology_weights[
i][
j];
172 src_dest_pair.first = src;
173 src_dest_pair.second = dest;
174 link_entry.
link = link;
182 const NetDest& routing_table_entry)
192 src_dest.first = src;
193 src_dest.second = dest;
196 routing_table_entry);
200 src_dest.first = src;
201 src_dest.second = dest;
204 routing_table_entry);
207 src_dest.first = src;
208 src_dest.second = dest;
225 int nodes = current_dist.size();
229 for (
int i = 0;
i < nodes;
i++) {
230 for (
int j = 0;
j < nodes;
j++) {
231 int minimum = current_dist[
i][
j];
232 int previous_minimum = minimum;
233 int intermediate_switch = -1;
234 for (
int k = 0;
k < nodes;
k++) {
235 minimum = min(minimum,
236 current_dist[
i][
k] + current_dist[
k][
j]);
237 if (previous_minimum != minimum) {
238 intermediate_switch =
k;
239 inter_switches[
i][
j] =
240 inter_switches[
i][
k] +
241 inter_switches[
k][
j] + 1;
243 previous_minimum = minimum;
245 if (current_dist[
i][
j] != minimum) {
247 current_dist[
i][
j] = minimum;
248 assert(intermediate_switch >= 0);
249 assert(intermediate_switch < latencies[
i].size());
250 latencies[
i][
j] = latencies[
i][intermediate_switch] +
251 latencies[intermediate_switch][
j];
272 return weights[src][next] + dist[next][
final] == dist[src][
final];
284 machines = MachineType_NUM;
285 max_machines = MachineType_base_number(MachineType_NUM);
287 for (
int m = 0;
m < machines;
m++) {
288 for (
NodeID i = 0;
i < MachineType_base_count((MachineType)
m);
i++) {
303 DPRINTF(RubyNetwork,
"Returning shortest path\n" 304 "(src-(2*max_machines)): %d, (next-(2*max_machines)): %d, " 305 "src: %d, next: %d, result: %s\n",
306 (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)
bool link_is_shortest_path_to_node(SwitchID src, SwitchID next, SwitchID final, const Matrix &weights, const Matrix &dist)
PortDirection src_outport_dirn
const Params * params() const
Overload hash function for BasicBlockRange type.
virtual void makeExtOutLink(SwitchID src, NodeID dest, BasicLink *link, const NetDest &routing_table_entry)=0
void add(MachineID newElement)
NodeID getVersion() const
const Params * params() const
std::vector< std::vector< int > > shortest_path(const Matrix &weights, Matrix &latencies, Matrix &inter_switches)
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
MachineType getType() const
const Params * params() const
std::vector< BasicIntLink * > m_int_link_vector
Topology(uint32_t num_routers, const std::vector< BasicExtLink *> &ext_links, const std::vector< BasicIntLink *> &int_links)
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)