diff options
Diffstat (limited to 'src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc')
-rw-r--r-- | src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc | 128 |
1 files changed, 66 insertions, 62 deletions
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 11a34c0ce..7e9fe0762 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc @@ -38,69 +38,67 @@ #include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh" #include "mem/ruby/common/NetDest.hh" -GarnetNetwork_d::GarnetNetwork_d(const string & name) - : Network(name) +GarnetNetwork_d::GarnetNetwork_d(const Params *p) + : BaseGarnetNetwork(p) { + m_ruby_start = 0; + m_flits_recieved = 0; + m_flits_injected = 0; + m_network_latency = 0.0; + m_queueing_latency = 0.0; + + 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); + 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 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); + + for (int j = 0; j < m_virtual_networks; j++) + { + m_toNetQueues[node][j] = new MessageBuffer(); // Instantiating the Message Buffers that interact with the coherence protocol + m_fromNetQueues[node][j] = new MessageBuffer(); + } + } } void GarnetNetwork_d::init() { - Network::init(argv); - - //added by SS - m_network_config_ptr = new NetworkConfig; - m_network_config_ptr->init(argv); - - m_ruby_start = 0; - m_flits_recieved = 0; - m_flits_injected = 0; - m_network_latency = 0.0; - m_queueing_latency = 0.0; - - 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); - 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 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); - - for (int j = 0; j < m_virtual_networks; j++) - { - m_toNetQueues[node][j] = new MessageBuffer(); // Instantiating the Message Buffers that interact with the coherence protocol - m_fromNetQueues[node][j] = new MessageBuffer(); - } - } - - // Setup the network switches - m_topology_ptr->makeTopology(); - - 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)); - } - - 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_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration - for(int i = 0; i < m_router_ptr_vector.size(); i++) - { - m_router_ptr_vector[i]->init(); - } + BaseGarnetNetwork::init(); + + // + // The topology pointer should have already been initialized in the parent + // network constructor. + // + assert(m_topology_ptr != NULL); + + 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)); + } + + 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_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration + for(int i = 0; i < m_router_ptr_vector.size(); i++) + { + m_router_ptr_vector[i]->init(); + } } GarnetNetwork_d::~GarnetNetwork_d() @@ -245,9 +243,9 @@ 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_network_config_ptr->getVCsPerClass()); + average_vc_load.setSize(m_virtual_networks*m_vcs_per_class); - for(int i = 0; i < m_virtual_networks*m_network_config_ptr->getVCsPerClass(); i++) + for(int i = 0; i < m_virtual_networks*m_vcs_per_class; i++) { average_vc_load[i] = 0; } @@ -263,7 +261,7 @@ void GarnetNetwork_d::printStats(ostream& out) const Vector<int > vc_load = m_link_ptr_vector[i]->getVcLoad(); for(int j = 0; j < vc_load.size(); j++) { - assert(vc_load.size() == m_network_config_ptr->getVCsPerClass()*m_virtual_networks); + assert(vc_load.size() == m_vcs_per_class*m_virtual_networks); average_vc_load[j] += vc_load[j]; } } @@ -271,7 +269,7 @@ void GarnetNetwork_d::printStats(ostream& out) const out << "Average Link Utilization :: " << average_link_utilization << " flits/cycle" << endl; out << "-------------" << endl; - for(int i = 0; i < m_network_config_ptr->getVCsPerClass()*m_virtual_networks; i++) + for(int i = 0; i < m_vcs_per_class*m_virtual_networks; i++) { average_vc_load[i] = (double(average_vc_load[i]) / (double(g_eventQueue_ptr->getTime()) - m_ruby_start)); out << "Average VC Load [" << i << "] = " << average_vc_load[i] << " flits/cycle " << endl; @@ -348,3 +346,9 @@ void GarnetNetwork_d::print(ostream& out) const { out << "[GarnetNetwork_d]"; } + +GarnetNetwork_d * +GarnetNetwork_dParams::create() +{ + return new GarnetNetwork_d(this); +} |