SimpleNetwork.cc (7056:b66b558578bd) | SimpleNetwork.cc (7454:3a3e8e8cce1b) |
---|---|
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; --- 12 unchanged lines hidden (view full) --- 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 | 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; --- 12 unchanged lines hidden (view full) --- 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 "base/stl_helpers.hh" |
|
29#include "mem/gems_common/Map.hh" 30#include "mem/protocol/MachineType.hh" 31#include "mem/protocol/Protocol.hh" 32#include "mem/protocol/TopologyType.hh" 33#include "mem/ruby/buffers/MessageBuffer.hh" 34#include "mem/ruby/common/NetDest.hh" 35#include "mem/ruby/network/simple/SimpleNetwork.hh" 36#include "mem/ruby/network/simple/Switch.hh" 37#include "mem/ruby/network/simple/Topology.hh" 38#include "mem/ruby/profiler/Profiler.hh" 39#include "mem/ruby/system/System.hh" 40 41using namespace std; | 30#include "mem/gems_common/Map.hh" 31#include "mem/protocol/MachineType.hh" 32#include "mem/protocol/Protocol.hh" 33#include "mem/protocol/TopologyType.hh" 34#include "mem/ruby/buffers/MessageBuffer.hh" 35#include "mem/ruby/common/NetDest.hh" 36#include "mem/ruby/network/simple/SimpleNetwork.hh" 37#include "mem/ruby/network/simple/Switch.hh" 38#include "mem/ruby/network/simple/Topology.hh" 39#include "mem/ruby/profiler/Profiler.hh" 40#include "mem/ruby/system/System.hh" 41 42using namespace std; |
43using m5::stl_helpers::deletePointers; |
|
42 43#if 0 44// ***BIG HACK*** - This is actually code that _should_ be in Network.cc 45 46// Note: Moved to Princeton Network 47// calls new to abstract away from the network 48Network* 49Network::createNetwork(int nodes) --- 4 unchanged lines hidden (view full) --- 54 55SimpleNetwork::SimpleNetwork(const Params *p) 56 : Network(p) 57{ 58 // Note: the parent Network Object constructor is called before the 59 // SimpleNetwork child constructor. Therefore, the member variables 60 // used below should already be initialized. 61 | 44 45#if 0 46// ***BIG HACK*** - This is actually code that _should_ be in Network.cc 47 48// Note: Moved to Princeton Network 49// calls new to abstract away from the network 50Network* 51Network::createNetwork(int nodes) --- 4 unchanged lines hidden (view full) --- 56 57SimpleNetwork::SimpleNetwork(const Params *p) 58 : Network(p) 59{ 60 // Note: the parent Network Object constructor is called before the 61 // SimpleNetwork child constructor. Therefore, the member variables 62 // used below should already be initialized. 63 |
62 m_endpoint_switches.setSize(m_nodes); | 64 m_endpoint_switches.resize(m_nodes); |
63 | 65 |
64 m_in_use.setSize(m_virtual_networks); 65 m_ordered.setSize(m_virtual_networks); | 66 m_in_use.resize(m_virtual_networks); 67 m_ordered.resize(m_virtual_networks); |
66 for (int i = 0; i < m_virtual_networks; i++) { 67 m_in_use[i] = false; 68 m_ordered[i] = false; 69 } 70 71 // Allocate to and from queues | 68 for (int i = 0; i < m_virtual_networks; i++) { 69 m_in_use[i] = false; 70 m_ordered[i] = false; 71 } 72 73 // Allocate to and from queues |
72 m_toNetQueues.setSize(m_nodes); 73 m_fromNetQueues.setSize(m_nodes); | 74 m_toNetQueues.resize(m_nodes); 75 m_fromNetQueues.resize(m_nodes); |
74 for (int node = 0; node < m_nodes; node++) { | 76 for (int node = 0; node < m_nodes; node++) { |
75 m_toNetQueues[node].setSize(m_virtual_networks); 76 m_fromNetQueues[node].setSize(m_virtual_networks); | 77 m_toNetQueues[node].resize(m_virtual_networks); 78 m_fromNetQueues[node].resize(m_virtual_networks); |
77 for (int j = 0; j < m_virtual_networks; j++) { 78 m_toNetQueues[node][j] = 79 new MessageBuffer(csprintf("toNet node %d j %d", node, j)); 80 m_fromNetQueues[node][j] = 81 new MessageBuffer(csprintf("fromNet node %d j %d", node, j)); 82 } 83 } 84} 85 86void 87SimpleNetwork::init() 88{ 89 Network::init(); 90 91 // The topology pointer should have already been initialized in 92 // the parent class network constructor. 93 assert(m_topology_ptr != NULL); 94 int number_of_switches = m_topology_ptr->numSwitches(); 95 for (int i = 0; i < number_of_switches; i++) { | 79 for (int j = 0; j < m_virtual_networks; j++) { 80 m_toNetQueues[node][j] = 81 new MessageBuffer(csprintf("toNet node %d j %d", node, j)); 82 m_fromNetQueues[node][j] = 83 new MessageBuffer(csprintf("fromNet node %d j %d", node, j)); 84 } 85 } 86} 87 88void 89SimpleNetwork::init() 90{ 91 Network::init(); 92 93 // The topology pointer should have already been initialized in 94 // the parent class network constructor. 95 assert(m_topology_ptr != NULL); 96 int number_of_switches = m_topology_ptr->numSwitches(); 97 for (int i = 0; i < number_of_switches; i++) { |
96 m_switch_ptr_vector.insertAtBottom(new Switch(i, this)); | 98 m_switch_ptr_vector.push_back(new Switch(i, this)); |
97 } 98 99 // false because this isn't a reconfiguration 100 m_topology_ptr->createLinks(this, false); 101} 102 103void 104SimpleNetwork::reset() --- 8 unchanged lines hidden (view full) --- 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++) { | 99 } 100 101 // false because this isn't a reconfiguration 102 m_topology_ptr->createLinks(this, false); 103} 104 105void 106SimpleNetwork::reset() --- 8 unchanged lines hidden (view full) --- 115 for(int i = 0; i < m_switch_ptr_vector.size(); i++){ 116 m_switch_ptr_vector[i]->clearBuffers(); 117 } 118} 119 120SimpleNetwork::~SimpleNetwork() 121{ 122 for (int i = 0; i < m_nodes; i++) { |
121 m_toNetQueues[i].deletePointers(); 122 m_fromNetQueues[i].deletePointers(); | 123 deletePointers(m_toNetQueues[i]); 124 deletePointers(m_fromNetQueues[i]); |
123 } | 125 } |
124 m_switch_ptr_vector.deletePointers(); 125 m_buffers_to_free.deletePointers(); | 126 deletePointers(m_switch_ptr_vector); 127 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, 132 const NetDest& routing_table_entry, int link_latency, int link_weight, 133 int bw_multiplier, bool isReconfiguration) --- 34 unchanged lines hidden (view full) --- 168 int bw_multiplier, bool isReconfiguration) 169{ 170 if (isReconfiguration) { 171 m_switch_ptr_vector[src]->reconfigureOutPort(routing_table_entry); 172 return; 173 } 174 175 // Create a set of new MessageBuffers | 128 // delete m_topology_ptr; 129} 130 131// From a switch to an endpoint node 132void 133SimpleNetwork::makeOutLink(SwitchID src, NodeID dest, 134 const NetDest& routing_table_entry, int link_latency, int link_weight, 135 int bw_multiplier, bool isReconfiguration) --- 34 unchanged lines hidden (view full) --- 170 int bw_multiplier, bool isReconfiguration) 171{ 172 if (isReconfiguration) { 173 m_switch_ptr_vector[src]->reconfigureOutPort(routing_table_entry); 174 return; 175 } 176 177 // Create a set of new MessageBuffers |
176 Vector<MessageBuffer*> queues; | 178 std::vector<MessageBuffer*> queues; |
177 for (int i = 0; i < m_virtual_networks; i++) { 178 // allocate a buffer 179 MessageBuffer* buffer_ptr = new MessageBuffer; 180 buffer_ptr->setOrdering(true); 181 if (m_buffer_size > 0) { | 179 for (int i = 0; i < m_virtual_networks; i++) { 180 // allocate a buffer 181 MessageBuffer* buffer_ptr = new MessageBuffer; 182 buffer_ptr->setOrdering(true); 183 if (m_buffer_size > 0) { |
182 buffer_ptr->setSize(m_buffer_size); | 184 buffer_ptr->resize(m_buffer_size); |
183 } | 185 } |
184 queues.insertAtBottom(buffer_ptr); | 186 queues.push_back(buffer_ptr); |
185 // remember to deallocate it | 187 // remember to deallocate it |
186 m_buffers_to_free.insertAtBottom(buffer_ptr); | 188 m_buffers_to_free.push_back(buffer_ptr); |
187 } 188 // Connect it to the two switches 189 m_switch_ptr_vector[dest]->addInPort(queues); 190 m_switch_ptr_vector[src]->addOutPort(queues, routing_table_entry, 191 link_latency, bw_multiplier); 192} 193 194void --- 17 unchanged lines hidden (view full) --- 212 213MessageBuffer* 214SimpleNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num) 215{ 216 checkNetworkAllocation(id, ordered, network_num); 217 return m_fromNetQueues[id][network_num]; 218} 219 | 189 } 190 // Connect it to the two switches 191 m_switch_ptr_vector[dest]->addInPort(queues); 192 m_switch_ptr_vector[src]->addOutPort(queues, routing_table_entry, 193 link_latency, bw_multiplier); 194} 195 196void --- 17 unchanged lines hidden (view full) --- 214 215MessageBuffer* 216SimpleNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num) 217{ 218 checkNetworkAllocation(id, ordered, network_num); 219 return m_fromNetQueues[id][network_num]; 220} 221 |
220const Vector<Throttle*>* | 222const std::vector<Throttle*>* |
221SimpleNetwork::getThrottles(NodeID id) const 222{ 223 assert(id >= 0); 224 assert(id < m_nodes); 225 assert(m_endpoint_switches[id] != NULL); 226 return m_endpoint_switches[id]->getThrottles(); 227} 228 --- 66 unchanged lines hidden --- | 223SimpleNetwork::getThrottles(NodeID id) const 224{ 225 assert(id >= 0); 226 assert(id < m_nodes); 227 assert(m_endpoint_switches[id] != NULL); 228 return m_endpoint_switches[id]->getThrottles(); 229} 230 --- 66 unchanged lines hidden --- |