gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
49namespace gem5
50{
51
52namespace ruby
53{
54
55class MessageBuffer;
56
57namespace garnet
58{
59
60class flitBuffer;
61
63{
64 public:
65 typedef GarnetNetworkInterfaceParams Params;
67 ~NetworkInterface() = default;
68
69 void addInPort(NetworkLink *in_link, CreditLink *credit_link);
70 void addOutPort(NetworkLink *out_link, CreditLink *credit_link,
71 SwitchID router_id, uint32_t consumerVcs);
72
73 void dequeueCallback();
74 void wakeup();
77
78 void print(std::ostream& out) const;
79 int get_vnet(int vc);
80 void init_net_ptr(GarnetNetwork *net_ptr) { m_net_ptr = net_ptr; }
81
83 uint32_t functionalWrite(Packet *);
84
85 void scheduleFlit(flit *t_flit);
86
87 int get_router_id(int vnet)
88 {
89 OutputPort *oPort = getOutportForVnet(vnet);
90 assert(oPort);
91 return oPort->routerID();
92 }
93
95 {
96 public:
97 OutputPort(NetworkLink *outLink, CreditLink *creditLink,
98 int routerID)
99 {
100 _vnets = outLink->mVnets;
102
103 _outNetLink = outLink;
104 _inCreditLink = creditLink;
105
107 _bitWidth = outLink->bitWidth;
108 _vcRoundRobin = 0;
109
110 }
111
112 flitBuffer *
114 {
115 return _outFlitQueue;
116 }
117
120 {
121 return _outNetLink;
122 }
123
124 CreditLink *
126 {
127 return _inCreditLink;
128 }
129
130 int
132 {
133 return _routerID;
134 }
135
136 uint32_t bitWidth()
137 {
138 return _bitWidth;
139 }
140
141 bool isVnetSupported(int pVnet)
142 {
143 if (!_vnets.size()) {
144 return true;
145 }
146
147 for (auto &it : _vnets) {
148 if (it == pVnet) {
149 return true;
150 }
151 }
152 return false;
153
154 }
155
156 std::string
158 {
159 std::stringstream ss;
160 for (auto &it : _vnets) {
161 ss << it;
162 ss << " ";
163 }
164 return ss.str();
165 }
166
168 {
169 return _vcRoundRobin;
170 }
171
172 void vcRoundRobin(int vc)
173 {
174 _vcRoundRobin = vc;
175 }
176
177
178 private:
181
184
185 int _vcRoundRobin; // For round robin scheduling
186
188 uint32_t _bitWidth;
189 };
190
192 {
193 public:
194 InputPort(NetworkLink *inLink, CreditLink *creditLink)
195 {
196 _vnets = inLink->mVnets;
198
199 _inNetLink = inLink;
200 _outCreditLink = creditLink;
201 _bitWidth = inLink->bitWidth;
202 }
203
204 flitBuffer *
206 {
207 return _outCreditQueue;
208 }
209
212 {
213 return _inNetLink;
214 }
215
216 CreditLink *
218 {
219 return _outCreditLink;
220 }
221
222 bool isVnetSupported(int pVnet)
223 {
224 if (!_vnets.size()) {
225 return true;
226 }
227
228 for (auto &it : _vnets) {
229 if (it == pVnet) {
230 return true;
231 }
232 }
233 return false;
234
235 }
236
237 void sendCredit(Credit *cFlit)
238 {
239 _outCreditQueue->insert(cFlit);
240 }
241
242 uint32_t bitWidth()
243 {
244 return _bitWidth;
245 }
246
247 std::string
249 {
250 std::stringstream ss;
251 for (auto &it : _vnets) {
252 ss << it;
253 ss << " ";
254 }
255 return ss.str();
256 }
257
258 // Queue for stalled flits
261 private:
264
267 uint32_t _bitWidth;
268 };
269
270
271 private:
281
283
284 // Input Flit Buffers
285 // The flit buffers which will serve the Consumer
288
289 // The Message buffers that takes messages from the protocol
291 // The Message buffers that provides messages to the protocol
293 // When a vc stays busy for a long time, it indicates a deadlock
295
296 void checkStallQueue();
297 bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
298 int calculateVC(int vnet);
299
300
301 void scheduleOutputPort(OutputPort *oPort);
302 void scheduleOutputLink();
303 void checkReschedule();
304
305 void incrementStats(flit *t_flit);
306
307 InputPort *getInportForVnet(int vnet);
308 OutputPort *getOutportForVnet(int vnet);
309};
310
311} // namespace garnet
312} // namespace ruby
313} // namespace gem5
314
315#endif // __MEM_RUBY_NETWORK_GARNET_0_NETWORKINTERFACE_HH__
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
InputPort(NetworkLink *inLink, CreditLink *creditLink)
OutputPort(NetworkLink *outLink, CreditLink *creditLink, int routerID)
std::vector< OutputPort * > outPorts
bool functionalRead(Packet *pkt, WriteMask &mask)
void addInPort(NetworkLink *in_link, CreditLink *credit_link)
void init_net_ptr(GarnetNetwork *net_ptr)
void addOutPort(NetworkLink *out_link, CreditLink *credit_link, SwitchID router_id, uint32_t consumerVcs)
void print(std::ostream &out) const
GarnetNetworkInterfaceParams Params
std::vector< MessageBuffer * > outNode_ptr
void addNode(std::vector< MessageBuffer * > &inNode, std::vector< MessageBuffer * > &outNode)
void scheduleOutputPort(OutputPort *oPort)
std::vector< MessageBuffer * > inNode_ptr
bool flitisizeMessage(MsgPtr msg_ptr, int vnet)
void scheduleOutputLink()
This function looks at the NI buffers if some buffer has flits which are ready to traverse the link i...
STL deque class.
Definition stl.hh:44
STL vector class.
Definition stl.hh:37
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 21 > ss
Definition misc_types.hh:60
Bitfield< 0 > p
std::shared_ptr< Message > MsgPtr
Definition Message.hh:60
unsigned int SwitchID
unsigned int NodeID
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0