All the implementations were doing the same things.
m_topology_ptr = new Topology(p->routers.size(), p->ext_links,
p->int_links);
+
+ // Allocate to and from queues
+ // Queues that are getting messages from protocol
+ m_toNetQueues.resize(m_nodes);
+
+ // Queues that are feeding the protocol
+ m_fromNetQueues.resize(m_nodes);
+
+ for (int node = 0; node < m_nodes; node++) {
+ // Setting number of virtual message buffers per Network Queue
+ m_toNetQueues[node].resize(m_virtual_networks);
+ m_fromNetQueues[node].resize(m_virtual_networks);
+
+ // Instantiating the Message Buffers that
+ // interact with the coherence protocol
+ for (int j = 0; j < m_virtual_networks; j++) {
+ m_toNetQueues[node][j] = new MessageBuffer();
+ m_fromNetQueues[node][j] = new MessageBuffer();
+ }
+ }
+
+ 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;
+ }
+
p->ruby_system->registerNetwork(this);
// Initialize the controller's network pointers
Stats::registerDumpCallback(new StatsCallback(this));
}
+Network::~Network()
+{
+ for (int node = 0; node < m_nodes; node++) {
+ // Delete the Message Buffers
+ for (int j = 0; j < m_virtual_networks; j++) {
+ delete m_toNetQueues[node][j];
+ delete m_fromNetQueues[node][j];
+ }
+ }
+
+ delete m_topology_ptr;
+}
+
void
Network::init()
{
public:
typedef RubyNetworkParams Params;
Network(const Params *p);
- virtual ~Network() {}
const Params * params() const
{ return dynamic_cast<const Params *>(_params);}
+ virtual ~Network();
virtual void init();
static uint32_t getNumberOfVirtualNetworks() { return m_virtual_networks; }
+ int getNumNodes() const { return m_nodes; }
+
static uint32_t MessageSizeType_to_int(MessageSizeType size_type);
// returns the queue requested for the given component
int netNumber, std::string vnet_type) = 0;
virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered,
int netNumber, std::string vnet_type) = 0;
- virtual int getNumNodes() {return 1;}
+
virtual void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
LinkDirection direction,
fatal("Garnet only supports uniform bw across all links and NIs\n");
}
}
-
- // Allocate to and from queues
-
- // Queues that are getting messages from protocol
- m_toNetQueues.resize(m_nodes);
-
- // Queues that are feeding the protocol
- m_fromNetQueues.resize(m_nodes);
-
- 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;
- }
-
- for (int node = 0; node < m_nodes; node++) {
- // Setting number of virtual message buffers per Network Queue
- m_toNetQueues[node].resize(m_virtual_networks);
- m_fromNetQueues[node].resize(m_virtual_networks);
-
- // Instantiating the Message Buffers that
- // interact with the coherence protocol
- for (int j = 0; j < m_virtual_networks; j++) {
- m_toNetQueues[node][j] = new MessageBuffer();
- m_fromNetQueues[node][j] = new MessageBuffer();
- }
- }
}
void
GarnetNetwork_d::~GarnetNetwork_d()
{
- for (int i = 0; i < m_nodes; i++) {
- deletePointers(m_toNetQueues[i]);
- deletePointers(m_fromNetQueues[i]);
- }
deletePointers(m_routers);
deletePointers(m_nis);
deletePointers(m_links);
deletePointers(m_creditlinks);
- delete m_topology_ptr;
}
/*
GarnetNetwork_d(const Params *p);
~GarnetNetwork_d();
-
void init();
- int getNumNodes() { return m_nodes; }
-
int getBuffersPerDataVC() {return m_buffers_per_data_vc; }
int getBuffersPerCtrlVC() {return m_buffers_per_ctrl_vc; }
assert(in.size() == m_virtual_networks);
inNode_ptr = in;
outNode_ptr = out;
- for (int j = 0; j < m_virtual_networks; j++) {
+ for (int j = 0; j < m_virtual_networks; j++) {
// the protocol injects messages into the NI
inNode_ptr[j]->setConsumer(this);
inNode_ptr[j]->setReceiver(this);
GarnetNetwork::~GarnetNetwork()
{
- for (int i = 0; i < m_nodes; i++) {
- deletePointers(m_toNetQueues[i]);
- deletePointers(m_fromNetQueues[i]);
- }
deletePointers(m_routers);
deletePointers(m_nis);
deletePointers(m_links);
- delete m_topology_ptr;
}
void
GarnetNetwork(const Params *p);
~GarnetNetwork();
-
void init();
int getBufferSize() { return m_buffer_size; }
int getNumPipeStages() {return m_number_of_pipe_stages; }
- int getNumNodes(){ return m_nodes; }
void collateStats();
void regStats();
// Note: the parent Network Object constructor is called before the
// SimpleNetwork child constructor. Therefore, the member variables
// used below should already be initialized.
-
m_endpoint_switches.resize(m_nodes);
- 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.resize(m_nodes);
- m_fromNetQueues.resize(m_nodes);
- for (int node = 0; node < m_nodes; node++) {
- 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));
- m_fromNetQueues[node][j] =
- new MessageBuffer(csprintf("fromNet node %d j %d", node, j));
- }
- }
-
// record the routers
for (vector<BasicRouter*>::const_iterator i = p->routers.begin();
i != p->routers.end(); ++i) {
SimpleNetwork::~SimpleNetwork()
{
- for (int i = 0; i < m_nodes; i++) {
- deletePointers(m_toNetQueues[i]);
- deletePointers(m_fromNetQueues[i]);
- }
deletePointers(m_switches);
deletePointers(m_buffers_to_free);
- // delete m_topology_ptr;
}
// From a switch to an endpoint node
bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
- int getNumNodes() {return m_nodes; }
-
// Methods used by Topology to setup the network
void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
LinkDirection direction,