gem5  v20.1.0.0
GarnetNetwork.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Advanced Micro Devices, Inc.
3  * Copyright (c) 2008 Princeton University
4  * Copyright (c) 2016 Georgia Institute of Technology
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met: redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer;
11  * redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution;
14  * neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 
32 #ifndef __MEM_RUBY_NETWORK_GARNET_0_GARNETNETWORK_HH__
33 #define __MEM_RUBY_NETWORK_GARNET_0_GARNETNETWORK_HH__
34 
35 #include <iostream>
36 #include <vector>
37 
41 #include "params/GarnetNetwork.hh"
42 
43 class FaultModel;
44 class NetworkInterface;
45 class Router;
46 class NetDest;
47 class NetworkLink;
48 class CreditLink;
49 
50 class GarnetNetwork : public Network
51 {
52  public:
53  typedef GarnetNetworkParams Params;
54  GarnetNetwork(const Params *p);
55  ~GarnetNetwork() = default;
56 
57  void init();
58 
59  const char *garnetVersion = "3.0";
60 
61  // Configuration (set externally)
62 
63  // for 2D topology
64  int getNumRows() const { return m_num_rows; }
65  int getNumCols() { return m_num_cols; }
66 
67  // for network
68  uint32_t getNiFlitSize() const { return m_ni_flit_size; }
71  int getRoutingAlgorithm() const { return m_routing_algorithm; }
72 
73  bool isFaultModelEnabled() const { return m_enable_fault_model; }
75 
76 
77  // Internal configuration
78  bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
79  VNET_type
80  get_vnet_type(int vnet)
81  {
82  return m_vnet_type[vnet];
83  }
84  int getNumRouters();
85  int get_router_id(int ni, int vnet);
86 
87 
88  // Methods used by Topology to setup the network
89  void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
90  std::vector<NetDest>& routing_table_entry);
91  void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
92  std::vector<NetDest>& routing_table_entry);
93  void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
94  std::vector<NetDest>& routing_table_entry,
95  PortDirection src_outport_dirn,
96  PortDirection dest_inport_dirn);
97 
100  uint32_t functionalWrite(Packet *pkt);
101 
102  // Stats
103  void collateStats();
104  void regStats();
105  void resetStats();
106  void print(std::ostream& out) const;
107 
108  // increment counters
109  void increment_injected_packets(int vnet) { m_packets_injected[vnet]++; }
110  void increment_received_packets(int vnet) { m_packets_received[vnet]++; }
111 
112  void
114  {
115  m_packet_network_latency[vnet] += latency;
116  }
117 
118  void
120  {
121  m_packet_queueing_latency[vnet] += latency;
122  }
123 
124  void increment_injected_flits(int vnet) { m_flits_injected[vnet]++; }
125  void increment_received_flits(int vnet) { m_flits_received[vnet]++; }
126 
127  void
129  {
130  m_flit_network_latency[vnet] += latency;
131  }
132 
133  void
135  {
136  m_flit_queueing_latency[vnet] += latency;
137  }
138 
139  void
141  {
142  m_total_hops += hops;
143  }
144 
145  protected:
146  // Configuration
149  uint32_t m_ni_flit_size;
155 
156  // Statistical variables
161 
167 
172 
178 
184 
187 
188  private:
189  GarnetNetwork(const GarnetNetwork& obj);
191 
193  std::vector<Router *> m_routers; // All Routers in Network
194  std::vector<NetworkLink *> m_networklinks; // All flit links in the network
195  std::vector<CreditLink *> m_creditlinks; // All credit links in the network
196  std::vector<NetworkInterface *> m_nis; // All NI's in Network
197 };
198 
199 inline std::ostream&
200 operator<<(std::ostream& out, const GarnetNetwork& obj)
201 {
202  obj.print(out);
203  out << std::flush;
204  return out;
205 }
206 
207 #endif //__MEM_RUBY_NETWORK_GARNET_0_GARNETNETWORK_HH__
GarnetNetwork::increment_received_flits
void increment_received_flits(int vnet)
Definition: GarnetNetwork.hh:125
GarnetNetwork::m_average_link_utilization
Stats::Scalar m_average_link_utilization
Definition: GarnetNetwork.hh:182
GarnetNetwork::increment_total_hops
void increment_total_hops(int hops)
Definition: GarnetNetwork.hh:140
GarnetNetwork::m_avg_packet_vnet_latency
Stats::Formula m_avg_packet_vnet_latency
Definition: GarnetNetwork.hh:162
GarnetNetwork::resetStats
void resetStats()
Callback to reset stats.
Definition: GarnetNetwork.cc:540
GarnetNetwork::getNiFlitSize
uint32_t getNiFlitSize() const
Definition: GarnetNetwork.hh:68
GarnetNetwork::m_vnet_type
std::vector< VNET_type > m_vnet_type
Definition: GarnetNetwork.hh:192
GarnetNetwork::increment_flit_network_latency
void increment_flit_network_latency(Tick latency, int vnet)
Definition: GarnetNetwork.hh:128
GarnetNetwork::m_nis
std::vector< NetworkInterface * > m_nis
Definition: GarnetNetwork.hh:196
GarnetNetwork::m_num_cols
int m_num_cols
Definition: GarnetNetwork.hh:148
FaultModel
Definition: FaultModel.hh:53
GarnetNetwork::m_packet_network_latency
Stats::Vector m_packet_network_latency
Definition: GarnetNetwork.hh:159
GarnetNetwork::m_flits_injected
Stats::Vector m_flits_injected
Definition: GarnetNetwork.hh:169
operator<<
std::ostream & operator<<(std::ostream &out, const GarnetNetwork &obj)
Definition: GarnetNetwork.hh:200
GarnetNetwork::get_router_id
int get_router_id(int ni, int vnet)
Definition: GarnetNetwork.cc:357
GarnetNetwork::m_ni_flit_size
uint32_t m_ni_flit_size
Definition: GarnetNetwork.hh:149
GarnetNetwork::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: GarnetNetwork.cc:102
GarnetNetwork::m_total_ext_out_link_utilization
Stats::Scalar m_total_ext_out_link_utilization
Definition: GarnetNetwork.hh:180
GarnetNetwork::makeExtInLink
void makeExtInLink(NodeID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)
Definition: GarnetNetwork.cc:154
GarnetNetwork::m_routers
std::vector< Router * > m_routers
Definition: GarnetNetwork.hh:193
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
GarnetNetwork::increment_packet_queueing_latency
void increment_packet_queueing_latency(Tick latency, int vnet)
Definition: GarnetNetwork.hh:119
GarnetNetwork::garnetVersion
const char * garnetVersion
Definition: GarnetNetwork.hh:59
GarnetNetwork::Params
GarnetNetworkParams Params
Definition: GarnetNetwork.hh:53
std::vector< NetDest >
GarnetNetwork::getBuffersPerCtrlVC
uint32_t getBuffersPerCtrlVC()
Definition: GarnetNetwork.hh:70
GarnetNetwork::m_total_hops
Stats::Scalar m_total_hops
Definition: GarnetNetwork.hh:185
CommonTypes.hh
Stats::Vector
A vector of scalar stats.
Definition: statistics.hh:2575
GarnetNetwork::m_flit_network_latency
Stats::Vector m_flit_network_latency
Definition: GarnetNetwork.hh:170
GarnetNetwork::increment_injected_flits
void increment_injected_flits(int vnet)
Definition: GarnetNetwork.hh:124
GarnetNetwork::increment_injected_packets
void increment_injected_packets(int vnet)
Definition: GarnetNetwork.hh:109
GarnetNetwork::increment_received_packets
void increment_received_packets(int vnet)
Definition: GarnetNetwork.hh:110
GarnetNetwork::increment_packet_network_latency
void increment_packet_network_latency(Tick latency, int vnet)
Definition: GarnetNetwork.hh:113
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
GarnetNetwork::m_avg_hops
Stats::Formula m_avg_hops
Definition: GarnetNetwork.hh:186
GarnetNetwork::m_avg_flit_network_latency
Stats::Formula m_avg_flit_network_latency
Definition: GarnetNetwork.hh:175
GarnetNetwork::makeInternalLink
void makeInternalLink(SwitchID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry, PortDirection src_outport_dirn, PortDirection dest_inport_dirn)
Definition: GarnetNetwork.cc:291
GarnetNetwork::getNumRouters
int getNumRouters()
Definition: GarnetNetwork.cc:350
Router
Definition: Router.hh:56
GarnetNetwork::m_avg_packet_latency
Stats::Formula m_avg_packet_latency
Definition: GarnetNetwork.hh:166
GarnetNetwork::m_packets_received
Stats::Vector m_packets_received
Definition: GarnetNetwork.hh:157
GarnetNetwork::m_avg_packet_vqueue_latency
Stats::Formula m_avg_packet_vqueue_latency
Definition: GarnetNetwork.hh:163
GarnetNetwork::isFaultModelEnabled
bool isFaultModelEnabled() const
Definition: GarnetNetwork.hh:73
GarnetNetwork::increment_flit_queueing_latency
void increment_flit_queueing_latency(Tick latency, int vnet)
Definition: GarnetNetwork.hh:134
Network::m_ordered
std::vector< bool > m_ordered
Definition: Network.hh:160
GarnetNetwork::print
void print(std::ostream &out) const
Definition: GarnetNetwork.cc:554
GarnetNetwork::m_total_int_link_utilization
Stats::Scalar m_total_int_link_utilization
Definition: GarnetNetwork.hh:181
GarnetNetwork::m_enable_fault_model
bool m_enable_fault_model
Definition: GarnetNetwork.hh:154
GarnetNetwork::m_buffers_per_data_vc
uint32_t m_buffers_per_data_vc
Definition: GarnetNetwork.hh:152
NetworkInterface
Definition: NetworkInterface.hh:52
GarnetNetwork::getRoutingAlgorithm
int getRoutingAlgorithm() const
Definition: GarnetNetwork.hh:71
GarnetNetwork::makeExtOutLink
void makeExtOutLink(SwitchID src, NodeID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)
Definition: GarnetNetwork.cc:220
Network
Definition: Network.hh:76
GarnetNetwork::m_avg_flit_vqueue_latency
Stats::Formula m_avg_flit_vqueue_latency
Definition: GarnetNetwork.hh:174
GarnetNetwork::~GarnetNetwork
~GarnetNetwork()=default
GarnetNetwork::operator=
GarnetNetwork & operator=(const GarnetNetwork &obj)
FaultModel.hh
GarnetNetwork::m_routing_algorithm
int m_routing_algorithm
Definition: GarnetNetwork.hh:153
GarnetNetwork::isVNetOrdered
bool isVNetOrdered(int vnet) const
Definition: GarnetNetwork.hh:78
GarnetNetwork::getBuffersPerDataVC
uint32_t getBuffersPerDataVC()
Definition: GarnetNetwork.hh:69
Network.hh
GarnetNetwork::m_flit_queueing_latency
Stats::Vector m_flit_queueing_latency
Definition: GarnetNetwork.hh:171
GarnetNetwork::m_average_vc_load
Stats::Vector m_average_vc_load
Definition: GarnetNetwork.hh:183
GarnetNetwork::m_avg_packet_network_latency
Stats::Formula m_avg_packet_network_latency
Definition: GarnetNetwork.hh:164
GarnetNetwork::m_avg_flit_queueing_latency
Stats::Formula m_avg_flit_queueing_latency
Definition: GarnetNetwork.hh:176
GarnetNetwork::m_max_vcs_per_vnet
uint32_t m_max_vcs_per_vnet
Definition: GarnetNetwork.hh:150
GarnetNetwork::m_num_rows
int m_num_rows
Definition: GarnetNetwork.hh:147
Stats::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3037
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
GarnetNetwork::m_buffers_per_ctrl_vc
uint32_t m_buffers_per_ctrl_vc
Definition: GarnetNetwork.hh:151
GarnetNetwork::GarnetNetwork
GarnetNetwork(const Params *p)
Definition: GarnetNetwork.cc:56
PowerISA::ni
Bitfield< 3 > ni
Definition: miscregs.hh:92
GarnetNetwork::m_avg_flit_latency
Stats::Formula m_avg_flit_latency
Definition: GarnetNetwork.hh:177
PortDirection
std::string PortDirection
Definition: Topology.hh:62
GarnetNetwork
Definition: GarnetNetwork.hh:50
GarnetNetwork::m_avg_flit_vnet_latency
Stats::Formula m_avg_flit_vnet_latency
Definition: GarnetNetwork.hh:173
GarnetNetwork::m_creditlinks
std::vector< CreditLink * > m_creditlinks
Definition: GarnetNetwork.hh:195
GarnetNetwork::collateStats
void collateStats()
Definition: GarnetNetwork.cc:508
NodeID
unsigned int NodeID
Definition: TypeDefines.hh:34
GarnetNetwork::regStats
void regStats()
Callback to set stat parameters.
Definition: GarnetNetwork.cc:365
GarnetNetwork::m_packets_injected
Stats::Vector m_packets_injected
Definition: GarnetNetwork.hh:158
GarnetNetwork::m_flits_received
Stats::Vector m_flits_received
Definition: GarnetNetwork.hh:168
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
GarnetNetwork::m_avg_packet_queueing_latency
Stats::Formula m_avg_packet_queueing_latency
Definition: GarnetNetwork.hh:165
GarnetNetwork::m_packet_queueing_latency
Stats::Vector m_packet_queueing_latency
Definition: GarnetNetwork.hh:160
VNET_type
VNET_type
Definition: CommonTypes.hh:41
GarnetNetwork::functionalWrite
uint32_t functionalWrite(Packet *pkt)
Function for performing a functional write.
Definition: GarnetNetwork.cc:566
GarnetNetwork::get_vnet_type
VNET_type get_vnet_type(int vnet)
Definition: GarnetNetwork.hh:80
GarnetNetwork::m_total_ext_in_link_utilization
Stats::Scalar m_total_ext_in_link_utilization
Definition: GarnetNetwork.hh:179
GarnetNetwork::m_networklinks
std::vector< NetworkLink * > m_networklinks
Definition: GarnetNetwork.hh:194
NetDest
Definition: NetDest.hh:39
GarnetNetwork::getNumCols
int getNumCols()
Definition: GarnetNetwork.hh:65
GarnetNetwork::fault_model
FaultModel * fault_model
Definition: GarnetNetwork.hh:74
SwitchID
unsigned int SwitchID
Definition: TypeDefines.hh:35
GarnetNetwork::getNumRows
int getNumRows() const
Definition: GarnetNetwork.hh:64

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17