Topology.hh (10005:8c2b0dc16ccd) Topology.hh (11096:efaacec43726)
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;

--- 50 unchanged lines hidden (view full) ---

59 LinkDirection direction;
60};
61
62typedef std::map<std::pair<SwitchID, SwitchID>, LinkEntry> LinkMap;
63
64class Topology
65{
66 public:
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;

--- 50 unchanged lines hidden (view full) ---

59 LinkDirection direction;
60};
61
62typedef std::map<std::pair<SwitchID, SwitchID>, LinkEntry> LinkMap;
63
64class Topology
65{
66 public:
67 Topology(uint32_t num_routers, std::vector<BasicExtLink *> ext_links,
68 std::vector<BasicIntLink *> int_links);
67 Topology(uint32_t num_routers, const std::vector<BasicExtLink *> &ext_links,
68 const std::vector<BasicIntLink *> &int_links);
69
70 uint32_t numSwitches() const { return m_number_of_switches; }
71 void createLinks(Network *net);
72 void print(std::ostream& out) const { out << "[Topology]"; }
73
69
70 uint32_t numSwitches() const { return m_number_of_switches; }
71 void createLinks(Network *net);
72 void print(std::ostream& out) const { out << "[Topology]"; }
73
74 protected:
74 private:
75 void addLink(SwitchID src, SwitchID dest, BasicLink* link,
76 LinkDirection dir);
77 void makeLink(Network *net, SwitchID src, SwitchID dest,
78 const NetDest& routing_table_entry);
79
75 void addLink(SwitchID src, SwitchID dest, BasicLink* link,
76 LinkDirection dir);
77 void makeLink(Network *net, SwitchID src, SwitchID dest,
78 const NetDest& routing_table_entry);
79
80 NodeID m_nodes;
81 uint32_t m_number_of_switches;
80 // Helper functions based on chapter 29 of Cormen et al.
81 void extend_shortest_path(Matrix &current_dist, Matrix &latencies,
82 Matrix &inter_switches);
82
83
84 std::vector<std::vector<int>> shortest_path(const Matrix &weights,
85 Matrix &latencies, Matrix &inter_switches);
86
87 bool link_is_shortest_path_to_node(SwitchID src, SwitchID next,
88 SwitchID final, const Matrix &weights, const Matrix &dist);
89
90 NetDest shortest_path_to_node(SwitchID src, SwitchID next,
91 const Matrix &weights, const Matrix &dist);
92
93 const uint32_t m_nodes;
94 const uint32_t m_number_of_switches;
95
83 std::vector<BasicExtLink*> m_ext_link_vector;
84 std::vector<BasicIntLink*> m_int_link_vector;
85
96 std::vector<BasicExtLink*> m_ext_link_vector;
97 std::vector<BasicIntLink*> m_int_link_vector;
98
86 Matrix m_component_latencies;
87 Matrix m_component_inter_switches;
88
89 LinkMap m_link_map;
90};
91
92inline std::ostream&
93operator<<(std::ostream& out, const Topology& obj)
94{
95 obj.print(out);
96 out << std::flush;
97 return out;
98}
99
100#endif // __MEM_RUBY_NETWORK_TOPOLOGY_HH__
99 LinkMap m_link_map;
100};
101
102inline std::ostream&
103operator<<(std::ostream& out, const Topology& obj)
104{
105 obj.print(out);
106 out << std::flush;
107 return out;
108}
109
110#endif // __MEM_RUBY_NETWORK_TOPOLOGY_HH__