diff options
author | Brad Beckmann <Brad.Beckmann@amd.com> | 2010-01-29 20:29:32 -0800 |
---|---|---|
committer | Brad Beckmann <Brad.Beckmann@amd.com> | 2010-01-29 20:29:32 -0800 |
commit | 8dd45674aef2822d4c6cb57f1a4aedc7d9ee311c (patch) | |
tree | 47d5d83cfdd2a6ff7025c3417fd843b7cd16841f /src/mem/ruby/network/garnet/flexible-pipeline | |
parent | b5444625056a93cd676c512a891b0c13c44cf58b (diff) | |
download | gem5-8dd45674aef2822d4c6cb57f1a4aedc7d9ee311c.tar.xz |
ruby: Converted Garnet to M5 configuration
Diffstat (limited to 'src/mem/ruby/network/garnet/flexible-pipeline')
8 files changed, 78 insertions, 153 deletions
diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc index a88263c62..82f664d26 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc +++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc @@ -39,63 +39,54 @@ #include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh" #include "mem/ruby/common/NetDest.hh" -GarnetNetwork::GarnetNetwork(const string & name) - : Network(name) +GarnetNetwork::GarnetNetwork(const Params *p) + : BaseGarnetNetwork(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); + 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::init() { -// printf("hello\n"); - Network::init(argv); -//added by SS -// assert (m_topology_ptr!=NULL); - - m_network_config_ptr = new NetworkConfig; - - m_network_config_ptr->init(argv); - - 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); - 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 - assert (m_topology_ptr!=NULL); - 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(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_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration + BaseGarnetNetwork::init(); + + // Setup the network switches + 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(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_topology_ptr->createLinks(this, false); // false because this isn't a reconfiguration } GarnetNetwork::~GarnetNetwork() @@ -216,9 +207,9 @@ 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_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; } @@ -233,7 +224,7 @@ void GarnetNetwork::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]; } } @@ -241,7 +232,7 @@ void GarnetNetwork::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; @@ -295,3 +286,9 @@ void GarnetNetwork::print(ostream& out) const { out << "[GarnetNetwork]"; } + +GarnetNetwork * +GarnetNetworkParams::create() +{ + return new GarnetNetwork(this); +} diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh index 03a17037f..3669799fa 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh +++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh @@ -32,9 +32,10 @@ #define GARNET_NETWORK_H #include "mem/ruby/network/garnet/NetworkHeader.hh" +#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh" #include "mem/gems_common/Vector.hh" -#include "mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh" #include "mem/ruby/network/Network.hh" +#include "params/GarnetNetwork.hh" class NetworkInterface; class MessageBuffer; @@ -43,17 +44,15 @@ class Topology; class NetDest; class NetworkLink; -class GarnetNetwork : public Network{ +class GarnetNetwork : public BaseGarnetNetwork { public: - GarnetNetwork(const string & name); + typedef GarnetNetworkParams Params; + GarnetNetwork(const Params *p); - ~GarnetNetwork(); + ~GarnetNetwork(); void init(); - //added by SS - NetworkConfig* getNetworkConfig() { return m_network_config_ptr; } - // 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); @@ -100,8 +99,6 @@ private: // Topology* m_topology_ptr; Time m_ruby_start; - - NetworkConfig* m_network_config_ptr; }; // Output operator declaration diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.py b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.py new file mode 100644 index 000000000..f8c0983bc --- /dev/null +++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.py @@ -0,0 +1,6 @@ +from m5.params import * +from BaseGarnetNetwork import BaseGarnetNetwork + +class GarnetNetwork(BaseGarnetNetwork): + type = 'GarnetNetwork' + diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh deleted file mode 100644 index 44900d25e..000000000 --- a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2008 Princeton University - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Authors: Niket Agarwal - */ - -/* - * This header file is used to define all configuration parameters - * required by the interconnection network. - */ - -#ifndef NETWORKCONFIG_H -#define NETWORKCONFIG_H - -#include "mem/ruby/network/garnet/NetworkHeader.hh" -#include "mem/gems_common/util.hh" - -class NetworkConfig { - private: - int m_flit_size; - int m_number_of_pipe_stages; - int m_vcs_per_class; - int m_buffer_size; - bool m_using_network_testing; - public: - NetworkConfig(){} - void init() { - for (size_t i=0; i<argv.size(); i+=2) { - if (argv[i] == "flit_size") - m_flit_size = atoi(argv[i+1].c_str()); - else if (argv[i] == "number_of_pipe_stages") - m_number_of_pipe_stages = atoi(argv[i+1].c_str()); - else if (argv[i] == "vcs_per_class") - m_vcs_per_class = atoi(argv[i+1].c_str()); - else if (argv[i] == "buffer_size") - m_buffer_size = atoi(argv[i+1].c_str()); - else if (argv[i] == "using_network_testing") - m_using_network_testing = atoi(argv[i+1].c_str()); - } - } - bool isNetworkTesting() {return m_using_network_testing; } - int getFlitSize() {return m_flit_size; } - int getNumPipeStages() {return m_number_of_pipe_stages; } - int getVCsPerClass() {return m_vcs_per_class; } - int getBufferSize() {return m_buffer_size; } -}; - - -#endif diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc index a8a8fd137..5f48d2f5e 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc +++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc @@ -38,7 +38,7 @@ NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork * m_id = id; m_net_ptr = network_ptr; m_virtual_networks = virtual_networks; - m_vc_per_vnet = m_net_ptr->getNetworkConfig()->getVCsPerClass(); + m_vc_per_vnet = m_net_ptr->getVCsPerClass(); m_num_vcs = m_vc_per_vnet*m_virtual_networks; m_vc_round_robin = 0; @@ -104,7 +104,7 @@ bool NetworkInterface::flitisizeMessage(MsgPtr msg_ptr, int vnet) NetworkMessage *net_msg_ptr = dynamic_cast<NetworkMessage*>(msg_ptr.ref()); NetDest net_msg_dest = net_msg_ptr->getInternalDestination(); 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->getNetworkConfig()->getFlitSize() ); // Number of flits is dependent on the link bandwidth available. This is expressed in terms of bytes/cycle or the flit size + 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 { @@ -231,7 +231,7 @@ void NetworkInterface::wakeup() DEBUG_EXPR(NETWORK_COMP, HighPrio, m_id); DEBUG_MSG(NETWORK_COMP, HighPrio, "Message got delivered"); DEBUG_EXPR(NETWORK_COMP, HighPrio, g_eventQueue_ptr->getTime()); - if(!m_net_ptr->getNetworkConfig()->isNetworkTesting()) // When we are doing network only testing, the messages do not have to be buffered into the message buffers + if(!m_net_ptr->isNetworkTesting()) // When we are doing network only testing, the messages do not have to be buffered into the message buffers { outNode_ptr[t_flit->get_vnet()]->enqueue(t_flit->get_msg_ptr(), 1); // enqueueing for protocol buffer. This is not required when doing network only testing } diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc index 3b1c84eb6..6e106137a 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc +++ b/src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc @@ -29,7 +29,6 @@ */ #include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh" -#include "mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh" #include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh" NetworkLink::NetworkLink(int id, int latency, GarnetNetwork *net_ptr) @@ -42,7 +41,7 @@ NetworkLink::NetworkLink(int id, int latency, GarnetNetwork *net_ptr) m_net_ptr = net_ptr; m_latency = latency; int num_net = net_ptr->getNumberOfVirtualNetworks(); - int num_vc = m_net_ptr->getNetworkConfig()->getVCsPerClass(); + int num_vc = m_net_ptr->getVCsPerClass(); m_vc_load.setSize(num_net*num_vc); for(int i = 0; i < num_net*num_vc; i++) diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc b/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc index 63f0373f8..9963555cb 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc +++ b/src/mem/ruby/network/garnet/flexible-pipeline/Router.cc @@ -39,7 +39,7 @@ Router::Router(int id, GarnetNetwork *network_ptr) m_id = id; m_net_ptr = network_ptr; m_virtual_networks = m_net_ptr->getNumberOfVirtualNetworks(); - m_vc_per_vnet = m_net_ptr->getNetworkConfig()->getVCsPerClass(); + m_vc_per_vnet = m_net_ptr->getVCsPerClass(); m_round_robin_inport = 0; m_round_robin_start = 0; m_num_vcs = m_vc_per_vnet*m_virtual_networks; @@ -98,7 +98,7 @@ void Router::addOutPort(NetworkLink *out_link, const NetDest& routing_table_entr Vector<flitBuffer *> intermediateQueues; for(int i = 0; i < m_num_vcs; i++) { - intermediateQueues.insertAtBottom(new flitBuffer(m_net_ptr->getNetworkConfig()->getBufferSize())); + intermediateQueues.insertAtBottom(new flitBuffer(m_net_ptr->getBufferSize())); } m_router_buffers.insertAtBottom(intermediateQueues); @@ -241,17 +241,17 @@ void Router::routeCompute(flit *m_flit, int inport) int outport = m_in_vc_state[inport][invc]->get_outport(); int outvc = m_in_vc_state[inport][invc]->get_outvc(); - assert(m_net_ptr->getNetworkConfig()->getNumPipeStages() >= 1); - m_flit->set_time(g_eventQueue_ptr->getTime() + (m_net_ptr->getNetworkConfig()->getNumPipeStages() - 1)); // Becasuse 1 cycle will be consumed in scheduling the output link + assert(m_net_ptr->getNumPipeStages() >= 1); + m_flit->set_time(g_eventQueue_ptr->getTime() + (m_net_ptr->getNumPipeStages() - 1)); // Becasuse 1 cycle will be consumed in scheduling the output link m_flit->set_vc(outvc); m_router_buffers[outport][outvc]->insert(m_flit); - if(m_net_ptr->getNetworkConfig()->getNumPipeStages() > 1) - g_eventQueue_ptr->scheduleEvent(this, m_net_ptr->getNetworkConfig()->getNumPipeStages() -1 ); + if(m_net_ptr->getNumPipeStages() > 1) + g_eventQueue_ptr->scheduleEvent(this, m_net_ptr->getNumPipeStages() -1 ); if((m_flit->get_type() == HEAD_) || (m_flit->get_type() == HEAD_TAIL_)) { NetDest destination = dynamic_cast<NetworkMessage*>(m_flit->get_msg_ptr().ref())->getInternalDestination(); - if(m_net_ptr->getNetworkConfig()->getNumPipeStages() > 1) + if(m_net_ptr->getNumPipeStages() > 1) { m_out_vc_state[outport][outvc]->setState(VC_AB_, g_eventQueue_ptr->getTime() + 1); m_out_link[outport]->request_vc_link(outvc, destination, g_eventQueue_ptr->getTime() + 1); diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/SConscript b/src/mem/ruby/network/garnet/flexible-pipeline/SConscript index e132741ca..fa23c02d6 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/SConscript +++ b/src/mem/ruby/network/garnet/flexible-pipeline/SConscript @@ -30,12 +30,11 @@ Import('*') -# temporarily disable -Return() - if not env['RUBY']: Return() +SimObject('GarnetNetwork.py') + Source('GarnetNetwork.cc') Source('InVcState.cc') Source('NetworkInterface.cc') |