gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
43  : BasicRouter(p), Consumer(this), m_latency(p.latency),
44  m_virtual_networks(p.virt_nets), m_vc_per_vnet(p.vcs_per_vnet),
45  m_num_vcs(m_virtual_networks * m_vc_per_vnet), m_bit_width(p.width),
46  m_network_ptr(nullptr), routingUnit(this), switchAllocator(this),
47  crossbarSwitch(this)
48 {
49  m_input_unit.clear();
50  m_output_unit.clear();
51 }
52 
53 void
55 {
57 
60 }
61 
62 void
64 {
65  DPRINTF(RubyNetwork, "Router %d woke up\n", m_id);
66  assert(clockEdge() == curTick());
67 
68  // check for incoming flits
69  for (int inport = 0; inport < m_input_unit.size(); inport++) {
70  m_input_unit[inport]->wakeup();
71  }
72 
73  // check for incoming credits
74  // Note: the credit update is happening before SA
75  // buffer turnaround time =
76  // credit traversal (1-cycle) + SA (1-cycle) + Link Traversal (1-cycle)
77  // if we want the credit update to take place after SA, this loop should
78  // be moved after the SA request
79  for (int outport = 0; outport < m_output_unit.size(); outport++) {
80  m_output_unit[outport]->wakeup();
81  }
82 
83  // Switch Allocation
85 
86  // Switch Traversal
88 }
89 
90 void
92  NetworkLink *in_link, CreditLink *credit_link)
93 {
94  fatal_if(in_link->bitWidth != m_bit_width, "Widths of link %s(%d)does"
95  " not match that of Router%d(%d). Consider inserting SerDes "
96  "Units.", in_link->name(), in_link->bitWidth, m_id, m_bit_width);
97 
98  int port_num = m_input_unit.size();
99  InputUnit *input_unit = new InputUnit(port_num, inport_dirn, this);
100 
101  input_unit->set_in_link(in_link);
102  input_unit->set_credit_link(credit_link);
103  in_link->setLinkConsumer(this);
104  in_link->setVcsPerVnet(get_vc_per_vnet());
105  credit_link->setSourceQueue(input_unit->getCreditQueue(), this);
106  credit_link->setVcsPerVnet(get_vc_per_vnet());
107 
108  m_input_unit.push_back(std::shared_ptr<InputUnit>(input_unit));
109 
110  routingUnit.addInDirection(inport_dirn, port_num);
111 }
112 
113 void
115  NetworkLink *out_link,
116  std::vector<NetDest>& routing_table_entry, int link_weight,
117  CreditLink *credit_link, uint32_t consumerVcs)
118 {
119  fatal_if(out_link->bitWidth != m_bit_width, "Widths of units do not match."
120  " Consider inserting SerDes Units");
121 
122  int port_num = m_output_unit.size();
123  OutputUnit *output_unit = new OutputUnit(port_num, outport_dirn, this,
124  consumerVcs);
125 
126  output_unit->set_out_link(out_link);
127  output_unit->set_credit_link(credit_link);
128  credit_link->setLinkConsumer(this);
129  credit_link->setVcsPerVnet(consumerVcs);
130  out_link->setSourceQueue(output_unit->getOutQueue(), this);
131  out_link->setVcsPerVnet(consumerVcs);
132 
133  m_output_unit.push_back(std::shared_ptr<OutputUnit>(output_unit));
134 
135  routingUnit.addRoute(routing_table_entry);
136  routingUnit.addWeight(link_weight);
137  routingUnit.addOutDirection(outport_dirn, port_num);
138 }
139 
142 {
143  return m_output_unit[outport]->get_direction();
144 }
145 
148 {
149  return m_input_unit[inport]->get_direction();
150 }
151 
152 int
153 Router::route_compute(RouteInfo route, int inport, PortDirection inport_dirn)
154 {
155  return routingUnit.outportCompute(route, inport, inport_dirn);
156 }
157 
158 void
159 Router::grant_switch(int inport, flit *t_flit)
160 {
161  crossbarSwitch.update_sw_winner(inport, t_flit);
162 }
163 
164 void
166 {
167  // wake up after time cycles
168  scheduleEvent(time);
169 }
170 
171 std::string
173 {
174  // PortDirection is actually a string
175  // If not, then this function should add a switch
176  // statement to convert direction to a string
177  // that can be printed out
178  return direction;
179 }
180 
181 void
183 {
185 
187  .name(name() + ".buffer_reads")
189  ;
190 
192  .name(name() + ".buffer_writes")
194  ;
195 
197  .name(name() + ".crossbar_activity")
199  ;
200 
202  .name(name() + ".sw_input_arbiter_activity")
204  ;
205 
207  .name(name() + ".sw_output_arbiter_activity")
209  ;
210 }
211 
212 void
214 {
215  for (int j = 0; j < m_virtual_networks; j++) {
216  for (int i = 0; i < m_input_unit.size(); i++) {
217  m_buffer_reads += m_input_unit[i]->get_buf_read_activity(j);
218  m_buffer_writes += m_input_unit[i]->get_buf_write_activity(j);
219  }
220  }
221 
226 }
227 
228 void
230 {
231  for (int i = 0; i < m_input_unit.size(); i++) {
232  m_input_unit[i]->resetStats();
233  }
234 
237 }
238 
239 void
240 Router::printFaultVector(std::ostream& out)
241 {
242  int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
243  int num_fault_types = m_network_ptr->fault_model->number_of_fault_types;
244  float fault_vector[num_fault_types];
245  get_fault_vector(temperature_celcius, fault_vector);
246  out << "Router-" << m_id << " fault vector: " << std::endl;
247  for (int fault_type_index = 0; fault_type_index < num_fault_types;
248  fault_type_index++) {
249  out << " - probability of (";
250  out <<
251  m_network_ptr->fault_model->fault_type_to_string(fault_type_index);
252  out << ") = ";
253  out << fault_vector[fault_type_index] << std::endl;
254  }
255 }
256 
257 void
259 {
260  int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
261  float aggregate_fault_prob;
262  get_aggregate_fault_probability(temperature_celcius,
263  &aggregate_fault_prob);
264  out << "Router-" << m_id << " fault probability: ";
265  out << aggregate_fault_prob << std::endl;
266 }
267 
268 uint32_t
270 {
271  uint32_t num_functional_writes = 0;
272  num_functional_writes += crossbarSwitch.functionalWrite(pkt);
273 
274  for (uint32_t i = 0; i < m_input_unit.size(); i++) {
275  num_functional_writes += m_input_unit[i]->functionalWrite(pkt);
276  }
277 
278  for (uint32_t i = 0; i < m_output_unit.size(); i++) {
279  num_functional_writes += m_output_unit[i]->functionalWrite(pkt);
280  }
281 
282  return num_functional_writes;
283 }
BasicRouter::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: BasicRouter.cc:39
Stats::Group::regStats
virtual void regStats()
Callback to set stat parameters.
Definition: group.cc:63
Router::m_virtual_networks
uint32_t m_virtual_networks
Definition: Router.hh:136
Router::m_sw_input_arbiter_activity
Stats::Scalar m_sw_input_arbiter_activity
Definition: Router.hh:151
Router::wakeup
void wakeup()
Definition: Router.cc:63
OutputUnit::getOutQueue
flitBuffer * getOutQueue()
Definition: OutputUnit.cc:142
flit
Definition: flit.hh:41
FaultModel::number_of_fault_types
@ number_of_fault_types
Definition: FaultModel.hh:75
RouteInfo
Definition: CommonTypes.hh:47
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
Router::m_buffer_reads
Stats::Scalar m_buffer_reads
Definition: Router.hh:148
Router::printAggregateFaultProbability
void printAggregateFaultProbability(std::ostream &out)
Definition: Router.cc:258
Router::m_bit_width
uint32_t m_bit_width
Definition: Router.hh:137
ArmISA::width
Bitfield< 4 > width
Definition: miscregs_types.hh:68
BasicRouter::m_id
uint32_t m_id
Definition: BasicRouter.hh:52
CrossbarSwitch::functionalWrite
uint32_t functionalWrite(Packet *pkt)
Definition: CrossbarSwitch.cc:86
RoutingUnit::addRoute
void addRoute(std::vector< NetDest > &routing_table_entry)
Definition: RoutingUnit.cc:47
InputUnit::set_credit_link
void set_credit_link(CreditLink *credit_link)
Definition: InputUnit.hh:136
InputUnit.hh
InputUnit::getCreditQueue
flitBuffer * getCreditQueue()
Definition: InputUnit.hh:125
Router::m_crossbar_activity
Stats::Scalar m_crossbar_activity
Definition: Router.hh:154
SwitchAllocator::init
void init()
Definition: SwitchAllocator.cc:52
std::vector< NetDest >
CrossbarSwitch::update_sw_winner
void update_sw_winner(int inport, flit *t_flit)
Definition: CrossbarSwitch.hh:54
Router::get_vc_per_vnet
uint32_t get_vc_per_vnet()
Definition: Router.hh:78
GarnetNetwork.hh
Router::switchAllocator
SwitchAllocator switchAllocator
Definition: Router.hh:141
Router::crossbarSwitch
CrossbarSwitch crossbarSwitch
Definition: Router.hh:142
RoutingUnit::addWeight
void addWeight(int link_weight)
Definition: RoutingUnit.cc:58
SwitchAllocator::resetStats
void resetStats()
Definition: SwitchAllocator.cc:393
Router::printFaultVector
void printFaultVector(std::ostream &out)
Definition: Router.cc:240
Stats::DataWrap::flags
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
Definition: statistics.hh:339
Router::schedule_wakeup
void schedule_wakeup(Cycles time)
Definition: Router.cc:165
OutputUnit::set_credit_link
void set_credit_link(CreditLink *credit_link)
Definition: OutputUnit.cc:154
Router::addInPort
void addInPort(PortDirection inport_dirn, NetworkLink *link, CreditLink *credit_link)
Definition: Router.cc:91
Router::routingUnit
RoutingUnit routingUnit
Definition: Router.hh:140
SwitchAllocator::wakeup
void wakeup()
Definition: SwitchAllocator.cc:87
ArmISA::j
Bitfield< 24 > j
Definition: miscregs_types.hh:54
OutputUnit::set_out_link
void set_out_link(NetworkLink *link)
Definition: OutputUnit.cc:148
SwitchAllocator::get_input_arbiter_activity
double get_input_arbiter_activity()
Definition: SwitchAllocator.hh:61
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:237
FaultModel::fault_type_to_string
std::string fault_type_to_string(int fault_type_index)
Definition: FaultModel.cc:100
CrossbarSwitch::init
void init()
Definition: CrossbarSwitch.cc:45
Consumer
Definition: Consumer.hh:55
Clocked::clockEdge
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...
Definition: clocked_object.hh:174
CrossbarSwitch::get_crossbar_activity
double get_crossbar_activity()
Definition: CrossbarSwitch.hh:59
Router::grant_switch
void grant_switch(int inport, flit *t_flit)
Definition: Router.cc:159
RoutingUnit::addInDirection
void addInDirection(PortDirection inport_dirn, int inport)
Definition: RoutingUnit.cc:139
BasicRouter
Definition: BasicRouter.hh:39
Router::route_compute
int route_compute(RouteInfo route, int inport, PortDirection direction)
Definition: Router.cc:153
Router::collateStats
void collateStats()
Definition: Router.cc:213
BASELINE_TEMPERATURE_CELCIUS
#define BASELINE_TEMPERATURE_CELCIUS
Definition: FaultModel.hh:44
CrossbarSwitch::resetStats
void resetStats()
Definition: CrossbarSwitch.cc:98
Stats::DataWrap::name
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
Definition: statistics.hh:270
Router::getPortDirectionName
std::string getPortDirectionName(PortDirection direction)
Definition: Router.cc:172
Stats::nozero
const FlagsType nozero
Don't print if this is zero.
Definition: info.hh:58
Router::m_network_ptr
GarnetNetwork * m_network_ptr
Definition: Router.hh:138
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:182
OutputUnit.hh
Router::get_aggregate_fault_probability
bool get_aggregate_fault_probability(int temperature, float *aggregate_fault_prob)
Definition: Router.hh:126
Router::Params
GarnetRouterParams Params
Definition: Router.hh:59
Router::resetStats
void resetStats()
Callback to reset stats.
Definition: Router.cc:229
Router::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: Router.cc:54
Router::functionalWrite
uint32_t functionalWrite(Packet *)
Definition: Router.cc:269
Router::getOutportDirection
PortDirection getOutportDirection(int outport)
Definition: Router.cc:141
OutputUnit
Definition: OutputUnit.hh:47
Router::get_fault_vector
bool get_fault_vector(int temperature, float fault_vector[])
Definition: Router.hh:122
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:258
CrossbarSwitch::wakeup
void wakeup()
Definition: CrossbarSwitch.cc:57
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
PortDirection
std::string PortDirection
Definition: Topology.hh:62
Router::m_buffer_writes
Stats::Scalar m_buffer_writes
Definition: Router.hh:149
Router::addOutPort
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:114
curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:43
InputUnit::set_in_link
void set_in_link(NetworkLink *link)
Definition: InputUnit.hh:128
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Router::regStats
void regStats()
Callback to set stat parameters.
Definition: Router.cc:182
RoutingUnit::addOutDirection
void addOutDirection(PortDirection outport_dirn, int outport)
Definition: RoutingUnit.cc:146
RoutingUnit::outportCompute
int outportCompute(RouteInfo route, int inport, PortDirection inport_dirn)
Definition: RoutingUnit.cc:159
fatal_if
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:219
Router::Router
Router(const Params &p)
Definition: Router.cc:42
Router::getInportDirection
PortDirection getInportDirection(int inport)
Definition: Router.cc:147
Router::m_sw_output_arbiter_activity
Stats::Scalar m_sw_output_arbiter_activity
Definition: Router.hh:152
Router::m_input_unit
std::vector< std::shared_ptr< InputUnit > > m_input_unit
Definition: Router.hh:144
InputUnit
Definition: InputUnit.hh:46
GarnetNetwork::fault_model
FaultModel * fault_model
Definition: GarnetNetwork.hh:74
Router::m_output_unit
std::vector< std::shared_ptr< OutputUnit > > m_output_unit
Definition: Router.hh:145
SwitchAllocator::get_output_arbiter_activity
double get_output_arbiter_activity()
Definition: SwitchAllocator.hh:66
Consumer::scheduleEvent
void scheduleEvent(Cycles timeDelta)
Definition: Consumer.cc:50
Router.hh

Generated on Tue Mar 23 2021 19:41:28 for gem5 by doxygen 1.8.17