SimpleNetwork.cc (8257:7226aebb77b4) SimpleNetwork.cc (8258:7c377f5162f8)
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/stl_helpers.hh"
33#include "mem/protocol/MachineType.hh"
34#include "mem/protocol/Protocol.hh"
35#include "mem/protocol/TopologyType.hh"
36#include "mem/ruby/buffers/MessageBuffer.hh"
37#include "mem/ruby/common/NetDest.hh"
38#include "mem/ruby/network/BasicLink.hh"
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/stl_helpers.hh"
33#include "mem/protocol/MachineType.hh"
34#include "mem/protocol/Protocol.hh"
35#include "mem/protocol/TopologyType.hh"
36#include "mem/ruby/buffers/MessageBuffer.hh"
37#include "mem/ruby/common/NetDest.hh"
38#include "mem/ruby/network/BasicLink.hh"
39#include "mem/ruby/network/simple/SimpleLink.hh"
39#include "mem/ruby/network/simple/SimpleNetwork.hh"
40#include "mem/ruby/network/simple/Switch.hh"
41#include "mem/ruby/network/simple/Throttle.hh"
42#include "mem/ruby/network/Topology.hh"
43#include "mem/ruby/profiler/Profiler.hh"
44#include "mem/ruby/system/System.hh"
45
46using namespace std;
47using m5::stl_helpers::deletePointers;
48
49#if 0
50// ***BIG HACK*** - This is actually code that _should_ be in Network.cc
51
52// Note: Moved to Princeton Network
53// calls new to abstract away from the network
54Network*
55Network::createNetwork(int nodes)
56{
57 return new SimpleNetwork(nodes);
58}
59#endif
60
61SimpleNetwork::SimpleNetwork(const Params *p)
62 : Network(p)
63{
64 // Note: the parent Network Object constructor is called before the
65 // SimpleNetwork child constructor. Therefore, the member variables
66 // used below should already be initialized.
67
68 m_endpoint_switches.resize(m_nodes);
69
70 m_in_use.resize(m_virtual_networks);
71 m_ordered.resize(m_virtual_networks);
72 for (int i = 0; i < m_virtual_networks; i++) {
73 m_in_use[i] = false;
74 m_ordered[i] = false;
75 }
76
77 // Allocate to and from queues
78 m_toNetQueues.resize(m_nodes);
79 m_fromNetQueues.resize(m_nodes);
80 for (int node = 0; node < m_nodes; node++) {
81 m_toNetQueues[node].resize(m_virtual_networks);
82 m_fromNetQueues[node].resize(m_virtual_networks);
83 for (int j = 0; j < m_virtual_networks; j++) {
84 m_toNetQueues[node][j] =
85 new MessageBuffer(csprintf("toNet node %d j %d", node, j));
86 m_fromNetQueues[node][j] =
87 new MessageBuffer(csprintf("fromNet node %d j %d", node, j));
88 }
89 }
90}
91
92void
93SimpleNetwork::init()
94{
95 Network::init();
96
97 // The topology pointer should have already been initialized in
98 // the parent class network constructor.
99 assert(m_topology_ptr != NULL);
100 int number_of_switches = m_topology_ptr->numSwitches();
101 for (int i = 0; i < number_of_switches; i++) {
102 m_switch_ptr_vector.push_back(new Switch(i, this));
103 }
104
105 // false because this isn't a reconfiguration
106 m_topology_ptr->createLinks(this, false);
107}
108
109void
110SimpleNetwork::reset()
111{
112 for (int node = 0; node < m_nodes; node++) {
113 for (int j = 0; j < m_virtual_networks; j++) {
114 m_toNetQueues[node][j]->clear();
115 m_fromNetQueues[node][j]->clear();
116 }
117 }
118
119 for(int i = 0; i < m_switch_ptr_vector.size(); i++){
120 m_switch_ptr_vector[i]->clearBuffers();
121 }
122}
123
124SimpleNetwork::~SimpleNetwork()
125{
126 for (int i = 0; i < m_nodes; i++) {
127 deletePointers(m_toNetQueues[i]);
128 deletePointers(m_fromNetQueues[i]);
129 }
130 deletePointers(m_switch_ptr_vector);
131 deletePointers(m_buffers_to_free);
132 // delete m_topology_ptr;
133}
134
135// From a switch to an endpoint node
136void
137SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
138 LinkDirection direction,
139 const NetDest& routing_table_entry,
140 bool isReconfiguration)
141{
142 assert(dest < m_nodes);
143 assert(src < m_switch_ptr_vector.size());
144 assert(m_switch_ptr_vector[src] != NULL);
145
146 if (isReconfiguration) {
147 m_switch_ptr_vector[src]->reconfigureOutPort(routing_table_entry);
148 return;
149 }
150
40#include "mem/ruby/network/simple/SimpleNetwork.hh"
41#include "mem/ruby/network/simple/Switch.hh"
42#include "mem/ruby/network/simple/Throttle.hh"
43#include "mem/ruby/network/Topology.hh"
44#include "mem/ruby/profiler/Profiler.hh"
45#include "mem/ruby/system/System.hh"
46
47using namespace std;
48using m5::stl_helpers::deletePointers;
49
50#if 0
51// ***BIG HACK*** - This is actually code that _should_ be in Network.cc
52
53// Note: Moved to Princeton Network
54// calls new to abstract away from the network
55Network*
56Network::createNetwork(int nodes)
57{
58 return new SimpleNetwork(nodes);
59}
60#endif
61
62SimpleNetwork::SimpleNetwork(const Params *p)
63 : Network(p)
64{
65 // Note: the parent Network Object constructor is called before the
66 // SimpleNetwork child constructor. Therefore, the member variables
67 // used below should already be initialized.
68
69 m_endpoint_switches.resize(m_nodes);
70
71 m_in_use.resize(m_virtual_networks);
72 m_ordered.resize(m_virtual_networks);
73 for (int i = 0; i < m_virtual_networks; i++) {
74 m_in_use[i] = false;
75 m_ordered[i] = false;
76 }
77
78 // Allocate to and from queues
79 m_toNetQueues.resize(m_nodes);
80 m_fromNetQueues.resize(m_nodes);
81 for (int node = 0; node < m_nodes; node++) {
82 m_toNetQueues[node].resize(m_virtual_networks);
83 m_fromNetQueues[node].resize(m_virtual_networks);
84 for (int j = 0; j < m_virtual_networks; j++) {
85 m_toNetQueues[node][j] =
86 new MessageBuffer(csprintf("toNet node %d j %d", node, j));
87 m_fromNetQueues[node][j] =
88 new MessageBuffer(csprintf("fromNet node %d j %d", node, j));
89 }
90 }
91}
92
93void
94SimpleNetwork::init()
95{
96 Network::init();
97
98 // The topology pointer should have already been initialized in
99 // the parent class network constructor.
100 assert(m_topology_ptr != NULL);
101 int number_of_switches = m_topology_ptr->numSwitches();
102 for (int i = 0; i < number_of_switches; i++) {
103 m_switch_ptr_vector.push_back(new Switch(i, this));
104 }
105
106 // false because this isn't a reconfiguration
107 m_topology_ptr->createLinks(this, false);
108}
109
110void
111SimpleNetwork::reset()
112{
113 for (int node = 0; node < m_nodes; node++) {
114 for (int j = 0; j < m_virtual_networks; j++) {
115 m_toNetQueues[node][j]->clear();
116 m_fromNetQueues[node][j]->clear();
117 }
118 }
119
120 for(int i = 0; i < m_switch_ptr_vector.size(); i++){
121 m_switch_ptr_vector[i]->clearBuffers();
122 }
123}
124
125SimpleNetwork::~SimpleNetwork()
126{
127 for (int i = 0; i < m_nodes; i++) {
128 deletePointers(m_toNetQueues[i]);
129 deletePointers(m_fromNetQueues[i]);
130 }
131 deletePointers(m_switch_ptr_vector);
132 deletePointers(m_buffers_to_free);
133 // delete m_topology_ptr;
134}
135
136// From a switch to an endpoint node
137void
138SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
139 LinkDirection direction,
140 const NetDest& routing_table_entry,
141 bool isReconfiguration)
142{
143 assert(dest < m_nodes);
144 assert(src < m_switch_ptr_vector.size());
145 assert(m_switch_ptr_vector[src] != NULL);
146
147 if (isReconfiguration) {
148 m_switch_ptr_vector[src]->reconfigureOutPort(routing_table_entry);
149 return;
150 }
151
152 SimpleExtLink *simple_link = safe_cast<SimpleExtLink*>(link);
153
151 m_switch_ptr_vector[src]->addOutPort(m_fromNetQueues[dest],
152 routing_table_entry,
154 m_switch_ptr_vector[src]->addOutPort(m_fromNetQueues[dest],
155 routing_table_entry,
153 link->m_latency,
154 link->m_bw_multiplier);
156 simple_link->m_latency,
157 simple_link->m_bw_multiplier);
155
156 m_endpoint_switches[dest] = m_switch_ptr_vector[src];
157}
158
159// From an endpoint node to a switch
160void
161SimpleNetwork::makeInLink(NodeID src, SwitchID dest, BasicLink* link,
162 LinkDirection direction,
163 const NetDest& routing_table_entry,
164 bool isReconfiguration)
165{
166 assert(src < m_nodes);
167 if (isReconfiguration) {
168 // do nothing
169 return;
170 }
171
172 m_switch_ptr_vector[dest]->addInPort(m_toNetQueues[src]);
173}
174
175// From a switch to a switch
176void
177SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
178 LinkDirection direction,
179 const NetDest& routing_table_entry,
180 bool isReconfiguration)
181{
182 if (isReconfiguration) {
183 m_switch_ptr_vector[src]->reconfigureOutPort(routing_table_entry);
184 return;
185 }
186
187 // Create a set of new MessageBuffers
188 std::vector<MessageBuffer*> queues;
189 for (int i = 0; i < m_virtual_networks; i++) {
190 // allocate a buffer
191 MessageBuffer* buffer_ptr = new MessageBuffer;
192 buffer_ptr->setOrdering(true);
193 if (m_buffer_size > 0) {
194 buffer_ptr->resize(m_buffer_size);
195 }
196 queues.push_back(buffer_ptr);
197 // remember to deallocate it
198 m_buffers_to_free.push_back(buffer_ptr);
199 }
200 // Connect it to the two switches
158
159 m_endpoint_switches[dest] = m_switch_ptr_vector[src];
160}
161
162// From an endpoint node to a switch
163void
164SimpleNetwork::makeInLink(NodeID src, SwitchID dest, BasicLink* link,
165 LinkDirection direction,
166 const NetDest& routing_table_entry,
167 bool isReconfiguration)
168{
169 assert(src < m_nodes);
170 if (isReconfiguration) {
171 // do nothing
172 return;
173 }
174
175 m_switch_ptr_vector[dest]->addInPort(m_toNetQueues[src]);
176}
177
178// From a switch to a switch
179void
180SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
181 LinkDirection direction,
182 const NetDest& routing_table_entry,
183 bool isReconfiguration)
184{
185 if (isReconfiguration) {
186 m_switch_ptr_vector[src]->reconfigureOutPort(routing_table_entry);
187 return;
188 }
189
190 // Create a set of new MessageBuffers
191 std::vector<MessageBuffer*> queues;
192 for (int i = 0; i < m_virtual_networks; i++) {
193 // allocate a buffer
194 MessageBuffer* buffer_ptr = new MessageBuffer;
195 buffer_ptr->setOrdering(true);
196 if (m_buffer_size > 0) {
197 buffer_ptr->resize(m_buffer_size);
198 }
199 queues.push_back(buffer_ptr);
200 // remember to deallocate it
201 m_buffers_to_free.push_back(buffer_ptr);
202 }
203 // Connect it to the two switches
204 SimpleIntLink *simple_link = safe_cast<SimpleIntLink*>(link);
205
201 m_switch_ptr_vector[dest]->addInPort(queues);
202 m_switch_ptr_vector[src]->addOutPort(queues, routing_table_entry,
206 m_switch_ptr_vector[dest]->addInPort(queues);
207 m_switch_ptr_vector[src]->addOutPort(queues, routing_table_entry,
203 link->m_latency,
204 link->m_bw_multiplier);
208 simple_link->m_latency,
209 simple_link->m_bw_multiplier);
205}
206
207void
208SimpleNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num)
209{
210 assert(id < m_nodes);
211 assert(network_num < m_virtual_networks);
212
213 if (ordered) {
214 m_ordered[network_num] = true;
215 }
216 m_in_use[network_num] = true;
217}
218
219MessageBuffer*
220SimpleNetwork::getToNetQueue(NodeID id, bool ordered, int network_num)
221{
222 checkNetworkAllocation(id, ordered, network_num);
223 return m_toNetQueues[id][network_num];
224}
225
226MessageBuffer*
227SimpleNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num)
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(RubySystem::getNetwork()->MessageSizeType_to_int(type))
290 << endl;
291
292 total_msgs += total_msg_counts[type];
293
294 total_bytes += total_msg_counts[type] *
295 uint64(RubySystem::getNetwork()->MessageSizeType_to_int(type));
296
297 }
298 }
299
300 out << "total_msgs: " << total_msgs
301 << " total_bytes: " << total_bytes << endl;
302
303 out << endl;
304 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
305 m_switch_ptr_vector[i]->printStats(out);
306 }
307 m_topology_ptr->printStats(out);
308}
309
310void
311SimpleNetwork::clearStats()
312{
313 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
314 m_switch_ptr_vector[i]->clearStats();
315 }
316 m_topology_ptr->clearStats();
317}
318
319void
320SimpleNetwork::printConfig(ostream& out) const
321{
322 out << endl;
323 out << "Network Configuration" << endl;
324 out << "---------------------" << endl;
325 out << "network: SIMPLE_NETWORK" << endl;
326 out << "topology: " << m_topology_ptr->getName() << endl;
327 out << endl;
328
329 for (int i = 0; i < m_virtual_networks; i++) {
330 out << "virtual_net_" << i << ": ";
331 if (m_in_use[i]) {
332 out << "active, ";
333 if (m_ordered[i]) {
334 out << "ordered" << endl;
335 } else {
336 out << "unordered" << endl;
337 }
338 } else {
339 out << "inactive" << endl;
340 }
341 }
342 out << endl;
343
344 for(int i = 0; i < m_switch_ptr_vector.size(); i++) {
345 m_switch_ptr_vector[i]->printConfig(out);
346 }
347
348 m_topology_ptr->printConfig(out);
349}
350
351void
352SimpleNetwork::print(ostream& out) const
353{
354 out << "[SimpleNetwork]";
355}
356
357
358SimpleNetwork *
359SimpleNetworkParams::create()
360{
361 return new SimpleNetwork(this);
362}
210}
211
212void
213SimpleNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num)
214{
215 assert(id < m_nodes);
216 assert(network_num < m_virtual_networks);
217
218 if (ordered) {
219 m_ordered[network_num] = true;
220 }
221 m_in_use[network_num] = true;
222}
223
224MessageBuffer*
225SimpleNetwork::getToNetQueue(NodeID id, bool ordered, int network_num)
226{
227 checkNetworkAllocation(id, ordered, network_num);
228 return m_toNetQueues[id][network_num];
229}
230
231MessageBuffer*
232SimpleNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num)
233{
234 checkNetworkAllocation(id, ordered, network_num);
235 return m_fromNetQueues[id][network_num];
236}
237
238const std::vector<Throttle*>*
239SimpleNetwork::getThrottles(NodeID id) const
240{
241 assert(id >= 0);
242 assert(id < m_nodes);
243 assert(m_endpoint_switches[id] != NULL);
244 return m_endpoint_switches[id]->getThrottles();
245}
246
247void
248SimpleNetwork::printStats(ostream& out) const
249{
250 out << endl;
251 out << "Network Stats" << endl;
252 out << "-------------" << endl;
253 out << endl;
254
255 //
256 // Determine total counts before printing out each switch's stats
257 //
258 std::vector<uint64> total_msg_counts;
259 total_msg_counts.resize(MessageSizeType_NUM);
260 for (MessageSizeType type = MessageSizeType_FIRST;
261 type < MessageSizeType_NUM;
262 ++type) {
263 total_msg_counts[type] = 0;
264 }
265
266 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
267 const std::vector<Throttle*>* throttles =
268 m_switch_ptr_vector[i]->getThrottles();
269
270 for (int p = 0; p < throttles->size(); p++) {
271
272 const std::vector<std::vector<int> >& message_counts =
273 ((*throttles)[p])->getCounters();
274
275 for (MessageSizeType type = MessageSizeType_FIRST;
276 type < MessageSizeType_NUM;
277 ++type) {
278
279 const std::vector<int> &mct = message_counts[type];
280 int sum = accumulate(mct.begin(), mct.end(), 0);
281 total_msg_counts[type] += uint64(sum);
282 }
283 }
284 }
285 uint64 total_msgs = 0;
286 uint64 total_bytes = 0;
287 for (MessageSizeType type = MessageSizeType_FIRST;
288 type < MessageSizeType_NUM;
289 ++type) {
290
291 if (total_msg_counts[type] > 0) {
292 out << "total_msg_count_" << type << ": " << total_msg_counts[type]
293 << " " << total_msg_counts[type] *
294 uint64(RubySystem::getNetwork()->MessageSizeType_to_int(type))
295 << endl;
296
297 total_msgs += total_msg_counts[type];
298
299 total_bytes += total_msg_counts[type] *
300 uint64(RubySystem::getNetwork()->MessageSizeType_to_int(type));
301
302 }
303 }
304
305 out << "total_msgs: " << total_msgs
306 << " total_bytes: " << total_bytes << endl;
307
308 out << endl;
309 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
310 m_switch_ptr_vector[i]->printStats(out);
311 }
312 m_topology_ptr->printStats(out);
313}
314
315void
316SimpleNetwork::clearStats()
317{
318 for (int i = 0; i < m_switch_ptr_vector.size(); i++) {
319 m_switch_ptr_vector[i]->clearStats();
320 }
321 m_topology_ptr->clearStats();
322}
323
324void
325SimpleNetwork::printConfig(ostream& out) const
326{
327 out << endl;
328 out << "Network Configuration" << endl;
329 out << "---------------------" << endl;
330 out << "network: SIMPLE_NETWORK" << endl;
331 out << "topology: " << m_topology_ptr->getName() << endl;
332 out << endl;
333
334 for (int i = 0; i < m_virtual_networks; i++) {
335 out << "virtual_net_" << i << ": ";
336 if (m_in_use[i]) {
337 out << "active, ";
338 if (m_ordered[i]) {
339 out << "ordered" << endl;
340 } else {
341 out << "unordered" << endl;
342 }
343 } else {
344 out << "inactive" << endl;
345 }
346 }
347 out << endl;
348
349 for(int i = 0; i < m_switch_ptr_vector.size(); i++) {
350 m_switch_ptr_vector[i]->printConfig(out);
351 }
352
353 m_topology_ptr->printConfig(out);
354}
355
356void
357SimpleNetwork::print(ostream& out) const
358{
359 out << "[SimpleNetwork]";
360}
361
362
363SimpleNetwork *
364SimpleNetworkParams::create()
365{
366 return new SimpleNetwork(this);
367}