1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 19 unchanged lines hidden (view full) --- 28 29#include <cassert> 30 31#include "base/trace.hh" 32#include "debug/RubyNetwork.hh" 33#include "mem/protocol/MachineType.hh" 34#include "mem/ruby/common/NetDest.hh" 35#include "mem/ruby/network/BasicLink.hh" |
36#include "mem/ruby/network/Topology.hh" 37#include "mem/ruby/slicc_interface/AbstractController.hh" 38 39using namespace std; 40 41const int INFINITE_LATENCY = 10000; // Yes, this is a big hack 42 43// Note: In this file, we use the first 2*m_nodes SwitchIDs to --- 8 unchanged lines hidden (view full) --- 52 Matrix& inter_switches); 53Matrix shortest_path(const Matrix& weights, Matrix& latencies, 54 Matrix& inter_switches); 55bool link_is_shortest_path_to_node(SwitchID src, SwitchID next, 56 SwitchID final, const Matrix& weights, const Matrix& dist); 57NetDest shortest_path_to_node(SwitchID src, SwitchID next, 58 const Matrix& weights, const Matrix& dist); 59 |
60Topology::Topology(uint32_t num_routers, vector<BasicExtLink *> ext_links, 61 vector<BasicIntLink *> int_links) 62 : m_number_of_switches(num_routers) |
63{ |
64 65 // initialize component latencies record 66 m_component_latencies.resize(0); 67 m_component_inter_switches.resize(0); 68 69 // Total nodes/controllers in network 70 // Must make sure this is called after the State Machine constructors 71 m_nodes = MachineType_base_number(MachineType_NUM); 72 assert(m_nodes > 1); 73 |
74 if (m_nodes != ext_links.size()) { |
75 fatal("m_nodes (%d) != ext_links vector length (%d)\n", |
76 m_nodes, ext_links.size()); |
77 } 78 79 // analyze both the internal and external links, create data structures 80 // Note that the python created links are bi-directional, but that the 81 // topology and networks utilize uni-directional links. Thus each 82 // BasicLink is converted to two calls to add link, on for each direction |
83 for (vector 84 i != ext_links.end(); ++i) { |
85 BasicExtLink *ext_link = (*i); 86 AbstractController *abs_cntrl = ext_link->params()->ext_node; 87 BasicRouter *router = ext_link->params()->int_node; 88 89 // Store the ExtLink pointers for later 90 m_ext_link_vector.push_back(ext_link); 91 92 int ext_idx1 = abs_cntrl->params()->cntrl_id; 93 int ext_idx2 = ext_idx1 + m_nodes; 94 int int_idx = router->params()->router_id + 2*m_nodes; 95 96 // create the internal uni-directional links in both directions 97 // the first direction is marked: In 98 addLink(ext_idx1, int_idx, ext_link, LinkDirection_In); 99 // the first direction is marked: Out 100 addLink(int_idx, ext_idx2, ext_link, LinkDirection_Out); 101 } 102 |
103 for (vector 104 i != int_links.end(); ++i) { |
105 BasicIntLink *int_link = (*i); 106 BasicRouter *router_a = int_link->params()->node_a; 107 BasicRouter *router_b = int_link->params()->node_b; 108 109 // Store the IntLink pointers for later 110 m_int_link_vector.push_back(int_link); 111 112 int a = router_a->params()->router_id + 2*m_nodes; 113 int b = router_b->params()->router_id + 2*m_nodes; 114 115 // create the internal uni-directional links in both directions 116 // the first direction is marked: In 117 addLink(a, b, int_link, LinkDirection_In); 118 // the second direction is marked: Out 119 addLink(b, a, int_link, LinkDirection_Out); 120 } 121} 122 123void |
124Topology::createLinks(Network *net, bool isReconfiguration) 125{ 126 // Find maximum switchID 127 SwitchID max_switch_id = 0; 128 for (LinkMap::const_iterator i = m_link_map.begin(); 129 i != m_link_map.end(); ++i) { 130 std::pair<int, int> src_dest = (*i).first; 131 max_switch_id = max(max_switch_id, src_dest.first); --- 198 unchanged lines hidden (view full) --- 330 DPRINTF(RubyNetwork, "Returning shortest path\n" 331 "(src-(2*max_machines)): %d, (next-(2*max_machines)): %d, " 332 "src: %d, next: %d, result: %s\n", 333 (src-(2*max_machines)), (next-(2*max_machines)), 334 src, next, result); 335 336 return result; 337} |