SimpleNetwork.hh revision 7055
12686Sksewell@umich.edu/* 25254Sksewell@umich.edu * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 35254Sksewell@umich.edu * All rights reserved. 42686Sksewell@umich.edu * 55254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 65254Sksewell@umich.edu * modification, are permitted provided that the following conditions are 75254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 85254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 95254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 105254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 115254Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 125254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 135254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 145254Sksewell@umich.edu * this software without specific prior written permission. 152686Sksewell@umich.edu * 165254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272706Sksewell@umich.edu */ 285254Sksewell@umich.edu 292686Sksewell@umich.edu/* 302686Sksewell@umich.edu * The SimpleNetwork class implements the interconnection 3111793Sbrandon.potter@amd.com * SimpleNetwork between components (processor/cache components and 3211793Sbrandon.potter@amd.com * memory/directory components). The interconnection network as 337678Sgblack@eecs.umich.edu * described here is not a physical network, but a programming concept 347678Sgblack@eecs.umich.edu * used to implement all communication between components. Thus parts 354661Sksewell@umich.edu * of this 'network' may model the on-chip connections between cache 368799Sgblack@eecs.umich.edu * controllers and directory controllers as well as the links between 378799Sgblack@eecs.umich.edu * chip and network switches. 384661Sksewell@umich.edu * 3912334Sgabeblack@google.com * Two conceptual networks, an address and data network, are modeled. 408229Snate@binkert.org * The data network is unordered, where the address network provides 418229Snate@binkert.org * and conforms to a global ordering of all transactions. 428799Sgblack@eecs.umich.edu * 438229Snate@binkert.org * Currently the data network is point-to-point and the address 442686Sksewell@umich.edu * network is a broadcast network. These two distinct conceptual 452686Sksewell@umich.edu * network can be modeled as physically separate networks or 464661Sksewell@umich.edu * multiplexed over a single physical network. 472686Sksewell@umich.edu * 485222Sksewell@umich.edu * The network encapsulates all notion of virtual global time and is 495222Sksewell@umich.edu * responsible for ordering the network transactions received. This 502686Sksewell@umich.edu * hides all of these ordering details from the processor/cache and 517707Sgblack@eecs.umich.edu * directory/memory modules. 525222Sksewell@umich.edu * 538775Sgblack@eecs.umich.edu * FIXME: Various flavor of networks are provided as a compiler time 545222Sksewell@umich.edu * configurable. We currently include this SimpleNetwork in the 555222Sksewell@umich.edu * makefile's vpath, so that SimpleNetwork.cc can provide an alternative 565222Sksewell@umich.edu * version constructor for the abstract Network class. It is easy to 575222Sksewell@umich.edu * modify this to make network a runtime configuable. Just make the 585222Sksewell@umich.edu * abstract Network class take a enumeration parameter, and based on 592686Sksewell@umich.edu * that to initial proper network. Or even better, just make the ruby 602686Sksewell@umich.edu * system initializer choose the proper network to initiate. 612686Sksewell@umich.edu */ 622686Sksewell@umich.edu 632686Sksewell@umich.edu#ifndef __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ 642686Sksewell@umich.edu#define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ 652686Sksewell@umich.edu 662686Sksewell@umich.edu#include <iostream> 672686Sksewell@umich.edu 682686Sksewell@umich.edu#include "mem/gems_common/Vector.hh" 692686Sksewell@umich.edu#include "mem/ruby/common/Global.hh" 702686Sksewell@umich.edu#include "mem/ruby/network/Network.hh" 712686Sksewell@umich.edu#include "mem/ruby/system/NodeID.hh" 722686Sksewell@umich.edu#include "params/SimpleNetwork.hh" 732686Sksewell@umich.edu#include "sim/sim_object.hh" 742686Sksewell@umich.edu 752686Sksewell@umich.educlass NetDest; 762686Sksewell@umich.educlass MessageBuffer; 772686Sksewell@umich.educlass Throttle; 782686Sksewell@umich.educlass Switch; 792686Sksewell@umich.educlass Topology; 802686Sksewell@umich.edu 812686Sksewell@umich.educlass SimpleNetwork : public Network 822686Sksewell@umich.edu{ 832686Sksewell@umich.edu public: 842686Sksewell@umich.edu typedef SimpleNetworkParams Params; 852686Sksewell@umich.edu SimpleNetwork(const Params *p); 862686Sksewell@umich.edu ~SimpleNetwork(); 872686Sksewell@umich.edu 882686Sksewell@umich.edu void init(); 892686Sksewell@umich.edu 902686Sksewell@umich.edu void printStats(std::ostream& out) const; 912686Sksewell@umich.edu void clearStats(); 922686Sksewell@umich.edu void printConfig(std::ostream& out) const; 932686Sksewell@umich.edu 942686Sksewell@umich.edu void reset(); 952686Sksewell@umich.edu 962686Sksewell@umich.edu // returns the queue requested for the given component 972686Sksewell@umich.edu MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num); 982686Sksewell@umich.edu MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num); 992686Sksewell@umich.edu virtual const Vector<Throttle*>* getThrottles(NodeID id) const; 1002686Sksewell@umich.edu 1012686Sksewell@umich.edu bool isVNetOrdered(int vnet) { return m_ordered[vnet]; } 1025222Sksewell@umich.edu bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; } 1032686Sksewell@umich.edu 1042686Sksewell@umich.edu int getNumNodes() {return m_nodes; } 1052686Sksewell@umich.edu 1062686Sksewell@umich.edu // Methods used by Topology to setup the network 1072686Sksewell@umich.edu void makeOutLink(SwitchID src, NodeID dest, 1082686Sksewell@umich.edu const NetDest& routing_table_entry, int link_latency, int link_weight, 1092686Sksewell@umich.edu int bw_multiplier, bool isReconfiguration); 1102686Sksewell@umich.edu void makeInLink(SwitchID src, NodeID dest, 1112686Sksewell@umich.edu const NetDest& routing_table_entry, int link_latency, 1122686Sksewell@umich.edu int bw_multiplier, bool isReconfiguration); 1135222Sksewell@umich.edu void makeInternalLink(SwitchID src, NodeID dest, 1142686Sksewell@umich.edu const NetDest& routing_table_entry, int link_latency, int link_weight, 1152686Sksewell@umich.edu int bw_multiplier, bool isReconfiguration); 1162686Sksewell@umich.edu 1172686Sksewell@umich.edu void print(std::ostream& out) const; 1182686Sksewell@umich.edu 1192686Sksewell@umich.edu private: 1205222Sksewell@umich.edu void checkNetworkAllocation(NodeID id, bool ordered, int network_num); 1212686Sksewell@umich.edu void addLink(SwitchID src, SwitchID dest, int link_latency); 1222686Sksewell@umich.edu void makeLink(SwitchID src, SwitchID dest, 1232686Sksewell@umich.edu const NetDest& routing_table_entry, int link_latency); 1242686Sksewell@umich.edu SwitchID createSwitch(); 1252686Sksewell@umich.edu void makeTopology(); 1262686Sksewell@umich.edu void linkTopology(); 1272686Sksewell@umich.edu 1285222Sksewell@umich.edu // Private copy constructor and assignment operator 1292686Sksewell@umich.edu SimpleNetwork(const SimpleNetwork& obj); 1302686Sksewell@umich.edu SimpleNetwork& operator=(const SimpleNetwork& obj); 1312686Sksewell@umich.edu 1325570Snate@binkert.org // vector of queues from the components 1332686Sksewell@umich.edu Vector<Vector<MessageBuffer*> > m_toNetQueues; 1342686Sksewell@umich.edu Vector<Vector<MessageBuffer*> > m_fromNetQueues; 1352686Sksewell@umich.edu 1362686Sksewell@umich.edu Vector<bool> m_in_use; 1372686Sksewell@umich.edu Vector<bool> m_ordered; 1382686Sksewell@umich.edu Vector<Switch*> m_switch_ptr_vector; 1392686Sksewell@umich.edu Vector<MessageBuffer*> m_buffers_to_free; 1405222Sksewell@umich.edu Vector<Switch*> m_endpoint_switches; 1412686Sksewell@umich.edu}; 1422686Sksewell@umich.edu 1432686Sksewell@umich.eduinline std::ostream& 1442686Sksewell@umich.eduoperator<<(std::ostream& out, const SimpleNetwork& obj) 1452686Sksewell@umich.edu{ 1462686Sksewell@umich.edu obj.print(out); 1472686Sksewell@umich.edu out << std::flush; 1482686Sksewell@umich.edu return out; 1492686Sksewell@umich.edu} 1502686Sksewell@umich.edu 1512686Sksewell@umich.edu#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ 1522686Sksewell@umich.edu