SimpleNetwork.py revision 13665
112952Sgabeblack@google.com# Copyright (c) 2009 Advanced Micro Devices, Inc. 212952Sgabeblack@google.com# All rights reserved. 312952Sgabeblack@google.com# 412952Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 512952Sgabeblack@google.com# modification, are permitted provided that the following conditions are 612952Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 712952Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 812952Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 912952Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 1012952Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 1112952Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 1212952Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 1312952Sgabeblack@google.com# this software without specific prior written permission. 1412952Sgabeblack@google.com# 1512952Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1612952Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1712952Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1812952Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1912952Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2012952Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2112952Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2212952Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2312952Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2412952Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2512952Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2612952Sgabeblack@google.com# 2712952Sgabeblack@google.com# Authors: Steve Reinhardt 2812952Sgabeblack@google.com# Brad Beckmann 2912952Sgabeblack@google.com 3012952Sgabeblack@google.comfrom m5.params import * 3112952Sgabeblack@google.comfrom m5.proxy import * 3212952Sgabeblack@google.com 3312952Sgabeblack@google.comfrom m5.objects.Network import RubyNetwork 3412997Sgabeblack@google.comfrom m5.objects.BasicRouter import BasicRouter 3512957Sgabeblack@google.comfrom m5.objects.MessageBuffer import MessageBuffer 3612952Sgabeblack@google.com 3712952Sgabeblack@google.comclass SimpleNetwork(RubyNetwork): 3812953Sgabeblack@google.com type = 'SimpleNetwork' 3913285Sgabeblack@google.com cxx_header = "mem/ruby/network/simple/SimpleNetwork.hh" 4012952Sgabeblack@google.com buffer_size = Param.Int(0, 4113063Sgabeblack@google.com "default buffer size; 0 indicates infinite buffering"); 4213206Sgabeblack@google.com endpoint_bandwidth = Param.Int(1000, "bandwidth adjustment factor"); 4313288Sgabeblack@google.com adaptive_routing = Param.Bool(False, "enable adaptive routing"); 4412952Sgabeblack@google.com int_link_buffers = VectorParam.MessageBuffer("Buffers for int_links") 4512952Sgabeblack@google.com 4612952Sgabeblack@google.com def setup_buffers(self): 4712952Sgabeblack@google.com # Note that all SimpleNetwork MessageBuffers are currently ordered 4813196Sgabeblack@google.com network_buffers = [] 4913196Sgabeblack@google.com for link in self.int_links: 5013196Sgabeblack@google.com # The network needs number_of_virtual_networks buffers per 5113196Sgabeblack@google.com # int_link port 5213196Sgabeblack@google.com for i in xrange(self.number_of_virtual_networks): 5313196Sgabeblack@google.com network_buffers.append(MessageBuffer(ordered = True)) 5413196Sgabeblack@google.com network_buffers.append(MessageBuffer(ordered = True)) 5512952Sgabeblack@google.com self.int_link_buffers = network_buffers 5612952Sgabeblack@google.com 5712952Sgabeblack@google.com # Also add buffers for all router-link connections 5813175Sgabeblack@google.com for router in self.routers: 5913175Sgabeblack@google.com router_buffers = [] 6013175Sgabeblack@google.com # Add message buffers to routers at the end of each 6113288Sgabeblack@google.com # unidirectional internal link 6213288Sgabeblack@google.com for link in self.int_links: 6313288Sgabeblack@google.com if link.dst_node == router: 6413087Sgabeblack@google.com for i in xrange(self.number_of_virtual_networks): 6512952Sgabeblack@google.com router_buffers.append(MessageBuffer(ordered = True)) 6612952Sgabeblack@google.com 6712952Sgabeblack@google.com # Add message buffers to routers for each external link connection 6812961Sgabeblack@google.com for link in self.ext_links: 6913093Sgabeblack@google.com # Routers can only be int_nodes on ext_links 7012952Sgabeblack@google.com if link.int_node in self.routers: 7112952Sgabeblack@google.com for i in xrange(self.number_of_virtual_networks): 7212997Sgabeblack@google.com router_buffers.append(MessageBuffer(ordered = True)) 7312952Sgabeblack@google.com router.port_buffers = router_buffers 7412952Sgabeblack@google.com 7513328Sgabeblack@google.comclass Switch(BasicRouter): 7613328Sgabeblack@google.com type = 'Switch' 7713328Sgabeblack@google.com cxx_header = 'mem/ruby/network/simple/Switch.hh' 7812952Sgabeblack@google.com virt_nets = Param.Int(Parent.number_of_virtual_networks, 7912952Sgabeblack@google.com "number of virtual networks") 8012952Sgabeblack@google.com port_buffers = VectorParam.MessageBuffer("Port buffers") 8112952Sgabeblack@google.com