From 8dd45674aef2822d4c6cb57f1a4aedc7d9ee311c Mon Sep 17 00:00:00 2001 From: Brad Beckmann Date: Fri, 29 Jan 2010 20:29:32 -0800 Subject: [PATCH] ruby: Converted Garnet to M5 configuration --- configs/common/Options.py | 2 + configs/ruby/Ruby.py | 7 +- .../ruby/network/garnet/BaseGarnetNetwork.cc | 46 +++++++ .../NetworkConfig.hh => BaseGarnetNetwork.hh} | 53 ++++---- .../ruby/network/garnet/BaseGarnetNetwork.py | 11 ++ src/mem/ruby/network/garnet/NetworkHeader.hh | 2 - src/mem/ruby/network/garnet/SConscript | 39 ++++++ .../garnet/fixed-pipeline/GarnetNetwork_d.cc | 128 +++++++++--------- .../garnet/fixed-pipeline/GarnetNetwork_d.hh | 13 +- .../garnet/fixed-pipeline/GarnetNetwork_d.py | 6 + .../fixed-pipeline/NetworkInterface_d.cc | 6 +- .../garnet/fixed-pipeline/NetworkLink_d.cc | 5 +- .../garnet/fixed-pipeline/NetworkLink_d.hh | 4 +- .../garnet/fixed-pipeline/OutVcState_d.cc | 3 +- .../garnet/fixed-pipeline/OutputUnit_d.cc | 1 - .../network/garnet/fixed-pipeline/Router_d.cc | 4 +- .../network/garnet/fixed-pipeline/Router_d.hh | 7 +- .../network/garnet/fixed-pipeline/SConscript | 9 +- .../garnet/fixed-pipeline/VCallocator_d.cc | 1 - .../garnet/flexible-pipeline/GarnetNetwork.cc | 109 ++++++++------- .../garnet/flexible-pipeline/GarnetNetwork.hh | 15 +- .../garnet/flexible-pipeline/GarnetNetwork.py | 6 + .../flexible-pipeline/NetworkInterface.cc | 6 +- .../garnet/flexible-pipeline/NetworkLink.cc | 3 +- .../garnet/flexible-pipeline/Router.cc | 14 +- .../garnet/flexible-pipeline/SConscript | 5 +- src/mem/ruby/system/System.cc | 2 - 27 files changed, 301 insertions(+), 206 deletions(-) create mode 100644 src/mem/ruby/network/garnet/BaseGarnetNetwork.cc rename src/mem/ruby/network/garnet/{flexible-pipeline/NetworkConfig.hh => BaseGarnetNetwork.hh} (56%) create mode 100644 src/mem/ruby/network/garnet/BaseGarnetNetwork.py create mode 100644 src/mem/ruby/network/garnet/SConscript create mode 100644 src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.py create mode 100644 src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.py diff --git a/configs/common/Options.py b/configs/common/Options.py index 1bed93178..7d1b0e745 100644 --- a/configs/common/Options.py +++ b/configs/common/Options.py @@ -41,6 +41,8 @@ parser.add_option("--topology", type="string", default="crossbar", help="'crossbar'|'mesh'") parser.add_option("--mesh-rows", type="int", default=1, help="the number of rows in the mesh topology") +parser.add_option("--garnet-network", type="string", default=none, + help="'fixed'|'flexible'") # Run duration options parser.add_option("-m", "--maxtick", type="int", default=m5.MaxTick, diff --git a/configs/ruby/Ruby.py b/configs/ruby/Ruby.py index d34ffd7a2..65adc152e 100644 --- a/configs/ruby/Ruby.py +++ b/configs/ruby/Ruby.py @@ -90,7 +90,12 @@ def create_system(options, physmem, piobus = None, dma_devices = []): len(cpu_sequencers), options.mesh_rows) - network = SimpleNetwork(topology = net_topology) + if options.garnet_network == "fixed": + network = GarnetNetwork_d(topology = net_topology) + elif options.garnet_network == "flexible": + network = GarnetNetwork(topology = net_topology) + else: + network = SimpleNetwork(topology = net_topology) # # determine the total memory size of the ruby system and verify it is equal diff --git a/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc b/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc new file mode 100644 index 000000000..4a0d4157b --- /dev/null +++ b/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc @@ -0,0 +1,46 @@ +/* + * 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 + */ + +#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh" + +BaseGarnetNetwork::BaseGarnetNetwork(const Params *p) + : Network(p) +{ + m_flit_size = p->flit_size; + m_number_of_pipe_stages = p->number_of_pipe_stages; + m_vcs_per_class = p->vcs_per_class; + m_buffer_size = p->buffer_size; + m_using_network_testing = p->using_network_testing; +} + +void BaseGarnetNetwork::init() +{ + Network::init(); +} diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh b/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh similarity index 56% rename from src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh rename to src/mem/ruby/network/garnet/BaseGarnetNetwork.hh index 44900d25e..1c90c2ca2 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/NetworkConfig.hh +++ b/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh @@ -33,40 +33,33 @@ * required by the interconnection network. */ -#ifndef NETWORKCONFIG_H -#define NETWORKCONFIG_H +#ifndef BASEGARNETNETWORK_H +#define BASEGARNETNETWORK_H #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/gems_common/util.hh" +#include "mem/ruby/network/Network.hh" +#include "params/BaseGarnetNetwork.hh" + +class BaseGarnetNetwork : public Network { + public: + typedef BaseGarnetNetworkParams Params; + BaseGarnetNetwork(const Params *p); + + void init(); + 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; } + + protected: + int m_flit_size; + int m_number_of_pipe_stages; + int m_vcs_per_class; + int m_buffer_size; + bool m_using_network_testing; -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; iinit(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; iaddNode(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; iaddNode(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 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 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); +} diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh index ccd3e379a..8a36c1572 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh @@ -33,8 +33,9 @@ #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/gems_common/Vector.hh" -#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh" +#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh" #include "mem/ruby/network/Network.hh" +#include "params/GarnetNetwork_d.hh" class NetworkInterface_d; class MessageBuffer; @@ -44,17 +45,15 @@ class NetDest; class NetworkLink_d; class CreditLink_d; -class GarnetNetwork_d : public Network{ +class GarnetNetwork_d : public BaseGarnetNetwork { public: - GarnetNetwork_d(const string & name); + typedef GarnetNetwork_dParams Params; + GarnetNetwork_d(const Params *p); ~GarnetNetwork_d(); void init(); - //added by SS - NetworkConfig* getNetworkConfig() { return m_network_config_ptr; } - int getNumNodes(){ return m_nodes;} // returns the queue requested for the given component @@ -99,8 +98,6 @@ public: void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration); private: - NetworkConfig* m_network_config_ptr; - void checkNetworkAllocation(NodeID id, bool ordered, int network_num); // Private copy constructor and assignment operator diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.py b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.py new file mode 100644 index 000000000..40a8bfb79 --- /dev/null +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.py @@ -0,0 +1,6 @@ +from m5.params import * +from BaseGarnetNetwork import BaseGarnetNetwork + +class GarnetNetwork_d(BaseGarnetNetwork): + type = 'GarnetNetwork_d' + diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc index 4ba885f60..26399e68e 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc @@ -38,7 +38,7 @@ NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwo 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; @@ -109,7 +109,7 @@ bool NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet) NetDest net_msg_dest = net_msg_ptr->getInternalDestination(); Vector 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 { @@ -216,7 +216,7 @@ void NetworkInterface_d::wakeup() if(t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) { free_signal = true; - 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/fixed-pipeline/NetworkLink_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc index 229497085..92b2d44f8 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.cc @@ -29,7 +29,6 @@ */ #include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh" -#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh" #include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh" /* @@ -54,9 +53,9 @@ NetworkLink_d::NetworkLink_d(int id, int link_latency, GarnetNetwork_d *net_ptr) m_latency = link_latency; linkBuffer = new flitBuffer_d(); m_link_utilized = 0; - m_vc_load.setSize(m_net_ptr->getNetworkConfig()->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks()); + m_vc_load.setSize(m_net_ptr->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks()); - for(int i = 0; i < m_net_ptr->getNetworkConfig()->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks(); i++) + for(int i = 0; i < m_net_ptr->getVCsPerClass()*net_ptr->getNumberOfVirtualNetworks(); i++) m_vc_load[i] = 0; } diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh index 1fad7509d..6ee1dcdfb 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh @@ -53,8 +53,8 @@ public: int get_id(){return m_id;} void wakeup(); - double calculate_offline_power(power_bus*); - double calculate_power(); + double calculate_offline_power(power_bus*) { return 0.0; } + double calculate_power() { return 0.0; } inline bool isReady() { diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.cc index 958886573..921f8701a 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.cc @@ -29,7 +29,6 @@ */ #include "mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.hh" -#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh" #include "mem/ruby/eventqueue/RubyEventQueue.hh" OutVcState_d::OutVcState_d(int id, GarnetNetwork_d *network_ptr) @@ -38,5 +37,5 @@ OutVcState_d::OutVcState_d(int id, GarnetNetwork_d *network_ptr) m_id = id; m_vc_state = IDLE_; m_time = g_eventQueue_ptr->getTime(); - m_credit_count = m_network_ptr->getNetworkConfig()->getBufferSize(); + m_credit_count = m_network_ptr->getBufferSize(); } diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc index 8a371bb5f..7934dc9bd 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.cc @@ -30,7 +30,6 @@ #include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" -#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh" OutputUnit_d::OutputUnit_d(int id, Router_d *router) { diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc index 89a893e3a..7185249e4 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.cc @@ -44,9 +44,9 @@ Router_d::Router_d(int id, GarnetNetwork_d *network_ptr) m_id = id; m_network_ptr = network_ptr; m_virtual_networks = network_ptr->getNumberOfVirtualNetworks(); - m_vc_per_vnet = m_network_ptr->getNetworkConfig()->getVCsPerClass(); + m_vc_per_vnet = m_network_ptr->getVCsPerClass(); m_num_vcs = m_virtual_networks*m_vc_per_vnet; - m_flit_width = m_network_ptr->getNetworkConfig()->getFlitSize(); + m_flit_width = m_network_ptr->getFlitSize(); m_routing_unit = new RoutingUnit_d(this); m_vc_alloc = new VCallocator_d(this); diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh index eca621479..505353089 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/Router_d.hh @@ -74,8 +74,11 @@ public: void swarb_req(); void power_router_initialize(power_router *router, power_router_info *info); - double calculate_power(); - double calculate_offline_power(power_router*, power_router_info*); + double calculate_power() { return 0.0; } + double calculate_offline_power(power_router*, power_router_info*) + { + return 0.0; + } void calculate_performance_numbers(); private: diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/SConscript b/src/mem/ruby/network/garnet/fixed-pipeline/SConscript index 84f4ba378..d3cf45878 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/SConscript +++ b/src/mem/ruby/network/garnet/fixed-pipeline/SConscript @@ -30,14 +30,13 @@ Import('*') -# temporarily disable -Return() - if not env['RUBY']: Return() -Source('GarnetNetwork_d.cc') -Source('InputUnit_d.cc') +SimObject('GarnetNetwork_d.py') + +Source('GarnetNetwork_d.cc', Werror=False) +Source('InputUnit_d.cc', Werror=False) Source('NetworkInterface_d.cc') Source('NetworkLink_d.cc') Source('OutVcState_d.cc') diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc index 7bfb4948d..e08c70769 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.cc @@ -28,7 +28,6 @@ * Authors: Niket Agarwal */ -#include "mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh" #include "mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" #include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh" 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; iaddNode(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; iaddNode(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 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 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" <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/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(msg_ptr.ref()); NetDest net_msg_dest = net_msg_ptr->getInternalDestination(); Vector 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 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(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') diff --git a/src/mem/ruby/system/System.cc b/src/mem/ruby/system/System.cc index 47b53aedd..dc8007b26 100644 --- a/src/mem/ruby/system/System.cc +++ b/src/mem/ruby/system/System.cc @@ -53,8 +53,6 @@ #include "mem/ruby/network/simple/Topology.hh" #include "mem/ruby/network/simple/SimpleNetwork.hh" #include "mem/ruby/system/RubyPort.hh" -//#include "mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.hh" -//#include "mem/ruby/network/garnet-fixed-pipeline/GarnetNetwork_d.hh" #include "mem/ruby/system/MemoryControl.hh" #include "base/output.hh" -- 2.30.2