From 66f0d26059ffaa09b829c0a84419936f88fd68c2 Mon Sep 17 00:00:00 2001 From: Tushar Krishna Date: Tue, 22 Jun 2010 15:36:07 -0700 Subject: style: updated garnet to match M5 coding style --- src/mem/ruby/network/garnet/BaseGarnetNetwork.cc | 3 +- src/mem/ruby/network/garnet/BaseGarnetNetwork.hh | 11 +- src/mem/ruby/network/garnet/NetworkHeader.hh | 7 +- .../network/garnet/fixed-pipeline/CreditLink_d.hh | 15 +- .../garnet/fixed-pipeline/GarnetNetwork_d.cc | 436 +++++++-------- .../garnet/fixed-pipeline/GarnetNetwork_d.hh | 155 +++--- .../network/garnet/fixed-pipeline/InputUnit_d.cc | 89 ++-- .../network/garnet/fixed-pipeline/InputUnit_d.hh | 269 +++++----- .../garnet/fixed-pipeline/NetworkInterface_d.cc | 514 +++++++++--------- .../garnet/fixed-pipeline/NetworkInterface_d.hh | 80 +-- .../network/garnet/fixed-pipeline/NetworkLink_d.cc | 77 ++- .../network/garnet/fixed-pipeline/NetworkLink_d.hh | 67 +-- .../network/garnet/fixed-pipeline/OutVcState_d.cc | 10 +- .../network/garnet/fixed-pipeline/OutVcState_d.hh | 79 ++- .../network/garnet/fixed-pipeline/OutputUnit_d.cc | 92 ++-- .../network/garnet/fixed-pipeline/OutputUnit_d.hh | 93 ++-- .../ruby/network/garnet/fixed-pipeline/Router_d.cc | 180 ++++--- .../ruby/network/garnet/fixed-pipeline/Router_d.hh | 83 +-- .../network/garnet/fixed-pipeline/RoutingUnit_d.cc | 69 +-- .../network/garnet/fixed-pipeline/RoutingUnit_d.hh | 29 +- .../network/garnet/fixed-pipeline/SWallocator_d.cc | 293 +++++------ .../network/garnet/fixed-pipeline/SWallocator_d.hh | 72 +-- .../ruby/network/garnet/fixed-pipeline/Switch_d.cc | 75 ++- .../ruby/network/garnet/fixed-pipeline/Switch_d.hh | 56 +- .../network/garnet/fixed-pipeline/VCallocator_d.cc | 336 ++++++------ .../network/garnet/fixed-pipeline/VCallocator_d.hh | 93 ++-- .../garnet/fixed-pipeline/VirtualChannel_d.cc | 67 +-- .../garnet/fixed-pipeline/VirtualChannel_d.hh | 124 ++--- .../network/garnet/fixed-pipeline/flitBuffer_d.cc | 58 +- .../network/garnet/fixed-pipeline/flitBuffer_d.hh | 73 +-- .../ruby/network/garnet/fixed-pipeline/flit_d.cc | 122 ++--- .../ruby/network/garnet/fixed-pipeline/flit_d.hh | 181 +++---- .../garnet/flexible-pipeline/FlexibleConsumer.hh | 20 +- .../garnet/flexible-pipeline/GarnetNetwork.cc | 352 +++++++------ .../garnet/flexible-pipeline/GarnetNetwork.hh | 85 +-- .../network/garnet/flexible-pipeline/InVcState.cc | 40 +- .../network/garnet/flexible-pipeline/InVcState.hh | 37 +- .../garnet/flexible-pipeline/NetworkInterface.cc | 444 +++++++++------- .../garnet/flexible-pipeline/NetworkInterface.hh | 88 ++-- .../garnet/flexible-pipeline/NetworkLink.cc | 127 +++-- .../garnet/flexible-pipeline/NetworkLink.hh | 74 +-- .../network/garnet/flexible-pipeline/OutVcState.cc | 24 +- .../network/garnet/flexible-pipeline/OutVcState.hh | 27 +- .../network/garnet/flexible-pipeline/Router.cc | 583 +++++++++++---------- .../network/garnet/flexible-pipeline/Router.hh | 88 ++-- .../network/garnet/flexible-pipeline/VCarbiter.cc | 8 +- .../network/garnet/flexible-pipeline/VCarbiter.hh | 23 +- .../ruby/network/garnet/flexible-pipeline/flit.cc | 109 ++-- .../ruby/network/garnet/flexible-pipeline/flit.hh | 70 +-- .../network/garnet/flexible-pipeline/flitBuffer.cc | 81 +-- .../network/garnet/flexible-pipeline/flitBuffer.hh | 41 +- .../garnet/flexible-pipeline/netconfig.defaults | 8 - 52 files changed, 3190 insertions(+), 3047 deletions(-) delete mode 100644 src/mem/ruby/network/garnet/flexible-pipeline/netconfig.defaults diff --git a/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc b/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc index 4a0d4157b..7290a70d9 100644 --- a/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc +++ b/src/mem/ruby/network/garnet/BaseGarnetNetwork.cc @@ -40,7 +40,8 @@ BaseGarnetNetwork::BaseGarnetNetwork(const Params *p) m_using_network_testing = p->using_network_testing; } -void BaseGarnetNetwork::init() +void +BaseGarnetNetwork::init() { Network::init(); } diff --git a/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh b/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh index a8eca11a4..51d84c6e0 100644 --- a/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh +++ b/src/mem/ruby/network/garnet/BaseGarnetNetwork.hh @@ -33,14 +33,15 @@ * required by the interconnection network. */ -#ifndef BASEGARNETNETWORK_H -#define BASEGARNETNETWORK_H +#ifndef __MEM_RUBY_NETWORK_GARNET_BASEGARNETNETWORK_HH__ +#define __MEM_RUBY_NETWORK_GARNET_BASEGARNETNETWORK_HH__ #include "mem/ruby/network/garnet/NetworkHeader.hh" #include "mem/ruby/network/Network.hh" #include "params/BaseGarnetNetwork.hh" -class BaseGarnetNetwork : public Network { +class BaseGarnetNetwork : public Network +{ public: typedef BaseGarnetNetworkParams Params; BaseGarnetNetwork(const Params *p); @@ -58,8 +59,6 @@ class BaseGarnetNetwork : public Network { int m_vcs_per_class; int m_buffer_size; bool m_using_network_testing; - }; - -#endif +#endif // __MEM_RUBY_NETWORK_GARNET_BASEGARNETNETWORK_HH__ diff --git a/src/mem/ruby/network/garnet/NetworkHeader.hh b/src/mem/ruby/network/garnet/NetworkHeader.hh index 98c8024fa..63900ad66 100644 --- a/src/mem/ruby/network/garnet/NetworkHeader.hh +++ b/src/mem/ruby/network/garnet/NetworkHeader.hh @@ -28,8 +28,8 @@ * Authors: Niket Agarwal */ -#ifndef NETWORK_HEADER_H -#define NETWORK_HEADER_H +#ifndef __MEM_RUBY_NETWORK_GARNET_NETWORKHEADER_HH__ +#define __MEM_RUBY_NETWORK_GARNET_NETWORKHEADER_HH__ #include "mem/ruby/common/Global.hh" #include "mem/ruby/system/NodeID.hh" @@ -40,5 +40,4 @@ enum flit_stage {I_, VA_, SA_, ST_, LT_, NUM_FLIT_STAGE_}; #define INFINITE_ 10000 -#endif - +#endif // __MEM_RUBY_NETWORK_GARNET_NETWORKHEADER_HH__ diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh index eda87da1a..779161336 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh @@ -28,14 +28,17 @@ * Authors: Niket Agarwal */ -#ifndef CREDIT_LINK_D_H -#define CREDIT_LINK_D_H +#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_CREDIT_LINK_D_HH__ +#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_CREDIT_LINK_D_HH__ #include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh" -class CreditLink_d : public NetworkLink_d { -public: - CreditLink_d(int id, int link_latency, GarnetNetwork_d *net_ptr):NetworkLink_d(id, link_latency, net_ptr) {} +class CreditLink_d : public NetworkLink_d +{ + public: + CreditLink_d(int id, int link_latency, GarnetNetwork_d *net_ptr) + : NetworkLink_d(id, link_latency, net_ptr) + {} }; -#endif +#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_CREDIT_LINK_D_HH__ 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 124a38e93..2a392c206 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.cc @@ -43,49 +43,50 @@ using namespace std; using m5::stl_helpers::deletePointers; GarnetNetwork_d::GarnetNetwork_d(const Params *p) - : BaseGarnetNetwork(p) + : BaseGarnetNetwork(p) { m_ruby_start = 0; - m_flits_recieved = 0; + m_flits_received = 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.resize(m_nodes); // Queues that are getting messages from protocol - m_fromNetQueues.resize(m_nodes); // Queues that are feeding the protocol + + // Queues that are getting messages from protocol + m_toNetQueues.resize(m_nodes); + + // Queues that are feeding the protocol + m_fromNetQueues.resize(m_nodes); m_in_use.resize(m_virtual_networks); m_ordered.resize(m_virtual_networks); - for (int i = 0; i < m_virtual_networks; i++) - { + 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 + + for (int node = 0; node < m_nodes; node++) { + // Setting how many vitual message buffers + // will there be per Network Queue m_toNetQueues[node].resize(m_virtual_networks); m_fromNetQueues[node].resize(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 + + // 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(); } } } -void GarnetNetwork_d::init() +void +GarnetNetwork_d::init() { BaseGarnetNetwork::init(); - // - // The topology pointer should have already been initialized in the parent - // network constructor. - // + // 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(); @@ -94,68 +95,70 @@ void GarnetNetwork_d::init() } for (int i=0; i < m_nodes; i++) { - NetworkInterface_d *ni = new NetworkInterface_d(i, m_virtual_networks, this); + NetworkInterface_d *ni = new NetworkInterface_d(i, m_virtual_networks, + this); ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]); m_ni_ptr_vector.push_back(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++) - { + // false because this isn't a reconfiguration + m_topology_ptr->createLinks(this, false); + for (int i = 0; i < m_router_ptr_vector.size(); i++) { m_router_ptr_vector[i]->init(); } } GarnetNetwork_d::~GarnetNetwork_d() { - for (int i = 0; i < m_nodes; i++) - { - deletePointers(m_toNetQueues[i]); - deletePointers(m_fromNetQueues[i]); - } - deletePointers(m_router_ptr_vector); - deletePointers(m_ni_ptr_vector); - deletePointers(m_link_ptr_vector); - deletePointers(m_creditlink_ptr_vector); - delete m_topology_ptr; + for (int i = 0; i < m_nodes; i++) { + deletePointers(m_toNetQueues[i]); + deletePointers(m_fromNetQueues[i]); + } + deletePointers(m_router_ptr_vector); + deletePointers(m_ni_ptr_vector); + deletePointers(m_link_ptr_vector); + deletePointers(m_creditlink_ptr_vector); + delete m_topology_ptr; } -void GarnetNetwork_d::reset() +void +GarnetNetwork_d::reset() { - for (int node = 0; node < m_nodes; node++) - { - for (int j = 0; j < m_virtual_networks; j++) - { - m_toNetQueues[node][j]->clear(); - m_fromNetQueues[node][j]->clear(); - } + for (int node = 0; node < m_nodes; node++) { + for (int j = 0; j < m_virtual_networks; j++) { + m_toNetQueues[node][j]->clear(); + m_fromNetQueues[node][j]->clear(); } + } } /* - * This function creates a link from the Network Interface (NI) into the Network. + * This function creates a link from the Network Interface (NI) + * into the Network. * It creates a Network Link from the NI to a Router and a Credit Link from * the Router to the NI */ -void GarnetNetwork_d::makeInLink(NodeID src, SwitchID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) +void +GarnetNetwork_d::makeInLink(NodeID src, SwitchID dest, + const NetDest& routing_table_entry, int link_latency, int bw_multiplier, + bool isReconfiguration) { - assert(src < m_nodes); - - if(!isReconfiguration) - { - NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this); - CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this); - m_link_ptr_vector.push_back(net_link); - m_creditlink_ptr_vector.push_back(credit_link); - - m_router_ptr_vector[dest]->addInPort(net_link, credit_link); - m_ni_ptr_vector[src]->addOutPort(net_link, credit_link); - } - else - { - ERROR_MSG("Fatal Error:: Reconfiguration not allowed here"); - // do nothing - } + assert(src < m_nodes); + + if (!isReconfiguration) { + NetworkLink_d *net_link = new NetworkLink_d + (m_link_ptr_vector.size(), link_latency, this); + CreditLink_d *credit_link = new CreditLink_d + (m_creditlink_ptr_vector.size(), link_latency, this); + m_link_ptr_vector.push_back(net_link); + m_creditlink_ptr_vector.push_back(credit_link); + + m_router_ptr_vector[dest]->addInPort(net_link, credit_link); + m_ni_ptr_vector[src]->addOutPort(net_link, credit_link); + } else { + ERROR_MSG("Fatal Error:: Reconfiguration not allowed here"); + // do nothing + } } /* @@ -164,191 +167,202 @@ void GarnetNetwork_d::makeInLink(NodeID src, SwitchID dest, const NetDest& routi * a Credit Link from NI to the Router */ -void GarnetNetwork_d::makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) +void +GarnetNetwork_d::makeOutLink(SwitchID src, NodeID dest, + const NetDest& routing_table_entry, int link_latency, int link_weight, + int bw_multiplier, bool isReconfiguration) { - assert(dest < m_nodes); - assert(src < m_router_ptr_vector.size()); - assert(m_router_ptr_vector[src] != NULL); - - if(!isReconfiguration) - { - NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this); - CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this); - m_link_ptr_vector.push_back(net_link); - m_creditlink_ptr_vector.push_back(credit_link); - - m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link); - m_ni_ptr_vector[dest]->addInPort(net_link, credit_link); - } - else - { - ERROR_MSG("Fatal Error:: Reconfiguration not allowed here"); - //do nothing - } + assert(dest < m_nodes); + assert(src < m_router_ptr_vector.size()); + assert(m_router_ptr_vector[src] != NULL); + + if (!isReconfiguration) { + NetworkLink_d *net_link = new NetworkLink_d + (m_link_ptr_vector.size(), link_latency, this); + CreditLink_d *credit_link = new CreditLink_d + (m_creditlink_ptr_vector.size(), link_latency, this); + m_link_ptr_vector.push_back(net_link); + m_creditlink_ptr_vector.push_back(credit_link); + + m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, + link_weight, credit_link); + m_ni_ptr_vector[dest]->addInPort(net_link, credit_link); + } else { + ERROR_MSG("Fatal Error:: Reconfiguration not allowed here"); + // do nothing + } } /* - * This function creates a internal network links + * This function creates an internal network link */ -void GarnetNetwork_d::makeInternalLink(SwitchID src, SwitchID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) +void +GarnetNetwork_d::makeInternalLink(SwitchID src, SwitchID dest, + const NetDest& routing_table_entry, int link_latency, int link_weight, + int bw_multiplier, bool isReconfiguration) { - if(!isReconfiguration) - { - NetworkLink_d *net_link = new NetworkLink_d(m_link_ptr_vector.size(), link_latency, this); - CreditLink_d *credit_link = new CreditLink_d(m_creditlink_ptr_vector.size(), link_latency, this); - m_link_ptr_vector.push_back(net_link); - m_creditlink_ptr_vector.push_back(credit_link); - - m_router_ptr_vector[dest]->addInPort(net_link, credit_link); - m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight, credit_link); - } - else - { - ERROR_MSG("Fatal Error:: Reconfiguration not allowed here"); - // do nothing - } + if (!isReconfiguration) { + NetworkLink_d *net_link = new NetworkLink_d + (m_link_ptr_vector.size(), link_latency, this); + CreditLink_d *credit_link = new CreditLink_d + (m_creditlink_ptr_vector.size(), link_latency, this); + m_link_ptr_vector.push_back(net_link); + m_creditlink_ptr_vector.push_back(credit_link); + + m_router_ptr_vector[dest]->addInPort(net_link, credit_link); + m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, + link_weight, credit_link); + } else { + ERROR_MSG("Fatal Error:: Reconfiguration not allowed here"); + // do nothing + } } -void GarnetNetwork_d::checkNetworkAllocation(NodeID id, bool ordered, int network_num) +void +GarnetNetwork_d::checkNetworkAllocation(NodeID id, bool ordered, + int network_num) { - ASSERT(id < m_nodes); - ASSERT(network_num < m_virtual_networks); + ASSERT(id < m_nodes); + ASSERT(network_num < m_virtual_networks); - if (ordered) - { - m_ordered[network_num] = true; - } - m_in_use[network_num] = true; + if (ordered) { + m_ordered[network_num] = true; + } + m_in_use[network_num] = true; } -MessageBuffer* GarnetNetwork_d::getToNetQueue(NodeID id, bool ordered, int network_num) +MessageBuffer* +GarnetNetwork_d::getToNetQueue(NodeID id, bool ordered, int network_num) { - checkNetworkAllocation(id, ordered, network_num); - return m_toNetQueues[id][network_num]; + checkNetworkAllocation(id, ordered, network_num); + return m_toNetQueues[id][network_num]; } -MessageBuffer* GarnetNetwork_d::getFromNetQueue(NodeID id, bool ordered, int network_num) +MessageBuffer* +GarnetNetwork_d::getFromNetQueue(NodeID id, bool ordered, int network_num) { - checkNetworkAllocation(id, ordered, network_num); - return m_fromNetQueues[id][network_num]; + checkNetworkAllocation(id, ordered, network_num); + return m_fromNetQueues[id][network_num]; } -void GarnetNetwork_d::clearStats() +void +GarnetNetwork_d::clearStats() { - m_ruby_start = g_eventQueue_ptr->getTime(); + m_ruby_start = g_eventQueue_ptr->getTime(); } -Time GarnetNetwork_d::getRubyStartTime() +Time +GarnetNetwork_d::getRubyStartTime() { - return m_ruby_start; + return m_ruby_start; } -void GarnetNetwork_d::printStats(ostream& out) const -{ double average_link_utilization = 0; - vector average_vc_load; - average_vc_load.resize(m_virtual_networks*m_vcs_per_class); - - for(int i = 0; i < m_virtual_networks*m_vcs_per_class; i++) - { - average_vc_load[i] = 0; - } - - out << endl; - out << "Network Stats" << endl; - out << "-------------" << endl; - out << endl; - for(int i = 0; i < m_link_ptr_vector.size(); i++) - { - average_link_utilization += (double(m_link_ptr_vector[i]->getLinkUtilization())) / (double(g_eventQueue_ptr->getTime()-m_ruby_start)); - - vector vc_load = m_link_ptr_vector[i]->getVcLoad(); - for(int j = 0; j < vc_load.size(); j++) - { - assert(vc_load.size() == m_vcs_per_class*m_virtual_networks); - average_vc_load[j] += vc_load[j]; - } - } - average_link_utilization = average_link_utilization/m_link_ptr_vector.size(); - out << "Average Link Utilization :: " << average_link_utilization << " flits/cycle" << endl; - out << "-------------" << endl; - - 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; - } - out << "-------------" << endl; - - // out << "Total flits injected = " << m_flits_injected << endl; - // out << "Total flits recieved = " << m_flits_recieved << endl; - out << "Average network latency = " << ((double) m_network_latency/ (double) m_flits_recieved)<< endl; - // out << "Average queueing latency = " << ((double) m_queueing_latency/ (double) m_flits_recieved)<< endl; - // out << "Average latency = " << ((double) (m_queueing_latency + m_network_latency) / (double) m_flits_recieved)<< endl; - out << "-------------" << endl; +void +GarnetNetwork_d::printStats(ostream& out) const +{ + double average_link_utilization = 0; + vector average_vc_load; + average_vc_load.resize(m_virtual_networks*m_vcs_per_class); - double m_total_link_power = 0.0; - double m_total_router_power = 0.0; + for (int i = 0; i < m_virtual_networks*m_vcs_per_class; i++) + { + average_vc_load[i] = 0; + } - for(int i = 0; i < m_link_ptr_vector.size(); i++) - { - m_total_link_power += m_link_ptr_vector[i]->calculate_power(); + out << endl; + out << "Network Stats" << endl; + out << "-------------" << endl; + out << endl; + for (int i = 0; i < m_link_ptr_vector.size(); i++) { + average_link_utilization += + (double(m_link_ptr_vector[i]->getLinkUtilization())) / + (double(g_eventQueue_ptr->getTime()-m_ruby_start)); + + vector vc_load = m_link_ptr_vector[i]->getVcLoad(); + for (int j = 0; j < vc_load.size(); j++) { + assert(vc_load.size() == m_vcs_per_class*m_virtual_networks); + average_vc_load[j] += vc_load[j]; } + } + average_link_utilization = + average_link_utilization/m_link_ptr_vector.size(); + out << "Average Link Utilization :: " << average_link_utilization + << " flits/cycle" << endl; + out << "-------------" << endl; + + 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; + } + out << "-------------" << endl; + + // out << "Total flits injected = " << m_flits_injected << endl; + // out << "Total flits received = " << m_flits_received << endl; + out << "Average network latency = " + << ((double) m_network_latency/ (double) m_flits_received)<< endl; + // out << "Average queueing latency = " + // << ((double) m_queueing_latency/ (double) m_flits_received)<< endl; + // out << "Average latency = " + // << ((double) (m_queueing_latency + m_network_latency) / + // (double) m_flits_received)<< endl; + out << "-------------" << endl; + + double m_total_link_power = 0.0; + double m_total_router_power = 0.0; + + for (int i = 0; i < m_link_ptr_vector.size(); i++) { + m_total_link_power += m_link_ptr_vector[i]->calculate_power(); + } - for(int i = 0; i < m_router_ptr_vector.size(); i++) - { - m_total_router_power += m_router_ptr_vector[i]->calculate_power(); - } - out << "Total Link Power = " << m_total_link_power << " W " << endl; - out << "Total Router Power = " << m_total_router_power << " W " <calculate_power(); + } + out << "Total Link Power = " << m_total_link_power << " W " << endl; + out << "Total Router Power = " << m_total_router_power << " W " <getName() << endl; - out << endl; - - for (int i = 0; i < m_virtual_networks; i++) - { - out << "virtual_net_" << i << ": "; - if (m_in_use[i]) - { - out << "active, "; - if (m_ordered[i]) - { - out << "ordered" << endl; - } - else - { - out << "unordered" << endl; - } - } - else - { - out << "inactive" << endl; - } + out << endl; + out << "Network Configuration" << endl; + out << "---------------------" << endl; + out << "network: GarnetNetwork_d" << endl; + out << "topology: " << m_topology_ptr->getName() << endl; + out << endl; + + for (int i = 0; i < m_virtual_networks; i++) { + out << "virtual_net_" << i << ": "; + if (m_in_use[i]) { + out << "active, "; + if (m_ordered[i]) { + out << "ordered" << endl; + } else { + out << "unordered" << endl; + } + } else { + out << "inactive" << endl; } - out << endl; + } + out << endl; - for(int i = 0; i < m_ni_ptr_vector.size(); i++) - { - m_ni_ptr_vector[i]->printConfig(out); - } - for(int i = 0; i < m_router_ptr_vector.size(); i++) - { - m_router_ptr_vector[i]->printConfig(out); - } - m_topology_ptr->printConfig(out); + for (int i = 0; i < m_ni_ptr_vector.size(); i++) { + m_ni_ptr_vector[i]->printConfig(out); + } + for (int i = 0; i < m_router_ptr_vector.size(); i++) { + m_router_ptr_vector[i]->printConfig(out); + } + m_topology_ptr->printConfig(out); } -void GarnetNetwork_d::print(ostream& out) const +void +GarnetNetwork_d::print(ostream& out) const { - out << "[GarnetNetwork_d]"; + out << "[GarnetNetwork_d]"; } GarnetNetwork_d * 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 7f1b293f4..d3fb9f39b 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh @@ -28,8 +28,8 @@ * Authors: Niket Agarwal */ -#ifndef GARNETNETWORK_D_H -#define GARNETNETWORK_D_H +#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__ +#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__ #include #include @@ -47,84 +47,83 @@ class NetDest; class NetworkLink_d; class CreditLink_d; -class GarnetNetwork_d : public BaseGarnetNetwork { -public: +class GarnetNetwork_d : public BaseGarnetNetwork +{ + public: typedef GarnetNetwork_dParams Params; GarnetNetwork_d(const Params *p); - ~GarnetNetwork_d(); - - void init(); - - int getNumNodes(){ return m_nodes;} - - // 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); - - void clearStats(); - void printStats(std::ostream& out) const; - void printConfig(std::ostream& out) const; - void print(std::ostream& out) const; - - inline void increment_injected_flits() - { - m_flits_injected++; - } - inline void increment_recieved_flits() - { - m_flits_recieved++; - } - inline void increment_network_latency(Time latency) - { - m_network_latency += latency; - } - inline void increment_queueing_latency(Time latency) - { - m_queueing_latency += latency; - } - - bool isVNetOrdered(int vnet) - { - return m_ordered[vnet]; - } - bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; } - - Time getRubyStartTime(); - - void reset(); - - // Methods used by Topology to setup the network - void makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration); - void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration); - void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration); - -private: - void checkNetworkAllocation(NodeID id, bool ordered, int network_num); - -// Private copy constructor and assignment operator - GarnetNetwork_d(const GarnetNetwork_d& obj); - GarnetNetwork_d& operator=(const GarnetNetwork_d& obj); - -/***********Data Members*************/ -// int m_virtual_networks; -// int m_nodes; - int m_flits_recieved, m_flits_injected; - double m_network_latency, m_queueing_latency; - - std::vector m_in_use; - std::vector m_ordered; - - std::vector > m_toNetQueues; - std::vector > m_fromNetQueues; - - std::vector m_router_ptr_vector; // All Routers in Network - std::vector m_link_ptr_vector; // All links in the network - std::vector m_creditlink_ptr_vector; // All links in the network - std::vector m_ni_ptr_vector; // All NI's in Network - -// Topology* m_topology_ptr; - Time m_ruby_start; + ~GarnetNetwork_d(); + + void init(); + + int getNumNodes() { return m_nodes; } + + // 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); + + void clearStats(); + void printStats(std::ostream& out) const; + void printConfig(std::ostream& out) const; + void print(std::ostream& out) const; + + inline void increment_injected_flits() { m_flits_injected++; } + inline void increment_received_flits() { m_flits_received++; } + + inline void + increment_network_latency(Time latency) + { + m_network_latency += latency; + } + + inline void + increment_queueing_latency(Time latency) + { + m_queueing_latency += latency; + } + + bool isVNetOrdered(int vnet) { return m_ordered[vnet]; } + bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; } + Time getRubyStartTime(); + + void reset(); + + // Methods used by Topology to setup the network + void makeOutLink(SwitchID src, NodeID dest, + const NetDest& routing_table_entry, int link_latency, int link_weight, + int bw_multiplier, bool isReconfiguration); + void makeInLink(SwitchID src, NodeID dest, + const NetDest& routing_table_entry, int link_latency, + int bw_multiplier, bool isReconfiguration); + void makeInternalLink(SwitchID src, NodeID dest, + const NetDest& routing_table_entry, int link_latency, int link_weight, + int bw_multiplier, bool isReconfiguration); + + private: + void checkNetworkAllocation(NodeID id, bool ordered, int network_num); + + GarnetNetwork_d(const GarnetNetwork_d& obj); + GarnetNetwork_d& operator=(const GarnetNetwork_d& obj); + + // int m_virtual_networks; + // int m_nodes; + int m_flits_received, m_flits_injected; + double m_network_latency, m_queueing_latency; + + std::vector m_in_use; + std::vector m_ordered; + + std::vector > m_toNetQueues; + std::vector > m_fromNetQueues; + + std::vector m_router_ptr_vector; // All Routers in Network + std::vector m_link_ptr_vector; // All links in the network + std::vector m_creditlink_ptr_vector; // All links in net + std::vector m_ni_ptr_vector; // All NI's in Network + + // Topology* m_topology_ptr; + Time m_ruby_start; }; inline std::ostream& @@ -135,4 +134,4 @@ operator<<(std::ostream& out, const GarnetNetwork_d& obj) return out; } -#endif //GARNETNETWORK_D_H +#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__ diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc index d41c3d4ee..057b11fe9 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.cc @@ -37,58 +37,65 @@ using m5::stl_helpers::deletePointers; InputUnit_d::InputUnit_d(int id, Router_d *router) { - m_id = id; - m_router = router; - m_num_vcs = m_router->get_num_vcs(); + m_id = id; + m_router = router; + m_num_vcs = m_router->get_num_vcs(); - m_num_buffer_reads = 0; - m_num_buffer_writes = 0; + m_num_buffer_reads = 0; + m_num_buffer_writes = 0; - creditQueue = new flitBuffer_d(); - // Instantiating the virtual channels - m_vcs.resize(m_num_vcs); - for(int i=0; i < m_num_vcs; i++) - { - m_vcs[i] = new VirtualChannel_d(i); - } + creditQueue = new flitBuffer_d(); + // Instantiating the virtual channels + m_vcs.resize(m_num_vcs); + for (int i=0; i < m_num_vcs; i++) { + m_vcs[i] = new VirtualChannel_d(i); + } } InputUnit_d::~InputUnit_d() { - delete creditQueue; - deletePointers(m_vcs); + delete creditQueue; + deletePointers(m_vcs); } -void InputUnit_d::wakeup() +void +InputUnit_d::wakeup() { - flit_d *t_flit; - if(m_in_link->isReady()) - { - t_flit = m_in_link->consumeLink(); - int vc = t_flit->get_vc(); - if((t_flit->get_type() == HEAD_) || (t_flit->get_type() == HEAD_TAIL_)) - { - assert(m_vcs[vc]->get_state() == IDLE_); - m_router->route_req(t_flit, this, vc); // Do the route computation for this vc - m_vcs[vc]->set_enqueue_time(g_eventQueue_ptr->getTime()); - } - else - { - t_flit->advance_stage(SA_); - m_router->swarb_req(); - } - m_vcs[vc]->insertFlit(t_flit); // write flit into input buffer - m_num_buffer_writes++; - m_num_buffer_reads++; // same as read because any flit that is written will be read only once + flit_d *t_flit; + if (m_in_link->isReady()) { + + t_flit = m_in_link->consumeLink(); + int vc = t_flit->get_vc(); + + if ((t_flit->get_type() == HEAD_) || + (t_flit->get_type() == HEAD_TAIL_)) { + + assert(m_vcs[vc]->get_state() == IDLE_); + // Do the route computation for this vc + m_router->route_req(t_flit, this, vc); + + m_vcs[vc]->set_enqueue_time(g_eventQueue_ptr->getTime()); + } else { + t_flit->advance_stage(SA_); + m_router->swarb_req(); } -} + // write flit into input buffer + m_vcs[vc]->insertFlit(t_flit); -void InputUnit_d::printConfig(ostream& out) + // number of writes same as reads + // any flit that is written will be read only once + m_num_buffer_writes++; + m_num_buffer_reads++; + } +} + +void +InputUnit_d::printConfig(ostream& out) { - out << endl; - out << "InputUnit Configuration" << endl; - out << "---------------------" << endl; - out << "id = " << m_id << endl; - out << "In link is " << m_in_link->get_id() << endl; + out << endl; + out << "InputUnit Configuration" << endl; + out << "---------------------" << endl; + out << "id = " << m_id << endl; + out << "In link is " << m_in_link->get_id() << endl; } diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh index 4f02729ed..bb2b7aa82 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh @@ -28,8 +28,8 @@ * Authors: Niket Agarwal */ -#ifndef INPUT_UNIT_D_H -#define INPUT_UNIT_D_H +#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_INPUT_UNIT_D_HH__ +#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_INPUT_UNIT_D_HH__ #include #include @@ -43,127 +43,148 @@ class Router_d; -class InputUnit_d : public Consumer { -public: - InputUnit_d(int id, Router_d *router); - ~InputUnit_d(); - - void wakeup(); - void printConfig(std::ostream& out); - flitBuffer_d* getCreditQueue() { return creditQueue; } - void print(std::ostream& out) const {}; - - inline int get_inlink_id() - { - return m_in_link->get_id(); - } - - inline void set_vc_state(VC_state_type state, int vc) - { - m_vcs[vc]->set_state(state); - } - inline void set_enqueue_time(int invc, Time time) - { - m_vcs[invc]->set_enqueue_time(time); - } - inline Time get_enqueue_time(int invc) - { - return m_vcs[invc]->get_enqueue_time(); - } - inline void update_credit(int in_vc, int credit) - { - m_vcs[in_vc]->update_credit(credit); - } - - inline bool has_credits(int vc) - { - return m_vcs[vc]->has_credits(); - } - - inline void increment_credit(int in_vc, bool free_signal) - { - flit_d *t_flit = new flit_d(in_vc, free_signal); - creditQueue->insert(t_flit); - g_eventQueue_ptr->scheduleEvent(m_credit_link, 1); - } - - inline int get_outvc(int invc) - { - return m_vcs[invc]->get_outvc(); - } - - inline void updateRoute(int vc, int outport) - { - m_vcs[vc]->set_outport(outport); - m_vcs[vc]->set_state(VC_AB_); - } - - inline void grant_vc(int in_vc, int out_vc) - { - m_vcs[in_vc]->grant_vc(out_vc); - } - - inline flit_d* peekTopFlit(int vc) - { - return m_vcs[vc]->peekTopFlit(); - } - - inline flit_d* getTopFlit(int vc) - { - return m_vcs[vc]->getTopFlit(); - } - - inline bool need_stage(int vc, VC_state_type state, flit_stage stage) - { - return m_vcs[vc]->need_stage(state, stage); - } - - inline bool need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage) - { - return m_vcs[vc]->need_stage_nextcycle(state, stage); - } - - inline bool isReady(int invc) - { - return m_vcs[invc]->isReady(); - } - - inline int get_route(int vc) - { - return m_vcs[vc]->get_route(); - } - inline void set_in_link(NetworkLink_d *link) - { - m_in_link = link; - } - - inline void set_credit_link(CreditLink_d *credit_link) - { - m_credit_link = credit_link; - } - - inline double get_buf_read_count() - { - return m_num_buffer_reads; - } - - inline double get_buf_write_count() - { - return m_num_buffer_writes; - } - -private: - int m_id; - int m_num_vcs; - double m_num_buffer_writes, m_num_buffer_reads; - - Router_d *m_router; - NetworkLink_d *m_in_link; - CreditLink_d *m_credit_link; - flitBuffer_d *creditQueue; - - // Virtual channels - std::vector m_vcs; // [vc] +class InputUnit_d : public Consumer +{ + public: + InputUnit_d(int id, Router_d *router); + ~InputUnit_d(); + + void wakeup(); + void printConfig(std::ostream& out); + flitBuffer_d* getCreditQueue() { return creditQueue; } + void print(std::ostream& out) const {}; + + inline int get_inlink_id() { return m_in_link->get_id(); } + + inline void + set_vc_state(VC_state_type state, int vc) + { + m_vcs[vc]->set_state(state); + } + + inline void + set_enqueue_time(int invc, Time time) + { + m_vcs[invc]->set_enqueue_time(time); + } + + inline Time + get_enqueue_time(int invc) + { + return m_vcs[invc]->get_enqueue_time(); + } + + inline void + update_credit(int in_vc, int credit) + { + m_vcs[in_vc]->update_credit(credit); + } + + inline bool + has_credits(int vc) + { + return m_vcs[vc]->has_credits(); + } + + inline void + increment_credit(int in_vc, bool free_signal) + { + flit_d *t_flit = new flit_d(in_vc, free_signal); + creditQueue->insert(t_flit); + g_eventQueue_ptr->scheduleEvent(m_credit_link, 1); + } + + inline int + get_outvc(int invc) + { + return m_vcs[invc]->get_outvc(); + } + + inline void + updateRoute(int vc, int outport) + { + m_vcs[vc]->set_outport(outport); + m_vcs[vc]->set_state(VC_AB_); + } + + inline void + grant_vc(int in_vc, int out_vc) + { + m_vcs[in_vc]->grant_vc(out_vc); + } + + inline flit_d* + peekTopFlit(int vc) + { + return m_vcs[vc]->peekTopFlit(); + } + + inline flit_d* + getTopFlit(int vc) + { + return m_vcs[vc]->getTopFlit(); + } + + inline bool + need_stage(int vc, VC_state_type state, flit_stage stage) + { + return m_vcs[vc]->need_stage(state, stage); + } + + inline bool + need_stage_nextcycle(int vc, VC_state_type state, flit_stage stage) + { + return m_vcs[vc]->need_stage_nextcycle(state, stage); + } + + inline bool + isReady(int invc) + { + return m_vcs[invc]->isReady(); + } + + inline int + get_route(int vc) + { + return m_vcs[vc]->get_route(); + } + + inline void + set_in_link(NetworkLink_d *link) + { + m_in_link = link; + } + + inline void + set_credit_link(CreditLink_d *credit_link) + { + m_credit_link = credit_link; + } + + inline double + get_buf_read_count() + { + return m_num_buffer_reads; + } + + inline double + get_buf_write_count() + { + return m_num_buffer_writes; + } + + private: + int m_id; + int m_num_vcs; + double m_num_buffer_writes, m_num_buffer_reads; + + Router_d *m_router; + NetworkLink_d *m_in_link; + CreditLink_d *m_credit_link; + flitBuffer_d *creditQueue; + + // Virtual channels + std::vector m_vcs; }; -#endif +#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_INPUT_UNIT_D_HH__ 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 3cda065ad..a33776c17 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.cc @@ -39,139 +39,153 @@ using namespace std; using m5::stl_helpers::deletePointers; -NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, GarnetNetwork_d *network_ptr) +NetworkInterface_d::NetworkInterface_d(int id, int virtual_networks, + GarnetNetwork_d *network_ptr) { - m_id = id; - m_net_ptr = network_ptr; - m_virtual_networks = virtual_networks; - m_vc_per_vnet = m_net_ptr->getVCsPerClass(); - m_num_vcs = m_vc_per_vnet*m_virtual_networks; - - m_vc_round_robin = 0; - m_ni_buffers.resize(m_num_vcs); - m_ni_enqueue_time.resize(m_num_vcs); - inNode_ptr.resize(m_virtual_networks); - outNode_ptr.resize(m_virtual_networks); - creditQueue = new flitBuffer_d(); - - for(int i =0; i < m_num_vcs; i++) - { - m_ni_buffers[i] = new flitBuffer_d(); // instantiating the NI flit buffers - m_ni_enqueue_time[i] = INFINITE_; - } - m_vc_allocator.resize(m_virtual_networks); // 1 allocator per virtual net - for(int i = 0; i < m_virtual_networks; i++) - { - m_vc_allocator[i] = 0; - } - - for(int i = 0; i < m_num_vcs; i++) - { - m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr)); - m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); - } + m_id = id; + m_net_ptr = network_ptr; + m_virtual_networks = virtual_networks; + m_vc_per_vnet = m_net_ptr->getVCsPerClass(); + m_num_vcs = m_vc_per_vnet*m_virtual_networks; + + m_vc_round_robin = 0; + m_ni_buffers.resize(m_num_vcs); + m_ni_enqueue_time.resize(m_num_vcs); + inNode_ptr.resize(m_virtual_networks); + outNode_ptr.resize(m_virtual_networks); + creditQueue = new flitBuffer_d(); + + // instantiating the NI flit buffers + for (int i = 0; i < m_num_vcs; i++) { + m_ni_buffers[i] = new flitBuffer_d(); + m_ni_enqueue_time[i] = INFINITE_; + } + m_vc_allocator.resize(m_virtual_networks); // 1 allocator per vnet + for (int i = 0; i < m_virtual_networks; i++) { + m_vc_allocator[i] = 0; + } + + for (int i = 0; i < m_num_vcs; i++) { + m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr)); + m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); + } } NetworkInterface_d::~NetworkInterface_d() { - deletePointers(m_out_vc_state); - deletePointers(m_ni_buffers); - delete creditQueue; - delete outSrcQueue; + deletePointers(m_out_vc_state); + deletePointers(m_ni_buffers); + delete creditQueue; + delete outSrcQueue; } -void NetworkInterface_d::addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link) +void +NetworkInterface_d::addInPort(NetworkLink_d *in_link, + CreditLink_d *credit_link) { - inNetLink = in_link; - in_link->setLinkConsumer(this); - m_ni_credit_link = credit_link; - credit_link->setSourceQueue(creditQueue); + inNetLink = in_link; + in_link->setLinkConsumer(this); + m_ni_credit_link = credit_link; + credit_link->setSourceQueue(creditQueue); } -void NetworkInterface_d::addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link) +void +NetworkInterface_d::addOutPort(NetworkLink_d *out_link, + CreditLink_d *credit_link) { - m_credit_link = credit_link; - credit_link->setLinkConsumer(this); + m_credit_link = credit_link; + credit_link->setLinkConsumer(this); - outNetLink = out_link; - outSrcQueue = new flitBuffer_d(); - out_link->setSourceQueue(outSrcQueue); + outNetLink = out_link; + outSrcQueue = new flitBuffer_d(); + out_link->setSourceQueue(outSrcQueue); } -void NetworkInterface_d::addNode(vector& in, vector& out) +void +NetworkInterface_d::addNode(vector& in, + vector& out) { - ASSERT(in.size() == m_virtual_networks); - inNode_ptr = in; - outNode_ptr = out; - for (int j = 0; j < m_virtual_networks; j++) - { - inNode_ptr[j]->setConsumer(this); // So that protocol injects messages into the NI - } + ASSERT(in.size() == m_virtual_networks); + inNode_ptr = in; + outNode_ptr = out; + for (int j = 0; j < m_virtual_networks; j++) { + + // the protocol injects messages into the NI + inNode_ptr[j]->setConsumer(this); + } } -bool NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet) +bool +NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet) { - NetworkMessage *net_msg_ptr = - safe_cast(msg_ptr.get()); - 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->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 - { - int vc = calculateVC(vnet); // this will return a free output virtual channel - if(vc == -1) - { - return false ; - } - MsgPtr new_msg_ptr = msg_ptr->clone(); - NodeID destID = dest_nodes[ctr]; - - NetworkMessage *new_net_msg_ptr = - safe_cast(new_msg_ptr.get()); - if(dest_nodes.size() > 1) - { - NetDest personal_dest; - for(int m = 0; m < (int) MachineType_NUM; m++) - { - if((destID >= MachineType_base_number((MachineType) m)) && destID < MachineType_base_number((MachineType) (m+1))) - { - // calculating the NetDest associated with this destination ID - personal_dest.clear(); - personal_dest.add((MachineID) {(MachineType) m, (destID - MachineType_base_number((MachineType) m))}); - new_net_msg_ptr->getInternalDestination() = personal_dest; - break; - } - } - net_msg_dest.removeNetDest(personal_dest); - net_msg_ptr->getInternalDestination().removeNetDest(personal_dest); // removing the destination from the original message to reflect that a message with this particular destination has been flitisized and an output vc is acquired - } - for(int i = 0; i < num_flits; i++) - { - m_net_ptr->increment_injected_flits(); - flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr); - fl->set_delay(g_eventQueue_ptr->getTime() - msg_ptr->getTime()); - m_ni_buffers[vc]->insert(fl); + NetworkMessage *net_msg_ptr = safe_cast(msg_ptr.get()); + NetDest net_msg_dest = net_msg_ptr->getInternalDestination(); + + // gets all the destinations associated with this message. + vector dest_nodes = net_msg_dest.getAllDest(); + + // 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() ); + + // loop to convert all multicast messages into unicast messages + for (int ctr = 0; ctr < dest_nodes.size(); ctr++) { + + // this will return a free output virtual channel + int vc = calculateVC(vnet); + + if (vc == -1) { + return false ; + } + MsgPtr new_msg_ptr = msg_ptr->clone(); + NodeID destID = dest_nodes[ctr]; + + NetworkMessage *new_net_msg_ptr = + safe_cast(new_msg_ptr.get()); + if (dest_nodes.size() > 1) { + NetDest personal_dest; + for (int m = 0; m < (int) MachineType_NUM; m++) { + if ((destID >= MachineType_base_number((MachineType) m)) && + destID < MachineType_base_number((MachineType) (m+1))) { + // calculating the NetDest associated with this destID + personal_dest.clear(); + personal_dest.add((MachineID) {(MachineType) m, (destID - + MachineType_base_number((MachineType) m))}); + new_net_msg_ptr->getInternalDestination() = personal_dest; + break; } - m_ni_enqueue_time[vc] = g_eventQueue_ptr->getTime(); - m_out_vc_state[vc]->setState(ACTIVE_, g_eventQueue_ptr->getTime()); + } + net_msg_dest.removeNetDest(personal_dest); + // removing the destination from the original message to reflect + // that a message with this particular destination has been + // flitisized and an output vc is acquired + net_msg_ptr->getInternalDestination().removeNetDest(personal_dest); + } + for (int i = 0; i < num_flits; i++) { + m_net_ptr->increment_injected_flits(); + flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr); + fl->set_delay(g_eventQueue_ptr->getTime() - msg_ptr->getTime()); + m_ni_buffers[vc]->insert(fl); } - return true ; + m_ni_enqueue_time[vc] = g_eventQueue_ptr->getTime(); + m_out_vc_state[vc]->setState(ACTIVE_, g_eventQueue_ptr->getTime()); + } + return true ; } // Looking for a free output vc -int NetworkInterface_d::calculateVC(int vnet) +int +NetworkInterface_d::calculateVC(int vnet) { - for(int i = 0; i < m_vc_per_vnet; i++) - { + for (int i = 0; i < m_vc_per_vnet; i++) { int delta = m_vc_allocator[vnet]; m_vc_allocator[vnet]++; if(m_vc_allocator[vnet] == m_vc_per_vnet) m_vc_allocator[vnet] = 0; - if(m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState(IDLE_, g_eventQueue_ptr->getTime())) - { + if (m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState( + IDLE_, g_eventQueue_ptr->getTime())) { return ((vnet*m_vc_per_vnet) + delta); } } @@ -179,176 +193,178 @@ int NetworkInterface_d::calculateVC(int vnet) } /* - * The NI wakeup checks whether there are any ready messages in the protocol buffer. If yes, - * it picks that up, flitisizes it into a number of flits and puts it into an output buffer - * and schedules the output link. On a wakeup it also checks whether there are flits in the - * input link. If yes, it picks them up and if the flit is a tail, the NI inserts the - * corresponding message into the protocol buffer. It also checks for credits being sent - * by the downstream router. + * The NI wakeup checks whether there are any ready messages in the protocol + * buffer. If yes, it picks that up, flitisizes it into a number of flits and + * puts it into an output buffer and schedules the output link. On a wakeup + * it also checks whether there are flits in the input link. If yes, it picks + * them up and if the flit is a tail, the NI inserts the corresponding message + * into the protocol buffer. It also checks for credits being sent by the + * downstream router. */ -void NetworkInterface_d::wakeup() +void +NetworkInterface_d::wakeup() { - DEBUG_EXPR(NETWORK_COMP, MedPrio, m_id); - DEBUG_MSG(NETWORK_COMP, MedPrio, "NI WOKE UP"); - DEBUG_EXPR(NETWORK_COMP, MedPrio, g_eventQueue_ptr->getTime()); - - MsgPtr msg_ptr; - - //Checking for messages coming from the protocol - for (int vnet = 0; vnet < m_virtual_networks; vnet++) // can pick up a message/cycle for each virtual net - { - while(inNode_ptr[vnet]->isReady()) // Is there a message waiting - { - msg_ptr = inNode_ptr[vnet]->peekMsgPtr(); - if(flitisizeMessage(msg_ptr, vnet)) - { - inNode_ptr[vnet]->pop(); - } - else - { - break; - } - } + DEBUG_EXPR(NETWORK_COMP, MedPrio, m_id); + DEBUG_MSG(NETWORK_COMP, MedPrio, "NI WOKE UP"); + DEBUG_EXPR(NETWORK_COMP, MedPrio, g_eventQueue_ptr->getTime()); + + MsgPtr msg_ptr; + + // Checking for messages coming from the protocol + // can pick up a message/cycle for each virtual net + for (int vnet = 0; vnet < m_virtual_networks; vnet++) { + while (inNode_ptr[vnet]->isReady()) { // Is there a message waiting + msg_ptr = inNode_ptr[vnet]->peekMsgPtr(); + if (flitisizeMessage(msg_ptr, vnet)) { + inNode_ptr[vnet]->pop(); + } else { + break; + } } - - scheduleOutputLink(); - checkReschedule(); - -/*********** Picking messages destined for this NI **********/ - - if(inNetLink->isReady()) - { - flit_d *t_flit = inNetLink->consumeLink(); - bool free_signal = false; - if(t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) - { - free_signal = true; - 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 - } - } - flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal); // Simply send a credit back since we are not buddering this flit in the NI - creditQueue->insert(credit_flit); - g_eventQueue_ptr->scheduleEvent(m_ni_credit_link, 1); - - m_net_ptr->increment_recieved_flits(); - int network_delay = g_eventQueue_ptr->getTime() - t_flit->get_enqueue_time(); - int queueing_delay = t_flit->get_delay(); - m_net_ptr->increment_network_latency(network_delay); - m_net_ptr->increment_queueing_latency(queueing_delay); - delete t_flit; + } + + scheduleOutputLink(); + checkReschedule(); + + /*********** Picking messages destined for this NI **********/ + + if (inNetLink->isReady()) { + flit_d *t_flit = inNetLink->consumeLink(); + bool free_signal = false; + if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) { + free_signal = true; + // When we are doing network only testing, the messages do not + // have to be buffered into the protocol buffers + if (!m_net_ptr->isNetworkTesting()) { + outNode_ptr[t_flit->get_vnet()]-> + enqueue(t_flit->get_msg_ptr(), 1); + } } - - /****************** Checking for credit link *******/ - - if(m_credit_link->isReady()) - { - flit_d *t_flit = m_credit_link->consumeLink(); - m_out_vc_state[t_flit->get_vc()]->increment_credit(); - if(t_flit->is_free_signal()) - { - m_out_vc_state[t_flit->get_vc()]->setState(IDLE_, g_eventQueue_ptr->getTime()); - } - delete t_flit; - } + // Simply send a credit back since we are not buffering + // this flit in the NI + flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal); + creditQueue->insert(credit_flit); + g_eventQueue_ptr->scheduleEvent(m_ni_credit_link, 1); + + m_net_ptr->increment_received_flits(); + int network_delay = g_eventQueue_ptr->getTime() - + t_flit->get_enqueue_time(); + int queueing_delay = t_flit->get_delay(); + m_net_ptr->increment_network_latency(network_delay); + m_net_ptr->increment_queueing_latency(queueing_delay); + delete t_flit; + } + + /****************** Checking for credit link *******/ + + if (m_credit_link->isReady()) { + flit_d *t_flit = m_credit_link->consumeLink(); + m_out_vc_state[t_flit->get_vc()]->increment_credit(); + if (t_flit->is_free_signal()) { + m_out_vc_state[t_flit->get_vc()]->setState(IDLE_, + g_eventQueue_ptr->getTime()); + } + delete t_flit; + } } -// This function look at the NI buffers and if some buffer has flits which are ready to traverse the link in the next cycle and also the downstream output vc associated with this flit has buffers left, the link is scheduled for the next cycle +/** This function looks at the NI buffers + * if some buffer has flits which are ready to traverse the link in the next + * cycle, and the downstream output vc associated with this flit has buffers + * left, the link is scheduled for the next cycle + */ -void NetworkInterface_d::scheduleOutputLink() +void +NetworkInterface_d::scheduleOutputLink() { - int vc = m_vc_round_robin; - m_vc_round_robin++; - if(m_vc_round_robin == m_num_vcs) - m_vc_round_robin = 0; - - for(int i = 0; i < m_num_vcs; i++) - { - vc++; - if(vc == m_num_vcs) - vc = 0; - if(m_ni_buffers[vc]->isReady() && m_out_vc_state[vc]->has_credits()) // models buffer backpressure - { - bool is_candidate_vc = true; - int t_vnet = get_vnet(vc); - int vc_base = t_vnet * m_vc_per_vnet; - - if(m_net_ptr->isVNetOrdered(t_vnet)) - { - for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) - { - int t_vc = vc_base + vc_offset; - if(m_ni_buffers[t_vc]->isReady()) - { - if(m_ni_enqueue_time[t_vc] < m_ni_enqueue_time[vc]) - { - is_candidate_vc = false; - break; - } - } - } - } - if(!is_candidate_vc) - continue; - - m_out_vc_state[vc]->decrement_credit(); - flit_d *t_flit = m_ni_buffers[vc]->getTopFlit(); // Just removing the flit - t_flit->set_time(g_eventQueue_ptr->getTime() + 1); - outSrcQueue->insert(t_flit); - g_eventQueue_ptr->scheduleEvent(outNetLink, 1); // schedule the out link - - if(t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) - { - m_ni_enqueue_time[vc] = INFINITE_; + int vc = m_vc_round_robin; + m_vc_round_robin++; + if (m_vc_round_robin == m_num_vcs) + m_vc_round_robin = 0; + + for (int i = 0; i < m_num_vcs; i++) { + vc++; + if (vc == m_num_vcs) + vc = 0; + + // model buffer backpressure + if (m_ni_buffers[vc]->isReady() && m_out_vc_state[vc]->has_credits()) { + bool is_candidate_vc = true; + int t_vnet = get_vnet(vc); + int vc_base = t_vnet * m_vc_per_vnet; + + if (m_net_ptr->isVNetOrdered(t_vnet)) { + for (int vc_offset = 0; vc_offset < m_vc_per_vnet; + vc_offset++) { + int t_vc = vc_base + vc_offset; + if (m_ni_buffers[t_vc]->isReady()) { + if (m_ni_enqueue_time[t_vc] < m_ni_enqueue_time[vc]) { + is_candidate_vc = false; + break; } - return; + } } + } + if (!is_candidate_vc) + continue; + + m_out_vc_state[vc]->decrement_credit(); + // Just removing the flit + flit_d *t_flit = m_ni_buffers[vc]->getTopFlit(); + t_flit->set_time(g_eventQueue_ptr->getTime() + 1); + outSrcQueue->insert(t_flit); + // schedule the out link + g_eventQueue_ptr->scheduleEvent(outNetLink, 1); + + if (t_flit->get_type() == TAIL_ || + t_flit->get_type() == HEAD_TAIL_) { + m_ni_enqueue_time[vc] = INFINITE_; + } + return; } + } } -int NetworkInterface_d::get_vnet(int vc) +int +NetworkInterface_d::get_vnet(int vc) { - for(int i = 0; i < m_net_ptr->getNumberOfVirtualNetworks(); i++) - { - if(vc >= (i*m_vc_per_vnet) && vc < ((i+1)*m_vc_per_vnet)) - { - return i; - } + for (int i = 0; i < m_net_ptr->getNumberOfVirtualNetworks(); i++) { + if (vc >= (i*m_vc_per_vnet) && vc < ((i+1)*m_vc_per_vnet)) { + return i; } - ERROR_MSG("Could not determine vc"); - return -1; + } + ERROR_MSG("Could not determine vc"); + return -1; } -void NetworkInterface_d::checkReschedule() +void +NetworkInterface_d::checkReschedule() { - for(int vnet = 0; vnet < m_virtual_networks; vnet++) - { - if(inNode_ptr[vnet]->isReady()) // Is there a message waiting - { - g_eventQueue_ptr->scheduleEvent(this, 1); - return; - } + for (int vnet = 0; vnet < m_virtual_networks; vnet++) { + if (inNode_ptr[vnet]->isReady()) { // Is there a message waiting + g_eventQueue_ptr->scheduleEvent(this, 1); + return; } - for(int vc = 0; vc < m_num_vcs; vc++) - { - if(m_ni_buffers[vc]->isReadyForNext()) - { - g_eventQueue_ptr->scheduleEvent(this, 1); - return; - } + } + for (int vc = 0; vc < m_num_vcs; vc++) { + if (m_ni_buffers[vc]->isReadyForNext()) { + g_eventQueue_ptr->scheduleEvent(this, 1); + return; } + } } -void NetworkInterface_d::printConfig(std::ostream& out) const +void +NetworkInterface_d::printConfig(std::ostream& out) const { - out << "[Network Interface " << m_id << "] - "; - out << "[inLink " << inNetLink->get_id() << "] - "; - out << "[outLink " << outNetLink->get_id() << "]" << std::endl; + out << "[Network Interface " << m_id << "] - "; + out << "[inLink " << inNetLink->get_id() << "] - "; + out << "[outLink " << outNetLink->get_id() << "]" << std::endl; } -void NetworkInterface_d::print(std::ostream& out) const +void +NetworkInterface_d::print(std::ostream& out) const { - out << "[Network Interface]"; + out << "[Network Interface]"; } diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh index 0da162f82..f1a577e4c 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh +++ b/src/mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh @@ -28,8 +28,8 @@ * Authors: Niket Agarwal */ -#ifndef NET_INTERFACE_D_H -#define NET_INTERFACE_D_H +#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_INTERFACE_D_HH__ +#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_INTERFACE_D_HH__ #include #include @@ -46,49 +46,53 @@ class NetworkMessage; class MessageBuffer; class flitBuffer_d; -class NetworkInterface_d : public Consumer { -public: - NetworkInterface_d(int id, int virtual_networks, GarnetNetwork_d* network_ptr); +class NetworkInterface_d : public Consumer +{ + public: + NetworkInterface_d(int id, int virtual_networks, + GarnetNetwork_d* network_ptr); - ~NetworkInterface_d(); + ~NetworkInterface_d(); - void addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link); - void addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link); + void addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link); + void addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link); - void wakeup(); - void addNode(std::vector &inNode, - std::vector &outNode); - void printConfig(std::ostream& out) const; - void print(std::ostream& out) const; - int get_vnet(int vc); + void wakeup(); + void addNode(std::vector &inNode, + std::vector &outNode); + void printConfig(std::ostream& out) const; + void print(std::ostream& out) const; + int get_vnet(int vc); -private: -/**************Data Members*************/ - GarnetNetwork_d *m_net_ptr; - int m_virtual_networks, m_num_vcs, m_vc_per_vnet; - NodeID m_id; - std::vector m_out_vc_state; - std::vector m_vc_allocator; - int m_vc_round_robin; // For round robin scheduling - flitBuffer_d *outSrcQueue; // For modelling link contention - flitBuffer_d *creditQueue; + private: + GarnetNetwork_d *m_net_ptr; + int m_virtual_networks, m_num_vcs, m_vc_per_vnet; + NodeID m_id; + std::vector m_out_vc_state; + std::vector m_vc_allocator; + int m_vc_round_robin; // For round robin scheduling + flitBuffer_d *outSrcQueue; // For modelling link contention + flitBuffer_d *creditQueue; - NetworkLink_d *inNetLink; - NetworkLink_d *outNetLink; - CreditLink_d *m_credit_link; - CreditLink_d *m_ni_credit_link; + NetworkLink_d *inNetLink; + NetworkLink_d *outNetLink; + CreditLink_d *m_credit_link; + CreditLink_d *m_ni_credit_link; - // Input Flit Buffers - std::vector m_ni_buffers; // The flit buffers which will serve the Consumer - std::vector