SimpleNetwork.cc (9593:9441ca79f3c8) SimpleNetwork.cc (9799:5aed42e54180)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <cassert>
30#include <numeric>
31
32#include "base/cast.hh"
33#include "base/stl_helpers.hh"
34#include "mem/ruby/buffers/MessageBuffer.hh"
35#include "mem/ruby/common/NetDest.hh"
36#include "mem/ruby/network/BasicLink.hh"
37#include "mem/ruby/network/simple/SimpleLink.hh"
38#include "mem/ruby/network/simple/SimpleNetwork.hh"
39#include "mem/ruby/network/simple/Switch.hh"
40#include "mem/ruby/network/simple/Throttle.hh"
41#include "mem/ruby/network/Topology.hh"
42#include "mem/ruby/profiler/Profiler.hh"
43#include "mem/ruby/system/System.hh"
44
45using namespace std;
46using m5::stl_helpers::deletePointers;
47
48SimpleNetwork::SimpleNetwork(const Params *p)
49 : Network(p)
50{
51 m_buffer_size = p->buffer_size;
52 m_endpoint_bandwidth = p->endpoint_bandwidth;
53 m_adaptive_routing = p->adaptive_routing;
54
55 // Note: the parent Network Object constructor is called before the
56 // SimpleNetwork child constructor. Therefore, the member variables
57 // used below should already be initialized.
58
59 m_endpoint_switches.resize(m_nodes);
60
61 m_in_use.resize(m_virtual_networks);
62 m_ordered.resize(m_virtual_networks);
63 for (int i = 0; i < m_virtual_networks; i++) {
64 m_in_use[i] = false;
65 m_ordered[i] = false;
66 }
67
68 // Allocate to and from queues
69 m_toNetQueues.resize(m_nodes);
70 m_fromNetQueues.resize(m_nodes);
71 for (int node = 0; node < m_nodes; node++) {
72 m_toNetQueues[node].resize(m_virtual_networks);
73 m_fromNetQueues[node].resize(m_virtual_networks);
74 for (int j = 0; j < m_virtual_networks; j++) {
75 m_toNetQueues[node][j] =
76 new MessageBuffer(csprintf("toNet node %d j %d", node, j));
77 m_fromNetQueues[node][j] =
78 new MessageBuffer(csprintf("fromNet node %d j %d", node, j));
79 }
80 }
81
82 // record the routers
83 for (vector<BasicRouter*>::const_iterator i = p->routers.begin();
84 i != p->routers.end(); ++i) {
85 Switch* s = safe_cast<Switch*>(*i);
86 m_switch_ptr_vector.push_back(s);
87 s->init_net_ptr(this);
88 }
89}
90
91void
92SimpleNetwork::init()
93{
94 Network::init();
95
96 // The topology pointer should have already been initialized in
97 // the parent class network constructor.
98 assert(m_topology_ptr != NULL);
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <cassert>
30#include <numeric>
31
32#include "base/cast.hh"
33#include "base/stl_helpers.hh"
34#include "mem/ruby/buffers/MessageBuffer.hh"
35#include "mem/ruby/common/NetDest.hh"
36#include "mem/ruby/network/BasicLink.hh"
37#include "mem/ruby/network/simple/SimpleLink.hh"
38#include "mem/ruby/network/simple/SimpleNetwork.hh"
39#include "mem/ruby/network/simple/Switch.hh"
40#include "mem/ruby/network/simple/Throttle.hh"
41#include "mem/ruby/network/Topology.hh"
42#include "mem/ruby/profiler/Profiler.hh"
43#include "mem/ruby/system/System.hh"
44
45using namespace std;
46using m5::stl_helpers::deletePointers;
47
48SimpleNetwork::SimpleNetwork(const Params *p)
49 : Network(p)
50{
51 m_buffer_size = p->buffer_size;
52 m_endpoint_bandwidth = p->endpoint_bandwidth;
53 m_adaptive_routing = p->adaptive_routing;
54
55 // Note: the parent Network Object constructor is called before the
56 // SimpleNetwork child constructor. Therefore, the member variables
57 // used below should already be initialized.
58
59 m_endpoint_switches.resize(m_nodes);
60
61 m_in_use.resize(m_virtual_networks);
62 m_ordered.resize(m_virtual_networks);
63 for (int i = 0; i < m_virtual_networks; i++) {
64 m_in_use[i] = false;
65 m_ordered[i] = false;
66 }
67
68 // Allocate to and from queues
69 m_toNetQueues.resize(m_nodes);
70 m_fromNetQueues.resize(m_nodes);
71 for (int node = 0; node < m_nodes; node++) {
72 m_toNetQueues[node].resize(m_virtual_networks);
73 m_fromNetQueues[node].resize(m_virtual_networks);
74 for (int j = 0; j < m_virtual_networks; j++) {
75 m_toNetQueues[node][j] =
76 new MessageBuffer(csprintf("toNet node %d j %d", node, j));
77 m_fromNetQueues[node][j] =
78 new MessageBuffer(csprintf("fromNet node %d j %d", node, j));
79 }
80 }
81
82 // record the routers
83 for (vector<BasicRouter*>::const_iterator i = p->routers.begin();
84 i != p->routers.end(); ++i) {
85 Switch* s = safe_cast<Switch*>(*i);
86 m_switch_ptr_vector.push_back(s);
87 s->init_net_ptr(this);
88 }
89}
90
91void
92SimpleNetwork::init()
93{
94 Network::init();
95
96 // The topology pointer should have already been initialized in
97 // the parent class network constructor.
98 assert(m_topology_ptr != NULL);
99 // false because this isn't a reconfiguration
100 m_topology_ptr->createLinks(this, false);
99 m_topology_ptr->createLinks(this);
101}
102
103void
104SimpleNetwork::reset()
105{
106 for (int node = 0; node < m_nodes; node++) {
107 for (int j = 0; j < m_virtual_networks; j++) {
108 m_toNetQueues[node][j]->clear();
109 m_fromNetQueues[node][j]->clear();
110 }
111 }
112
113 for(int i = 0; i < m_switch_ptr_vector.size(); i++){
114 m_switch_ptr_vector[i]->clearBuffers();
115 }
116}
117
118SimpleNetwork::~SimpleNetwork()
119{
120 for (int i = 0; i < m_nodes; i++) {
121 deletePointers(m_toNetQueues[i]);
122 deletePointers(m_fromNetQueues[i]);
123 }
124 deletePointers(m_switch_ptr_vector);
125 deletePointers(m_buffers_to_free);
126 // delete m_topology_ptr;
127}
128
129// From a switch to an endpoint node
130void
131SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
132 LinkDirection direction,
100}
101
102void
103SimpleNetwork::reset()
104{
105 for (int node = 0; node < m_nodes; node++) {
106 for (int j = 0; j < m_virtual_networks; j++) {
107 m_toNetQueues[node][j]->clear();
108 m_fromNetQueues[node][j]->clear();
109 }
110 }
111
112 for(int i = 0; i < m_switch_ptr_vector.size(); i++){
113 m_switch_ptr_vector[i]->clearBuffers();
114 }
115}
116
117SimpleNetwork::~SimpleNetwork()
118{
119 for (int i = 0; i < m_nodes; i++) {
120 deletePointers(m_toNetQueues[i]);
121 deletePointers(m_fromNetQueues[i]);
122 }
123 deletePointers(m_switch_ptr_vector);
124 deletePointers(m_buffers_to_free);
125 // delete m_topology_ptr;
126}
127
128// From a switch to an endpoint node
129void
130SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
131 LinkDirection direction,
133 const NetDest& routing_table_entry,
134 bool isReconfiguration)
132 const NetDest& routing_table_entry)
135{
136 assert(dest < m_nodes);
137 assert(src < m_switch_ptr_vector.size());
138 assert(m_switch_ptr_vector[src] != NULL);
139
133{
134 assert(dest < m_nodes);
135 assert(src < m_switch_ptr_vector.size());
136 assert(m_switch_ptr_vector[src] != NULL);
137
140 if (isReconfiguration) {
141 m_switch_ptr_vector[src]->reconfigureOutPort(routing_table_entry);
142 return;
143 }
144
145 SimpleExtLink *simple_link = safe_cast<SimpleExtLink*>(link);
146
147 m_switch_ptr_vector[src]->addOutPort(m_fromNetQueues[dest],
148 routing_table_entry,
149 simple_link->m_latency,
150 simple_link->m_bw_multiplier);
151
152 m_endpoint_switches[dest] = m_switch_ptr_vector[src];
153}
154
155// From an endpoint node to a switch
156void
157SimpleNetwork::makeInLink(NodeID src, SwitchID dest, BasicLink* link,
158 LinkDirection direction,
138 SimpleExtLink *simple_link = safe_cast<SimpleExtLink*>(link);
139
140 m_switch_ptr_vector[src]->addOutPort(m_fromNetQueues[dest],
141 routing_table_entry,
142 simple_link->m_latency,
143 simple_link->m_bw_multiplier);
144
145 m_endpoint_switches[dest] = m_switch_ptr_vector[src];
146}
147
148// From an endpoint node to a switch
149void
150SimpleNetwork::makeInLink(NodeID src, SwitchID dest, BasicLink* link,
151 LinkDirection direction,
159 const NetDest& routing_table_entry,
160 bool isReconfiguration)
152 const NetDest& routing_table_entry)
161{
162 assert(src < m_nodes);
153{
154 assert(src < m_nodes);
163 if (isReconfiguration) {
164 // do nothing
165 return;
166 }
167
168 m_switch_ptr_vector[dest]->addInPort(m_toNetQueues[src]);
169}
170
171// From a switch to a switch
172void
173SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
174 LinkDirection direction,
155 m_switch_ptr_vector[dest]->addInPort(m_toNetQueues[src]);
156}
157
158// From a switch to a switch
159void
160SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
161 LinkDirection direction,
175 const NetDest& routing_table_entry,
176 bool isReconfiguration)
162 const NetDest& routing_table_entry)
177{
163{
178 if (isReconfiguration) {
179 m_switch_ptr_vector[src]->reconfigureOutPort(routing_table_entry);
180 return;
181 }
182
183 // Create a set of new MessageBuffers
184 std::vector<MessageBuffer*> queues;
185 for (int i = 0; i < m_virtual_networks; i++) {
186 // allocate a buffer
187 MessageBuffer* buffer_ptr = new MessageBuffer;
188 buffer_ptr->setOrdering(true);
189 if (m_buffer_size > 0) {
190 buffer_ptr->resize(m_buffer_size);
191 }
192 queues.push_back(buffer_ptr);
193 // remember to deallocate it
194 m_buffers_to_free.push_back(buffer_ptr);
195 }
196 // Connect it to the two switches
197 SimpleIntLink *simple_link = safe_cast<SimpleIntLink*>(link);
198
199 m_switch_ptr_vector[dest]->addInPort(queues);
200 m_switch_ptr_vector[src]->addOutPort(queues, routing_table_entry,
201 simple_link->m_latency,
202 simple_link->m_bw_multiplier);
203}
204
205void
206SimpleNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num)
207{
208 assert(id < m_nodes);
209 assert(network_num < m_virtual_networks);
210
211 if (ordered) {
212 m_ordered[network_num] = true;
213 }
214 m_in_use[network_num] = true;
215}
216
217MessageBuffer*
218SimpleNetwork::getToNetQueue(NodeID id, bool ordered, int network_num,
219 std::string vnet_type)
220{
221 checkNetworkAllocation(id, ordered, network_num);
222 return m_toNetQueues[id][network_num];
223}
224
225MessageBuffer*
226SimpleNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num,
227 std::string vnet_type)
228{
229 checkNetworkAllocation(id, ordered, network_num);
230 return m_fromNetQueues[id][network_num];
231}
232
233const std::vector<Throttle*>*
234SimpleNetwork::getThrottles(NodeID id) const
235{
236 assert(id >= 0);
237 assert(id < m_nodes);
238 assert(m_endpoint_switches[id] != NULL);
239 return m_endpoint_switches[id]->getThrottles();
240}
241
242void
243SimpleNetwork::printStats(ostream& out) const
244{
245 out << endl;
246 out << "Network Stats" << endl;
247 out << "-------------" << endl;
248 out << endl;
249
250 //
251 // Determine total counts before printing out each switch's stats
252 //
253 std::vector<uint64> total_msg_counts;
254 total_msg_counts.resize(MessageSizeType_NUM);
255 for (MessageSizeType type = MessageSizeType_FIRST;
256 type < MessageSizeType_NUM;
257 ++type) {
258 total_msg_counts[type] = 0;
259 }
260
261 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
262 const std::vector<Throttle*>* throttles =
263 m_switch_ptr_vector[i]->getThrottles();
264
265 for (int p = 0; p < throttles->size(); p++) {
266
267 const std::vector<std::vector<int> >& message_counts =
268 ((*throttles)[p])->getCounters();
269
270 for (MessageSizeType type = MessageSizeType_FIRST;
271 type < MessageSizeType_NUM;
272 ++type) {
273
274 const std::vector<int> &mct = message_counts[type];
275 int sum = accumulate(mct.begin(), mct.end(), 0);
276 total_msg_counts[type] += uint64(sum);
277 }
278 }
279 }
280 uint64 total_msgs = 0;
281 uint64 total_bytes = 0;
282 for (MessageSizeType type = MessageSizeType_FIRST;
283 type < MessageSizeType_NUM;
284 ++type) {
285
286 if (total_msg_counts[type] > 0) {
287 out << "total_msg_count_" << type << ": " << total_msg_counts[type]
288 << " " << total_msg_counts[type] *
289 uint64(MessageSizeType_to_int(type))
290 << endl;
291
292 total_msgs += total_msg_counts[type];
293
294 total_bytes += total_msg_counts[type] *
295 uint64(MessageSizeType_to_int(type));
296 }
297 }
298
299 out << "total_msgs: " << total_msgs
300 << " total_bytes: " << total_bytes << endl;
301
302 out << endl;
303 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
304 m_switch_ptr_vector[i]->printStats(out);
305 }
306}
307
308void
309SimpleNetwork::clearStats()
310{
311 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
312 m_switch_ptr_vector[i]->clearStats();
313 }
314}
315
316void
317SimpleNetwork::print(ostream& out) const
318{
319 out << "[SimpleNetwork]";
320}
321
322SimpleNetwork *
323SimpleNetworkParams::create()
324{
325 return new SimpleNetwork(this);
326}
327
328/*
329 * The simple network has an array of switches. These switches have buffers
330 * that need to be accessed for functional reads and writes. Also the links
331 * between different switches have buffers that need to be accessed.
332 */
333bool
334SimpleNetwork::functionalRead(Packet *pkt)
335{
336 for (unsigned int i = 0; i < m_switch_ptr_vector.size(); i++) {
337 if (m_switch_ptr_vector[i]->functionalRead(pkt)) {
338 return true;
339 }
340 }
341
342 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
343 if (m_buffers_to_free[i]->functionalRead(pkt)) {
344 return true;
345 }
346 }
347
348 return false;
349}
350
351uint32_t
352SimpleNetwork::functionalWrite(Packet *pkt)
353{
354 uint32_t num_functional_writes = 0;
355
356 for (unsigned int i = 0; i < m_switch_ptr_vector.size(); i++) {
357 num_functional_writes += m_switch_ptr_vector[i]->functionalWrite(pkt);
358 }
359
360 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
361 num_functional_writes += m_buffers_to_free[i]->functionalWrite(pkt);
362 }
363 return num_functional_writes;
364}
164 // Create a set of new MessageBuffers
165 std::vector<MessageBuffer*> queues;
166 for (int i = 0; i < m_virtual_networks; i++) {
167 // allocate a buffer
168 MessageBuffer* buffer_ptr = new MessageBuffer;
169 buffer_ptr->setOrdering(true);
170 if (m_buffer_size > 0) {
171 buffer_ptr->resize(m_buffer_size);
172 }
173 queues.push_back(buffer_ptr);
174 // remember to deallocate it
175 m_buffers_to_free.push_back(buffer_ptr);
176 }
177 // Connect it to the two switches
178 SimpleIntLink *simple_link = safe_cast<SimpleIntLink*>(link);
179
180 m_switch_ptr_vector[dest]->addInPort(queues);
181 m_switch_ptr_vector[src]->addOutPort(queues, routing_table_entry,
182 simple_link->m_latency,
183 simple_link->m_bw_multiplier);
184}
185
186void
187SimpleNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num)
188{
189 assert(id < m_nodes);
190 assert(network_num < m_virtual_networks);
191
192 if (ordered) {
193 m_ordered[network_num] = true;
194 }
195 m_in_use[network_num] = true;
196}
197
198MessageBuffer*
199SimpleNetwork::getToNetQueue(NodeID id, bool ordered, int network_num,
200 std::string vnet_type)
201{
202 checkNetworkAllocation(id, ordered, network_num);
203 return m_toNetQueues[id][network_num];
204}
205
206MessageBuffer*
207SimpleNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num,
208 std::string vnet_type)
209{
210 checkNetworkAllocation(id, ordered, network_num);
211 return m_fromNetQueues[id][network_num];
212}
213
214const std::vector<Throttle*>*
215SimpleNetwork::getThrottles(NodeID id) const
216{
217 assert(id >= 0);
218 assert(id < m_nodes);
219 assert(m_endpoint_switches[id] != NULL);
220 return m_endpoint_switches[id]->getThrottles();
221}
222
223void
224SimpleNetwork::printStats(ostream& out) const
225{
226 out << endl;
227 out << "Network Stats" << endl;
228 out << "-------------" << endl;
229 out << endl;
230
231 //
232 // Determine total counts before printing out each switch's stats
233 //
234 std::vector<uint64> total_msg_counts;
235 total_msg_counts.resize(MessageSizeType_NUM);
236 for (MessageSizeType type = MessageSizeType_FIRST;
237 type < MessageSizeType_NUM;
238 ++type) {
239 total_msg_counts[type] = 0;
240 }
241
242 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
243 const std::vector<Throttle*>* throttles =
244 m_switch_ptr_vector[i]->getThrottles();
245
246 for (int p = 0; p < throttles->size(); p++) {
247
248 const std::vector<std::vector<int> >& message_counts =
249 ((*throttles)[p])->getCounters();
250
251 for (MessageSizeType type = MessageSizeType_FIRST;
252 type < MessageSizeType_NUM;
253 ++type) {
254
255 const std::vector<int> &mct = message_counts[type];
256 int sum = accumulate(mct.begin(), mct.end(), 0);
257 total_msg_counts[type] += uint64(sum);
258 }
259 }
260 }
261 uint64 total_msgs = 0;
262 uint64 total_bytes = 0;
263 for (MessageSizeType type = MessageSizeType_FIRST;
264 type < MessageSizeType_NUM;
265 ++type) {
266
267 if (total_msg_counts[type] > 0) {
268 out << "total_msg_count_" << type << ": " << total_msg_counts[type]
269 << " " << total_msg_counts[type] *
270 uint64(MessageSizeType_to_int(type))
271 << endl;
272
273 total_msgs += total_msg_counts[type];
274
275 total_bytes += total_msg_counts[type] *
276 uint64(MessageSizeType_to_int(type));
277 }
278 }
279
280 out << "total_msgs: " << total_msgs
281 << " total_bytes: " << total_bytes << endl;
282
283 out << endl;
284 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
285 m_switch_ptr_vector[i]->printStats(out);
286 }
287}
288
289void
290SimpleNetwork::clearStats()
291{
292 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
293 m_switch_ptr_vector[i]->clearStats();
294 }
295}
296
297void
298SimpleNetwork::print(ostream& out) const
299{
300 out << "[SimpleNetwork]";
301}
302
303SimpleNetwork *
304SimpleNetworkParams::create()
305{
306 return new SimpleNetwork(this);
307}
308
309/*
310 * The simple network has an array of switches. These switches have buffers
311 * that need to be accessed for functional reads and writes. Also the links
312 * between different switches have buffers that need to be accessed.
313 */
314bool
315SimpleNetwork::functionalRead(Packet *pkt)
316{
317 for (unsigned int i = 0; i < m_switch_ptr_vector.size(); i++) {
318 if (m_switch_ptr_vector[i]->functionalRead(pkt)) {
319 return true;
320 }
321 }
322
323 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
324 if (m_buffers_to_free[i]->functionalRead(pkt)) {
325 return true;
326 }
327 }
328
329 return false;
330}
331
332uint32_t
333SimpleNetwork::functionalWrite(Packet *pkt)
334{
335 uint32_t num_functional_writes = 0;
336
337 for (unsigned int i = 0; i < m_switch_ptr_vector.size(); i++) {
338 num_functional_writes += m_switch_ptr_vector[i]->functionalWrite(pkt);
339 }
340
341 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
342 num_functional_writes += m_buffers_to_free[i]->functionalWrite(pkt);
343 }
344 return num_functional_writes;
345}