SimpleNetwork.cc (10917:c38f28fad4c3) SimpleNetwork.cc (11021:e8a6637afa4c)
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;

--- 48 unchanged lines hidden (view full) ---

57
58 // record the routers
59 for (vector<BasicRouter*>::const_iterator i = p->routers.begin();
60 i != p->routers.end(); ++i) {
61 Switch* s = safe_cast<Switch*>(*i);
62 m_switches.push_back(s);
63 s->init_net_ptr(this);
64 }
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;

--- 48 unchanged lines hidden (view full) ---

57
58 // record the routers
59 for (vector<BasicRouter*>::const_iterator i = p->routers.begin();
60 i != p->routers.end(); ++i) {
61 Switch* s = safe_cast<Switch*>(*i);
62 m_switches.push_back(s);
63 s->init_net_ptr(this);
64 }
65
66 m_int_link_buffers = p->int_link_buffers;
67 m_num_connected_buffers = 0;
65}
66
67void
68SimpleNetwork::init()
69{
70 Network::init();
71
72 // The topology pointer should have already been initialized in
73 // the parent class network constructor.
74 assert(m_topology_ptr != NULL);
75 m_topology_ptr->createLinks(this);
76}
77
78SimpleNetwork::~SimpleNetwork()
79{
80 deletePointers(m_switches);
68}
69
70void
71SimpleNetwork::init()
72{
73 Network::init();
74
75 // The topology pointer should have already been initialized in
76 // the parent class network constructor.
77 assert(m_topology_ptr != NULL);
78 m_topology_ptr->createLinks(this);
79}
80
81SimpleNetwork::~SimpleNetwork()
82{
83 deletePointers(m_switches);
81 deletePointers(m_buffers_to_free);
84 deletePointers(m_int_link_buffers);
82}
83
84// From a switch to an endpoint node
85void
86SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
87 LinkDirection direction,
88 const NetDest& routing_table_entry)
89{

--- 26 unchanged lines hidden (view full) ---

116 LinkDirection direction,
117 const NetDest& routing_table_entry)
118{
119 // Create a set of new MessageBuffers
120 std::vector<MessageBuffer*> queues(m_virtual_networks);
121
122 for (int i = 0; i < m_virtual_networks; i++) {
123 // allocate a buffer
85}
86
87// From a switch to an endpoint node
88void
89SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
90 LinkDirection direction,
91 const NetDest& routing_table_entry)
92{

--- 26 unchanged lines hidden (view full) ---

119 LinkDirection direction,
120 const NetDest& routing_table_entry)
121{
122 // Create a set of new MessageBuffers
123 std::vector<MessageBuffer*> queues(m_virtual_networks);
124
125 for (int i = 0; i < m_virtual_networks; i++) {
126 // allocate a buffer
124 MessageBuffer* buffer_ptr = new MessageBuffer;
125 buffer_ptr->setOrdering(true);
126
127 if (m_buffer_size > 0) {
128 buffer_ptr->resize(m_buffer_size);
129 }
130
127 assert(m_num_connected_buffers < m_int_link_buffers.size());
128 MessageBuffer* buffer_ptr = m_int_link_buffers[m_num_connected_buffers];
129 m_num_connected_buffers++;
131 queues[i] = buffer_ptr;
130 queues[i] = buffer_ptr;
132 // remember to deallocate it
133 m_buffers_to_free.push_back(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,
141 simple_link->m_latency,

--- 89 unchanged lines hidden (view full) ---

231SimpleNetwork::functionalRead(Packet *pkt)
232{
233 for (unsigned int i = 0; i < m_switches.size(); i++) {
234 if (m_switches[i]->functionalRead(pkt)) {
235 return true;
236 }
237 }
238
131 }
132
133 // Connect it to the two switches
134 SimpleIntLink *simple_link = safe_cast<SimpleIntLink*>(link);
135
136 m_switches[dest]->addInPort(queues);
137 m_switches[src]->addOutPort(queues, routing_table_entry,
138 simple_link->m_latency,

--- 89 unchanged lines hidden (view full) ---

228SimpleNetwork::functionalRead(Packet *pkt)
229{
230 for (unsigned int i = 0; i < m_switches.size(); i++) {
231 if (m_switches[i]->functionalRead(pkt)) {
232 return true;
233 }
234 }
235
239 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
240 if (m_buffers_to_free[i]->functionalRead(pkt)) {
236 for (unsigned int i = 0; i < m_int_link_buffers.size(); ++i) {
237 if (m_int_link_buffers[i]->functionalRead(pkt)) {
241 return true;
242 }
243 }
244
245 return false;
246}
247
248uint32_t
249SimpleNetwork::functionalWrite(Packet *pkt)
250{
251 uint32_t num_functional_writes = 0;
252
253 for (unsigned int i = 0; i < m_switches.size(); i++) {
254 num_functional_writes += m_switches[i]->functionalWrite(pkt);
255 }
256
238 return true;
239 }
240 }
241
242 return false;
243}
244
245uint32_t
246SimpleNetwork::functionalWrite(Packet *pkt)
247{
248 uint32_t num_functional_writes = 0;
249
250 for (unsigned int i = 0; i < m_switches.size(); i++) {
251 num_functional_writes += m_switches[i]->functionalWrite(pkt);
252 }
253
257 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
258 num_functional_writes += m_buffers_to_free[i]->functionalWrite(pkt);
254 for (unsigned int i = 0; i < m_int_link_buffers.size(); ++i) {
255 num_functional_writes += m_int_link_buffers[i]->functionalWrite(pkt);
259 }
260 return num_functional_writes;
261}
256 }
257 return num_functional_writes;
258}