gem5  v20.1.0.0
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 
42 using namespace std;
43 
45  : BasicRouter(p), Consumer(this), m_latency(p->latency),
46  m_virtual_networks(p->virt_nets), m_vc_per_vnet(p->vcs_per_vnet),
47  m_num_vcs(m_virtual_networks * m_vc_per_vnet), m_bit_width(p->width),
48  m_network_ptr(nullptr), routingUnit(this), switchAllocator(this),
49  crossbarSwitch(this)
50 {
51  m_input_unit.clear();
52  m_output_unit.clear();
53 }
54 
55 void
57 {
59 
62 }
63 
64 void
66 {
67  DPRINTF(RubyNetwork, "Router %d woke up\n", m_id);
68  assert(clockEdge() == curTick());
69 
70  // check for incoming flits
71  for (int inport = 0; inport < m_input_unit.size(); inport++) {
72  m_input_unit[inport]->wakeup();
73  }
74 
75  // check for incoming credits
76  // Note: the credit update is happening before SA
77  // buffer turnaround time =
78  // credit traversal (1-cycle) + SA (1-cycle) + Link Traversal (1-cycle)
79  // if we want the credit update to take place after SA, this loop should
80  // be moved after the SA request
81  for (int outport = 0; outport < m_output_unit.size(); outport++) {
82  m_output_unit[outport]->wakeup();
83  }
84 
85  // Switch Allocation
87 
88  // Switch Traversal
90 }
91 
92 void
94  NetworkLink *in_link, CreditLink *credit_link)
95 {
96  fatal_if(in_link->bitWidth != m_bit_width, "Widths of link %s(%d)does"
97  " not match that of Router%d(%d). Consider inserting SerDes "
98  "Units.", in_link->name(), in_link->bitWidth, m_id, m_bit_width);
99 
100  int port_num = m_input_unit.size();
101  InputUnit *input_unit = new InputUnit(port_num, inport_dirn, this);
102 
103  input_unit->set_in_link(in_link);
104  input_unit->set_credit_link(credit_link);
105  in_link->setLinkConsumer(this);
106  in_link->setVcsPerVnet(get_vc_per_vnet());
107  credit_link->setSourceQueue(input_unit->getCreditQueue(), this);
108  credit_link->setVcsPerVnet(get_vc_per_vnet());
109 
110  m_input_unit.push_back(std::shared_ptr<InputUnit>(input_unit));
111 
112  routingUnit.addInDirection(inport_dirn, port_num);
113 }
114 
115 void
117  NetworkLink *out_link,
118  std::vector<NetDest>& routing_table_entry, int link_weight,
119  CreditLink *credit_link, uint32_t consumerVcs)
120 {
121  fatal_if(out_link->bitWidth != m_bit_width, "Widths of units do not match."
122  " Consider inserting SerDes Units");
123 
124  int port_num = m_output_unit.size();
125  OutputUnit *output_unit = new OutputUnit(port_num, outport_dirn, this,
126  consumerVcs);
127 
128  output_unit->set_out_link(out_link);
129  output_unit->set_credit_link(credit_link);
130  credit_link->setLinkConsumer(this);
131  credit_link->setVcsPerVnet(consumerVcs);
132  out_link->setSourceQueue(output_unit->getOutQueue(), this);
133  out_link->setVcsPerVnet(consumerVcs);
134 
135  m_output_unit.push_back(std::shared_ptr<OutputUnit>(output_unit));
136 
137  routingUnit.addRoute(routing_table_entry);
138  routingUnit.addWeight(link_weight);
139  routingUnit.addOutDirection(outport_dirn, port_num);
140 }
141 
144 {
145  return m_output_unit[outport]->get_direction();
146 }
147 
150 {
151  return m_input_unit[inport]->get_direction();
152 }
153 
154 int
155 Router::route_compute(RouteInfo route, int inport, PortDirection inport_dirn)
156 {
157  return routingUnit.outportCompute(route, inport, inport_dirn);
158 }
159 
160 void
161 Router::grant_switch(int inport, flit *t_flit)
162 {
163  crossbarSwitch.update_sw_winner(inport, t_flit);
164 }
165 
166 void
168 {
169  // wake up after time cycles
170  scheduleEvent(time);
171 }
172 
173 std::string
175 {
176  // PortDirection is actually a string
177  // If not, then this function should add a switch
178  // statement to convert direction to a string
179  // that can be printed out
180  return direction;
181 }
182 
183 void
185 {
187 
189  .name(name() + ".buffer_reads")
191  ;
192 
194  .name(name() + ".buffer_writes")
196  ;
197 
199  .name(name() + ".crossbar_activity")
201  ;
202 
204  .name(name() + ".sw_input_arbiter_activity")
206  ;
207 
209  .name(name() + ".sw_output_arbiter_activity")
211  ;
212 }
213 
214 void
216 {
217  for (int j = 0; j < m_virtual_networks; j++) {
218  for (int i = 0; i < m_input_unit.size(); i++) {
219  m_buffer_reads += m_input_unit[i]->get_buf_read_activity(j);
220  m_buffer_writes += m_input_unit[i]->get_buf_write_activity(j);
221  }
222  }
223 
228 }
229 
230 void
232 {
233  for (int i = 0; i < m_input_unit.size(); i++) {
234  m_input_unit[i]->resetStats();
235  }
236 
239 }
240 
241 void
243 {
244  int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
245  int num_fault_types = m_network_ptr->fault_model->number_of_fault_types;
246  float fault_vector[num_fault_types];
247  get_fault_vector(temperature_celcius, fault_vector);
248  out << "Router-" << m_id << " fault vector: " << endl;
249  for (int fault_type_index = 0; fault_type_index < num_fault_types;
250  fault_type_index++) {
251  out << " - probability of (";
252  out <<
253  m_network_ptr->fault_model->fault_type_to_string(fault_type_index);
254  out << ") = ";
255  out << fault_vector[fault_type_index] << endl;
256  }
257 }
258 
259 void
261 {
262  int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
263  float aggregate_fault_prob;
264  get_aggregate_fault_probability(temperature_celcius,
265  &aggregate_fault_prob);
266  out << "Router-" << m_id << " fault probability: ";
267  out << aggregate_fault_prob << endl;
268 }
269 
270 uint32_t
272 {
273  uint32_t num_functional_writes = 0;
274  num_functional_writes += crossbarSwitch.functionalWrite(pkt);
275 
276  for (uint32_t i = 0; i < m_input_unit.size(); i++) {
277  num_functional_writes += m_input_unit[i]->functionalWrite(pkt);
278  }
279 
280  for (uint32_t i = 0; i < m_output_unit.size(); i++) {
281  num_functional_writes += m_output_unit[i]->functionalWrite(pkt);
282  }
283 
284  return num_functional_writes;
285 }
286 
287 Router *
288 GarnetRouterParams::create()
289 {
290  return new Router(this);
291 }
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:64
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:65
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:76
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:260
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:53
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
Router::Router
Router(const Params *p)
Definition: Router.cc:44
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:242
Stats::DataWrap::flags
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
Definition: statistics.hh:331
Router::schedule_wakeup
void schedule_wakeup(Cycles time)
Definition: Router.cc:167
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:93
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
BasicRouter::Params
BasicRouterParams Params
Definition: BasicRouter.hh:42
SwitchAllocator::get_input_arbiter_activity
double get_input_arbiter_activity()
Definition: SwitchAllocator.hh:61
Router
Definition: Router.hh:56
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
CrossbarSwitch::init
void init()
Definition: CrossbarSwitch.cc:45
Consumer
Definition: Consumer.hh:43
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:161
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:155
Router::collateStats
void collateStats()
Definition: Router.cc:215
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:274
Router::getPortDirectionName
std::string getPortDirectionName(PortDirection direction)
Definition: Router.cc:174
Stats::nozero
const FlagsType nozero
Don't print if this is zero.
Definition: info.hh:57
Router::m_network_ptr
GarnetNetwork * m_network_ptr
Definition: Router.hh:138
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
OutputUnit.hh
FaultModel::fault_type_to_string
std::string fault_type_to_string(int fault_type_index)
Definition: FaultModel.cc:102
Router::get_aggregate_fault_probability
bool get_aggregate_fault_probability(int temperature, float *aggregate_fault_prob)
Definition: Router.hh:126
Router::resetStats
void resetStats()
Callback to reset stats.
Definition: Router.cc:231
Router::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: Router.cc:56
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
Router::functionalWrite
uint32_t functionalWrite(Packet *)
Definition: Router.cc:271
Router::getOutportDirection
PortDirection getOutportDirection(int outport)
Definition: Router.cc:143
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:257
CrossbarSwitch::wakeup
void wakeup()
Definition: CrossbarSwitch.cc:57
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
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:116
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:184
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::getInportDirection
PortDirection getInportDirection(int inport)
Definition: Router.cc:149
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:34
curTick
Tick curTick()
The current simulated tick.
Definition: core.hh:45
Router.hh

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