From 00dbadcbb09c51b8d05a22c21193b55d7e9a0cf1 Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Mon, 1 Sep 2014 16:55:42 -0500 Subject: ruby: network: move getNumNodes() to base class All the implementations were doing the same things. --- src/mem/ruby/network/Network.cc | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/mem/ruby/network/Network.cc') 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() { -- cgit v1.2.3