gem5 v24.0.0.0
Loading...
Searching...
No Matches
Router.cc
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
34
35#include "debug/RubyNetwork.hh"
41
42namespace gem5
43{
44
45namespace ruby
46{
47
48namespace garnet
49{
50
52 : BasicRouter(p), Consumer(this), m_latency(p.latency),
53 m_virtual_networks(p.virt_nets), m_vc_per_vnet(p.vcs_per_vnet),
54 m_num_vcs(m_virtual_networks * m_vc_per_vnet), m_bit_width(p.width),
55 m_network_ptr(nullptr), routingUnit(this), switchAllocator(this),
56 crossbarSwitch(this)
57{
58 m_input_unit.clear();
59 m_output_unit.clear();
60}
61
62void
70
71void
73{
74 DPRINTF(RubyNetwork, "Router %d woke up\n", m_id);
75 assert(clockEdge() == curTick());
76
77 // check for incoming flits
78 for (int inport = 0; inport < m_input_unit.size(); inport++) {
79 m_input_unit[inport]->wakeup();
80 }
81
82 // check for incoming credits
83 // Note: the credit update is happening before SA
84 // buffer turnaround time =
85 // credit traversal (1-cycle) + SA (1-cycle) + Link Traversal (1-cycle)
86 // if we want the credit update to take place after SA, this loop should
87 // be moved after the SA request
88 for (int outport = 0; outport < m_output_unit.size(); outport++) {
89 m_output_unit[outport]->wakeup();
90 }
91
92 // Switch Allocation
94
95 // Switch Traversal
97}
98
99void
101 NetworkLink *in_link, CreditLink *credit_link)
102{
103 fatal_if(in_link->bitWidth != m_bit_width, "Widths of link %s(%d)does"
104 " not match that of Router%d(%d). Consider inserting SerDes "
105 "Units.", in_link->name(), in_link->bitWidth, m_id, m_bit_width);
106
107 int port_num = m_input_unit.size();
108 InputUnit *input_unit = new InputUnit(port_num, inport_dirn, this);
109
110 input_unit->set_in_link(in_link);
111 input_unit->set_credit_link(credit_link);
112 in_link->setLinkConsumer(this);
113 in_link->setVcsPerVnet(get_vc_per_vnet());
114 credit_link->setSourceQueue(input_unit->getCreditQueue(), this);
115 credit_link->setVcsPerVnet(get_vc_per_vnet());
116
117 m_input_unit.push_back(std::shared_ptr<InputUnit>(input_unit));
118
119 routingUnit.addInDirection(inport_dirn, port_num);
120}
121
122void
124 NetworkLink *out_link,
125 std::vector<NetDest>& routing_table_entry, int link_weight,
126 CreditLink *credit_link, uint32_t consumerVcs)
127{
128 fatal_if(out_link->bitWidth != m_bit_width, "Widths of units do not match."
129 " Consider inserting SerDes Units");
130
131 int port_num = m_output_unit.size();
132 OutputUnit *output_unit = new OutputUnit(port_num, outport_dirn, this,
133 consumerVcs);
134
135 output_unit->set_out_link(out_link);
136 output_unit->set_credit_link(credit_link);
137 credit_link->setLinkConsumer(this);
138 credit_link->setVcsPerVnet(consumerVcs);
139 out_link->setSourceQueue(output_unit->getOutQueue(), this);
140 out_link->setVcsPerVnet(consumerVcs);
141
142 m_output_unit.push_back(std::shared_ptr<OutputUnit>(output_unit));
143
144 routingUnit.addRoute(routing_table_entry);
145 routingUnit.addWeight(link_weight);
146 routingUnit.addOutDirection(outport_dirn, port_num);
147}
148
151{
152 return m_output_unit[outport]->get_direction();
153}
154
157{
158 return m_input_unit[inport]->get_direction();
159}
160
161int
162Router::route_compute(RouteInfo route, int inport, PortDirection inport_dirn)
163{
164 return routingUnit.outportCompute(route, inport, inport_dirn);
165}
166
167void
168Router::grant_switch(int inport, flit *t_flit)
169{
170 crossbarSwitch.update_sw_winner(inport, t_flit);
171}
172
173void
175{
176 // wake up after time cycles
177 scheduleEvent(time);
178}
179
180std::string
182{
183 // PortDirection is actually a string
184 // If not, then this function should add a switch
185 // statement to convert direction to a string
186 // that can be printed out
187 return direction;
188}
189
190void
192{
194
196 .name(name() + ".buffer_reads")
198 ;
199
201 .name(name() + ".buffer_writes")
203 ;
204
206 .name(name() + ".crossbar_activity")
208 ;
209
211 .name(name() + ".sw_input_arbiter_activity")
213 ;
214
216 .name(name() + ".sw_output_arbiter_activity")
218 ;
219}
220
221void
223{
224 for (int j = 0; j < m_virtual_networks; j++) {
225 for (int i = 0; i < m_input_unit.size(); i++) {
226 m_buffer_reads += m_input_unit[i]->get_buf_read_activity(j);
227 m_buffer_writes += m_input_unit[i]->get_buf_write_activity(j);
228 }
229 }
230
235}
236
237void
239{
240 for (int i = 0; i < m_input_unit.size(); i++) {
241 m_input_unit[i]->resetStats();
242 }
243
246}
247
248void
249Router::printFaultVector(std::ostream& out)
250{
251 int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
252 int num_fault_types = m_network_ptr->fault_model->number_of_fault_types;
253 float fault_vector[num_fault_types];
254 get_fault_vector(temperature_celcius, fault_vector);
255 out << "Router-" << m_id << " fault vector: " << std::endl;
256 for (int fault_type_index = 0; fault_type_index < num_fault_types;
257 fault_type_index++) {
258 out << " - probability of (";
259 out <<
261 out << ") = ";
262 out << fault_vector[fault_type_index] << std::endl;
263 }
264}
265
266void
268{
269 int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
270 float aggregate_fault_prob;
271 get_aggregate_fault_probability(temperature_celcius,
272 &aggregate_fault_prob);
273 out << "Router-" << m_id << " fault probability: ";
274 out << aggregate_fault_prob << std::endl;
275}
276
277bool
279{
280 bool read = false;
282 read = true;
283
284 for (uint32_t i = 0; i < m_input_unit.size(); i++) {
285 if (m_input_unit[i]->functionalRead(pkt, mask))
286 read = true;
287 }
288
289 for (uint32_t i = 0; i < m_output_unit.size(); i++) {
291 read = true;
292 }
293
294 return read;
295}
296
297uint32_t
299{
300 uint32_t num_functional_writes = 0;
301 num_functional_writes += crossbarSwitch.functionalWrite(pkt);
302
303 for (uint32_t i = 0; i < m_input_unit.size(); i++) {
304 num_functional_writes += m_input_unit[i]->functionalWrite(pkt);
305 }
306
307 for (uint32_t i = 0; i < m_output_unit.size(); i++) {
308 num_functional_writes += m_output_unit[i]->functionalWrite(pkt);
309 }
310
311 return num_functional_writes;
312}
313
314} // namespace garnet
315} // namespace ruby
316} // namespace gem5
#define BASELINE_TEMPERATURE_CELCIUS
Definition FaultModel.hh:44
#define DPRINTF(x,...)
Definition trace.hh:210
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
virtual std::string name() const
Definition named.hh:47
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
void scheduleEvent(Cycles timeDelta)
Definition Consumer.cc:56
std::string fault_type_to_string(int fault_type_index)
uint32_t functionalWrite(Packet *pkt)
bool functionalRead(Packet *pkt, WriteMask &mask)
void update_sw_winner(int inport, flit *t_flit)
void set_credit_link(CreditLink *credit_link)
Definition InputUnit.hh:145
void set_in_link(NetworkLink *link)
Definition InputUnit.hh:137
void set_out_link(NetworkLink *link)
void set_credit_link(CreditLink *credit_link)
bool get_fault_vector(int temperature, float fault_vector[])
Definition Router.hh:132
PortDirection getOutportDirection(int outport)
Definition Router.cc:150
void addInPort(PortDirection inport_dirn, NetworkLink *link, CreditLink *credit_link)
Definition Router.cc:100
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition Router.cc:63
uint32_t functionalWrite(Packet *)
Definition Router.cc:298
statistics::Scalar m_buffer_reads
Definition Router.hh:159
bool get_aggregate_fault_probability(int temperature, float *aggregate_fault_prob)
Definition Router.hh:136
statistics::Scalar m_buffer_writes
Definition Router.hh:160
GarnetNetwork * m_network_ptr
Definition Router.hh:149
void printFaultVector(std::ostream &out)
Definition Router.cc:249
PortDirection getInportDirection(int inport)
Definition Router.cc:156
Router(const Params &p)
Definition Router.cc:51
std::vector< std::shared_ptr< InputUnit > > m_input_unit
Definition Router.hh:155
GarnetRouterParams Params
Definition Router.hh:69
statistics::Scalar m_sw_input_arbiter_activity
Definition Router.hh:162
SwitchAllocator switchAllocator
Definition Router.hh:152
bool functionalRead(Packet *pkt, WriteMask &mask)
Definition Router.cc:278
void printAggregateFaultProbability(std::ostream &out)
Definition Router.cc:267
void resetStats()
Callback to reset stats.
Definition Router.cc:238
std::string getPortDirectionName(PortDirection direction)
Definition Router.cc:181
void grant_switch(int inport, flit *t_flit)
Definition Router.cc:168
statistics::Scalar m_crossbar_activity
Definition Router.hh:165
statistics::Scalar m_sw_output_arbiter_activity
Definition Router.hh:163
int route_compute(RouteInfo route, int inport, PortDirection direction)
Definition Router.cc:162
void addOutPort(PortDirection outport_dirn, NetworkLink *link, std::vector< NetDest > &routing_table_entry, int link_weight, CreditLink *credit_link, uint32_t consumerVcs)
Definition Router.cc:123
void schedule_wakeup(Cycles time)
Definition Router.cc:174
void regStats()
Callback to set stat parameters.
Definition Router.cc:191
uint32_t get_vc_per_vnet()
Definition Router.hh:88
CrossbarSwitch crossbarSwitch
Definition Router.hh:153
std::vector< std::shared_ptr< OutputUnit > > m_output_unit
Definition Router.hh:156
void addOutDirection(PortDirection outport_dirn, int outport)
void addInDirection(PortDirection inport_dirn, int inport)
void addRoute(std::vector< NetDest > &routing_table_entry)
void addWeight(int link_weight)
int outportCompute(RouteInfo route, int inport, PortDirection inport_dirn)
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
STL vector class.
Definition stl.hh:37
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition logging.hh:236
virtual void regStats()
Callback to set stat parameters.
Definition group.cc:68
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 4 > width
Definition misc_types.hh:72
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 0 > p
std::string PortDirection
const FlagsType nozero
Don't print if this is zero.
Definition info.hh:67
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46

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