diff options
author | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:07 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:07 -0700 |
commit | 006818aeea6176c4500c5f7414e9f2a822c77062 (patch) | |
tree | 74adbd6cc14951943bd6eafc4aba2fb98be7a526 /src/mem/ruby/network | |
parent | bc87fa30d72df7db6265be50b2c39dc218076f9f (diff) | |
download | gem5-006818aeea6176c4500c5f7414e9f2a822c77062.tar.xz |
ruby: get rid of Vector and use STL
add a couple of helper functions to base for deleteing all pointers in
a container and outputting containers to a stream
Diffstat (limited to 'src/mem/ruby/network')
40 files changed, 344 insertions, 300 deletions
diff --git a/src/mem/ruby/network/Network.cc b/src/mem/ruby/network/Network.cc index 89b9168b6..f2e056f75 100644 --- a/src/mem/ruby/network/Network.cc +++ b/src/mem/ruby/network/Network.cc @@ -90,7 +90,7 @@ Network::MessageSizeType_to_int(MessageSizeType size_type) return 0; } -const Vector<Throttle*>* +const std::vector<Throttle*>* Network::getThrottles(NodeID id) const { return NULL; diff --git a/src/mem/ruby/network/Network.hh b/src/mem/ruby/network/Network.hh index fb56904db..51be0105c 100644 --- a/src/mem/ruby/network/Network.hh +++ b/src/mem/ruby/network/Network.hh @@ -42,6 +42,7 @@ #include <iostream> #include <string> +#include <vector> #include "mem/protocol/MessageSizeType.hh" #include "mem/ruby/common/Global.hh" @@ -76,7 +77,7 @@ class Network : public SimObject int netNumber) = 0; virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0; - virtual const Vector<Throttle*>* getThrottles(NodeID id) const; + virtual const std::vector<Throttle*>* getThrottles(NodeID id) const; virtual int getNumNodes() {return 1;} virtual void makeOutLink(SwitchID src, NodeID dest, diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc index 8bdea4894..124a38e93 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc @@ -28,6 +28,7 @@ * Authors: Niket Agarwal */ +#include "base/stl_helpers.hh" #include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh" #include "mem/protocol/MachineType.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh" @@ -39,6 +40,7 @@ #include "mem/ruby/common/NetDest.hh" using namespace std; +using m5::stl_helpers::deletePointers; GarnetNetwork_d::GarnetNetwork_d(const Params *p) : BaseGarnetNetwork(p) @@ -52,10 +54,10 @@ GarnetNetwork_d::GarnetNetwork_d(const Params *p) m_router_ptr_vector.clear(); // Allocate to and from queues - m_toNetQueues.setSize(m_nodes); // Queues that are getting messages from protocol - m_fromNetQueues.setSize(m_nodes); // Queues that are feeding the protocol - m_in_use.setSize(m_virtual_networks); - m_ordered.setSize(m_virtual_networks); + m_toNetQueues.resize(m_nodes); // Queues that are getting messages from protocol + m_fromNetQueues.resize(m_nodes); // Queues that are feeding the protocol + m_in_use.resize(m_virtual_networks); + m_ordered.resize(m_virtual_networks); for (int i = 0; i < m_virtual_networks; i++) { m_in_use[i] = false; @@ -65,8 +67,8 @@ GarnetNetwork_d::GarnetNetwork_d(const Params *p) for (int node = 0; node < m_nodes; node++) { //Setting how many vitual message buffers will there be per Network Queue - m_toNetQueues[node].setSize(m_virtual_networks); - m_fromNetQueues[node].setSize(m_virtual_networks); + m_toNetQueues[node].resize(m_virtual_networks); + m_fromNetQueues[node].resize(m_virtual_networks); for (int j = 0; j < m_virtual_networks; j++) { @@ -88,13 +90,13 @@ void GarnetNetwork_d::init() int number_of_routers = m_topology_ptr->numSwitches(); for (int i=0; i<number_of_routers; i++) { - m_router_ptr_vector.insertAtBottom(new Router_d(i, this)); + m_router_ptr_vector.push_back(new Router_d(i, this)); } for (int i=0; i < m_nodes; i++) { NetworkInterface_d *ni = new NetworkInterface_d(i, m_virtual_networks, this); ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]); - m_ni_ptr_vector.insertAtBottom(ni); + m_ni_ptr_vector.push_back(ni); } m_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration for(int i = 0; i < m_router_ptr_vector.size(); i++) @@ -107,13 +109,13 @@ GarnetNetwork_d::~GarnetNetwork_d() { for (int i = 0; i < m_nodes; i++) { - m_toNetQueues[i].deletePointers(); - m_fromNetQueues[i].deletePointers(); + deletePointers(m_toNetQueues[i]); + deletePointers(m_fromNetQueues[i]); } - m_router_ptr_vector.deletePointers(); - m_ni_ptr_vector.deletePointers(); - m_link_ptr_vector.deletePointers(); - m_creditlink_ptr_vector.deletePointers(); + deletePointers(m_router_ptr_vector); + deletePointers(m_ni_ptr_vector); + deletePointers(m_link_ptr_vector); + deletePointers(m_creditlink_ptr_vector); delete m_topology_ptr; } @@ -143,8 +145,8 @@ void GarnetNetwork_d::makeInLink(NodeID src, SwitchID dest, const NetDest& routi { NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this); CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this); - m_link_ptr_vector.insertAtBottom(net_link); - m_creditlink_ptr_vector.insertAtBottom(credit_link); + m_link_ptr_vector.push_back(net_link); + m_creditlink_ptr_vector.push_back(credit_link); m_router_ptr_vector[dest]->addInPort(net_link, credit_link); m_ni_ptr_vector[src]->addOutPort(net_link, credit_link); @@ -172,8 +174,8 @@ void GarnetNetwork_d::makeOutLink(SwitchID src, NodeID dest, const NetDest& rout { NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this); CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this); - m_link_ptr_vector.insertAtBottom(net_link); - m_creditlink_ptr_vector.insertAtBottom(credit_link); + m_link_ptr_vector.push_back(net_link); + m_creditlink_ptr_vector.push_back(credit_link); m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link); m_ni_ptr_vector[dest]->addInPort(net_link, credit_link); @@ -195,8 +197,8 @@ void GarnetNetwork_d::makeInternalLink(SwitchID src, SwitchID dest, const NetDes { NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this); CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this); - m_link_ptr_vector.insertAtBottom(net_link); - m_creditlink_ptr_vector.insertAtBottom(credit_link); + m_link_ptr_vector.push_back(net_link); + m_creditlink_ptr_vector.push_back(credit_link); m_router_ptr_vector[dest]->addInPort(net_link, credit_link); m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link); @@ -244,8 +246,8 @@ Time GarnetNetwork_d::getRubyStartTime() void GarnetNetwork_d::printStats(ostream& out) const { double average_link_utilization = 0; - Vector<double > average_vc_load; - average_vc_load.setSize(m_virtual_networks*m_vcs_per_class); + vector<double> average_vc_load; + average_vc_load.resize(m_virtual_networks*m_vcs_per_class); for(int i = 0; i < m_virtual_networks*m_vcs_per_class; i++) { @@ -260,7 +262,7 @@ void GarnetNetwork_d::printStats(ostream& out) const { average_link_utilization += (double(m_link_ptr_vector[i]->getLinkUtilization())) / (double(g_eventQueue_ptr->getTime()-m_ruby_start)); - Vector<int > vc_load = m_link_ptr_vector[i]->getVcLoad(); + vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad(); for(int j = 0; j < vc_load.size(); j++) { assert(vc_load.size() == m_vcs_per_class*m_virtual_networks); diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh index 7cb87b21a..7f1b293f4 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh @@ -32,9 +32,9 @@ #define GARNETNETWORK_D_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" -#include "mem/gems_common/Vector.hh" #include "mem/ruby/network/garnet/BaseGarnetNetwork.hh" #include "mem/ruby/network/Network.hh" #include "params/GarnetNetwork_d.hh" @@ -112,16 +112,16 @@ private: int m_flits_recieved, m_flits_injected; double m_network_latency, m_queueing_latency; - Vector<bool> m_in_use; - Vector<bool> m_ordered; + std::vector<bool> m_in_use; + std::vector<bool> m_ordered; - Vector<Vector<MessageBuffer*> > m_toNetQueues; - Vector<Vector<MessageBuffer*> > m_fromNetQueues; + std::vector<std::vector<MessageBuffer*> > m_toNetQueues; + std::vector<std::vector<MessageBuffer*> > m_fromNetQueues; - Vector<Router_d *> m_router_ptr_vector; // All Routers in Network - Vector<NetworkLink_d *> m_link_ptr_vector; // All links in the network - Vector<CreditLink_d *> m_creditlink_ptr_vector; // All links in the network - Vector<NetworkInterface_d *> m_ni_ptr_vector; // All NI's in Network + std::vector<Router_d *> m_router_ptr_vector; // All Routers in Network + std::vector<NetworkLink_d *> m_link_ptr_vector; // All links in the network + std::vector<CreditLink_d *> m_creditlink_ptr_vector; // All links in the network + std::vector<NetworkInterface_d *> m_ni_ptr_vector; // All NI's in Network // Topology* m_topology_ptr; Time m_ruby_start; diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc index ea8f7789b..d41c3d4ee 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc @@ -28,10 +28,12 @@ * Authors: Niket Agarwal */ +#include "base/stl_helpers.hh" #include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" using namespace std; +using m5::stl_helpers::deletePointers; InputUnit_d::InputUnit_d(int id, Router_d *router) { @@ -44,7 +46,7 @@ InputUnit_d::InputUnit_d(int id, Router_d *router) creditQueue = new flitBuffer_d(); // Instantiating the virtual channels - m_vcs.setSize(m_num_vcs); + m_vcs.resize(m_num_vcs); for(int i=0; i < m_num_vcs; i++) { m_vcs[i] = new VirtualChannel_d(i); @@ -54,7 +56,7 @@ InputUnit_d::InputUnit_d(int id, Router_d *router) InputUnit_d::~InputUnit_d() { delete creditQueue; - m_vcs.deletePointers(); + deletePointers(m_vcs); } void InputUnit_d::wakeup() diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh index 05358bc8b..4f02729ed 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh @@ -32,11 +32,11 @@ #define INPUT_UNIT_D_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh" #include "mem/ruby/common/Consumer.hh" -#include "mem/gems_common/Vector.hh" #include "mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh" @@ -163,7 +163,7 @@ private: flitBuffer_d *creditQueue; // Virtual channels - Vector<VirtualChannel_d *> m_vcs; // [vc] + std::vector<VirtualChannel_d *> m_vcs; // [vc] }; #endif diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc index 2a2536d53..3cda065ad 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc @@ -30,11 +30,15 @@ #include <cmath> +#include "base/stl_helpers.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh" #include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh" #include "mem/ruby/slicc_interface/NetworkMessage.hh" +using namespace std; +using m5::stl_helpers::deletePointers; + NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwork_d *network_ptr) { m_id = id; @@ -44,10 +48,10 @@ NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwo m_num_vcs = m_vc_per_vnet*m_virtual_networks; m_vc_round_robin = 0; - m_ni_buffers.setSize(m_num_vcs); - m_ni_enqueue_time.setSize(m_num_vcs); - inNode_ptr.setSize(m_virtual_networks); - outNode_ptr.setSize(m_virtual_networks); + m_ni_buffers.resize(m_num_vcs); + m_ni_enqueue_time.resize(m_num_vcs); + inNode_ptr.resize(m_virtual_networks); + outNode_ptr.resize(m_virtual_networks); creditQueue = new flitBuffer_d(); for(int i =0; i < m_num_vcs; i++) @@ -55,7 +59,7 @@ NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwo m_ni_buffers[i] = new flitBuffer_d(); // instantiating the NI flit buffers m_ni_enqueue_time[i] = INFINITE_; } - m_vc_allocator.setSize(m_virtual_networks); // 1 allocator per virtual net + m_vc_allocator.resize(m_virtual_networks); // 1 allocator per virtual net for(int i = 0; i < m_virtual_networks; i++) { m_vc_allocator[i] = 0; @@ -63,15 +67,15 @@ NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwo for(int i = 0; i < m_num_vcs; i++) { - m_out_vc_state.insertAtBottom(new OutVcState_d(i, m_net_ptr)); + m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr)); m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); } } NetworkInterface_d::~NetworkInterface_d() { - m_out_vc_state.deletePointers(); - m_ni_buffers.deletePointers(); + deletePointers(m_out_vc_state); + deletePointers(m_ni_buffers); delete creditQueue; delete outSrcQueue; } @@ -94,7 +98,7 @@ void NetworkInterface_d::addOutPort(NetworkLink_d *out_link, CreditLink_d *credi out_link->setSourceQueue(outSrcQueue); } -void NetworkInterface_d::addNode(Vector<MessageBuffer*>& in, Vector<MessageBuffer*>& out) +void NetworkInterface_d::addNode(vector<MessageBuffer*>& in, vector<MessageBuffer*>& out) { ASSERT(in.size() == m_virtual_networks); inNode_ptr = in; @@ -110,7 +114,7 @@ bool NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet) NetworkMessage *net_msg_ptr = safe_cast<NetworkMessage *>(msg_ptr.get()); NetDest net_msg_dest = net_msg_ptr->getInternalDestination(); - Vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message. + vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message. int num_flits = (int) ceil((double) m_net_ptr->MessageSizeType_to_int(net_msg_ptr->getMessageSize())/m_net_ptr->getFlitSize() ); // Number of flits is dependent on the link bandwidth available. This is expressed in terms of bytes/cycle or the flit size diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh index 88d882969..0da162f82 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh @@ -32,10 +32,10 @@ #define NET_INTERFACE_D_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh" -#include "mem/gems_common/Vector.hh" #include "mem/ruby/common/Consumer.hh" #include "mem/ruby/slicc_interface/Message.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh" @@ -56,7 +56,8 @@ public: void addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link); void wakeup(); - void addNode(Vector<MessageBuffer *> &inNode, Vector<MessageBuffer *> &outNode); + void addNode(std::vector<MessageBuffer *> &inNode, + std::vector<MessageBuffer *> &outNode); void printConfig(std::ostream& out) const; void print(std::ostream& out) const; int get_vnet(int vc); @@ -66,8 +67,8 @@ private: GarnetNetwork_d *m_net_ptr; int m_virtual_networks, m_num_vcs, m_vc_per_vnet; NodeID m_id; - Vector<OutVcState_d *> m_out_vc_state; - Vector<int > m_vc_allocator; + std::vector<OutVcState_d *> m_out_vc_state; + std::vector<int > m_vc_allocator; int m_vc_round_robin; // For round robin scheduling flitBuffer_d *outSrcQueue; // For modelling link contention flitBuffer_d *creditQueue; @@ -78,11 +79,11 @@ private: CreditLink_d *m_ni_credit_link; // Input Flit Buffers - Vector<flitBuffer_d *> m_ni_buffers; // The flit buffers which will serve the Consumer - Vector<Time > m_ni_enqueue_time; + std::vector<flitBuffer_d *> m_ni_buffers; // The flit buffers which will serve the Consumer + std::vector<Time > m_ni_enqueue_time; - Vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol - Vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol + std::vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol + std::vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol bool flitisizeMessage(MsgPtr msg_ptr, int vnet); int calculateVC(int vnet); diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc index 92b2d44f8..b45a7be06 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc @@ -40,7 +40,7 @@ NetworkLink_d::NetworkLink_d(int id) linkBuffer = new flitBuffer_d(); m_link_utilized = 0; - m_vc_load.setSize(NetworkConfig::getVCsPerClass()*RubySystem::getNetwork()->getNumberOfVirtualNetworks()); + m_vc_load.resize(NetworkConfig::getVCsPerClass()*RubySystem::getNetwork()->getNumberOfVirtualNetworks()); for(int i = 0; i < NetworkConfig::getVCsPerClass()*RubySystem::getNetwork()->getNumberOfVirtualNetworks(); i++) m_vc_load[i] = 0; @@ -53,7 +53,7 @@ NetworkLink_d::NetworkLink_d(int id, int link_latency, GarnetNetwork_d *net_ptr) m_latency = link_latency; linkBuffer = new flitBuffer_d(); m_link_utilized = 0; - m_vc_load.setSize(m_net_ptr->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks()); + m_vc_load.resize(m_net_ptr->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks()); for(int i = 0; i < m_net_ptr->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks(); i++) m_vc_load[i] = 0; @@ -87,7 +87,7 @@ void NetworkLink_d::wakeup() } } -Vector<int> NetworkLink_d::getVcLoad() +std::vector<int> NetworkLink_d::getVcLoad() { return m_vc_load; } diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh index c5f9f14d1..29699562d 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh @@ -32,6 +32,7 @@ #define NETWORK_LINK_D_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/common/Consumer.hh" @@ -51,7 +52,7 @@ public: void setSourceQueue(flitBuffer_d *srcQueue); void print(std::ostream& out) const{} int getLinkUtilization(); - Vector<int> getVcLoad(); + std::vector<int> getVcLoad(); int get_id(){return m_id;} void wakeup(); @@ -80,7 +81,7 @@ protected: Consumer *link_consumer; flitBuffer_d *link_srcQueue; int m_link_utilized; - Vector<int > m_vc_load; + std::vector<int> m_vc_load; int m_flit_width; }; diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc index 99475cf69..6e0508e75 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc @@ -28,10 +28,12 @@ * Authors: Niket Agarwal */ +#include "base/stl_helpers.hh" #include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" using namespace std; +using m5::stl_helpers::deletePointers; OutputUnit_d::OutputUnit_d(int id, Router_d *router) { @@ -42,14 +44,14 @@ OutputUnit_d::OutputUnit_d(int id, Router_d *router) for(int i = 0; i < m_num_vcs; i++) { - m_outvc_state.insertAtBottom(new OutVcState_d(i, m_router->get_net_ptr())); + m_outvc_state.push_back(new OutVcState_d(i, m_router->get_net_ptr())); } } OutputUnit_d::~OutputUnit_d() { delete m_out_buffer; - m_outvc_state.deletePointers(); + deletePointers(m_outvc_state); } void OutputUnit_d::decrement_credit(int out_vc) diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh index 93cfd9d12..3daf8a76c 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh @@ -32,6 +32,7 @@ #define OUTPUT_UNIT_D_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/common/Consumer.hh" @@ -85,7 +86,7 @@ private: CreditLink_d *m_credit_link; flitBuffer_d *m_out_buffer; // This is for the network link to consume - Vector<OutVcState_d *> m_outvc_state; // vc state of downstream router + std::vector<OutVcState_d *> m_outvc_state; // vc state of downstream router }; diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc index 428ba3260..e7b766dd7 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc @@ -28,6 +28,7 @@ * Authors: Niket Agarwal */ +#include "base/stl_helpers.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh" @@ -40,6 +41,7 @@ #include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh" using namespace std; +using m5::stl_helpers::deletePointers; Router_d::Router_d(int id, GarnetNetwork_d *network_ptr) { @@ -69,8 +71,8 @@ Router_d::Router_d(int id, GarnetNetwork_d *network_ptr) Router_d::~Router_d() { - m_input_unit.deletePointers(); - m_output_unit.deletePointers(); + deletePointers(m_input_unit); + deletePointers(m_output_unit); delete m_routing_unit; delete m_vc_alloc; delete m_sw_alloc; @@ -94,7 +96,7 @@ void Router_d::addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link) in_link->setLinkConsumer(input_unit); credit_link->setSourceQueue(input_unit->getCreditQueue()); - m_input_unit.insertAtBottom(input_unit); + m_input_unit.push_back(input_unit); } void Router_d::addOutPort(NetworkLink_d *out_link, const NetDest& routing_table_entry, int link_weight, CreditLink_d *credit_link) @@ -107,7 +109,7 @@ void Router_d::addOutPort(NetworkLink_d *out_link, const NetDest& routing_table_ credit_link->setLinkConsumer(output_unit); out_link->setSourceQueue(output_unit->getOutQueue()); - m_output_unit.insertAtBottom(output_unit); + m_output_unit.push_back(output_unit); m_routing_unit->addRoute(routing_table_entry); m_routing_unit->addWeight(link_weight); diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh index 91f79882c..f1b1e26aa 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh @@ -32,9 +32,9 @@ #define ROUTER_D_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" -#include "mem/gems_common/Vector.hh" #include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh" #include "mem/ruby/common/NetDest.hh" #include "mem/ruby/network/orion/power_router_init.hh" @@ -66,8 +66,8 @@ public: int get_id() { return m_id; } GarnetNetwork_d* get_net_ptr() { return m_network_ptr; } - Vector<InputUnit_d *>& get_inputUnit_ref() { return m_input_unit; } - Vector<OutputUnit_d *>& get_outputUnit_ref() { return m_output_unit; } + std::vector<InputUnit_d *>& get_inputUnit_ref() { return m_input_unit; } + std::vector<OutputUnit_d *>& get_outputUnit_ref() { return m_output_unit; } void update_sw_winner(int inport, flit_d *t_flit); void update_incredit(int in_port, int in_vc, int credit); @@ -88,8 +88,8 @@ private: double buf_read_count, buf_write_count, crossbar_count, vc_local_arbit_count, vc_global_arbit_count, sw_local_arbit_count, sw_global_arbit_count; - Vector<InputUnit_d *> m_input_unit; - Vector<OutputUnit_d *> m_output_unit; + std::vector<InputUnit_d *> m_input_unit; + std::vector<OutputUnit_d *> m_output_unit; RoutingUnit_d *m_routing_unit; VCallocator_d *m_vc_alloc; SWallocator_d *m_sw_alloc; diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.cc index fabda735a..a152c35d7 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.cc @@ -42,12 +42,12 @@ RoutingUnit_d::RoutingUnit_d(Router_d *router) void RoutingUnit_d::addRoute(const NetDest& routing_table_entry) { - m_routing_table.insertAtBottom(routing_table_entry); + m_routing_table.push_back(routing_table_entry); } void RoutingUnit_d::addWeight(int link_weight) { - m_weight_table.insertAtBottom(link_weight); + m_weight_table.push_back(link_weight); } void RoutingUnit_d::RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc) diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.hh index 9688623a7..409eb70f9 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.hh @@ -49,8 +49,8 @@ public: private: Router_d *m_router; - Vector<NetDest > m_routing_table; - Vector<int > m_weight_table; + std::vector<NetDest > m_routing_table; + std::vector<int > m_weight_table; }; #endif diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.cc index 4d607619f..c72a66189 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.cc @@ -51,10 +51,10 @@ void SWallocator_d::init() m_num_inports = m_router->get_num_inports(); m_num_outports = m_router->get_num_outports(); - m_round_robin_outport.setSize(m_num_outports); - m_round_robin_inport.setSize(m_num_inports); - m_port_req.setSize(m_num_outports); - m_vc_winners.setSize(m_num_outports); + m_round_robin_outport.resize(m_num_outports); + m_round_robin_inport.resize(m_num_inports); + m_port_req.resize(m_num_outports); + m_vc_winners.resize(m_num_outports); for(int i = 0; i < m_num_inports; i++) { @@ -63,8 +63,8 @@ void SWallocator_d::init() for(int i = 0; i < m_num_outports; i++) { - m_port_req[i].setSize(m_num_inports); - m_vc_winners[i].setSize(m_num_inports); + m_port_req[i].resize(m_num_inports); + m_vc_winners[i].resize(m_num_inports); m_round_robin_outport[i] = 0; diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh index 95a7dad1c..db175e445 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh @@ -32,6 +32,7 @@ #define SW_ALLOCATOR_D_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/common/Consumer.hh" @@ -68,12 +69,12 @@ private: double m_local_arbiter_activity, m_global_arbiter_activity; Router_d *m_router; - Vector<int > m_round_robin_outport; - Vector<int > m_round_robin_inport; - Vector<Vector<bool > > m_port_req; - Vector<Vector<int > > m_vc_winners; // a list for each outport - Vector<InputUnit_d *> m_input_unit; - Vector<OutputUnit_d *> m_output_unit; + std::vector<int> m_round_robin_outport; + std::vector<int> m_round_robin_inport; + std::vector<std::vector<bool> > m_port_req; + std::vector<std::vector<int> > m_vc_winners; // a list for each outport + std::vector<InputUnit_d *> m_input_unit; + std::vector<OutputUnit_d *> m_output_unit; }; #endif diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.cc index 9b999341d..22ec2c1f4 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.cc @@ -28,10 +28,13 @@ * Authors: Niket Agarwal */ +#include "base/stl_helpers.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh" +using m5::stl_helpers::deletePointers; + Switch_d::Switch_d(Router_d *router) { m_router = router; @@ -41,7 +44,7 @@ Switch_d::Switch_d(Router_d *router) Switch_d::~Switch_d() { - m_switch_buffer.deletePointers(); + deletePointers(m_switch_buffer); } void Switch_d::init() @@ -49,7 +52,7 @@ void Switch_d::init() m_output_unit = m_router->get_outputUnit_ref(); m_num_inports = m_router->get_num_inports(); - m_switch_buffer.setSize(m_num_inports); + m_switch_buffer.resize(m_num_inports); for(int i = 0; i < m_num_inports; i++) { m_switch_buffer[i] = new flitBuffer_d(); diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh index 09973b82d..83817b353 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh @@ -32,6 +32,7 @@ #define SWITCH_D_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/common/Consumer.hh" @@ -63,8 +64,8 @@ private: int m_num_inports; double m_crossbar_activity; Router_d *m_router; - Vector<flitBuffer_d *> m_switch_buffer; - Vector<OutputUnit_d *> m_output_unit; + std::vector<flitBuffer_d *> m_switch_buffer; + std::vector<OutputUnit_d *> m_output_unit; }; #endif diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc index e08c70769..af1c608eb 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc @@ -50,14 +50,14 @@ void VCallocator_d::init() m_num_inports = m_router->get_num_inports(); m_num_outports = m_router->get_num_outports(); - m_round_robin_invc.setSize(m_num_inports); - m_round_robin_outvc.setSize(m_num_outports); - m_outvc_req.setSize(m_num_outports); - m_outvc_is_req.setSize(m_num_outports); + m_round_robin_invc.resize(m_num_inports); + m_round_robin_outvc.resize(m_num_outports); + m_outvc_req.resize(m_num_outports); + m_outvc_is_req.resize(m_num_outports); for(int i = 0; i < m_num_inports; i++) { - m_round_robin_invc[i].setSize(m_num_vcs); + m_round_robin_invc[i].resize(m_num_vcs); for(int j = 0; j < m_num_vcs; j++) { @@ -67,9 +67,9 @@ void VCallocator_d::init() for(int i = 0; i < m_num_outports; i++) { - m_round_robin_outvc[i].setSize(m_num_vcs); - m_outvc_req[i].setSize(m_num_vcs); - m_outvc_is_req[i].setSize(m_num_vcs); + m_round_robin_outvc[i].resize(m_num_vcs); + m_outvc_req[i].resize(m_num_vcs); + m_outvc_is_req[i].resize(m_num_vcs); for(int j = 0; j < m_num_vcs; j++) { @@ -77,11 +77,11 @@ void VCallocator_d::init() m_round_robin_outvc[i][j].second = 0; m_outvc_is_req[i][j] = false; - m_outvc_req[i][j].setSize(m_num_inports); + m_outvc_req[i][j].resize(m_num_inports); for(int k = 0; k < m_num_inports; k++) { - m_outvc_req[i][j][k].setSize(m_num_vcs); + m_outvc_req[i][j][k].resize(m_num_vcs); for(int l = 0; l < m_num_vcs; l++) { m_outvc_req[i][j][k][l] = false; diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh index c6d06d1ae..942a3c6b0 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh @@ -32,6 +32,7 @@ #define VC_ALLOCATOR_D_H #include <iostream> +#include <vector> #include <utility> #include "mem/ruby/network/garnet/NetworkHeader.hh" @@ -71,13 +72,13 @@ private: double m_local_arbiter_activity, m_global_arbiter_activity; Router_d *m_router; - Vector<Vector <int > > m_round_robin_invc; // First stage of arbitration where all vcs select an output vc to content for - Vector<Vector <std::pair<int, int> > > m_round_robin_outvc; // Arbiter for every output vc - Vector<Vector<Vector<Vector<bool > > > > m_outvc_req; // [outport][outvc][inpotr][invc]. set true in the first phase of allocation - Vector<Vector<bool > > m_outvc_is_req; + std::vector<std::vector<int > > m_round_robin_invc; // First stage of arbitration where all vcs select an output vc to content for + std::vector<std::vector<std::pair<int, int> > > m_round_robin_outvc; // Arbiter for every output vc + std::vector<std::vector<std::vector<std::vector<bool> > > > m_outvc_req; // [outport][outvc][inpotr][invc]. set true in the first phase of allocation + std::vector<std::vector<bool> > m_outvc_is_req; - Vector<InputUnit_d *> m_input_unit ; - Vector<OutputUnit_d *> m_output_unit ; + std::vector<InputUnit_d *> m_input_unit ; + std::vector<OutputUnit_d *> m_output_unit ; }; diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc index e063e6a0e..232898c52 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc +++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc @@ -28,6 +28,7 @@ * Authors: Niket Agarwal */ +#include "base/stl_helpers.hh" #include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh" #include "mem/protocol/MachineType.hh" #include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh" @@ -40,6 +41,7 @@ #include "mem/ruby/common/NetDest.hh" using namespace std; +using m5::stl_helpers::deletePointers; GarnetNetwork::GarnetNetwork(const Params *p) : BaseGarnetNetwork(p) @@ -47,10 +49,10 @@ GarnetNetwork::GarnetNetwork(const Params *p) m_ruby_start = 0; // Allocate to and from queues - m_toNetQueues.setSize(m_nodes); // Queues that are getting messages from protocol - m_fromNetQueues.setSize(m_nodes); // Queues that are feeding the protocol - m_in_use.setSize(m_virtual_networks); - m_ordered.setSize(m_virtual_networks); + m_toNetQueues.resize(m_nodes); // Queues that are getting messages from protocol + m_fromNetQueues.resize(m_nodes); // Queues that are feeding the protocol + m_in_use.resize(m_virtual_networks); + m_ordered.resize(m_virtual_networks); for (int i = 0; i < m_virtual_networks; i++) { m_in_use[i] = false; @@ -60,8 +62,8 @@ GarnetNetwork::GarnetNetwork(const Params *p) for (int node = 0; node < m_nodes; node++) { //Setting how many vitual message buffers will there be per Network Queue - m_toNetQueues[node].setSize(m_virtual_networks); - m_fromNetQueues[node].setSize(m_virtual_networks); + m_toNetQueues[node].resize(m_virtual_networks); + m_fromNetQueues[node].resize(m_virtual_networks); for (int j = 0; j < m_virtual_networks; j++) { @@ -80,13 +82,13 @@ void GarnetNetwork::init() int number_of_routers = m_topology_ptr->numSwitches(); for (int i=0; i<number_of_routers; i++) { - m_router_ptr_vector.insertAtBottom(new Router(i, this)); + m_router_ptr_vector.push_back(new Router(i, this)); } for (int i=0; i < m_nodes; i++) { NetworkInterface *ni = new NetworkInterface(i, m_virtual_networks, this); ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]); - m_ni_ptr_vector.insertAtBottom(ni); + m_ni_ptr_vector.push_back(ni); } m_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration } @@ -95,12 +97,12 @@ GarnetNetwork::~GarnetNetwork() { for (int i = 0; i < m_nodes; i++) { - m_toNetQueues[i].deletePointers(); - m_fromNetQueues[i].deletePointers(); + deletePointers(m_toNetQueues[i]); + deletePointers(m_fromNetQueues[i]); } - m_router_ptr_vector.deletePointers(); - m_ni_ptr_vector.deletePointers(); - m_link_ptr_vector.deletePointers(); + deletePointers(m_router_ptr_vector); + deletePointers(m_ni_ptr_vector); + deletePointers(m_link_ptr_vector); delete m_topology_ptr; } @@ -123,7 +125,7 @@ void GarnetNetwork::makeInLink(NodeID src, SwitchID dest, const NetDest& routing if(!isReconfiguration) { NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this); - m_link_ptr_vector.insertAtBottom(net_link); + m_link_ptr_vector.push_back(net_link); m_router_ptr_vector[dest]->addInPort(net_link); m_ni_ptr_vector[src]->addOutPort(net_link); } @@ -143,7 +145,7 @@ void GarnetNetwork::makeOutLink(SwitchID src, NodeID dest, const NetDest& routin if(!isReconfiguration) { NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this); - m_link_ptr_vector.insertAtBottom(net_link); + m_link_ptr_vector.push_back(net_link); m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight); m_ni_ptr_vector[dest]->addInPort(net_link); } @@ -159,7 +161,7 @@ void GarnetNetwork::makeInternalLink(SwitchID src, SwitchID dest, const NetDest& if(!isReconfiguration) { NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this); - m_link_ptr_vector.insertAtBottom(net_link); + m_link_ptr_vector.push_back(net_link); m_router_ptr_vector[dest]->addInPort(net_link); m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight); } @@ -208,8 +210,8 @@ Time GarnetNetwork::getRubyStartTime() void GarnetNetwork::printStats(ostream& out) const { double average_link_utilization = 0; - Vector<double > average_vc_load; - average_vc_load.setSize(m_virtual_networks*m_vcs_per_class); + std::vector<double> average_vc_load; + average_vc_load.resize(m_virtual_networks*m_vcs_per_class); for(int i = 0; i < m_virtual_networks*m_vcs_per_class; i++) { @@ -223,7 +225,7 @@ void GarnetNetwork::printStats(ostream& out) const for(int i = 0; i < m_link_ptr_vector.size(); i++) { average_link_utilization += m_link_ptr_vector[i]->getLinkUtilization(); - Vector<int > vc_load = m_link_ptr_vector[i]->getVcLoad(); + std::vector<int> vc_load = m_link_ptr_vector[i]->getVcLoad(); for(int j = 0; j < vc_load.size(); j++) { assert(vc_load.size() == m_vcs_per_class*m_virtual_networks); diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh index c116a324b..62857223e 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh +++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh @@ -32,10 +32,10 @@ #define GARNET_NETWORK_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/BaseGarnetNetwork.hh" -#include "mem/gems_common/Vector.hh" #include "mem/ruby/network/Network.hh" #include "params/GarnetNetwork.hh" @@ -89,15 +89,15 @@ private: // int m_virtual_networks; // int m_nodes; - Vector<bool> m_in_use; - Vector<bool> m_ordered; + std::vector<bool> m_in_use; + std::vector<bool> m_ordered; - Vector<Vector<MessageBuffer*> > m_toNetQueues; - Vector<Vector<MessageBuffer*> > m_fromNetQueues; + std::vector<std::vector<MessageBuffer*> > m_toNetQueues; + std::vector<std::vector<MessageBuffer*> > m_fromNetQueues; - Vector<Router *> m_router_ptr_vector; // All Routers in Network - Vector<NetworkLink *> m_link_ptr_vector; // All links in the network - Vector<NetworkInterface *> m_ni_ptr_vector; // All NI's in Network + std::vector<Router *> m_router_ptr_vector; // All Routers in Network + std::vector<NetworkLink *> m_link_ptr_vector; // All links in the network + std::vector<NetworkInterface *> m_ni_ptr_vector; // All NI's in Network // Topology* m_topology_ptr; Time m_ruby_start; diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc index c81f5e4b2..b233ca0f5 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc +++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc @@ -30,11 +30,15 @@ #include <cmath> +#include "base/stl_helpers.hh" #include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh" #include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh" #include "mem/ruby/slicc_interface/NetworkMessage.hh" +using namespace std; +using m5::stl_helpers::deletePointers; + NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork *network_ptr) { m_id = id; @@ -44,14 +48,14 @@ NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork * m_num_vcs = m_vc_per_vnet*m_virtual_networks; m_vc_round_robin = 0; - m_ni_buffers.setSize(m_num_vcs); - inNode_ptr.setSize(m_virtual_networks); - outNode_ptr.setSize(m_virtual_networks); + m_ni_buffers.resize(m_num_vcs); + inNode_ptr.resize(m_virtual_networks); + outNode_ptr.resize(m_virtual_networks); for(int i =0; i < m_num_vcs; i++) m_ni_buffers[i] = new flitBuffer(); // instantiating the NI flit buffers - m_vc_allocator.setSize(m_virtual_networks); + m_vc_allocator.resize(m_virtual_networks); for(int i = 0; i < m_virtual_networks; i++) { m_vc_allocator[i] = 0; @@ -59,15 +63,15 @@ NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork * for(int i = 0; i < m_num_vcs; i++) { - m_out_vc_state.insertAtBottom(new OutVcState(i)); + m_out_vc_state.push_back(new OutVcState(i)); m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); } } NetworkInterface::~NetworkInterface() { - m_out_vc_state.deletePointers(); - m_ni_buffers.deletePointers(); + deletePointers(m_out_vc_state); + deletePointers(m_ni_buffers); delete outSrcQueue; } @@ -85,7 +89,7 @@ void NetworkInterface::addOutPort(NetworkLink *out_link) out_link->setSource(this); } -void NetworkInterface::addNode(Vector<MessageBuffer*>& in, Vector<MessageBuffer*>& out) +void NetworkInterface::addNode(vector<MessageBuffer*>& in, vector<MessageBuffer*>& out) { ASSERT(in.size() == m_virtual_networks); inNode_ptr = in; @@ -106,7 +110,7 @@ bool NetworkInterface::flitisizeMessage(MsgPtr msg_ptr, int vnet) NetworkMessage *net_msg_ptr = safe_cast<NetworkMessage*>(msg_ptr.get()); NetDest net_msg_dest = net_msg_ptr->getInternalDestination(); - Vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message. + vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message. int num_flits = (int) ceil((double) m_net_ptr->MessageSizeType_to_int(net_msg_ptr->getMessageSize())/m_net_ptr->getFlitSize() ); // Number of flits is dependent on the link bandwidth available. This is expressed in terms of bytes/cycle or the flit size for(int ctr = 0; ctr < dest_nodes.size(); ctr++) // loop because we will be converting all multicast messages into unicast messages diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh index bc2701125..01608498d 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh +++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh @@ -32,10 +32,10 @@ #define NET_INTERFACE_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh" -#include "mem/gems_common/Vector.hh" #include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh" #include "mem/ruby/slicc_interface/Message.hh" #include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh" @@ -55,7 +55,7 @@ public: void addOutPort(NetworkLink *out_link); void wakeup(); - void addNode(Vector<MessageBuffer *> &inNode, Vector<MessageBuffer *> &outNode); + void addNode(std::vector<MessageBuffer *> &inNode, std::vector<MessageBuffer *> &outNode); void grant_vc(int out_port, int vc, Time grant_time); void release_vc(int out_port, int vc, Time release_time); bool isBufferNotFull(int vc, int inport) @@ -73,8 +73,8 @@ private: int m_virtual_networks, m_num_vcs, m_vc_per_vnet; NodeID m_id; - Vector<OutVcState *> m_out_vc_state; - Vector<int > m_vc_allocator; + std::vector<OutVcState *> m_out_vc_state; + std::vector<int> m_vc_allocator; int m_vc_round_robin; // For round robin scheduling flitBuffer *outSrcQueue; // For modelling link contention @@ -82,10 +82,10 @@ private: NetworkLink *outNetLink; // Input Flit Buffers - Vector<flitBuffer *> m_ni_buffers; // The flit buffers which will serve the Consumer + std::vector<flitBuffer *> m_ni_buffers; // The flit buffers which will serve the Consumer - Vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol - Vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol + std::vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol + std::vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol bool flitisizeMessage(MsgPtr msg_ptr, int vnet); int calculateVC(int vnet); diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc index 6e106137a..2947ce8ec 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc +++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc @@ -42,7 +42,7 @@ NetworkLink::NetworkLink(int id, int latency, GarnetNetwork *net_ptr) m_latency = latency; int num_net = net_ptr->getNumberOfVirtualNetworks(); int num_vc = m_net_ptr->getVCsPerClass(); - m_vc_load.setSize(num_net*num_vc); + m_vc_load.resize(num_net * num_vc); for(int i = 0; i < num_net*num_vc; i++) m_vc_load[i] = 0; @@ -91,7 +91,7 @@ void NetworkLink::release_vc_link(int vc, Time release_time) link_source->release_vc(m_out_port, vc, release_time); } -Vector<int> NetworkLink::getVcLoad() +std::vector<int> NetworkLink::getVcLoad() { return m_vc_load; } diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh index 3f648ae14..c23d55b48 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh +++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh @@ -32,6 +32,7 @@ #define NETWORK_LINK_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh" @@ -67,13 +68,13 @@ public: bool isBufferNotFull_link(int vc); void setSource(FlexibleConsumer *source); double getLinkUtilization(); - Vector<int> getVcLoad(); + std::vector<int> getVcLoad(); protected: int m_id, m_latency; int m_in_port, m_out_port; int m_link_utilized; - Vector<int > m_vc_load; + std::vector<int> m_vc_load; GarnetNetwork *m_net_ptr; flitBuffer *linkBuffer; diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc b/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc index 4cdb9dad8..95b92d49d 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc +++ b/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc @@ -28,6 +28,7 @@ * Authors: Niket Agarwal */ +#include "base/stl_helpers.hh" #include "mem/ruby/network/garnet/flexible-pipeline/Router.hh" #include "mem/ruby/slicc_interface/NetworkMessage.hh" #include "mem/ruby/network/garnet/flexible-pipeline/InVcState.hh" @@ -35,6 +36,7 @@ #include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh" using namespace std; +using m5::stl_helpers::deletePointers; Router::Router(int id, GarnetNetwork *network_ptr) { @@ -52,14 +54,14 @@ Router::~Router() { for (int i = 0; i < m_in_link.size(); i++) { - m_in_vc_state[i].deletePointers(); + deletePointers(m_in_vc_state[i]); } for (int i = 0; i < m_out_link.size(); i++) { - m_out_vc_state[i].deletePointers(); - m_router_buffers[i].deletePointers(); + deletePointers(m_out_vc_state[i]); + deletePointers(m_router_buffers[i]); } - m_out_src_queue.deletePointers(); + deletePointers(m_out_src_queue); delete m_vc_arbiter; } @@ -67,19 +69,19 @@ Router::~Router() void Router::addInPort(NetworkLink *in_link) { int port = m_in_link.size(); - Vector<InVcState *> in_vc_vector; + vector<InVcState *> in_vc_vector; for(int i = 0; i < m_num_vcs; i++) { - in_vc_vector.insertAtBottom(new InVcState(i)); + in_vc_vector.push_back(new InVcState(i)); in_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); } - m_in_vc_state.insertAtBottom(in_vc_vector); - m_in_link.insertAtBottom(in_link); + m_in_vc_state.push_back(in_vc_vector); + m_in_link.push_back(in_link); in_link->setLinkConsumer(this); in_link->setInPort(port); int start = 0; - m_round_robin_invc.insertAtBottom(start); + m_round_robin_invc.push_back(start); } @@ -88,30 +90,30 @@ void Router::addOutPort(NetworkLink *out_link, const NetDest& routing_table_entr int port = m_out_link.size(); out_link->setOutPort(port); int start = 0; - m_vc_round_robin.insertAtBottom(start); + m_vc_round_robin.push_back(start); - m_out_src_queue.insertAtBottom(new flitBuffer()); + m_out_src_queue.push_back(new flitBuffer()); - m_out_link.insertAtBottom(out_link); - m_routing_table.insertAtBottom(routing_table_entry); + m_out_link.push_back(out_link); + m_routing_table.push_back(routing_table_entry); out_link->setSourceQueue(m_out_src_queue[port]); out_link->setSource(this); - Vector<flitBuffer *> intermediateQueues; + vector<flitBuffer *> intermediateQueues; for(int i = 0; i < m_num_vcs; i++) { - intermediateQueues.insertAtBottom(new flitBuffer(m_net_ptr->getBufferSize())); + intermediateQueues.push_back(new flitBuffer(m_net_ptr->getBufferSize())); } - m_router_buffers.insertAtBottom(intermediateQueues); + m_router_buffers.push_back(intermediateQueues); - Vector<OutVcState *> out_vc_vector; + vector<OutVcState *> out_vc_vector; for(int i = 0; i < m_num_vcs; i++) { - out_vc_vector.insertAtBottom(new OutVcState(i)); + out_vc_vector.push_back(new OutVcState(i)); out_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); } - m_out_vc_state.insertAtBottom(out_vc_vector); - m_link_weights.insertAtBottom(link_weight); + m_out_vc_state.push_back(out_vc_vector); + m_link_weights.push_back(link_weight); } bool Router::isBufferNotFull(int vc, int inport) @@ -164,7 +166,7 @@ void Router::vc_arbitrate() if(in_vc_state->isInState(VC_AB_, g_eventQueue_ptr->getTime())) { int outport = in_vc_state->get_outport(); - Vector<int > valid_vcs = get_valid_vcs(invc); + vector<int> valid_vcs = get_valid_vcs(invc); for(int valid_vc_iter = 0; valid_vc_iter < valid_vcs.size(); valid_vc_iter++) { if(m_out_vc_state[outport][valid_vcs[valid_vc_iter]]->isInState(IDLE_, g_eventQueue_ptr->getTime())) @@ -180,9 +182,9 @@ void Router::vc_arbitrate() } } -Vector<int > Router::get_valid_vcs(int invc) +vector<int> Router::get_valid_vcs(int invc) { - Vector<int > vc_list; + vector<int> vc_list; for(int vnet = 0; vnet < m_virtual_networks; vnet++) { @@ -197,7 +199,7 @@ Vector<int > Router::get_valid_vcs(int invc) for(int offset = 0; offset < vc_per_vnet; offset++) { - vc_list.insertAtBottom(base+offset); + vc_list.push_back(base+offset); } break; } diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/Router.hh b/src/mem/ruby/network/garnet/flexible-pipeline/Router.hh index 5d2610fae..b6ebb601f 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/Router.hh +++ b/src/mem/ruby/network/garnet/flexible-pipeline/Router.hh @@ -32,6 +32,7 @@ #define ROUTER_H #include <iostream> +#include <vector> #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh" @@ -68,23 +69,23 @@ private: int m_id; int m_virtual_networks, m_num_vcs, m_vc_per_vnet; GarnetNetwork *m_net_ptr; - Vector<int > m_vc_round_robin; // For scheduling of out source queues + std::vector<int> m_vc_round_robin; // For scheduling of out source queues int m_round_robin_inport, m_round_robin_start; // for vc arbitration - Vector<int > m_round_robin_invc; // For every outport. for vc arbitration + std::vector<int> m_round_robin_invc; // For every outport. for vc arbitration - Vector<Vector<flitBuffer *> > m_router_buffers; // These are essentially output buffers - Vector<flitBuffer *> m_out_src_queue; // These are source queues for the output link - Vector<NetworkLink *> m_in_link; - Vector<NetworkLink *> m_out_link; - Vector<Vector<InVcState * > > m_in_vc_state; - Vector<Vector<OutVcState * > > m_out_vc_state; - Vector<NetDest> m_routing_table; - Vector<int > m_link_weights; + std::vector<std::vector<flitBuffer *> > m_router_buffers; // These are essentially output buffers + std::vector<flitBuffer *> m_out_src_queue; // These are source queues for the output link + std::vector<NetworkLink *> m_in_link; + std::vector<NetworkLink *> m_out_link; + std::vector<std::vector<InVcState *> > m_in_vc_state; + std::vector<std::vector<OutVcState *> > m_out_vc_state; + std::vector<NetDest> m_routing_table; + std::vector<int> m_link_weights; VCarbiter *m_vc_arbiter; /*********** Private methods *************/ int getRoute(NetDest destination); - Vector<int > get_valid_vcs(int invc); + std::vector<int> get_valid_vcs(int invc); void routeCompute(flit *m_flit, int inport); void checkReschedule(); void check_arbiter_reschedule(); diff --git a/src/mem/ruby/network/simple/PerfectSwitch.cc b/src/mem/ruby/network/simple/PerfectSwitch.cc index 8e6114ba9..5a1ee32ec 100644 --- a/src/mem/ruby/network/simple/PerfectSwitch.cc +++ b/src/mem/ruby/network/simple/PerfectSwitch.cc @@ -26,6 +26,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <algorithm> + #include "mem/protocol/Protocol.hh" #include "mem/ruby/buffers/MessageBuffer.hh" #include "mem/ruby/network/simple/PerfectSwitch.hh" @@ -55,11 +57,11 @@ PerfectSwitch::PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr) } void -PerfectSwitch::addInPort(const Vector<MessageBuffer*>& in) +PerfectSwitch::addInPort(const vector<MessageBuffer*>& in) { assert(in.size() == m_virtual_networks); NodeID port = m_in.size(); - m_in.insertAtBottom(in); + m_in.push_back(in); for (int j = 0; j < m_virtual_networks; j++) { m_in[port][j]->setConsumer(this); string desc = csprintf("[Queue from port %s %s %s to PerfectSwitch]", @@ -70,7 +72,7 @@ PerfectSwitch::addInPort(const Vector<MessageBuffer*>& in) } void -PerfectSwitch::addOutPort(const Vector<MessageBuffer*>& out, +PerfectSwitch::addOutPort(const vector<MessageBuffer*>& out, const NetDest& routing_table_entry) { assert(out.size() == m_virtual_networks); @@ -79,11 +81,11 @@ PerfectSwitch::addOutPort(const Vector<MessageBuffer*>& out, LinkOrder l; l.m_value = 0; l.m_link = m_out.size(); - m_link_order.insertAtBottom(l); + m_link_order.push_back(l); // Add to routing table - m_out.insertAtBottom(out); - m_routing_table.insertAtBottom(routing_table_entry); + m_out.push_back(out); + m_routing_table.push_back(routing_table_entry); } void @@ -111,7 +113,7 @@ PerfectSwitch::clearBuffers() void PerfectSwitch::reconfigureOutPort(const NetDest& routing_table_entry) { - m_routing_table.insertAtBottom(routing_table_entry); + m_routing_table.push_back(routing_table_entry); } PerfectSwitch::~PerfectSwitch() @@ -161,8 +163,8 @@ PerfectSwitch::wakeup() } // temporary vectors to store the routing results - Vector<LinkID> output_links; - Vector<NetDest> output_link_destinations; + vector<LinkID> output_links; + vector<NetDest> output_link_destinations; // Is there a message waiting? while (m_in[incoming][vnet]->isReady()) { @@ -206,7 +208,7 @@ PerfectSwitch::wakeup() } // Look at the most empty link first - m_link_order.sortVector(); + sort(m_link_order.begin(), m_link_order.end()); } } @@ -220,14 +222,14 @@ PerfectSwitch::wakeup() continue; // Remember what link we're using - output_links.insertAtBottom(link); + output_links.push_back(link); // Need to remember which destinations need this // message in another vector. This Set is the // intersection of the routing_table entry and the // current destination set. The intersection must // not be empty, since we are inside "if" - output_link_destinations.insertAtBottom(msg_dsts.AND(dst)); + output_link_destinations.push_back(msg_dsts.AND(dst)); // Next, we update the msg_destination not to // include those nodes that were already handled diff --git a/src/mem/ruby/network/simple/PerfectSwitch.hh b/src/mem/ruby/network/simple/PerfectSwitch.hh index 68bf0df9c..a7e577df0 100644 --- a/src/mem/ruby/network/simple/PerfectSwitch.hh +++ b/src/mem/ruby/network/simple/PerfectSwitch.hh @@ -37,8 +37,8 @@ #define __MEM_RUBY_NETWORK_SIMPLE_PERFECTSWITCH_HH__ #include <iostream> +#include <vector> -#include "mem/gems_common/Vector.hh" #include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Global.hh" #include "mem/ruby/system/NodeID.hh" @@ -59,8 +59,8 @@ class PerfectSwitch : public Consumer PerfectSwitch(SwitchID sid, SimpleNetwork* network_ptr); ~PerfectSwitch(); - void addInPort(const Vector<MessageBuffer*>& in); - void addOutPort(const Vector<MessageBuffer*>& out, + void addInPort(const std::vector<MessageBuffer*>& in); + void addOutPort(const std::vector<MessageBuffer*>& out, const NetDest& routing_table_entry); void clearRoutingTables(); void clearBuffers(); @@ -84,10 +84,10 @@ class PerfectSwitch : public Consumer SwitchID m_switch_id; // vector of queues from the components - Vector<Vector<MessageBuffer*> > m_in; - Vector<Vector<MessageBuffer*> > m_out; - Vector<NetDest> m_routing_table; - Vector<LinkOrder> m_link_order; + std::vector<std::vector<MessageBuffer*> > m_in; + std::vector<std::vector<MessageBuffer*> > m_out; + std::vector<NetDest> m_routing_table; + std::vector<LinkOrder> m_link_order; int m_virtual_networks; int m_round_robin_start; int m_wakeups_wo_switch; diff --git a/src/mem/ruby/network/simple/SimpleNetwork.cc b/src/mem/ruby/network/simple/SimpleNetwork.cc index 47404ad01..cb32ed9e1 100644 --- a/src/mem/ruby/network/simple/SimpleNetwork.cc +++ b/src/mem/ruby/network/simple/SimpleNetwork.cc @@ -26,6 +26,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "base/stl_helpers.hh" #include "mem/gems_common/Map.hh" #include "mem/protocol/MachineType.hh" #include "mem/protocol/Protocol.hh" @@ -39,6 +40,7 @@ #include "mem/ruby/system/System.hh" using namespace std; +using m5::stl_helpers::deletePointers; #if 0 // ***BIG HACK*** - This is actually code that _should_ be in Network.cc @@ -59,21 +61,21 @@ SimpleNetwork::SimpleNetwork(const Params *p) // SimpleNetwork child constructor. Therefore, the member variables // used below should already be initialized. - m_endpoint_switches.setSize(m_nodes); + m_endpoint_switches.resize(m_nodes); - m_in_use.setSize(m_virtual_networks); - m_ordered.setSize(m_virtual_networks); + m_in_use.resize(m_virtual_networks); + m_ordered.resize(m_virtual_networks); for (int i = 0; i < m_virtual_networks; i++) { m_in_use[i] = false; m_ordered[i] = false; } // Allocate to and from queues - m_toNetQueues.setSize(m_nodes); - m_fromNetQueues.setSize(m_nodes); + m_toNetQueues.resize(m_nodes); + m_fromNetQueues.resize(m_nodes); for (int node = 0; node < m_nodes; node++) { - m_toNetQueues[node].setSize(m_virtual_networks); - m_fromNetQueues[node].setSize(m_virtual_networks); + m_toNetQueues[node].resize(m_virtual_networks); + m_fromNetQueues[node].resize(m_virtual_networks); for (int j = 0; j < m_virtual_networks; j++) { m_toNetQueues[node][j] = new MessageBuffer(csprintf("toNet node %d j %d", node, j)); @@ -93,7 +95,7 @@ SimpleNetwork::init() assert(m_topology_ptr != NULL); int number_of_switches = m_topology_ptr->numSwitches(); for (int i = 0; i < number_of_switches; i++) { - m_switch_ptr_vector.insertAtBottom(new Switch(i, this)); + m_switch_ptr_vector.push_back(new Switch(i, this)); } // false because this isn't a reconfiguration @@ -118,11 +120,11 @@ SimpleNetwork::reset() SimpleNetwork::~SimpleNetwork() { for (int i = 0; i < m_nodes; i++) { - m_toNetQueues[i].deletePointers(); - m_fromNetQueues[i].deletePointers(); + deletePointers(m_toNetQueues[i]); + deletePointers(m_fromNetQueues[i]); } - m_switch_ptr_vector.deletePointers(); - m_buffers_to_free.deletePointers(); + deletePointers(m_switch_ptr_vector); + deletePointers(m_buffers_to_free); // delete m_topology_ptr; } @@ -173,17 +175,17 @@ SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, } // Create a set of new MessageBuffers - Vector<MessageBuffer*> queues; + std::vector<MessageBuffer*> queues; for (int i = 0; i < m_virtual_networks; i++) { // allocate a buffer MessageBuffer* buffer_ptr = new MessageBuffer; buffer_ptr->setOrdering(true); if (m_buffer_size > 0) { - buffer_ptr->setSize(m_buffer_size); + buffer_ptr->resize(m_buffer_size); } - queues.insertAtBottom(buffer_ptr); + queues.push_back(buffer_ptr); // remember to deallocate it - m_buffers_to_free.insertAtBottom(buffer_ptr); + m_buffers_to_free.push_back(buffer_ptr); } // Connect it to the two switches m_switch_ptr_vector[dest]->addInPort(queues); @@ -217,7 +219,7 @@ SimpleNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num) return m_fromNetQueues[id][network_num]; } -const Vector<Throttle*>* +const std::vector<Throttle*>* SimpleNetwork::getThrottles(NodeID id) const { assert(id >= 0); diff --git a/src/mem/ruby/network/simple/SimpleNetwork.hh b/src/mem/ruby/network/simple/SimpleNetwork.hh index f9cb22a6a..6767f725b 100644 --- a/src/mem/ruby/network/simple/SimpleNetwork.hh +++ b/src/mem/ruby/network/simple/SimpleNetwork.hh @@ -64,8 +64,8 @@ #define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ #include <iostream> +#include <vector> -#include "mem/gems_common/Vector.hh" #include "mem/ruby/common/Global.hh" #include "mem/ruby/network/Network.hh" #include "mem/ruby/system/NodeID.hh" @@ -96,7 +96,7 @@ class SimpleNetwork : public Network // returns the queue requested for the given component MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num); MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num); - virtual const Vector<Throttle*>* getThrottles(NodeID id) const; + virtual const std::vector<Throttle*>* getThrottles(NodeID id) const; bool isVNetOrdered(int vnet) { return m_ordered[vnet]; } bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; } @@ -130,14 +130,14 @@ class SimpleNetwork : public Network SimpleNetwork& operator=(const SimpleNetwork& obj); // vector of queues from the components - Vector<Vector<MessageBuffer*> > m_toNetQueues; - Vector<Vector<MessageBuffer*> > m_fromNetQueues; - - Vector<bool> m_in_use; - Vector<bool> m_ordered; - Vector<Switch*> m_switch_ptr_vector; - Vector<MessageBuffer*> m_buffers_to_free; - Vector<Switch*> m_endpoint_switches; + std::vector<std::vector<MessageBuffer*> > m_toNetQueues; + std::vector<std::vector<MessageBuffer*> > m_fromNetQueues; + + std::vector<bool> m_in_use; + std::vector<bool> m_ordered; + std::vector<Switch*> m_switch_ptr_vector; + std::vector<MessageBuffer*> m_buffers_to_free; + std::vector<Switch*> m_endpoint_switches; }; inline std::ostream& diff --git a/src/mem/ruby/network/simple/Switch.cc b/src/mem/ruby/network/simple/Switch.cc index e88a24505..3439bf44b 100644 --- a/src/mem/ruby/network/simple/Switch.cc +++ b/src/mem/ruby/network/simple/Switch.cc @@ -26,6 +26,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <numeric> + +#include "base/stl_helpers.hh" #include "mem/protocol/MessageSizeType.hh" #include "mem/protocol/Protocol.hh" #include "mem/ruby/buffers/MessageBuffer.hh" @@ -35,12 +38,13 @@ #include "mem/ruby/network/simple/Throttle.hh" using namespace std; +using m5::stl_helpers::deletePointers; +using m5::stl_helpers::operator<<; Switch::Switch(SwitchID sid, SimpleNetwork* network_ptr) { m_perfect_switch_ptr = new PerfectSwitch(sid, network_ptr); m_switch_id = sid; - m_throttles.setSize(0); } Switch::~Switch() @@ -48,20 +52,20 @@ Switch::~Switch() delete m_perfect_switch_ptr; // Delete throttles (one per output port) - m_throttles.deletePointers(); + deletePointers(m_throttles); // Delete MessageBuffers - m_buffers_to_free.deletePointers(); + deletePointers(m_buffers_to_free); } void -Switch::addInPort(const Vector<MessageBuffer*>& in) +Switch::addInPort(const vector<MessageBuffer*>& in) { m_perfect_switch_ptr->addInPort(in); } void -Switch::addOutPort(const Vector<MessageBuffer*>& out, +Switch::addOutPort(const vector<MessageBuffer*>& out, const NetDest& routing_table_entry, int link_latency, int bw_multiplier) { Throttle* throttle_ptr = NULL; @@ -69,20 +73,20 @@ Switch::addOutPort(const Vector<MessageBuffer*>& out, // Create a throttle throttle_ptr = new Throttle(m_switch_id, m_throttles.size(), link_latency, bw_multiplier); - m_throttles.insertAtBottom(throttle_ptr); + m_throttles.push_back(throttle_ptr); // Create one buffer per vnet (these are intermediaryQueues) - Vector<MessageBuffer*> intermediateBuffers; + vector<MessageBuffer*> intermediateBuffers; for (int i = 0; i < out.size(); i++) { MessageBuffer* buffer_ptr = new MessageBuffer; // Make these queues ordered buffer_ptr->setOrdering(true); Network* net_ptr = RubySystem::getNetwork(); if (net_ptr->getBufferSize() > 0) { - buffer_ptr->setSize(net_ptr->getBufferSize()); + buffer_ptr->resize(net_ptr->getBufferSize()); } - intermediateBuffers.insertAtBottom(buffer_ptr); - m_buffers_to_free.insertAtBottom(buffer_ptr); + intermediateBuffers.push_back(buffer_ptr); + m_buffers_to_free.push_back(buffer_ptr); } // Hook the queues to the PerfectSwitch @@ -122,7 +126,7 @@ Switch::getThrottle(LinkID link_number) const return m_throttles[link_number]; } -const Vector<Throttle*>* +const vector<Throttle*>* Switch::getThrottles() const { return &m_throttles; @@ -172,18 +176,21 @@ Switch::printStats(std::ostream& out) const if (!throttle_ptr) continue; - const Vector<Vector<int> >& message_counts = + const vector<vector<int> >& message_counts = throttle_ptr->getCounters(); for (int int_type = 0; int_type < MessageSizeType_NUM; int_type++) { MessageSizeType type = MessageSizeType(int_type); - int sum = message_counts[type].sum(); + const vector<int> &mct = message_counts[type]; + int sum = accumulate(mct.begin(), mct.end(), 0); if (sum == 0) continue; out << " outgoing_messages_switch_" << m_switch_id << "_link_" << link << "_" << type << ": " << sum << " " << sum * RubySystem::getNetwork()->MessageSizeType_to_int(type) - << " " << message_counts[type] << " base_latency: " + << " "; + out << mct; + out << " base_latency: " << throttle_ptr->getLatency() << endl; } } diff --git a/src/mem/ruby/network/simple/Switch.hh b/src/mem/ruby/network/simple/Switch.hh index 598450df3..6e80c8642 100644 --- a/src/mem/ruby/network/simple/Switch.hh +++ b/src/mem/ruby/network/simple/Switch.hh @@ -40,8 +40,8 @@ #define __MEM_RUBY_NETWORK_SIMPLE_SWITCH_HH__ #include <iostream> +#include <vector> -#include "mem/gems_common/Vector.hh" #include "mem/ruby/common/Global.hh" class MessageBuffer; @@ -57,12 +57,12 @@ class Switch Switch(SwitchID sid, SimpleNetwork* network_ptr); ~Switch(); - void addInPort(const Vector<MessageBuffer*>& in); - void addOutPort(const Vector<MessageBuffer*>& out, + void addInPort(const std::vector<MessageBuffer*>& in); + void addOutPort(const std::vector<MessageBuffer*>& out, const NetDest& routing_table_entry, int link_latency, int bw_multiplier); const Throttle* getThrottle(LinkID link_number) const; - const Vector<Throttle*>* getThrottles() const; + const std::vector<Throttle*>* getThrottles() const; void clearRoutingTables(); void clearBuffers(); void reconfigureOutPort(const NetDest& routing_table_entry); @@ -80,8 +80,8 @@ class Switch PerfectSwitch* m_perfect_switch_ptr; Network* m_network_ptr; - Vector<Throttle*> m_throttles; - Vector<MessageBuffer*> m_buffers_to_free; + std::vector<Throttle*> m_throttles; + std::vector<MessageBuffer*> m_buffers_to_free; SwitchID m_switch_id; }; diff --git a/src/mem/ruby/network/simple/Throttle.cc b/src/mem/ruby/network/simple/Throttle.cc index 5d74afb24..a77d40dee 100644 --- a/src/mem/ruby/network/simple/Throttle.cc +++ b/src/mem/ruby/network/simple/Throttle.cc @@ -85,17 +85,17 @@ Throttle::clear() } void -Throttle::addLinks(const Vector<MessageBuffer*>& in_vec, - const Vector<MessageBuffer*>& out_vec) +Throttle::addLinks(const std::vector<MessageBuffer*>& in_vec, + const std::vector<MessageBuffer*>& out_vec) { assert(in_vec.size() == out_vec.size()); for (int i=0; i<in_vec.size(); i++) { addVirtualNetwork(in_vec[i], out_vec[i]); } - m_message_counters.setSize(MessageSizeType_NUM); + m_message_counters.resize(MessageSizeType_NUM); for (int i = 0; i < MessageSizeType_NUM; i++) { - m_message_counters[i].setSize(in_vec.size()); + m_message_counters[i].resize(in_vec.size()); for (int j = 0; j<m_message_counters[i].size(); j++) { m_message_counters[i][j] = 0; } @@ -105,9 +105,9 @@ Throttle::addLinks(const Vector<MessageBuffer*>& in_vec, void Throttle::addVirtualNetwork(MessageBuffer* in_ptr, MessageBuffer* out_ptr) { - m_units_remaining.insertAtBottom(0); - m_in.insertAtBottom(in_ptr); - m_out.insertAtBottom(out_ptr); + m_units_remaining.push_back(0); + m_in.push_back(in_ptr); + m_out.push_back(out_ptr); // Set consumer and description m_in[m_vnets]->setConsumer(this); diff --git a/src/mem/ruby/network/simple/Throttle.hh b/src/mem/ruby/network/simple/Throttle.hh index 74cd7b356..c80f24d77 100644 --- a/src/mem/ruby/network/simple/Throttle.hh +++ b/src/mem/ruby/network/simple/Throttle.hh @@ -39,8 +39,8 @@ #define __MEM_RUBY_NETWORK_SIMPLE_THROTTLE_HH__ #include <iostream> +#include <vector> -#include "mem/gems_common/Vector.hh" #include "mem/ruby/common/Consumer.hh" #include "mem/ruby/common/Global.hh" #include "mem/ruby/network/Network.hh" @@ -57,8 +57,8 @@ class Throttle : public Consumer Throttle(NodeID node, int link_latency, int link_bandwidth_multiplier); ~Throttle() {} - void addLinks(const Vector<MessageBuffer*>& in_vec, - const Vector<MessageBuffer*>& out_vec); + void addLinks(const std::vector<MessageBuffer*>& in_vec, + const std::vector<MessageBuffer*>& out_vec); void wakeup(); void printStats(std::ostream& out) const; @@ -74,7 +74,7 @@ class Throttle : public Consumer } int getLatency() const { return m_link_latency; } - const Vector<Vector<int> >& + const std::vector<std::vector<int> >& getCounters() const { return m_message_counters; @@ -93,11 +93,11 @@ class Throttle : public Consumer Throttle(const Throttle& obj); Throttle& operator=(const Throttle& obj); - Vector<MessageBuffer*> m_in; - Vector<MessageBuffer*> m_out; - Vector<Vector<int> > m_message_counters; + std::vector<MessageBuffer*> m_in; + std::vector<MessageBuffer*> m_out; + std::vector<std::vector<int> > m_message_counters; int m_vnets; - Vector<int> m_units_remaining; + std::vector<int> m_units_remaining; int m_sID; NodeID m_node; int m_link_bandwidth_multiplier; diff --git a/src/mem/ruby/network/simple/Topology.cc b/src/mem/ruby/network/simple/Topology.cc index 18618580a..bd167bd40 100644 --- a/src/mem/ruby/network/simple/Topology.cc +++ b/src/mem/ruby/network/simple/Topology.cc @@ -63,8 +63,8 @@ Topology::Topology(const Params *p) m_print_config = p->print_config; m_number_of_switches = p->num_int_nodes; // initialize component latencies record - m_component_latencies.setSize(0); - m_component_inter_switches.setSize(0); + m_component_latencies.resize(0); + m_component_inter_switches.resize(0); // Total nodes/controllers in network // Must make sure this is called after the State Machine constructors @@ -85,7 +85,7 @@ Topology::Topology(const Params *p) AbstractController *c = p->ext_node; // Store the controller pointers for later - m_controller_vector.insertAtBottom(c); + m_controller_vector.push_back(c); int ext_idx1 = MachineType_base_number(c->getMachineType()) + c->getVersion(); @@ -133,24 +133,24 @@ Topology::createLinks(Network *net, bool isReconfiguration) Matrix topology_latency; Matrix topology_bw_multis; int num_switches = max_switch_id+1; - topology_weights.setSize(num_switches); - topology_latency.setSize(num_switches); - topology_bw_multis.setSize(num_switches); + topology_weights.resize(num_switches); + topology_latency.resize(num_switches); + topology_bw_multis.resize(num_switches); // FIXME setting the size of a member variable here is a HACK! - m_component_latencies.setSize(num_switches); + m_component_latencies.resize(num_switches); // FIXME setting the size of a member variable here is a HACK! - m_component_inter_switches.setSize(num_switches); + m_component_inter_switches.resize(num_switches); for (int i = 0; i < topology_weights.size(); i++) { - topology_weights[i].setSize(num_switches); - topology_latency[i].setSize(num_switches); - topology_bw_multis[i].setSize(num_switches); - m_component_latencies[i].setSize(num_switches); + topology_weights[i].resize(num_switches); + topology_latency[i].resize(num_switches); + topology_bw_multis[i].resize(num_switches); + m_component_latencies[i].resize(num_switches); // FIXME setting the size of a member variable here is a HACK! - m_component_inter_switches[i].setSize(num_switches); + m_component_inter_switches[i].resize(num_switches); for (int j = 0; j < topology_weights[i].size(); j++) { topology_weights[i][j] = INFINITE_LATENCY; @@ -226,11 +226,11 @@ Topology::addLink(SwitchID src, SwitchID dest, int link_latency, { ASSERT(src <= m_number_of_switches+m_nodes+m_nodes); ASSERT(dest <= m_number_of_switches+m_nodes+m_nodes); - m_links_src_vector.insertAtBottom(src); - m_links_dest_vector.insertAtBottom(dest); - m_links_latency_vector.insertAtBottom(link_latency); - m_links_weight_vector.insertAtBottom(link_weight); - m_bw_multiplier_vector.insertAtBottom(bw_multiplier); + m_links_src_vector.push_back(src); + m_links_dest_vector.push_back(dest); + m_links_latency_vector.push_back(link_latency); + m_links_weight_vector.push_back(link_weight); + m_bw_multiplier_vector.push_back(bw_multiplier); } void diff --git a/src/mem/ruby/network/simple/Topology.hh b/src/mem/ruby/network/simple/Topology.hh index 9bcc66c81..c92848d8f 100644 --- a/src/mem/ruby/network/simple/Topology.hh +++ b/src/mem/ruby/network/simple/Topology.hh @@ -42,8 +42,8 @@ #include <iostream> #include <string> +#include <vector> -#include "mem/gems_common/Vector.hh" #include "mem/ruby/common/Global.hh" #include "mem/ruby/system/NodeID.hh" #include "params/ExtLink.hh" @@ -55,7 +55,7 @@ class Network; class NetDest; -typedef Vector<Vector<int> > Matrix; +typedef std::vector<std::vector<int> > Matrix; class Link : public SimObject { @@ -111,8 +111,9 @@ class Topology : public SimObject const NetDest& routing_table_entry, int link_latency, int weight, int bw_multiplier, bool isReconfiguration); - //void makeSwitchesPerChip(Vector<Vector< SwitchID> > &nodePairs, - // Vector<int> &latencies, Vector<int> &bw_multis, int numberOfChips); + //void makeSwitchesPerChip(std::vector<std::vector<SwitchID > > &nodePairs, + // std::vector<int> &latencies, std::vector<int> &bw_multis, + // int numberOfChips); std::string getDesignStr(); // Private copy constructor and assignment operator @@ -124,13 +125,13 @@ class Topology : public SimObject NodeID m_nodes; int m_number_of_switches; - Vector<AbstractController*> m_controller_vector; + std::vector<AbstractController*> m_controller_vector; - Vector<SwitchID> m_links_src_vector; - Vector<SwitchID> m_links_dest_vector; - Vector<int> m_links_latency_vector; - Vector<int> m_links_weight_vector; - Vector<int> m_bw_multiplier_vector; + std::vector<SwitchID> m_links_src_vector; + std::vector<SwitchID> m_links_dest_vector; + std::vector<int> m_links_latency_vector; + std::vector<int> m_links_weight_vector; + std::vector<int> m_bw_multiplier_vector; Matrix m_component_latencies; Matrix m_component_inter_switches; |