gem5  v20.1.0.0
NetworkInterface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Advanced Micro Devices, Inc.
3  * Copyright (c) 2020 Inria
4  * Copyright (c) 2016 Georgia Institute of Technology
5  * Copyright (c) 2008 Princeton University
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met: redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer;
12  * redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution;
15  * neither the name of the copyright holders nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 
33 #ifndef __MEM_RUBY_NETWORK_GARNET_0_NETWORKINTERFACE_HH__
34 #define __MEM_RUBY_NETWORK_GARNET_0_NETWORKINTERFACE_HH__
35 
36 #include <iostream>
37 #include <vector>
38 
47 #include "params/GarnetNetworkInterface.hh"
48 
49 class MessageBuffer;
50 class flitBuffer;
51 
52 class NetworkInterface : public ClockedObject, public Consumer
53 {
54  public:
55  typedef GarnetNetworkInterfaceParams Params;
56  NetworkInterface(const Params *p);
57  ~NetworkInterface() = default;
58 
59  void addInPort(NetworkLink *in_link, CreditLink *credit_link);
60  void addOutPort(NetworkLink *out_link, CreditLink *credit_link,
61  SwitchID router_id, uint32_t consumerVcs);
62 
63  void dequeueCallback();
64  void wakeup();
67 
68  void print(std::ostream& out) const;
69  int get_vnet(int vc);
70  void init_net_ptr(GarnetNetwork *net_ptr) { m_net_ptr = net_ptr; }
71 
72  uint32_t functionalWrite(Packet *);
73 
74  void scheduleFlit(flit *t_flit);
75 
76  int get_router_id(int vnet)
77  {
78  OutputPort *oPort = getOutportForVnet(vnet);
79  assert(oPort);
80  return oPort->routerID();
81  }
82 
83  class OutputPort
84  {
85  public:
86  OutputPort(NetworkLink *outLink, CreditLink *creditLink,
87  int routerID)
88  {
89  _vnets = outLink->mVnets;
90  _outFlitQueue = new flitBuffer();
91 
92  _outNetLink = outLink;
93  _inCreditLink = creditLink;
94 
96  _bitWidth = outLink->bitWidth;
97  _vcRoundRobin = 0;
98 
99  }
100 
101  flitBuffer *
103  {
104  return _outFlitQueue;
105  }
106 
107  NetworkLink *
109  {
110  return _outNetLink;
111  }
112 
113  CreditLink *
115  {
116  return _inCreditLink;
117  }
118 
119  int
121  {
122  return _routerID;
123  }
124 
125  uint32_t bitWidth()
126  {
127  return _bitWidth;
128  }
129 
130  bool isVnetSupported(int pVnet)
131  {
132  if (!_vnets.size()) {
133  return true;
134  }
135 
136  for (auto &it : _vnets) {
137  if (it == pVnet) {
138  return true;
139  }
140  }
141  return false;
142 
143  }
144 
145  std::string
147  {
148  std::stringstream ss;
149  for (auto &it : _vnets) {
150  ss << it;
151  ss << " ";
152  }
153  return ss.str();
154  }
155 
157  {
158  return _vcRoundRobin;
159  }
160 
161  void vcRoundRobin(int vc)
162  {
163  _vcRoundRobin = vc;
164  }
165 
166 
167  private:
170 
173 
174  int _vcRoundRobin; // For round robin scheduling
175 
177  uint32_t _bitWidth;
178  };
179 
180  class InputPort
181  {
182  public:
183  InputPort(NetworkLink *inLink, CreditLink *creditLink)
184  {
185  _vnets = inLink->mVnets;
186  _outCreditQueue = new flitBuffer();
187 
188  _inNetLink = inLink;
189  _outCreditLink = creditLink;
190  _bitWidth = inLink->bitWidth;
191  }
192 
193  flitBuffer *
195  {
196  return _outCreditQueue;
197  }
198 
199  NetworkLink *
201  {
202  return _inNetLink;
203  }
204 
205  CreditLink *
207  {
208  return _outCreditLink;
209  }
210 
211  bool isVnetSupported(int pVnet)
212  {
213  if (!_vnets.size()) {
214  return true;
215  }
216 
217  for (auto &it : _vnets) {
218  if (it == pVnet) {
219  return true;
220  }
221  }
222  return false;
223 
224  }
225 
226  void sendCredit(Credit *cFlit)
227  {
228  _outCreditQueue->insert(cFlit);
229  }
230 
231  uint32_t bitWidth()
232  {
233  return _bitWidth;
234  }
235 
236  std::string
238  {
239  std::stringstream ss;
240  for (auto &it : _vnets) {
241  ss << it;
242  ss << " ";
243  }
244  return ss.str();
245  }
246 
247  // Queue for stalled flits
250  private:
253 
256  uint32_t _bitWidth;
257  };
258 
259 
260  private:
262  const NodeID m_id;
270 
272 
273  // Input Flit Buffers
274  // The flit buffers which will serve the Consumer
277 
278  // The Message buffers that takes messages from the protocol
280  // The Message buffers that provides messages to the protocol
282  // When a vc stays busy for a long time, it indicates a deadlock
284 
285  void checkStallQueue();
286  bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
287  int calculateVC(int vnet);
288 
289 
290  void scheduleOutputPort(OutputPort *oPort);
291  void scheduleOutputLink();
292  void checkReschedule();
293 
294  void incrementStats(flit *t_flit);
295 
296  InputPort *getInportForVnet(int vnet);
297  OutputPort *getOutportForVnet(int vnet);
298 };
299 
300 #endif // __MEM_RUBY_NETWORK_GARNET_0_NETWORKINTERFACE_HH__
NetworkInterface::addInPort
void addInPort(NetworkLink *in_link, CreditLink *credit_link)
Definition: NetworkInterface.cc:59
flitBuffer
Definition: flitBuffer.hh:41
NetworkInterface::InputPort::_vnets
std::vector< int > _vnets
Definition: NetworkInterface.hh:251
NetworkInterface::OutputPort::vcRoundRobin
int vcRoundRobin()
Definition: NetworkInterface.hh:156
NetworkInterface::print
void print(std::ostream &out) const
Definition: NetworkInterface.cc:656
flit
Definition: flit.hh:41
NetworkInterface::InputPort::inNetLink
NetworkLink * inNetLink()
Definition: NetworkInterface.hh:200
NetworkInterface::OutputPort::printVnets
std::string printVnets()
Definition: NetworkInterface.hh:146
NetworkInterface::init_net_ptr
void init_net_ptr(GarnetNetwork *net_ptr)
Definition: NetworkInterface.hh:70
NetworkInterface::get_vnet
int get_vnet(int vc)
Definition: NetworkInterface.cc:598
NetworkInterface::m_net_ptr
GarnetNetwork * m_net_ptr
Definition: NetworkInterface.hh:261
NetworkInterface::InputPort::messageEnqueuedThisCycle
bool messageEnqueuedThisCycle
Definition: NetworkInterface.hh:249
NetworkInterface::InputPort::m_stall_queue
std::deque< flit * > m_stall_queue
Definition: NetworkInterface.hh:248
NetworkInterface::OutputPort::outFlitQueue
flitBuffer * outFlitQueue()
Definition: NetworkInterface.hh:102
NetworkInterface::OutputPort::_inCreditLink
CreditLink * _inCreditLink
Definition: NetworkInterface.hh:172
NetworkInterface::OutputPort::_outNetLink
NetworkLink * _outNetLink
Definition: NetworkInterface.hh:171
std::vector< MessageBuffer * >
GarnetNetwork.hh
NetworkInterface::OutputPort::inCreditLink
CreditLink * inCreditLink()
Definition: NetworkInterface.hh:114
NetworkInterface::outVcState
std::vector< OutVcState > outVcState
Definition: NetworkInterface.hh:269
CommonTypes.hh
NetworkInterface::m_id
const NodeID m_id
Definition: NetworkInterface.hh:262
NetworkInterface::OutputPort::bitWidth
uint32_t bitWidth()
Definition: NetworkInterface.hh:125
NetworkInterface::m_vc_allocator
std::vector< int > m_vc_allocator
Definition: NetworkInterface.hh:265
ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:231
Credit
Definition: Credit.hh:45
NetworkInterface::InputPort::_inNetLink
NetworkLink * _inNetLink
Definition: NetworkInterface.hh:254
NetworkInterface::m_deadlock_threshold
int m_deadlock_threshold
Definition: NetworkInterface.hh:268
NetworkInterface::wakeup
void wakeup()
Definition: NetworkInterface.cc:184
NetworkInterface::addOutPort
void addOutPort(NetworkLink *out_link, CreditLink *credit_link, SwitchID router_id, uint32_t consumerVcs)
Definition: NetworkInterface.cc:77
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
NetworkInterface::vc_busy_counter
std::vector< int > vc_busy_counter
Definition: NetworkInterface.hh:283
NetworkInterface::inPorts
std::vector< InputPort * > inPorts
Definition: NetworkInterface.hh:267
NetworkInterface::m_virtual_networks
const int m_virtual_networks
Definition: NetworkInterface.hh:263
NetworkInterface::outNode_ptr
std::vector< MessageBuffer * > outNode_ptr
Definition: NetworkInterface.hh:281
NetworkInterface::Params
GarnetNetworkInterfaceParams Params
Definition: NetworkInterface.hh:55
NetworkInterface::InputPort::_outCreditLink
CreditLink * _outCreditLink
Definition: NetworkInterface.hh:255
NetworkInterface::addNode
void addNode(std::vector< MessageBuffer * > &inNode, std::vector< MessageBuffer * > &outNode)
Definition: NetworkInterface.cc:123
NetworkInterface::scheduleOutputLink
void scheduleOutputLink()
This function looks at the NI buffers if some buffer has flits which are ready to traverse the link i...
Definition: NetworkInterface.cc:542
Consumer
Definition: Consumer.hh:43
NetworkInterface::OutputPort::_vcRoundRobin
int _vcRoundRobin
Definition: NetworkInterface.hh:174
NetworkInterface::get_router_id
int get_router_id(int vnet)
Definition: NetworkInterface.hh:76
NetworkInterface::~NetworkInterface
~NetworkInterface()=default
NetworkInterface::InputPort::bitWidth
uint32_t bitWidth()
Definition: NetworkInterface.hh:231
NetworkInterface::InputPort::isVnetSupported
bool isVnetSupported(int pVnet)
Definition: NetworkInterface.hh:211
NetworkInterface
Definition: NetworkInterface.hh:52
NetworkInterface::checkReschedule
void checkReschedule()
Definition: NetworkInterface.cc:615
NetworkInterface::InputPort::_bitWidth
uint32_t _bitWidth
Definition: NetworkInterface.hh:256
NetworkInterface::InputPort
Definition: NetworkInterface.hh:180
NetworkInterface::scheduleFlit
void scheduleFlit(flit *t_flit)
Definition: NetworkInterface.cc:580
NetworkInterface::getInportForVnet
InputPort * getInportForVnet(int vnet)
Definition: NetworkInterface.cc:551
NetworkInterface::incrementStats
void incrementStats(flit *t_flit)
Definition: NetworkInterface.cc:147
NetworkInterface::OutputPort::_outFlitQueue
flitBuffer * _outFlitQueue
Definition: NetworkInterface.hh:169
MsgPtr
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:40
NetworkInterface::OutputPort::isVnetSupported
bool isVnetSupported(int pVnet)
Definition: NetworkInterface.hh:130
NetworkInterface::calculateVC
int calculateVC(int vnet)
Definition: NetworkInterface.cc:450
OutVcState.hh
NetworkInterface::InputPort::outCreditQueue
flitBuffer * outCreditQueue()
Definition: NetworkInterface.hh:194
NetworkInterface::OutputPort::vcRoundRobin
void vcRoundRobin(int vc)
Definition: NetworkInterface.hh:161
flitBuffer::insert
void insert(flit *flt)
Definition: flitBuffer.hh:70
NetworkInterface::NetworkInterface
NetworkInterface(const Params *p)
Definition: NetworkInterface.cc:47
NetworkInterface::OutputPort::OutputPort
OutputPort(NetworkLink *outLink, CreditLink *creditLink, int routerID)
Definition: NetworkInterface.hh:86
NetworkInterface::OutputPort::routerID
int routerID()
Definition: NetworkInterface.hh:120
NetworkInterface::m_vc_per_vnet
int m_vc_per_vnet
Definition: NetworkInterface.hh:264
Consumer.hh
NetworkInterface::flitisizeMessage
bool flitisizeMessage(MsgPtr msg_ptr, int vnet)
Definition: NetworkInterface.cc:362
NetworkInterface::m_stall_count
std::vector< int > m_stall_count
Definition: NetworkInterface.hh:271
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
std::deque< flit * >
NetworkInterface::OutputPort::_bitWidth
uint32_t _bitWidth
Definition: NetworkInterface.hh:177
Credit.hh
NetworkInterface::OutputPort::outNetLink
NetworkLink * outNetLink()
Definition: NetworkInterface.hh:108
NetworkInterface::OutputPort::_vnets
std::vector< int > _vnets
Definition: NetworkInterface.hh:168
NetworkInterface::InputPort::outCreditLink
CreditLink * outCreditLink()
Definition: NetworkInterface.hh:206
NetworkInterface::dequeueCallback
void dequeueCallback()
Definition: NetworkInterface.cc:137
GarnetNetwork
Definition: GarnetNetwork.hh:50
NodeID
unsigned int NodeID
Definition: TypeDefines.hh:34
NetworkInterface::niOutVcs
std::vector< flitBuffer > niOutVcs
Definition: NetworkInterface.hh:275
NetworkInterface::m_ni_out_vcs_enqueue_time
std::vector< Tick > m_ni_out_vcs_enqueue_time
Definition: NetworkInterface.hh:276
NetworkInterface::getOutportForVnet
OutputPort * getOutportForVnet(int vnet)
Definition: NetworkInterface.cc:569
NetworkInterface::outPorts
std::vector< OutputPort * > outPorts
Definition: NetworkInterface.hh:266
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
MessageBuffer
Definition: MessageBuffer.hh:68
NetworkInterface::InputPort::printVnets
std::string printVnets()
Definition: NetworkInterface.hh:237
NetworkInterface::InputPort::sendCredit
void sendCredit(Credit *cFlit)
Definition: NetworkInterface.hh:226
Message.hh
NetworkInterface::InputPort::_outCreditQueue
flitBuffer * _outCreditQueue
Definition: NetworkInterface.hh:252
NetworkInterface::OutputPort
Definition: NetworkInterface.hh:83
NetworkInterface::checkStallQueue
void checkStallQueue()
Definition: NetworkInterface.cc:309
NetworkInterface::InputPort::InputPort
InputPort(NetworkLink *inLink, CreditLink *creditLink)
Definition: NetworkInterface.hh:183
NetworkInterface::functionalWrite
uint32_t functionalWrite(Packet *)
Definition: NetworkInterface.cc:662
SwitchID
unsigned int SwitchID
Definition: TypeDefines.hh:35
NetworkInterface::OutputPort::_routerID
int _routerID
Definition: NetworkInterface.hh:176
NetworkInterface::inNode_ptr
std::vector< MessageBuffer * > inNode_ptr
Definition: NetworkInterface.hh:279
NetworkInterface::scheduleOutputPort
void scheduleOutputPort(OutputPort *oPort)
Definition: NetworkInterface.cc:474

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