35a36,37
> #include "mem/ruby/network/BasicLink.hh"
> #include "mem/ruby/network/BasicRouter.hh"
44d45
< const int DEFAULT_BW_MULTIPLIER = 1; // Just to be consistent with above :)
45a47,48
> class BasicRouter;
>
67c70,71
< m_number_of_switches = p->num_int_nodes;
---
> m_number_of_switches = p->routers.size();
>
80c84
< m_nodes != params()->ext_links.size());
---
> m_nodes != params()->ext_links.size());
83,85c87,91
< // First create the links between the endpoints (i.e. controllers)
< // and the network.
< for (vector<ExtLink*>::const_iterator i = params()->ext_links.begin();
---
> // analyze both the internal and external links, create data structures
> // Note that the python created links are bi-directional, but that the
> // topology and networks utilize uni-directional links. Thus each
> // BasicLink is converted to two calls to add link, on for each direction
> for (vector<BasicExtLink*>::const_iterator i = params()->ext_links.begin();
87,88c93,95
< const ExtLinkParams *p = (*i)->params();
< AbstractController *c = p->ext_node;
---
> BasicExtLink *ext_link = (*i);
> AbstractController *abs_cntrl = ext_link->params()->ext_node;
> BasicRouter *router = ext_link->params()->int_node;
90,91c97,99
< // Store the controller pointers for later
< m_controller_vector.push_back(c);
---
> // Store the controller and ExtLink pointers for later
> m_controller_vector.push_back(abs_cntrl);
> m_ext_link_vector.push_back(ext_link);
93,94c101
< int ext_idx1 =
< MachineType_base_number(c->getMachineType()) + c->getVersion();
---
> int ext_idx1 = abs_cntrl->params()->cntrl_id;
96c103
< int int_idx = p->int_node + 2*m_nodes;
---
> int int_idx = router->params()->router_id + 2*m_nodes;
98,100c105,109
< // create the links in both directions
< addLink(ext_idx1, int_idx, p->latency, p->bw_multiplier, p->weight);
< addLink(int_idx, ext_idx2, p->latency, p->bw_multiplier, p->weight);
---
> // create the internal uni-directional links in both directions
> // the first direction is marked: In
> addLink(ext_idx1, int_idx, ext_link, LinkDirection_In);
> // the first direction is marked: Out
> addLink(int_idx, ext_idx2, ext_link, LinkDirection_Out);
103c112
< for (vector<IntLink*>::const_iterator i = params()->int_links.begin();
---
> for (vector<BasicIntLink*>::const_iterator i = params()->int_links.begin();
105,107c114,116
< const IntLinkParams *p = (*i)->params();
< int a = p->node_a + 2*m_nodes;
< int b = p->node_b + 2*m_nodes;
---
> BasicIntLink *int_link = (*i);
> BasicRouter *router_a = int_link->params()->node_a;
> BasicRouter *router_b = int_link->params()->node_b;
109,111c118,128
< // create the links in both directions
< addLink(a, b, p->latency, p->bw_multiplier, p->weight);
< addLink(b, a, p->latency, p->bw_multiplier, p->weight);
---
> // Store the IntLink pointers for later
> m_int_link_vector.push_back(int_link);
>
> int a = router_a->params()->router_id + 2*m_nodes;
> int b = router_b->params()->router_id + 2*m_nodes;
>
> // create the internal uni-directional links in both directions
> // the first direction is marked: In
> addLink(a, b, int_link, LinkDirection_In);
> // the second direction is marked: Out
> addLink(b, a, int_link, LinkDirection_Out);
114a132,135
> void
> Topology::init()
> {
> }
115a137
>
119,120c141,145
< for (int cntrl = 0; cntrl < m_controller_vector.size(); cntrl++) {
< m_controller_vector[cntrl]->initNetworkPtr(net_ptr);
---
> for (vector<BasicExtLink*>::const_iterator i = params()->ext_links.begin();
> i != params()->ext_links.end(); ++i) {
> BasicExtLink *ext_link = (*i);
> AbstractController *abs_cntrl = ext_link->params()->ext_node;
> abs_cntrl->initNetworkPtr(net_ptr);
129,131c154,158
< for (int i = 0; i < m_links_src_vector.size(); i++) {
< max_switch_id = max(max_switch_id, m_links_src_vector[i]);
< max_switch_id = max(max_switch_id, m_links_dest_vector[i]);
---
> for (LinkMap::const_iterator i = m_link_map.begin();
> i != m_link_map.end(); ++i) {
> std::pair<int, int> src_dest = (*i).first;
> max_switch_id = max(max_switch_id, src_dest.first);
> max_switch_id = max(max_switch_id, src_dest.second);
134c161
< // Initialize weight vector
---
> // Initialize weight, latency, and inter switched vectors
136,137d162
< Matrix topology_latency;
< Matrix topology_bw_multis;
140,143d164
< topology_latency.resize(num_switches);
< topology_bw_multis.resize(num_switches);
<
< // FIXME setting the size of a member variable here is a HACK!
145,146d165
<
< // FIXME setting the size of a member variable here is a HACK!
151,152d169
< topology_latency[i].resize(num_switches);
< topology_bw_multis[i].resize(num_switches);
154,155d170
<
< // FIXME setting the size of a member variable here is a HACK!
162,163d176
< topology_latency[i][j] = -1;
< topology_bw_multis[i][j] = -1;
178,184c191,198
< for (int i = 0; i < m_links_src_vector.size(); i++) {
< int src = m_links_src_vector[i];
< int dst = m_links_dest_vector[i];
< topology_weights[src][dst] = m_links_weight_vector[i];
< topology_latency[src][dst] = m_links_latency_vector[i];
< m_component_latencies[src][dst] = m_links_latency_vector[i];
< topology_bw_multis[src][dst] = m_bw_multiplier_vector[i];
---
> for (LinkMap::const_iterator i = m_link_map.begin();
> i != m_link_map.end(); ++i) {
> std::pair<int, int> src_dest = (*i).first;
> BasicLink* link = (*i).second.link;
> int src = src_dest.first;
> int dst = src_dest.second;
> m_component_latencies[src][dst] = link->m_latency;
> topology_weights[src][dst] = link->m_weight;
186c200
<
---
>
193,194d206
< int bw_multiplier = topology_bw_multis[i][j];
< int latency = topology_latency[i][j];
197,200c209,210
< topology_weights, dist);
< assert(latency != -1);
< makeLink(net, i, j, destination_set, latency, weight,
< bw_multiplier, isReconfiguration);
---
> topology_weights, dist);
> makeLink(net, i, j, destination_set, isReconfiguration);
206,212d215
< SwitchID
< Topology::newSwitchID()
< {
< m_number_of_switches++;
< return m_number_of_switches-1+m_nodes+m_nodes;
< }
<
214c217,218
< Topology::addLink(SwitchID src, SwitchID dest, int link_latency)
---
> Topology::addLink(SwitchID src, SwitchID dest, BasicLink* link,
> LinkDirection dir)
216,229d219
< addLink(src, dest, link_latency, DEFAULT_BW_MULTIPLIER, link_latency);
< }
<
< void
< Topology::addLink(SwitchID src, SwitchID dest, int link_latency,
< int bw_multiplier)
< {
< addLink(src, dest, link_latency, bw_multiplier, link_latency);
< }
<
< void
< Topology::addLink(SwitchID src, SwitchID dest, int link_latency,
< int bw_multiplier, int link_weight)
< {
232,236c222,230
< m_links_src_vector.push_back(src);
< m_links_dest_vector.push_back(dest);
< m_links_latency_vector.push_back(link_latency);
< m_links_weight_vector.push_back(link_weight);
< m_bw_multiplier_vector.push_back(bw_multiplier);
---
>
> std::pair<int, int> src_dest_pair;
> LinkEntry link_entry;
>
> src_dest_pair.first = src;
> src_dest_pair.second = dest;
> link_entry.direction = dir;
> link_entry.link = link;
> m_link_map[src_dest_pair] = link_entry;
241,242c235
< const NetDest& routing_table_entry, int link_latency, int link_weight,
< int bw_multiplier, bool isReconfiguration)
---
> const NetDest& routing_table_entry, bool isReconfiguration)
247a241,243
> std::pair<int, int> src_dest;
> LinkEntry link_entry;
>
249,250c245,251
< net->makeInLink(src, dest-(2*m_nodes), routing_table_entry,
< link_latency, bw_multiplier, isReconfiguration);
---
> src_dest.first = src;
> src_dest.second = dest;
> link_entry = m_link_map[src_dest];
> net->makeInLink(src, dest - (2 * m_nodes), link_entry.link,
> link_entry.direction,
> routing_table_entry,
> isReconfiguration);
253,255c254,261
< NodeID node = dest-m_nodes;
< net->makeOutLink(src-(2*m_nodes), node, routing_table_entry,
< link_latency, link_weight, bw_multiplier, isReconfiguration);
---
> NodeID node = dest - m_nodes;
> src_dest.first = src;
> src_dest.second = dest;
> link_entry = m_link_map[src_dest];
> net->makeOutLink(src - (2 * m_nodes), node, link_entry.link,
> link_entry.direction,
> routing_table_entry,
> isReconfiguration);
257,260c263,269
< assert((src >= 2*m_nodes) && (dest >= 2*m_nodes));
< net->makeInternalLink(src-(2*m_nodes), dest-(2*m_nodes),
< routing_table_entry, link_latency, link_weight, bw_multiplier,
< isReconfiguration);
---
> assert((src >= 2 * m_nodes) && (dest >= 2 * m_nodes));
> src_dest.first = src;
> src_dest.second = dest;
> link_entry = m_link_map[src_dest];
> net->makeInternalLink(src - (2 * m_nodes), dest - (2 * m_nodes),
> link_entry.link, link_entry.direction,
> routing_table_entry, isReconfiguration);
426,442d434
< Link *
< LinkParams::create()
< {
< return new Link(this);
< }
<
< ExtLink *
< ExtLinkParams::create()
< {
< return new ExtLink(this);
< }
<
< IntLink *
< IntLinkParams::create()
< {
< return new IntLink(this);
< }