SimpleNetwork.hh revision 8308
16145Snate@binkert.org/* 26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36145Snate@binkert.org * All rights reserved. 46145Snate@binkert.org * 56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66145Snate@binkert.org * modification, are permitted provided that the following conditions are 76145Snate@binkert.org * met: redistributions of source code must retain the above copyright 86145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116145Snate@binkert.org * documentation and/or other materials provided with the distribution; 126145Snate@binkert.org * neither the name of the copyright holders nor the names of its 136145Snate@binkert.org * contributors may be used to endorse or promote products derived from 146145Snate@binkert.org * this software without specific prior written permission. 156145Snate@binkert.org * 166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145Snate@binkert.org */ 286145Snate@binkert.org 297054Snate@binkert.org#ifndef __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ 307054Snate@binkert.org#define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ 316145Snate@binkert.org 327055Snate@binkert.org#include <iostream> 337454Snate@binkert.org#include <vector> 347055Snate@binkert.org 356154Snate@binkert.org#include "mem/ruby/common/Global.hh" 366154Snate@binkert.org#include "mem/ruby/network/Network.hh" 376154Snate@binkert.org#include "mem/ruby/system/NodeID.hh" 387054Snate@binkert.org#include "params/SimpleNetwork.hh" 396876Ssteve.reinhardt@amd.com#include "sim/sim_object.hh" 406145Snate@binkert.org 416145Snate@binkert.orgclass NetDest; 426145Snate@binkert.orgclass MessageBuffer; 436145Snate@binkert.orgclass Throttle; 446145Snate@binkert.orgclass Switch; 456145Snate@binkert.orgclass Topology; 466145Snate@binkert.org 477054Snate@binkert.orgclass SimpleNetwork : public Network 487054Snate@binkert.org{ 497054Snate@binkert.org public: 506876Ssteve.reinhardt@amd.com typedef SimpleNetworkParams Params; 516876Ssteve.reinhardt@amd.com SimpleNetwork(const Params *p); 527054Snate@binkert.org ~SimpleNetwork(); 536145Snate@binkert.org 547054Snate@binkert.org void init(); 556145Snate@binkert.org 568259SBrad.Beckmann@amd.com int getBufferSize() { return m_buffer_size; } 578259SBrad.Beckmann@amd.com int getEndpointBandwidth() { return m_endpoint_bandwidth; } 588259SBrad.Beckmann@amd.com bool getAdaptiveRouting() {return m_adaptive_routing; } 598259SBrad.Beckmann@amd.com 607055Snate@binkert.org void printStats(std::ostream& out) const; 617054Snate@binkert.org void clearStats(); 627055Snate@binkert.org void printConfig(std::ostream& out) const; 636285Snate@binkert.org 647054Snate@binkert.org void reset(); 656145Snate@binkert.org 667054Snate@binkert.org // returns the queue requested for the given component 678308Stushar@csail.mit.edu MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num, std::string vnet_type); 688308Stushar@csail.mit.edu MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num, std::string vnet_type); 697454Snate@binkert.org virtual const std::vector<Throttle*>* getThrottles(NodeID id) const; 706145Snate@binkert.org 717054Snate@binkert.org bool isVNetOrdered(int vnet) { return m_ordered[vnet]; } 727054Snate@binkert.org bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; } 736145Snate@binkert.org 747054Snate@binkert.org int getNumNodes() {return m_nodes; } 756145Snate@binkert.org 767054Snate@binkert.org // Methods used by Topology to setup the network 778257SBrad.Beckmann@amd.com void makeOutLink(SwitchID src, NodeID dest, BasicLink* link, 788257SBrad.Beckmann@amd.com LinkDirection direction, 798257SBrad.Beckmann@amd.com const NetDest& routing_table_entry, 808257SBrad.Beckmann@amd.com bool isReconfiguration); 818257SBrad.Beckmann@amd.com void makeInLink(NodeID src, SwitchID dest, BasicLink* link, 828257SBrad.Beckmann@amd.com LinkDirection direction, 838257SBrad.Beckmann@amd.com const NetDest& routing_table_entry, 848257SBrad.Beckmann@amd.com bool isReconfiguration); 858257SBrad.Beckmann@amd.com void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link, 868257SBrad.Beckmann@amd.com LinkDirection direction, 878257SBrad.Beckmann@amd.com const NetDest& routing_table_entry, 888257SBrad.Beckmann@amd.com bool isReconfiguration); 896145Snate@binkert.org 907055Snate@binkert.org void print(std::ostream& out) const; 916145Snate@binkert.org 927054Snate@binkert.org private: 937054Snate@binkert.org void checkNetworkAllocation(NodeID id, bool ordered, int network_num); 947054Snate@binkert.org void addLink(SwitchID src, SwitchID dest, int link_latency); 957054Snate@binkert.org void makeLink(SwitchID src, SwitchID dest, 967054Snate@binkert.org const NetDest& routing_table_entry, int link_latency); 977054Snate@binkert.org SwitchID createSwitch(); 987054Snate@binkert.org void makeTopology(); 997054Snate@binkert.org void linkTopology(); 1006145Snate@binkert.org 1017054Snate@binkert.org // Private copy constructor and assignment operator 1027054Snate@binkert.org SimpleNetwork(const SimpleNetwork& obj); 1037054Snate@binkert.org SimpleNetwork& operator=(const SimpleNetwork& obj); 1046145Snate@binkert.org 1057054Snate@binkert.org // vector of queues from the components 1067454Snate@binkert.org std::vector<std::vector<MessageBuffer*> > m_toNetQueues; 1077454Snate@binkert.org std::vector<std::vector<MessageBuffer*> > m_fromNetQueues; 1086145Snate@binkert.org 1097454Snate@binkert.org std::vector<bool> m_in_use; 1107454Snate@binkert.org std::vector<bool> m_ordered; 1117454Snate@binkert.org std::vector<Switch*> m_switch_ptr_vector; 1127454Snate@binkert.org std::vector<MessageBuffer*> m_buffers_to_free; 1137454Snate@binkert.org std::vector<Switch*> m_endpoint_switches; 1148259SBrad.Beckmann@amd.com 1158259SBrad.Beckmann@amd.com int m_buffer_size; 1168259SBrad.Beckmann@amd.com int m_endpoint_bandwidth; 1178259SBrad.Beckmann@amd.com bool m_adaptive_routing; 1186145Snate@binkert.org}; 1196145Snate@binkert.org 1207055Snate@binkert.orginline std::ostream& 1217055Snate@binkert.orgoperator<<(std::ostream& out, const SimpleNetwork& obj) 1226145Snate@binkert.org{ 1237054Snate@binkert.org obj.print(out); 1247055Snate@binkert.org out << std::flush; 1257054Snate@binkert.org return out; 1266145Snate@binkert.org} 1276145Snate@binkert.org 1287054Snate@binkert.org#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__ 129