From 6bee1d912482ee57ed79bb557afdad25563e9955 Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Mon, 14 Sep 2015 10:14:50 -0500 Subject: ruby: topology: refactor code. --- src/mem/ruby/network/Topology.hh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/mem/ruby/network/Topology.hh') diff --git a/src/mem/ruby/network/Topology.hh b/src/mem/ruby/network/Topology.hh index 1a11156e7..7fa0914a1 100644 --- a/src/mem/ruby/network/Topology.hh +++ b/src/mem/ruby/network/Topology.hh @@ -64,28 +64,38 @@ typedef std::map, LinkEntry> LinkMap; class Topology { public: - Topology(uint32_t num_routers, std::vector ext_links, - std::vector int_links); + Topology(uint32_t num_routers, const std::vector &ext_links, + const std::vector &int_links); uint32_t numSwitches() const { return m_number_of_switches; } void createLinks(Network *net); void print(std::ostream& out) const { out << "[Topology]"; } - protected: + private: void addLink(SwitchID src, SwitchID dest, BasicLink* link, LinkDirection dir); void makeLink(Network *net, SwitchID src, SwitchID dest, const NetDest& routing_table_entry); - NodeID m_nodes; - uint32_t m_number_of_switches; + // Helper functions based on chapter 29 of Cormen et al. + void extend_shortest_path(Matrix ¤t_dist, Matrix &latencies, + Matrix &inter_switches); + + std::vector> shortest_path(const Matrix &weights, + Matrix &latencies, Matrix &inter_switches); + + bool link_is_shortest_path_to_node(SwitchID src, SwitchID next, + SwitchID final, const Matrix &weights, const Matrix &dist); + + NetDest shortest_path_to_node(SwitchID src, SwitchID next, + const Matrix &weights, const Matrix &dist); + + const uint32_t m_nodes; + const uint32_t m_number_of_switches; std::vector m_ext_link_vector; std::vector m_int_link_vector; - Matrix m_component_latencies; - Matrix m_component_inter_switches; - LinkMap m_link_map; }; -- cgit v1.2.3