gem5  v21.1.0.2
SimpleNetwork.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Advanced Micro Devices, Inc.
3  * Copyright (c) 2019,2021 ARM Limited
4  * All rights reserved.
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
43 
44 #include <cassert>
45 #include <numeric>
46 
47 #include "base/cast.hh"
54 
55 namespace gem5
56 {
57 
58 namespace ruby
59 {
60 
62  : Network(p), m_buffer_size(p.buffer_size),
63  m_endpoint_bandwidth(p.endpoint_bandwidth),
64  m_adaptive_routing(p.adaptive_routing),
65  networkStats(this)
66 {
67  // record the routers
68  for (std::vector<BasicRouter*>::const_iterator i = p.routers.begin();
69  i != p.routers.end(); ++i) {
70  Switch* s = safe_cast<Switch*>(*i);
71  m_switches.push_back(s);
72  s->init_net_ptr(this);
73  }
74 
75  m_int_link_buffers = p.int_link_buffers;
77 }
78 
79 void
81 {
82  Network::init();
83 
84  // The topology pointer should have already been initialized in
85  // the parent class network constructor.
86  assert(m_topology_ptr != NULL);
88 }
89 
90 // From a switch to an endpoint node
91 void
93  BasicLink* link,
94  std::vector<NetDest>& routing_table_entry)
95 {
96  NodeID local_dest = getLocalNodeID(global_dest);
97  assert(local_dest < m_nodes);
98  assert(src < m_switches.size());
99  assert(m_switches[src] != NULL);
100 
101  SimpleExtLink *simple_link = safe_cast<SimpleExtLink*>(link);
102 
103  m_switches[src]->addOutPort(m_fromNetQueues[local_dest],
104  routing_table_entry[0], simple_link->m_latency,
105  simple_link->m_bw_multiplier);
106 }
107 
108 // From an endpoint node to a switch
109 void
111  std::vector<NetDest>& routing_table_entry)
112 {
113  NodeID local_src = getLocalNodeID(global_src);
114  assert(local_src < m_nodes);
115  m_switches[dest]->addInPort(m_toNetQueues[local_src]);
116 }
117 
118 // From a switch to a switch
119 void
121  std::vector<NetDest>& routing_table_entry,
122  PortDirection src_outport,
123  PortDirection dst_inport)
124 {
125  // Create a set of new MessageBuffers
127 
128  for (int i = 0; i < m_virtual_networks; i++) {
129  // allocate a buffer
133  queues[i] = buffer_ptr;
134  }
135 
136  // Connect it to the two switches
137  SimpleIntLink *simple_link = safe_cast<SimpleIntLink*>(link);
138 
139  m_switches[dest]->addInPort(queues);
140  m_switches[src]->addOutPort(queues, routing_table_entry[0],
141  simple_link->m_latency,
142  simple_link->m_bw_multiplier);
143 }
144 
145 void
147 {
149 
150  for (MessageSizeType type = MessageSizeType_FIRST;
151  type < MessageSizeType_NUM; ++type) {
152  networkStats.m_msg_counts[(unsigned int) type] =
154  csprintf("msg_count.%s", MessageSizeType_to_string(type)).c_str());
155  networkStats.m_msg_counts[(unsigned int) type]
156  ->flags(statistics::nozero)
157  ;
158 
159  networkStats.m_msg_bytes[(unsigned int) type] =
161  csprintf("msg_byte.%s", MessageSizeType_to_string(type)).c_str());
162  networkStats.m_msg_bytes[(unsigned int) type]
163  ->flags(statistics::nozero)
164  ;
165 
166  // Now state what the formula is.
167  for (int i = 0; i < m_switches.size(); i++) {
168  *(networkStats.m_msg_counts[(unsigned int) type]) +=
169  sum(m_switches[i]->getMsgCount(type));
170  }
171 
172  *(networkStats.m_msg_bytes[(unsigned int) type]) =
173  *(networkStats.m_msg_counts[(unsigned int) type]) *
175  }
176 }
177 
178 void
180 {
181  for (int i = 0; i < m_switches.size(); i++) {
182  m_switches[i]->collateStats();
183  }
184 }
185 
186 void
187 SimpleNetwork::print(std::ostream& out) const
188 {
189  out << "[SimpleNetwork]";
190 }
191 
192 /*
193  * The simple network has an array of switches. These switches have buffers
194  * that need to be accessed for functional reads and writes. Also the links
195  * between different switches have buffers that need to be accessed.
196  */
197 bool
199 {
200  for (unsigned int i = 0; i < m_switches.size(); i++) {
201  if (m_switches[i]->functionalRead(pkt))
202  return true;
203  }
204  for (unsigned int i = 0; i < m_int_link_buffers.size(); ++i) {
206  return true;
207  }
208 
209  return false;
210 }
211 
212 bool
214 {
215  bool read = false;
216  for (unsigned int i = 0; i < m_switches.size(); i++) {
217  if (m_switches[i]->functionalRead(pkt, mask))
218  read = true;
219  }
220  for (unsigned int i = 0; i < m_int_link_buffers.size(); ++i) {
222  read = true;
223  }
224  return read;
225 }
226 
227 uint32_t
229 {
230  uint32_t num_functional_writes = 0;
231 
232  for (unsigned int i = 0; i < m_switches.size(); i++) {
233  num_functional_writes += m_switches[i]->functionalWrite(pkt);
234  }
235 
236  for (unsigned int i = 0; i < m_int_link_buffers.size(); ++i) {
237  num_functional_writes += m_int_link_buffers[i]->functionalWrite(pkt);
238  }
239  return num_functional_writes;
240 }
241 
244  : statistics::Group(parent)
245 {
246 
247 }
248 
249 } // namespace ruby
250 } // namespace gem5
gem5::ruby::SimpleNetwork::print
void print(std::ostream &out) const
Definition: SimpleNetwork.cc:187
gem5::ruby::Network::m_virtual_networks
static uint32_t m_virtual_networks
Definition: Network.hh:156
gem5::ruby::SimpleNetwork::NetworkStats::m_msg_bytes
statistics::Formula * m_msg_bytes[MessageSizeType_NUM]
Definition: SimpleNetwork.hh:119
gem5::ruby::WriteMask
Definition: WriteMask.hh:59
Profiler.hh
gem5::ruby::PortDirection
std::string PortDirection
Definition: Topology.hh:68
gem5::ruby::Network::MessageSizeType_to_int
static uint32_t MessageSizeType_to_int(MessageSizeType size_type)
Definition: Network.cc:164
gem5::ruby::SimpleNetwork::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: SimpleNetwork.cc:80
gem5::ruby::SimpleNetwork::networkStats
gem5::ruby::SimpleNetwork::NetworkStats networkStats
gem5::ruby::SimpleNetwork::m_num_connected_buffers
int m_num_connected_buffers
Definition: SimpleNetwork.hh:107
gem5::ruby::SimpleNetwork::makeExtInLink
void makeExtInLink(NodeID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)
Definition: SimpleNetwork.cc:110
gem5::statistics::nozero
const FlagsType nozero
Don't print if this is zero.
Definition: info.hh:68
gem5::ruby::Network
Definition: Network.hh:82
gem5::SimObject::init
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: sim_object.cc:76
gem5::ruby::Topology::createLinks
void createLinks(Network *net)
Definition: Topology.cc:115
cast.hh
SimpleNetwork.hh
gem5::statistics::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2536
std::vector
STL vector class.
Definition: stl.hh:37
gem5::csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
gem5::ruby::Switch
Definition: Switch.hh:77
Throttle.hh
gem5::mask
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
gem5::statistics::constant
Temp constant(T val)
Definition: statistics.hh:2862
gem5::ruby::SimpleNetwork::NetworkStats::NetworkStats
NetworkStats(statistics::Group *parent)
Definition: SimpleNetwork.cc:243
gem5::ruby::SimpleNetwork::m_int_link_buffers
std::vector< MessageBuffer * > m_int_link_buffers
Definition: SimpleNetwork.hh:106
gem5::ruby::Network::m_nodes
uint32_t m_nodes
Definition: Network.hh:155
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::ruby::SimpleNetwork::regStats
void regStats()
Callback to set stat parameters.
Definition: SimpleNetwork.cc:146
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::X86ISA::type
type
Definition: misc.hh:733
gem5::ArmISA::s
Bitfield< 4 > s
Definition: misc_types.hh:561
gem5::ruby::Network::getLocalNodeID
NodeID getLocalNodeID(NodeID global_id) const
Definition: Network.cc:253
gem5::ruby::Network::m_fromNetQueues
std::vector< std::vector< MessageBuffer * > > m_fromNetQueues
Definition: Network.hh:164
gem5::ruby::SwitchID
unsigned int SwitchID
Definition: TypeDefines.hh:41
gem5::ruby::SimpleNetwork::makeExtOutLink
void makeExtOutLink(SwitchID src, NodeID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry)
Definition: SimpleNetwork.cc:92
gem5::statistics::Group::regStats
virtual void regStats()
Callback to set stat parameters.
Definition: group.cc:69
gem5::ruby::Network::m_toNetQueues
std::vector< std::vector< MessageBuffer * > > m_toNetQueues
Definition: Network.hh:163
gem5::ruby::SimpleNetwork::Params
SimpleNetworkParams Params
Definition: SimpleNetwork.hh:64
MessageBuffer.hh
gem5::ruby::SimpleNetwork::functionalWrite
uint32_t functionalWrite(Packet *pkt)
Definition: SimpleNetwork.cc:228
gem5::ruby::Network::m_topology_ptr
Topology * m_topology_ptr
Definition: Network.hh:158
Switch.hh
gem5::ruby::SimpleNetwork::functionalRead
bool functionalRead(Packet *pkt)
Definition: SimpleNetwork.cc:198
gem5::ruby::SimpleNetwork::NetworkStats::m_msg_counts
statistics::Formula * m_msg_counts[MessageSizeType_NUM]
Definition: SimpleNetwork.hh:118
gem5::ruby::SimpleNetwork::collateStats
void collateStats()
Definition: SimpleNetwork.cc:179
gem5::ruby::SimpleNetwork::SimpleNetwork
SimpleNetwork(const Params &p)
Definition: SimpleNetwork.cc:61
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::ruby::NodeID
unsigned int NodeID
Definition: TypeDefines.hh:40
gem5::RiscvISA::sum
Bitfield< 18 > sum
Definition: misc.hh:545
gem5::ruby::SimpleNetwork::m_switches
std::vector< Switch * > m_switches
Definition: SimpleNetwork.hh:105
gem5::ruby::MessageBuffer
Definition: MessageBuffer.hh:74
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ruby::SimpleNetwork::makeInternalLink
void makeInternalLink(SwitchID src, SwitchID dest, BasicLink *link, std::vector< NetDest > &routing_table_entry, PortDirection src_outport, PortDirection dst_inport)
Definition: SimpleNetwork.cc:120
NetDest.hh

Generated on Tue Sep 21 2021 12:25:41 for gem5 by doxygen 1.8.17