gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GarnetNetwork.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 Princeton University
3  * Copyright (c) 2016 Georgia Institute of Technology
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  * Authors: Niket Agarwal
30  * Tushar Krishna
31  */
32 
33 
34 #ifndef __MEM_RUBY_NETWORK_GARNET_NETWORK_HH__
35 #define __MEM_RUBY_NETWORK_GARNET_NETWORK_HH__
36 
37 #include <iostream>
38 #include <vector>
39 
43 #include "params/GarnetNetwork.hh"
44 
45 class FaultModel;
46 class NetworkInterface;
47 class Router;
48 class NetDest;
49 class NetworkLink;
50 class CreditLink;
51 
52 class GarnetNetwork : public Network
53 {
54  public:
55  typedef GarnetNetworkParams Params;
56  GarnetNetwork(const Params *p);
57 
59  void init();
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; }
69  uint32_t getVCsPerVnet() const { return m_vcs_per_vnet; }
72  int getRoutingAlgorithm() const { return m_routing_algorithm; }
73 
74  bool isFaultModelEnabled() const { return m_enable_fault_model; }
76 
77 
78  // Internal configuration
79  bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
80  VNET_type
81  get_vnet_type(int vc)
82  {
83  int vnet = vc/getVCsPerVnet();
84  return m_vnet_type[vnet];
85  }
86  int getNumRouters();
87  int get_router_id(int ni);
88 
89 
90  // Methods used by Topology to setup the network
91  void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
92  const NetDest& routing_table_entry);
93  void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
94  const NetDest& routing_table_entry);
95  void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
96  const NetDest& routing_table_entry,
97  PortDirection src_outport_dirn,
98  PortDirection dest_inport_dirn);
99 
102  uint32_t functionalWrite(Packet *pkt);
103 
104  // Stats
105  void collateStats();
106  void regStats();
107  void print(std::ostream& out) const;
108 
109  // increment counters
110  void increment_injected_packets(int vnet) { m_packets_injected[vnet]++; }
111  void increment_received_packets(int vnet) { m_packets_received[vnet]++; }
112 
113  void
115  {
116  m_packet_network_latency[vnet] += latency;
117  }
118 
119  void
121  {
122  m_packet_queueing_latency[vnet] += latency;
123  }
124 
125  void increment_injected_flits(int vnet) { m_flits_injected[vnet]++; }
126  void increment_received_flits(int vnet) { m_flits_received[vnet]++; }
127 
128  void
130  {
131  m_flit_network_latency[vnet] += latency;
132  }
133 
134  void
136  {
137  m_flit_queueing_latency[vnet] += latency;
138  }
139 
140  void
142  {
143  m_total_hops += hops;
144  }
145 
146  protected:
147  // Configuration
150  uint32_t m_ni_flit_size;
151  uint32_t m_vcs_per_vnet;
156 
157  // Statistical variables
162 
168 
173 
179 
185 
188 
189  private:
190  GarnetNetwork(const GarnetNetwork& obj);
192 
194  std::vector<Router *> m_routers; // All Routers in Network
195  std::vector<NetworkLink *> m_networklinks; // All flit links in the network
196  std::vector<CreditLink *> m_creditlinks; // All credit links in the network
197  std::vector<NetworkInterface *> m_nis; // All NI's in Network
198 };
199 
200 inline std::ostream&
201 operator<<(std::ostream& out, const GarnetNetwork& obj)
202 {
203  obj.print(out);
204  out << std::flush;
205  return out;
206 }
207 
208 #endif // __MEM_RUBY_NETWORK_GARNET_NETWORK_HH__
Stats::Formula m_avg_flit_queueing_latency
GarnetNetworkParams Params
void print(std::ostream &out) const
bool isVNetOrdered(int vnet) const
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
std::vector< CreditLink * > m_creditlinks
Stats::Vector m_packets_injected
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
int getNumRows() const
void increment_injected_flits(int vnet)
Stats::Vector m_flits_injected
Stats::Formula m_avg_packet_latency
uint32_t getVCsPerVnet() const
Stats::Formula m_avg_packet_network_latency
Stats::Vector m_flits_received
uint32_t m_buffers_per_ctrl_vc
Stats::Vector m_average_vc_load
A vector of scalar stats.
Definition: statistics.hh:2499
Stats::Scalar m_total_int_link_utilization
void regStats()
Register statistics for this object.
void increment_total_hops(int hops)
std::vector< bool > m_ordered
Definition: Network.hh:120
Stats::Scalar m_total_ext_out_link_utilization
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
Stats::Formula m_avg_packet_queueing_latency
uint32_t m_vcs_per_vnet
VNET_type
Definition: CommonTypes.hh:43
void makeExtInLink(NodeID src, SwitchID dest, BasicLink *link, const NetDest &routing_table_entry)
std::vector< Router * > m_routers
unsigned int NodeID
Definition: TypeDefines.hh:34
Stats::Vector m_packet_network_latency
unsigned int SwitchID
Definition: TypeDefines.hh:35
uint32_t getBuffersPerCtrlVC()
GarnetNetwork(const Params *p)
FaultModel * fault_model
VNET_type get_vnet_type(int vc)
void increment_packet_queueing_latency(Cycles latency, int vnet)
std::vector< VNET_type > m_vnet_type
std::string PortDirection
Definition: Topology.hh:55
void increment_injected_packets(int vnet)
std::ostream & operator<<(std::ostream &out, const GarnetNetwork &obj)
std::vector< NetworkInterface * > m_nis
uint32_t getNiFlitSize() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
void increment_packet_network_latency(Cycles latency, int vnet)
GarnetNetwork & operator=(const GarnetNetwork &obj)
int get_router_id(int ni)
Bitfield< 3 > ni
Definition: miscregs.hh:94
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2895
Stats::Formula m_avg_hops
Stats::Scalar m_average_link_utilization
Stats::Vector m_packets_received
Definition: Router.hh:57
uint32_t getBuffersPerDataVC()
Stats::Formula m_avg_packet_vqueue_latency
void increment_received_packets(int vnet)
void makeInternalLink(SwitchID src, SwitchID dest, BasicLink *link, const NetDest &routing_table_entry, PortDirection src_outport_dirn, PortDirection dest_inport_dirn)
void increment_flit_queueing_latency(Cycles latency, int vnet)
Stats::Scalar m_total_hops
Stats::Vector m_flit_network_latency
Stats::Formula m_avg_flit_vqueue_latency
Stats::Formula m_avg_flit_network_latency
std::vector< NetworkLink * > m_networklinks
bool isFaultModelEnabled() const
uint32_t functionalWrite(Packet *pkt)
Function for performing a functional write.
uint32_t m_ni_flit_size
void increment_flit_network_latency(Cycles latency, int vnet)
Stats::Formula m_avg_flit_latency
Stats::Formula m_avg_packet_vnet_latency
int getRoutingAlgorithm() const
uint32_t m_buffers_per_data_vc
Stats::Scalar m_total_ext_in_link_utilization
void makeExtOutLink(SwitchID src, NodeID dest, BasicLink *link, const NetDest &routing_table_entry)
Bitfield< 0 > p
Stats::Vector m_flit_queueing_latency
Stats::Formula m_avg_flit_vnet_latency
Stats::Vector m_packet_queueing_latency
void increment_received_flits(int vnet)
bool m_enable_fault_model

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6