summaryrefslogtreecommitdiff
path: root/src/mem/ruby/network/Network.cc
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2014-09-01 16:55:42 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2014-09-01 16:55:42 -0500
commit00dbadcbb09c51b8d05a22c21193b55d7e9a0cf1 (patch)
treefc8e8e99d2f1e48176e0f00c7cf3c567aa5ddbec /src/mem/ruby/network/Network.cc
parentcc2cc588693bb73b1892aea82fd0ac9729196f25 (diff)
downloadgem5-00dbadcbb09c51b8d05a22c21193b55d7e9a0cf1.tar.xz
ruby: network: move getNumNodes() to base class
All the implementations were doing the same things.
Diffstat (limited to 'src/mem/ruby/network/Network.cc')
-rw-r--r--src/mem/ruby/network/Network.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/mem/ruby/network/Network.cc b/src/mem/ruby/network/Network.cc
index 6e8437160..60531a423 100644
--- a/src/mem/ruby/network/Network.cc
+++ b/src/mem/ruby/network/Network.cc
@@ -49,6 +49,35 @@ Network::Network(const Params *p)
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
@@ -63,6 +92,19 @@ Network::Network(const Params *p)
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()
{