gem5  v21.1.0.2
Topology.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Advanced Micro Devices, Inc.
3  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 /*
31  * The topology here is configurable; it can be a hierachical (default
32  * one) or a 2D torus or a 2D torus with half switches killed. I think
33  * all input port has a one-input-one-output switch connected just to
34  * control and bandwidth, since we don't control bandwidth on input
35  * ports. Basically, the class has a vector of nodes and edges. First
36  * 2*m_nodes elements in the node vector are input and output
37  * ports. Edges are represented in two vectors of src and dest
38  * nodes. All edges have latency.
39  */
40 
41 #ifndef __MEM_RUBY_NETWORK_TOPOLOGY_HH__
42 #define __MEM_RUBY_NETWORK_TOPOLOGY_HH__
43 
44 #include <iostream>
45 #include <string>
46 #include <vector>
47 
50 #include "mem/ruby/protocol/LinkDirection.hh"
51 
52 namespace gem5
53 {
54 
55 namespace ruby
56 {
57 
58 class NetDest;
59 class Network;
60 
61 /*
62  * We use a three-dimensional vector matrix for calculating
63  * the shortest paths for each pair of source and destination
64  * and for each type of virtual network. The three dimensions
65  * represent the source ID, destination ID, and vnet number.
66  */
68 typedef std::string PortDirection;
69 
70 struct LinkEntry
71 {
75 };
76 
77 typedef std::map<std::pair<SwitchID, SwitchID>,
79 
80 class Topology
81 {
82  public:
83  Topology(uint32_t num_nodes, uint32_t num_routers, uint32_t num_vnets,
84  const std::vector<BasicExtLink *> &ext_links,
85  const std::vector<BasicIntLink *> &int_links);
86 
87  uint32_t numSwitches() const { return m_number_of_switches; }
88  void createLinks(Network *net);
89  void print(std::ostream& out) const { out << "[Topology]"; }
90 
91  private:
92  void addLink(SwitchID src, SwitchID dest, BasicLink* link,
93  PortDirection src_outport_dirn = "",
94  PortDirection dest_inport_dirn = "");
95  void makeLink(Network *net, SwitchID src, SwitchID dest,
96  std::vector<NetDest>& routing_table_entry);
97 
98  // Helper functions based on chapter 29 of Cormen et al.
99  void extend_shortest_path(Matrix &current_dist, Matrix &latencies,
100  Matrix &inter_switches);
101 
102  Matrix shortest_path(const Matrix &weights,
103  Matrix &latencies, Matrix &inter_switches);
104 
106  SwitchID final, const Matrix &weights, const Matrix &dist,
107  int vnet);
108 
110  const Matrix &weights, const Matrix &dist,
111  int vnet);
112 
113  const uint32_t m_nodes;
114  const uint32_t m_number_of_switches;
115  int m_vnets;
116 
119 
121 };
122 
123 inline std::ostream&
124 operator<<(std::ostream& out, const Topology& obj)
125 {
126  obj.print(out);
127  out << std::flush;
128  return out;
129 }
130 
131 } // namespace ruby
132 } // namespace gem5
133 
134 #endif // __MEM_RUBY_NETWORK_TOPOLOGY_HH__
gem5::ruby::LinkEntry::link
BasicLink * link
Definition: Topology.hh:72
gem5::ruby::PortDirection
std::string PortDirection
Definition: Topology.hh:68
gem5::ruby::LinkEntry
Definition: Topology.hh:70
gem5::ruby::Topology
Definition: Topology.hh:80
gem5::ruby::LinkMap
std::map< std::pair< SwitchID, SwitchID >, std::vector< LinkEntry > > LinkMap
Definition: Topology.hh:78
gem5::ruby::operator<<
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
gem5::ruby::Matrix
std::vector< std::vector< std::vector< int > > > Matrix
Definition: Topology.hh:59
gem5::ruby::Topology::m_int_link_vector
std::vector< BasicIntLink * > m_int_link_vector
Definition: Topology.hh:118
gem5::ruby::Topology::addLink
void addLink(SwitchID src, SwitchID dest, BasicLink *link, PortDirection src_outport_dirn="", PortDirection dest_inport_dirn="")
Definition: Topology.cc:218
gem5::ruby::Network
Definition: Network.hh:82
gem5::ruby::Topology::createLinks
void createLinks(Network *net)
Definition: Topology.cc:115
gem5::ruby::Topology::Topology
Topology(uint32_t num_nodes, uint32_t num_routers, uint32_t num_vnets, const std::vector< BasicExtLink * > &ext_links, const std::vector< BasicIntLink * > &int_links)
Definition: Topology.cc:56
std::vector
STL vector class.
Definition: stl.hh:37
gem5::statistics::dist
const FlagsType dist
Print the distribution.
Definition: info.hh:66
gem5::ruby::Topology::shortest_path_to_node
NetDest shortest_path_to_node(SwitchID src, SwitchID next, const Matrix &weights, const Matrix &dist, int vnet)
Definition: Topology.cc:412
gem5::ruby::Topology::extend_shortest_path
void extend_shortest_path(Matrix &current_dist, Matrix &latencies, Matrix &inter_switches)
Definition: Topology.cc:336
gem5::ruby::Topology::numSwitches
uint32_t numSwitches() const
Definition: Topology.hh:87
TypeDefines.hh
gem5::ruby::Topology::print
void print(std::ostream &out) const
Definition: Topology.hh:89
gem5::ruby::Topology::m_nodes
const uint32_t m_nodes
Definition: Topology.hh:113
gem5::ruby::LinkEntry::src_outport_dirn
PortDirection src_outport_dirn
Definition: Topology.hh:73
gem5::ruby::LinkEntry::dst_inport_dirn
PortDirection dst_inport_dirn
Definition: Topology.hh:74
gem5::ruby::SwitchID
unsigned int SwitchID
Definition: TypeDefines.hh:41
gem5::ruby::Topology::makeLink
void makeLink(Network *net, SwitchID src, SwitchID dest, std::vector< NetDest > &routing_table_entry)
Definition: Topology.cc:250
gem5::ruby::NetDest
Definition: NetDest.hh:45
gem5::ruby::Topology::m_number_of_switches
const uint32_t m_number_of_switches
Definition: Topology.hh:114
gem5::ruby::Topology::m_vnets
int m_vnets
Definition: Topology.hh:115
gem5::ruby::Topology::shortest_path
Matrix shortest_path(const Matrix &weights, Matrix &latencies, Matrix &inter_switches)
Definition: Topology.cc:394
gem5::ruby::Topology::link_is_shortest_path_to_node
bool link_is_shortest_path_to_node(SwitchID src, SwitchID next, SwitchID final, const Matrix &weights, const Matrix &dist, int vnet)
Definition: Topology.cc:403
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ruby::Topology::m_link_map
LinkMap m_link_map
Definition: Topology.hh:120
gem5::ruby::Topology::m_ext_link_vector
std::vector< BasicExtLink * > m_ext_link_vector
Definition: Topology.hh:117

Generated on Tue Sep 21 2021 12:25:41 for gem5 by doxygen 1.8.17