diff options
author | Nathan Binkert <nate@binkert.org> | 2009-05-11 10:38:43 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2009-05-11 10:38:43 -0700 |
commit | 2f30950143cc70bc42a3c8a4111d7cf8198ec881 (patch) | |
tree | 708f6c22edb3c6feb31dd82866c26623a5329580 /src/mem/ruby/network/garnet-flexible-pipeline | |
parent | c70241810d4e4f523f173c1646b008dc40faad8e (diff) | |
download | gem5-2f30950143cc70bc42a3c8a4111d7cf8198ec881.tar.xz |
ruby: Import ruby and slicc from GEMS
We eventually plan to replace the m5 cache hierarchy with the GEMS
hierarchy, but for now we will make both live alongside eachother.
Diffstat (limited to 'src/mem/ruby/network/garnet-flexible-pipeline')
21 files changed, 2477 insertions, 0 deletions
diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/FlexibleConsumer.hh b/src/mem/ruby/network/garnet-flexible-pipeline/FlexibleConsumer.hh new file mode 100644 index 000000000..773d00323 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/FlexibleConsumer.hh @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * FlexibleConsumer.h + * + * Niket Agarwal, Princeton University + * + * */ +#ifndef FLEXIBLE_CONSUMER_H +#define FLEXIBLE_CONSUMER_H + +#include "Consumer.hh" +#include "NetworkHeader.hh" +#include "NetDest.hh" + +class FlexibleConsumer : public Consumer { +public: + virtual bool isBufferNotFull(int vc, int inport) {return true;} + virtual void grant_vc(int out_port, int vc, Time grant_time) {} + virtual void release_vc(int out_port, int vc, Time release_time) {} + virtual void request_vc(int vc, int in_port, NetDest destination, Time request_time) {} +}; + +#endif diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.cc b/src/mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.cc new file mode 100644 index 000000000..3d7c555b5 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.cc @@ -0,0 +1,307 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * GarnetNetwork.C + * + * Niket Agarwal, Princeton University + * + * */ + +#include "GarnetNetwork.hh" +#include "MachineType.hh" +#include "NetworkInterface.hh" +#include "MessageBuffer.hh" +#include "Router.hh" +#include "Topology.hh" +#include "SimpleNetwork.hh" +#include "GarnetNetwork_d.hh" +#include "NetworkLink.hh" +#include "NetDest.hh" + +// calls new to abstract away from the network +Network* Network::createNetwork(int nodes) +{ + NetworkConfig::readNetConfig(); + // Instantiate a network depending on what kind of network is requested + if(NetworkConfig::isGarnetNetwork()) + { + if(NetworkConfig::isDetailNetwork()) + return new GarnetNetwork_d(nodes); + else + return new GarnetNetwork(nodes); + } + else + return new SimpleNetwork(nodes); +} + +GarnetNetwork::GarnetNetwork(int nodes) +{ + m_nodes = MachineType_base_number(MachineType_NUM); // Total nodes in network + m_virtual_networks = NUMBER_OF_VIRTUAL_NETWORKS; // Number of virtual networks = number of message classes in the coherence protocol + 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 + m_topology_ptr = new Topology(this, m_nodes); + + int number_of_routers = m_topology_ptr->numSwitches(); + for (int i=0; i<number_of_routers; i++) { + m_router_ptr_vector.insertAtBottom(new Router(i, this)); + } + + for (int i=0; i < m_nodes; i++) { + NetworkInterface *ni = new NetworkInterface(i, m_virtual_networks, this); + ni->addNode(m_toNetQueues[i], m_fromNetQueues[i]); + m_ni_ptr_vector.insertAtBottom(ni); + } + m_topology_ptr->createLinks(false); // false because this isn't a reconfiguration +} + +GarnetNetwork::~GarnetNetwork() +{ + for (int i = 0; i < m_nodes; i++) + { + m_toNetQueues[i].deletePointers(); + m_fromNetQueues[i].deletePointers(); + } + m_router_ptr_vector.deletePointers(); + m_ni_ptr_vector.deletePointers(); + m_link_ptr_vector.deletePointers(); + delete m_topology_ptr; +} + +void GarnetNetwork::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(); + } + } +} + +void GarnetNetwork::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 *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this); + m_link_ptr_vector.insertAtBottom(net_link); + m_router_ptr_vector[dest]->addInPort(net_link); + m_ni_ptr_vector[src]->addOutPort(net_link); + } + else + { + ERROR_MSG("Fatal Error:: Reconfiguration not allowed here"); + // do nothing + } +} + +void GarnetNetwork::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 *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this); + m_link_ptr_vector.insertAtBottom(net_link); + m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight); + m_ni_ptr_vector[dest]->addInPort(net_link); + } + else + { + ERROR_MSG("Fatal Error:: Reconfiguration not allowed here"); + //do nothing + } +} + +void GarnetNetwork::makeInternalLink(SwitchID src, SwitchID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) +{ + if(!isReconfiguration) + { + NetworkLink *net_link = new NetworkLink(m_link_ptr_vector.size(), link_latency, this); + m_link_ptr_vector.insertAtBottom(net_link); + m_router_ptr_vector[dest]->addInPort(net_link); + m_router_ptr_vector[src]->addOutPort(net_link, routing_table_entry, link_weight); + } + else + { + ERROR_MSG("Fatal Error:: Reconfiguration not allowed here"); + // do nothing + } + +} + +void GarnetNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num) +{ + ASSERT(id < m_nodes); + ASSERT(network_num < m_virtual_networks); + + if (ordered) + { + m_ordered[network_num] = true; + } + m_in_use[network_num] = true; +} + +MessageBuffer* GarnetNetwork::getToNetQueue(NodeID id, bool ordered, int network_num) +{ + checkNetworkAllocation(id, ordered, network_num); + return m_toNetQueues[id][network_num]; +} + +MessageBuffer* GarnetNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num) +{ + checkNetworkAllocation(id, ordered, network_num); + return m_fromNetQueues[id][network_num]; +} + +void GarnetNetwork::clearStats() +{ + m_ruby_start = g_eventQueue_ptr->getTime(); +} + +Time GarnetNetwork::getRubyStartTime() +{ + return m_ruby_start; +} + +void GarnetNetwork::printStats(ostream& out) const +{ double average_link_utilization = 0; + Vector<double > average_vc_load; + average_vc_load.setSize(m_virtual_networks*NetworkConfig::getVCsPerClass()); + + for(int i = 0; i < m_virtual_networks*NetworkConfig::getVCsPerClass(); 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 += m_link_ptr_vector[i]->getLinkUtilization(); + Vector<int > vc_load = m_link_ptr_vector[i]->getVcLoad(); + for(int j = 0; j < vc_load.size(); j++) + { + assert(vc_load.size() == NetworkConfig::getVCsPerClass()*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 < NetworkConfig::getVCsPerClass()*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; +} + +void GarnetNetwork::printConfig(ostream& out) const +{ + out << endl; + out << "Network Configuration" << endl; + out << "---------------------" << endl; + out << "network: GARNET_NETWORK" << endl; + out << "topology: " << g_NETWORK_TOPOLOGY << 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; + + 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); + } + if (g_PRINT_TOPOLOGY) + { + m_topology_ptr->printConfig(out); + } +} + +void GarnetNetwork::print(ostream& out) const +{ + out << "[GarnetNetwork]"; +} diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.hh b/src/mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.hh new file mode 100644 index 000000000..cb9a8908a --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/GarnetNetwork.hh @@ -0,0 +1,117 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * GarnetNetwork.h + * + * Niket Agarwal, Princeton University + * + * */ + +#ifndef GARNET_NETWORK_H +#define GARNET_NETWORK_H + +#include "NetworkHeader.hh" +#include "Vector.hh" +#include "NetworkConfig.hh" +#include "Network.hh" + +class NetworkInterface; +class MessageBuffer; +class Router; +class Topology; +class NetDest; +class NetworkLink; + +class GarnetNetwork : public Network{ +public: + GarnetNetwork(int nodes); + + ~GarnetNetwork(); + + // 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(ostream& out) const; + void printConfig(ostream& out) const; + void print(ostream& out) const; + + bool isVNetOrdered(int vnet) { return m_ordered[vnet]; } + bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; } + + Time getRubyStartTime(); + int getNumNodes(){ return m_nodes; } + + 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(const GarnetNetwork& obj); + GarnetNetwork& operator=(const GarnetNetwork& obj); + +/***********Data Members*************/ + int m_virtual_networks; + int m_nodes; + + Vector<bool> m_in_use; + Vector<bool> m_ordered; + + Vector<Vector<MessageBuffer*> > m_toNetQueues; + Vector<Vector<MessageBuffer*> > m_fromNetQueues; + + Vector<Router *> m_router_ptr_vector; // All Routers in Network + Vector<NetworkLink *> m_link_ptr_vector; // All links in the network + Vector<NetworkInterface *> m_ni_ptr_vector; // All NI's in Network + + Topology* m_topology_ptr; + Time m_ruby_start; +}; + +// Output operator declaration +ostream& operator<<(ostream& out, const GarnetNetwork& obj); + +// ******************* Definitions ******************* +// Output operator definition +extern inline +ostream& operator<<(ostream& out, const GarnetNetwork& obj) +{ + obj.print(out); + out << flush; + return out; +} + +#endif //NETWORK_H diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/InVcState.cc b/src/mem/ruby/network/garnet-flexible-pipeline/InVcState.cc new file mode 100644 index 000000000..52090cb2b --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/InVcState.cc @@ -0,0 +1,75 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * InVCState.C + * + * Niket Agarwal, Princeton University + * + * */ + +#include "InVcState.hh" + +InVcState::InVcState(int id) +{ + m_id = id; + m_vc_state = IDLE_; +} + +bool InVcState::isInState(VC_state_type state, Time request_time) +{ + return ((m_vc_state == state) && (request_time >= m_time) ); +} + +void InVcState::setRoute(int route) +{ + m_route = route; +} + +void InVcState::setState(VC_state_type state, Time time) +{ + m_vc_state = state; + m_time = time; +} + +void InVcState::grant_vc(int out_vc, Time grant_time) +{ + m_vc_state = ACTIVE_; + m_time = grant_time; + m_output_vc = out_vc; +} + +int InVcState::get_outport() +{ + return m_route; +} + +int InVcState::get_outvc() +{ + return m_output_vc; +} diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/InVcState.hh b/src/mem/ruby/network/garnet-flexible-pipeline/InVcState.hh new file mode 100644 index 000000000..efbd0d513 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/InVcState.hh @@ -0,0 +1,61 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * + * InVCState.h + * + * Niket Agarwal, Princeton University + * + * */ + +#ifndef IN_VC_STATE_H +#define IN_VC_STATE_H + +#include "NetworkHeader.hh" + +class InVcState { +public: + InVcState(int id); + + void setRoute(int route); + void setState(VC_state_type state, Time time); + int get_outport(); + int get_outvc(); + void grant_vc(int out_vc, Time grant_time); + bool isInState(VC_state_type state, Time time); + +private: + int m_id; + int m_route; + int m_output_vc; + VC_state_type m_vc_state; + Time m_time; +}; + +#endif diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh new file mode 100644 index 000000000..53dd67563 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkConfig.hh @@ -0,0 +1,123 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * NetworkConfig.h + * + * Description: This header file is used to define all configuration parameters required by the interconnection network. + * + * Niket Agarwal, Princeton University + * + * */ + +#ifndef NETWORKCONFIG_H +#define NETWORKCONFIG_H + +#include "NetworkHeader.hh" +#include "util.hh" +#include "RubyConfig.hh" + +class NetworkConfig { + public: + static bool isGarnetNetwork() {return g_GARNET_NETWORK; } + static bool isDetailNetwork() {return g_DETAIL_NETWORK; } + static int isNetworkTesting() {return g_NETWORK_TESTING; } + static int getFlitSize() {return g_FLIT_SIZE; } + static int getNumPipeStages() {return g_NUM_PIPE_STAGES; } + static int getVCsPerClass() {return g_VCS_PER_CLASS; } + static int getBufferSize() {return g_BUFFER_SIZE; } + // This is no longer used. See config/rubyconfig.defaults to set Garnet parameters. + static void readNetConfig() + { + /* + string filename = "network/garnet-flexible-pipeline/"; + filename += NETCONFIG_DEFAULTS; + + if (g_SIMICS) { + filename = "../../../ruby/"+filename; + } + ifstream NetconfigFile( filename.c_str(), ios::in); + if(!NetconfigFile.is_open()) + { + cout << filename << endl; + cerr << "Network Configuration file cannot be opened\n"; + exit(1); + } + + string line = ""; + + while(!NetconfigFile.eof()) + { + getline(NetconfigFile, line, '\n'); + string var = string_split(line, ':'); + + if(!var.compare("g_GARNET_NETWORK")) + { + if(!line.compare("true")) + g_GARNET_NETWORK = true; + else + g_GARNET_NETWORK = false; + } + if(!var.compare("g_DETAIL_NETWORK")) + { + if(!line.compare("true")) + g_DETAIL_NETWORK = true; + else + g_DETAIL_NETWORK = false; + } + if(!var.compare("g_NETWORK_TESTING")) + { + if(!line.compare("true")) + g_NETWORK_TESTING = true; + else + g_NETWORK_TESTING = false; + } + if(!var.compare("g_FLIT_SIZE")) + g_FLIT_SIZE = atoi(line.c_str()); + if(!var.compare("g_NUM_PIPE_STAGES")) + g_NUM_PIPE_STAGES = atoi(line.c_str()); + if(!var.compare("g_VCS_PER_CLASS")) + g_VCS_PER_CLASS = atoi(line.c_str()); + if(!var.compare("g_BUFFER_SIZE")) + g_BUFFER_SIZE = atoi(line.c_str()); + } + NetconfigFile.close(); + */ + /* + cout << "g_GARNET_NETWORK = " << g_GARNET_NETWORK << endl; + cout << "g_DETAIL_NETWORK = " << g_DETAIL_NETWORK << endl; + cout << "g_NETWORK_TESTING = " << g_NETWORK_TESTING << endl; + cout << "g_FLIT_SIZE = " << g_FLIT_SIZE << endl; + cout << "g_NUM_PIPE_STAGES = " << g_NUM_PIPE_STAGES << endl; + cout << "g_VCS_PER_CLASS= " << g_VCS_PER_CLASS << endl; + cout << "g_BUFFER_SIZE = " << g_BUFFER_SIZE << endl; + */ + } +}; + +#endif diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/NetworkInterface.cc b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkInterface.cc new file mode 100644 index 000000000..3dfb5b4b9 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkInterface.cc @@ -0,0 +1,306 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * NetworkInterface.C + * + * Niket Agarwal, Princeton University + * + * */ + +#include "NetworkInterface.hh" +#include "MessageBuffer.hh" +#include "flitBuffer.hh" +#include "NetworkMessage.hh" + +NetworkInterface::NetworkInterface(int id, int virtual_networks, GarnetNetwork *network_ptr) +{ + m_id = id; + m_net_ptr = network_ptr; + m_virtual_networks = virtual_networks; + m_vc_per_vnet = NetworkConfig::getVCsPerClass(); + m_num_vcs = m_vc_per_vnet*m_virtual_networks; + + m_vc_round_robin = 0; + m_ni_buffers.setSize(m_num_vcs); + inNode_ptr.setSize(m_virtual_networks); + outNode_ptr.setSize(m_virtual_networks); + + for(int i =0; i < m_num_vcs; i++) + m_ni_buffers[i] = new flitBuffer(); // instantiating the NI flit buffers + + m_vc_allocator.setSize(m_virtual_networks); + 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.insertAtBottom(new OutVcState(i)); + m_out_vc_state[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); + } +} + +NetworkInterface::~NetworkInterface() +{ + m_out_vc_state.deletePointers(); + m_ni_buffers.deletePointers(); + delete outSrcQueue; +} + +void NetworkInterface::addInPort(NetworkLink *in_link) +{ + inNetLink = in_link; + in_link->setLinkConsumer(this); +} + +void NetworkInterface::addOutPort(NetworkLink *out_link) +{ + outNetLink = out_link; + outSrcQueue = new flitBuffer(); + out_link->setSourceQueue(outSrcQueue); + out_link->setSource(this); +} + +void NetworkInterface::addNode(Vector<MessageBuffer*>& in, Vector<MessageBuffer*>& 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 + } +} + +void NetworkInterface::request_vc(int in_vc, int in_port, NetDest destination, Time request_time) +{ + inNetLink->grant_vc_link(in_vc, request_time); +} + +bool NetworkInterface::flitisizeMessage(MsgPtr msg_ptr, int vnet) +{ + NetworkMessage *net_msg_ptr = dynamic_cast<NetworkMessage*>(msg_ptr.ref()); + NetDest net_msg_dest = net_msg_ptr->getInternalDestination(); + Vector<NodeID> dest_nodes = net_msg_dest.getAllDest(); // gets all the destinations associated with this message. + int num_flits = (int) ceil((double) MessageSizeType_to_int(net_msg_ptr->getMessageSize())/NetworkConfig::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) + { + // did not find a free output vc + return false ; + } + MsgPtr new_msg_ptr = *(msg_ptr.ref()); + NodeID destID = dest_nodes[ctr]; + + NetworkMessage *new_net_msg_ptr = dynamic_cast<NetworkMessage*>(new_msg_ptr.ref()); + 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++) + { + flit *fl = new flit(i, vc, vnet, num_flits, new_msg_ptr); + m_ni_buffers[vc]->insert(fl); + } + + m_out_vc_state[vc]->setState(VC_AB_, g_eventQueue_ptr->getTime()); + outNetLink->request_vc_link(vc, new_net_msg_ptr->getInternalDestination(), g_eventQueue_ptr->getTime()); // setting an output vc request for the next hop. It is only when an output vc is acquired at the next hop that this flit will be ready to traverse the link and into the next hop + } + + return true ; +} + +// An output vc has been granted at the next hop to one of the vc's. We have to update the state of the vc to reflect this +void NetworkInterface::grant_vc(int out_port, int vc, Time grant_time) +{ + + assert(m_out_vc_state[vc]->isInState(VC_AB_, grant_time)); + m_out_vc_state[vc]->grant_vc(grant_time); + g_eventQueue_ptr->scheduleEvent(this, 1); +} + +// The tail flit corresponding to this vc has been buffered at the next hop and thus this vc is now free +void NetworkInterface::release_vc(int out_port, int vc, Time release_time) +{ + assert(m_out_vc_state[vc]->isInState(ACTIVE_, release_time)); + m_out_vc_state[vc]->setState(IDLE_, release_time); + g_eventQueue_ptr->scheduleEvent(this, 1); +} + +// Looking for a free output vc +int NetworkInterface::calculateVC(int vnet) +{ + int vc_per_vnet; + if(m_net_ptr->isVNetOrdered(vnet)) + vc_per_vnet = 1; + else + vc_per_vnet = m_vc_per_vnet; + + for(int i = 0; i < vc_per_vnet; i++) + { + int delta = m_vc_allocator[vnet]; + m_vc_allocator[vnet]++; + if(m_vc_allocator[vnet] == 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())) + { + return ((vnet*m_vc_per_vnet) + delta); + } + } + return -1; +} + +/* + * 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. + */ + +void NetworkInterface::wakeup() +{ + 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; + } + } + } + + scheduleOutputLink(); + checkReschedule(); + +/*********** Picking messages destined for this NI **********/ + + if(inNetLink->isReady()) + { + flit *t_flit = inNetLink->consumeLink(); + if(t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) + { + 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(!NetworkConfig::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 + } + inNetLink->release_vc_link(t_flit->get_vc(), g_eventQueue_ptr->getTime() + 1); // signal the upstream router that this vc can be freed now + } + 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 +void NetworkInterface::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()) + { + if(m_out_vc_state[vc]->isInState(ACTIVE_, g_eventQueue_ptr->getTime()) && outNetLink->isBufferNotFull_link(vc)) // models buffer backpressure + { + flit *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 + return; + } + } + } +} + +void NetworkInterface::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 vc = 0; vc < m_num_vcs; vc++) + { + if(m_ni_buffers[vc]->isReadyForNext()) + { + g_eventQueue_ptr->scheduleEvent(this, 1); + return; + } + } +} + +void NetworkInterface::printConfig(ostream& out) const +{ + out << "[Network Interface " << m_id << "] - "; + out << "[inLink " << inNetLink->get_id() << "] - "; + out << "[outLink " << outNetLink->get_id() << "]" << endl; +} + +void NetworkInterface::print(ostream& out) const +{ + out << "[Network Interface]"; +} diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/NetworkInterface.hh b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkInterface.hh new file mode 100644 index 000000000..d7932432b --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkInterface.hh @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * NetworkInterface.h + * + * Niket Agarwal, Princeton University + * + * */ +#ifndef NET_INTERFACE_H +#define NET_INTERFACE_H + +#include "NetworkHeader.hh" +#include "GarnetNetwork.hh" +#include "Vector.hh" +#include "FlexibleConsumer.hh" +#include "Message.hh" +#include "NetworkLink.hh" +#include "OutVcState.hh" + +class NetworkMessage; +class MessageBuffer; +class flitBuffer; + +class NetworkInterface : public FlexibleConsumer { +public: + NetworkInterface(int id, int virtual_networks, GarnetNetwork* network_ptr); + + ~NetworkInterface(); + + void addInPort(NetworkLink *in_link); + void addOutPort(NetworkLink *out_link); + + void wakeup(); + void addNode(Vector<MessageBuffer *> &inNode, Vector<MessageBuffer *> &outNode); + void grant_vc(int out_port, int vc, Time grant_time); + void release_vc(int out_port, int vc, Time release_time); + bool isBufferNotFull(int vc, int inport) + { + return true; + } + void request_vc(int in_vc, int in_port, NetDest destination, Time request_time); + + void printConfig(ostream& out) const; + void print(ostream& out) const; + +private: +/**************Data Members*************/ + GarnetNetwork *m_net_ptr; + int m_virtual_networks, m_num_vcs, m_vc_per_vnet; + NodeID m_id; + + Vector<OutVcState *> m_out_vc_state; + Vector<int > m_vc_allocator; + int m_vc_round_robin; // For round robin scheduling + flitBuffer *outSrcQueue; // For modelling link contention + + NetworkLink *inNetLink; + NetworkLink *outNetLink; + + // Input Flit Buffers + Vector<flitBuffer *> m_ni_buffers; // The flit buffers which will serve the Consumer + + Vector<MessageBuffer *> inNode_ptr; // The Message buffers that takes messages from the protocol + Vector<MessageBuffer *> outNode_ptr; // The Message buffers that provides messages to the protocol + + bool flitisizeMessage(MsgPtr msg_ptr, int vnet); + int calculateVC(int vnet); + void scheduleOutputLink(); + void checkReschedule(); +}; + +#endif diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/NetworkLink.cc b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkLink.cc new file mode 100644 index 000000000..e586ece9e --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkLink.cc @@ -0,0 +1,147 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * NetworkLink.C + * + * Niket Agarwal, Princeton University + * + * */ + +#include "NetworkLink.hh" +#include "NetworkConfig.hh" +#include "GarnetNetwork.hh" + +NetworkLink::NetworkLink(int id, int latency, GarnetNetwork *net_ptr) +{ + m_id = id; + linkBuffer = new flitBuffer(); + m_in_port = 0; + m_out_port = 0; + m_link_utilized = 0; + m_net_ptr = net_ptr; + m_latency = latency; + int num_net = NUMBER_OF_VIRTUAL_NETWORKS; + int num_vc = NetworkConfig::getVCsPerClass(); + m_vc_load.setSize(num_net*num_vc); + + for(int i = 0; i < num_net*num_vc; i++) + m_vc_load[i] = 0; +} + +NetworkLink::~NetworkLink() +{ + delete linkBuffer; +} + +int NetworkLink::get_id() +{ + return m_id; +} + +void NetworkLink::setLinkConsumer(FlexibleConsumer *consumer) +{ + link_consumer = consumer; +} + +void NetworkLink::setSourceQueue(flitBuffer *srcQueue) +{ + link_srcQueue = srcQueue; +} + +void NetworkLink::setSource(FlexibleConsumer *source) +{ + link_source = source; +} +void NetworkLink::request_vc_link(int vc, NetDest destination, Time request_time) +{ + link_consumer->request_vc(vc, m_in_port, destination, request_time); +} +bool NetworkLink::isBufferNotFull_link(int vc) +{ + return link_consumer->isBufferNotFull(vc, m_in_port); +} + +void NetworkLink::grant_vc_link(int vc, Time grant_time) +{ + link_source->grant_vc(m_out_port, vc, grant_time); +} + +void NetworkLink::release_vc_link(int vc, Time release_time) +{ + link_source->release_vc(m_out_port, vc, release_time); +} + +Vector<int> NetworkLink::getVcLoad() +{ + return m_vc_load; +} + +double NetworkLink::getLinkUtilization() +{ + Time m_ruby_start = m_net_ptr->getRubyStartTime(); + return (double(m_link_utilized)) / (double(g_eventQueue_ptr->getTime()-m_ruby_start)); +} + +bool NetworkLink::isReady() +{ + return linkBuffer->isReady(); +} + +void NetworkLink::setInPort(int port) +{ + m_in_port = port; +} + +void NetworkLink::setOutPort(int port) +{ + m_out_port = port; +} + +void NetworkLink::wakeup() +{ + if(link_srcQueue->isReady()) + { + flit *t_flit = link_srcQueue->getTopFlit(); + t_flit->set_time(g_eventQueue_ptr->getTime() + m_latency); + linkBuffer->insert(t_flit); + g_eventQueue_ptr->scheduleEvent(link_consumer, m_latency); + m_link_utilized++; + m_vc_load[t_flit->get_vc()]++; + } +} + +flit* NetworkLink::peekLink() +{ + return linkBuffer->peekTopFlit(); +} + +flit* NetworkLink::consumeLink() +{ + return linkBuffer->getTopFlit(); +} diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/NetworkLink.hh b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkLink.hh new file mode 100644 index 000000000..cdea89d79 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/NetworkLink.hh @@ -0,0 +1,88 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * NetworkLink.h + * + * Niket Agarwal, Princeton University + * + * */ +#ifndef NETWORK_LINK_H +#define NETWORK_LINK_H + +#include "NetworkHeader.hh" +#include "FlexibleConsumer.hh" +#include "flitBuffer.hh" +#include "PrioHeap.hh" +#include "NetDest.hh" + +class GarnetNetwork; + +class NetworkLink : public FlexibleConsumer { +public: + NetworkLink(); + NetworkLink(int id, int latency, GarnetNetwork *net_ptr); + ~NetworkLink(); + + void setLinkConsumer(FlexibleConsumer *consumer); + void setSourceQueue(flitBuffer *srcQueue); + flit* peekLink(); + flit* consumeLink(); + + void print(ostream& out) const {} + + bool is_vc_ready(flit *t_flit); + + int get_id(); + void setInPort(int port); + void setOutPort(int port); + void wakeup(); + bool isReady(); + void grant_vc_link(int vc, Time grant_time); + void release_vc_link(int vc, Time release_time); + void request_vc_link(int vc, NetDest destination, Time request_time); + bool isBufferNotFull_link(int vc); + void setSource(FlexibleConsumer *source); + double getLinkUtilization(); + Vector<int> getVcLoad(); + +protected: + int m_id, m_latency; + int m_in_port, m_out_port; + int m_link_utilized; + Vector<int > m_vc_load; + GarnetNetwork *m_net_ptr; + + flitBuffer *linkBuffer; + FlexibleConsumer *link_consumer; + FlexibleConsumer *link_source; + flitBuffer *link_srcQueue; +}; + +#endif + diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/OutVcState.cc b/src/mem/ruby/network/garnet-flexible-pipeline/OutVcState.cc new file mode 100644 index 000000000..5d43a7821 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/OutVcState.cc @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * OutVCState.C + * + * Niket Agarwal, Princeton University + * + * */ + +#include "OutVcState.hh" + +OutVcState::OutVcState(int id) +{ + m_id = id; + m_vc_state = IDLE_; +} + +bool OutVcState::isInState(VC_state_type state, Time request_time) +{ + return ((m_vc_state == state) && (request_time >= m_time) ); +} + +void OutVcState::grant_vc(Time grant_time) +{ + m_time = grant_time; + m_vc_state = ACTIVE_; +} + +void OutVcState::setState(VC_state_type state, Time time) +{ + m_vc_state = state; + m_time = time; +} + diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/OutVcState.hh b/src/mem/ruby/network/garnet-flexible-pipeline/OutVcState.hh new file mode 100644 index 000000000..81120ee8c --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/OutVcState.hh @@ -0,0 +1,55 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * OutVCState.h + * + * Niket Agarwal, Princeton University + * + * */ + +#ifndef OUT_VC_STATE_H +#define OUT_VC_STATE_H + +#include "NetworkHeader.hh" + +class OutVcState { +public: + OutVcState(int id); + + bool isInState(VC_state_type state, Time request_time); + void setState(VC_state_type state, Time time); + void grant_vc(Time grant_time); + +private: + int m_id ; + Time m_time; + VC_state_type m_vc_state; +}; + +#endif diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/Router.cc b/src/mem/ruby/network/garnet-flexible-pipeline/Router.cc new file mode 100644 index 000000000..4809d43ed --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/Router.cc @@ -0,0 +1,389 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * Router.C + * + * Niket Agarwal, Princeton University + * + * */ + +#include "Router.hh" +#include "NetworkMessage.hh" +#include "InVcState.hh" +#include "OutVcState.hh" +#include "VCarbiter.hh" + +Router::Router(int id, GarnetNetwork *network_ptr) +{ + m_id = id; + m_net_ptr = network_ptr; + m_virtual_networks = NUMBER_OF_VIRTUAL_NETWORKS; + m_vc_per_vnet = NetworkConfig::getVCsPerClass(); + m_round_robin_inport = 0; + m_round_robin_start = 0; + m_num_vcs = m_vc_per_vnet*m_virtual_networks; + m_vc_arbiter = new VCarbiter(this); +} + +Router::~Router() +{ + for (int i = 0; i < m_in_link.size(); i++) + { + m_in_vc_state[i].deletePointers(); + } + for (int i = 0; i < m_out_link.size(); i++) + { + m_out_vc_state[i].deletePointers(); + m_router_buffers[i].deletePointers(); + } + m_out_src_queue.deletePointers(); + delete m_vc_arbiter; + +} + +void Router::addInPort(NetworkLink *in_link) +{ + int port = m_in_link.size(); + Vector<InVcState *> in_vc_vector; + for(int i = 0; i < m_num_vcs; i++) + { + in_vc_vector.insertAtBottom(new InVcState(i)); + in_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); + } + m_in_vc_state.insertAtBottom(in_vc_vector); + m_in_link.insertAtBottom(in_link); + in_link->setLinkConsumer(this); + in_link->setInPort(port); + + int start = 0; + m_round_robin_invc.insertAtBottom(start); + +} + +void Router::addOutPort(NetworkLink *out_link, const NetDest& routing_table_entry, int link_weight) +{ + int port = m_out_link.size(); + out_link->setOutPort(port); + int start = 0; + m_vc_round_robin.insertAtBottom(start); + + m_out_src_queue.insertAtBottom(new flitBuffer()); + + m_out_link.insertAtBottom(out_link); + m_routing_table.insertAtBottom(routing_table_entry); + out_link->setSourceQueue(m_out_src_queue[port]); + out_link->setSource(this); + + Vector<flitBuffer *> intermediateQueues; + for(int i = 0; i < m_num_vcs; i++) + { + intermediateQueues.insertAtBottom(new flitBuffer(NetworkConfig::getBufferSize())); + } + m_router_buffers.insertAtBottom(intermediateQueues); + + Vector<OutVcState *> out_vc_vector; + for(int i = 0; i < m_num_vcs; i++) + { + out_vc_vector.insertAtBottom(new OutVcState(i)); + out_vc_vector[i]->setState(IDLE_, g_eventQueue_ptr->getTime()); + } + m_out_vc_state.insertAtBottom(out_vc_vector); + m_link_weights.insertAtBottom(link_weight); +} + +bool Router::isBufferNotFull(int vc, int inport) +{ + int outport = m_in_vc_state[inport][vc]->get_outport(); + int outvc = m_in_vc_state[inport][vc]->get_outvc(); + + return (!m_router_buffers[outport][outvc]->isFull()); +} + +// A request for an output vc has been placed by an upstream Router/NI. This has to be updated and arbitration performed +void Router::request_vc(int in_vc, int in_port, NetDest destination, Time request_time) +{ + assert(m_in_vc_state[in_port][in_vc]->isInState(IDLE_, request_time)); + + int outport = getRoute(destination); + m_in_vc_state[in_port][in_vc]->setRoute(outport); + m_in_vc_state[in_port][in_vc]->setState(VC_AB_, request_time); + assert(request_time >= g_eventQueue_ptr->getTime()); + if(request_time > g_eventQueue_ptr->getTime()) + g_eventQueue_ptr->scheduleEventAbsolute(m_vc_arbiter, request_time); + else + vc_arbitrate(); +} + +void Router::vc_arbitrate() +{ + int inport = m_round_robin_inport; + m_round_robin_inport++; + if(m_round_robin_inport == m_in_link.size()) + m_round_robin_inport = 0; + + for(int port_iter = 0; port_iter < m_in_link.size(); port_iter++) + { + inport++; + if(inport >= m_in_link.size()) + inport = 0; + int invc = m_round_robin_invc[inport]; + m_round_robin_invc[inport]++; + + if(m_round_robin_invc[inport] >= m_num_vcs) + m_round_robin_invc[inport] = 0; + for(int vc_iter = 0; vc_iter < m_num_vcs; vc_iter++) + { + invc++; + if(invc >= m_num_vcs) + invc = 0; + InVcState *in_vc_state = m_in_vc_state[inport][invc]; + + if(in_vc_state->isInState(VC_AB_, g_eventQueue_ptr->getTime())) + { + int outport = in_vc_state->get_outport(); + Vector<int > valid_vcs = get_valid_vcs(invc); + for(int valid_vc_iter = 0; valid_vc_iter < valid_vcs.size(); valid_vc_iter++) + { + if(m_out_vc_state[outport][valid_vcs[valid_vc_iter]]->isInState(IDLE_, g_eventQueue_ptr->getTime())) + { + in_vc_state->grant_vc(valid_vcs[valid_vc_iter], g_eventQueue_ptr->getTime()); + m_in_link[inport]->grant_vc_link(invc, g_eventQueue_ptr->getTime()); + m_out_vc_state[outport][valid_vcs[valid_vc_iter]]->setState(VC_AB_, g_eventQueue_ptr->getTime()); + break; + } + } + } + } + } +} + +Vector<int > Router::get_valid_vcs(int invc) +{ + Vector<int > vc_list; + + for(int vnet = 0; vnet < m_virtual_networks; vnet++) + { + if(invc >= (vnet*m_vc_per_vnet) && invc < ((vnet+1)*m_vc_per_vnet)) + { + int base = vnet*m_vc_per_vnet; + int vc_per_vnet; + if(m_net_ptr->isVNetOrdered(vnet)) + vc_per_vnet = 1; + else + vc_per_vnet = m_vc_per_vnet; + + for(int offset = 0; offset < vc_per_vnet; offset++) + { + vc_list.insertAtBottom(base+offset); + } + break; + } + } + return vc_list; +} + +void Router::grant_vc(int out_port, int vc, Time grant_time) +{ + assert(m_out_vc_state[out_port][vc]->isInState(VC_AB_, grant_time)); + m_out_vc_state[out_port][vc]->grant_vc(grant_time); + g_eventQueue_ptr->scheduleEvent(this, 1); +} + +void Router::release_vc(int out_port, int vc, Time release_time) +{ + assert(m_out_vc_state[out_port][vc]->isInState(ACTIVE_, release_time)); + m_out_vc_state[out_port][vc]->setState(IDLE_, release_time); + g_eventQueue_ptr->scheduleEvent(this, 1); +} + +// This function calculated the output port for a particular destination. +int Router::getRoute(NetDest destination) +{ + int output_link = -1; + int min_weight = INFINITE_; + for(int link = 0; link < m_routing_table.size(); link++) + { + if (destination.intersectionIsNotEmpty(m_routing_table[link])) + { + if((m_link_weights[link] >= min_weight)) + continue; + output_link = link; + min_weight = m_link_weights[link]; + } + } + return output_link; +} + +void Router::routeCompute(flit *m_flit, int inport) +{ + int invc = m_flit->get_vc(); + int outport = m_in_vc_state[inport][invc]->get_outport(); + int outvc = m_in_vc_state[inport][invc]->get_outvc(); + + assert(NetworkConfig::getNumPipeStages() >= 1); + m_flit->set_time(g_eventQueue_ptr->getTime() + (NetworkConfig::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(NetworkConfig::getNumPipeStages() > 1) + g_eventQueue_ptr->scheduleEvent(this, NetworkConfig::getNumPipeStages() -1 ); + if((m_flit->get_type() == HEAD_) || (m_flit->get_type() == HEAD_TAIL_)) + { + NetDest destination = dynamic_cast<NetworkMessage*>(m_flit->get_msg_ptr().ref())->getInternalDestination(); + if(NetworkConfig::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); + } + else + { + m_out_vc_state[outport][outvc]->setState(VC_AB_, g_eventQueue_ptr->getTime()); + m_out_link[outport]->request_vc_link(outvc, destination, g_eventQueue_ptr->getTime()); + } + } + if((m_flit->get_type() == TAIL_) || (m_flit->get_type() == HEAD_TAIL_)) + { + m_in_vc_state[inport][invc]->setState(IDLE_, g_eventQueue_ptr->getTime() + 1); + m_in_link[inport]->release_vc_link(invc, g_eventQueue_ptr->getTime() + 1); + } +} + +void Router::wakeup() +{ + flit *t_flit; + + int incoming_port = m_round_robin_start; // This is for round-robin scheduling of incoming ports + m_round_robin_start++; + if (m_round_robin_start >= m_in_link.size()) { + m_round_robin_start = 0; + } + + for(int port = 0; port < m_in_link.size(); port++) + { + // Round robin scheduling + incoming_port++; + if(incoming_port >= m_in_link.size()) + incoming_port = 0; + if(m_in_link[incoming_port]->isReady()) // checking the incoming link + { + DEBUG_EXPR(NETWORK_COMP, HighPrio, m_id); + DEBUG_EXPR(NETWORK_COMP, HighPrio, g_eventQueue_ptr->getTime()); + t_flit = m_in_link[incoming_port]->peekLink(); + routeCompute(t_flit, incoming_port); + m_in_link[incoming_port]->consumeLink(); + } + } + scheduleOutputLinks(); + checkReschedule(); // This is for flits lying in the router buffers + vc_arbitrate(); + check_arbiter_reschedule(); +} + +void Router::scheduleOutputLinks() +{ + for(int port = 0; port < m_out_link.size(); port++) + { + int vc_tolookat = m_vc_round_robin[port]; + m_vc_round_robin[port]++; + if(m_vc_round_robin[port] == m_num_vcs) + m_vc_round_robin[port] = 0; + + for(int i = 0; i < m_num_vcs; i++) + { + vc_tolookat++; + if(vc_tolookat == m_num_vcs) + vc_tolookat = 0; + + if(m_router_buffers[port][vc_tolookat]->isReady()) + { + if(m_out_vc_state[port][vc_tolookat]->isInState(ACTIVE_, g_eventQueue_ptr->getTime()) && m_out_link[port]->isBufferNotFull_link(vc_tolookat)) + // models buffer backpressure + { + flit *t_flit = m_router_buffers[port][vc_tolookat]->getTopFlit(); + t_flit->set_time(g_eventQueue_ptr->getTime() + 1 ); + m_out_src_queue[port]->insert(t_flit); + g_eventQueue_ptr->scheduleEvent(m_out_link[port], 1); + break; // done for this port + } + } + } + } +} + +void Router::checkReschedule() +{ + for(int port = 0; port < m_out_link.size(); port++) + { + for(int vc = 0; vc < m_num_vcs; vc++) + { + if(m_router_buffers[port][vc]->isReadyForNext()) + { + g_eventQueue_ptr->scheduleEvent(this, 1); + return; + } + } + } +} + +void Router::check_arbiter_reschedule() +{ + for(int port = 0; port < m_in_link.size(); port++) + { + for(int vc = 0; vc < m_num_vcs; vc++) + { + if(m_in_vc_state[port][vc]->isInState(VC_AB_, g_eventQueue_ptr->getTime() + 1)) + { + g_eventQueue_ptr->scheduleEvent(m_vc_arbiter, 1); + return; + } + } + } +} + +void Router::printConfig(ostream& out) const +{ + out << "[Router " << m_id << "] :: " << endl; + out << "[inLink - "; + for(int i = 0;i < m_in_link.size(); i++) + out << m_in_link[i]->get_id() << " - "; + out << "]" << endl; + out << "[outLink - "; + for(int i = 0;i < m_out_link.size(); i++) + out << m_out_link[i]->get_id() << " - "; + out << "]" << endl; +/* out << "---------- routing table -------------" << endl; + for(int i =0; i < m_routing_table.size(); i++) + out << m_routing_table[i] << endl; +*/ +} + +void Router::print(ostream& out) const +{ + out << "[Router]"; +} diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/Router.hh b/src/mem/ruby/network/garnet-flexible-pipeline/Router.hh new file mode 100644 index 000000000..c0d91e0dd --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/Router.hh @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * Router.h + * + * Niket Agarwal, Princeton University + * + * */ + +#ifndef ROUTER_H +#define ROUTER_H + +#include "NetworkHeader.hh" +#include "GarnetNetwork.hh" +#include "FlexibleConsumer.hh" +#include "PrioHeap.hh" +#include "NetworkLink.hh" +#include "NetDest.hh" +#include "flitBuffer.hh" +#include "InVcState.hh" +#include "OutVcState.hh" + +class VCarbiter; + +class Router : public FlexibleConsumer { +public: + Router(int id, GarnetNetwork *network_ptr); + + ~Router(); + + void addInPort(NetworkLink *in_link); + void addOutPort(NetworkLink *out_link, const NetDest& routing_table_entry, int link_weight); + void wakeup(); + void request_vc(int in_vc, int in_port, NetDest destination, Time request_time); + bool isBufferNotFull(int vc, int inport); + void grant_vc(int out_port, int vc, Time grant_time); + void release_vc(int out_port, int vc, Time release_time); + void vc_arbitrate(); + + void printConfig(ostream& out) const; + void print(ostream& out) const; + +private: +/***************Data Members******************/ + int m_id; + int m_virtual_networks, m_num_vcs, m_vc_per_vnet; + GarnetNetwork *m_net_ptr; + Vector<int > m_vc_round_robin; // For scheduling of out source queues + int m_round_robin_inport, m_round_robin_start; // for vc arbitration + Vector<int > m_round_robin_invc; // For every outport. for vc arbitration + + Vector<Vector<flitBuffer *> > m_router_buffers; // These are essentially output buffers + Vector<flitBuffer *> m_out_src_queue; // These are source queues for the output link + Vector<NetworkLink *> m_in_link; + Vector<NetworkLink *> m_out_link; + Vector<Vector<InVcState * > > m_in_vc_state; + Vector<Vector<OutVcState * > > m_out_vc_state; + Vector<NetDest> m_routing_table; + Vector<int > m_link_weights; + VCarbiter *m_vc_arbiter; + +/*********** Private methods *************/ + int getRoute(NetDest destination); + Vector<int > get_valid_vcs(int invc); + void routeCompute(flit *m_flit, int inport); + void checkReschedule(); + void check_arbiter_reschedule(); + void scheduleOutputLinks(); +}; + +#endif + diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/VCarbiter.cc b/src/mem/ruby/network/garnet-flexible-pipeline/VCarbiter.cc new file mode 100644 index 000000000..7ebd83de3 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/VCarbiter.cc @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * VCarbiter.C + * + * Niket Agarwal, Princeton University + * + * */ + +#include "VCarbiter.hh" +#include "Router.hh" + +VCarbiter::VCarbiter(Router *router) +{ + m_router = router; +} + +void VCarbiter::wakeup() +{ + m_router->vc_arbitrate(); +} diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/VCarbiter.hh b/src/mem/ruby/network/garnet-flexible-pipeline/VCarbiter.hh new file mode 100644 index 000000000..10368f2b4 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/VCarbiter.hh @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * VCarbiter.h + * + * Niket Agarwal, Princeton University + * + * */ + +#ifndef VC_ARBITER_H +#define VC_ARBITER_H + +#include "NetworkHeader.hh" +#include "Consumer.hh" + +class Router; + +class VCarbiter : public Consumer{ +public: + VCarbiter(Router *router); + ~VCarbiter() {} + + void print(ostream& out) const {} + void wakeup(); + +private: + Router *m_router; +}; + +#endif diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/flit.cc b/src/mem/ruby/network/garnet-flexible-pipeline/flit.cc new file mode 100644 index 000000000..f3cba2035 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/flit.cc @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * flit.C + * + * Niket Agarwal, Princeton University + * + * */ + +#include "flit.hh" + +flit::flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr) +{ + m_size = size; + m_msg_ptr = msg_ptr; + m_enqueue_time = g_eventQueue_ptr->getTime(); + m_time = g_eventQueue_ptr->getTime(); + m_id = id; + m_vnet = vnet; + m_vc = vc; + + if(size == 1) + { + m_type = HEAD_TAIL_; + return; + } + if(id == 0) + m_type = HEAD_; + else if(id == (size - 1)) + m_type = TAIL_; + else + m_type = BODY_; +} + +int flit::get_size() +{ + return m_size; +} +int flit::get_id() +{ + return m_id; +} +Time flit::get_time() +{ + return m_time; +} + +Time flit::get_enqueue_time() +{ + return m_enqueue_time; +} +void flit::set_time(Time time) +{ + m_time = time; +} + +int flit::get_vnet() +{ + return m_vnet; +} +int flit::get_vc() +{ + return m_vc; +} +void flit::set_vc(int vc) +{ + m_vc = vc; +} +MsgPtr& flit::get_msg_ptr() +{ + return m_msg_ptr; +} +flit_type flit::get_type() +{ + return m_type; +} + +void flit::print(ostream& out) const +{ + out << "[flit:: "; + out << "Id=" << m_id << " "; + out << "Type=" << m_type << " "; + out << "Vnet=" << m_vnet << " "; + out << "VC=" << m_vc << " "; + out << "Enqueue Time=" << m_enqueue_time << " "; + out << "]"; +} diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/flit.hh b/src/mem/ruby/network/garnet-flexible-pipeline/flit.hh new file mode 100644 index 000000000..fc8042cfc --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/flit.hh @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * flit.h + * + * Niket Agarwal, Princeton University + * + * */ + +#include "NetworkHeader.hh" +#include "Message.hh" + +#ifndef FLIT_H +#define FLIT_H + +class flit { +public: + flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr); + + int get_size(); + int get_id(); + Time get_time(); + Time get_enqueue_time(); + void set_time(Time time); + int get_vnet(); + int get_vc(); + void set_vc(int vc); + MsgPtr& get_msg_ptr(); + flit_type get_type(); + void print(ostream&out) const; + +private: +/************Data Members*************/ + int m_id; + int m_vnet; + int m_vc; + int m_size; + Time m_enqueue_time, m_time; + flit_type m_type; + MsgPtr m_msg_ptr; + +}; + +inline extern bool node_less_then_eq(flit* n1, flit* n2); + +inline extern +bool node_less_then_eq(flit* n1, flit* n2) +{ + if (n1->get_time() == n2->get_time()) { +// ASSERT(n1->flit_id != n2->flit_id); + return (n1->get_id() <= n2->get_id()); + } else { + return (n1->get_time() <= n2->get_time()); + } +} + +// Output operator declaration +ostream& operator<<(ostream& out, const flit& obj); + +// ******************* Definitions ******************* + +// Output operator definition +extern inline +ostream& operator<<(ostream& out, const flit& obj) +{ + obj.print(out); + out << flush; + return out; +} + +#endif diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/flitBuffer.cc b/src/mem/ruby/network/garnet-flexible-pipeline/flitBuffer.cc new file mode 100644 index 000000000..e0fb26e0a --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/flitBuffer.cc @@ -0,0 +1,104 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * flitBuffer.C + * + * Niket Agarwal, Princeton University + * + * */ + +#include "flitBuffer.hh" + +flitBuffer::flitBuffer() +{ + max_size = INFINITE_; +} + +flitBuffer::flitBuffer(int maximum_size) +{ + max_size = maximum_size; +} + +bool flitBuffer::isEmpty() +{ + return (m_buffer.size() == 0); +} + +bool flitBuffer::isReady() +{ + if(m_buffer.size() != 0 ) + { + flit *t_flit = m_buffer.peekMin(); + if(t_flit->get_time() <= g_eventQueue_ptr->getTime()) + return true; + } + return false; +} + +bool flitBuffer::isReadyForNext() +{ + if(m_buffer.size() != 0 ) + { + flit *t_flit = m_buffer.peekMin(); + if(t_flit->get_time() <= (g_eventQueue_ptr->getTime() + 1)) + return true; + } + return false; +} + +bool flitBuffer::isFull() +{ + return (m_buffer.size() >= max_size); +} + +void flitBuffer::setMaxSize(int maximum) +{ + max_size = maximum; +} + +flit* flitBuffer:: getTopFlit() +{ + return m_buffer.extractMin(); +} + +flit* flitBuffer::peekTopFlit() +{ + return m_buffer.peekMin(); +} + +void flitBuffer::insert(flit *flt) +{ + m_buffer.insert(flt); +} + +void flitBuffer::print(ostream& out) const +{ + out << "[flitBuffer: "; + out << m_buffer.size() << "] " << endl; +} diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/flitBuffer.hh b/src/mem/ruby/network/garnet-flexible-pipeline/flitBuffer.hh new file mode 100644 index 000000000..1eb122a51 --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/flitBuffer.hh @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood + * 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. + */ + +/* + * flitBuffer.h + * + * Niket Agarwal, Princeton University + * + * */ + +#ifndef FLIT_BUFFER_H +#define FLIT_BUFFER_H + +#include "NetworkHeader.hh" +#include "PrioHeap.hh" +#include "flit.hh" + +class flitBuffer { +public: + flitBuffer(); + flitBuffer(int maximum_size); + + bool isReady(); + bool isReadyForNext(); + bool isFull(); + bool isEmpty(); + void setMaxSize(int maximum); + flit *getTopFlit(); + flit *peekTopFlit(); + void insert(flit *flt); + void print(ostream& out) const; + +/**********Data Members*********/ +private: + PrioHeap <flit *> m_buffer; + int size, max_size; +}; + +ostream& operator<<(ostream& out, const flitBuffer& obj); + +// ******************* Definitions ******************* + +// Output operator definition +extern inline +ostream& operator<<(ostream& out, const flitBuffer& obj) +{ + obj.print(out); + out << flush; + return out; +} + +#endif + diff --git a/src/mem/ruby/network/garnet-flexible-pipeline/netconfig.defaults b/src/mem/ruby/network/garnet-flexible-pipeline/netconfig.defaults new file mode 100644 index 000000000..e60f1921d --- /dev/null +++ b/src/mem/ruby/network/garnet-flexible-pipeline/netconfig.defaults @@ -0,0 +1,8 @@ +// Note: You should set Garnet's parameters in config/rubyconfig.defaults and not here +g_GARNET_NETWORK:true +g_DETAIL_NETWORK:true +g_NETWORK_TESTING:false +g_FLIT_SIZE:16 +g_NUM_PIPE_STAGES:4 +g_VCS_PER_CLASS:4 +g_BUFFER_SIZE:4 |