ruby: remove the original garnet code.

Only garnet2.0 will be supported henceforth.
This commit is contained in:
Tushar Krishna 2016-10-06 14:35:21 -04:00
parent 0962d76827
commit b512f4bf71
63 changed files with 0 additions and 7167 deletions

View file

@ -1,123 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
#include "mem/ruby/network/MessageBuffer.hh"
using namespace std;
BaseGarnetNetwork::BaseGarnetNetwork(const Params *p)
: Network(p)
{
m_ni_flit_size = p->ni_flit_size;
m_vcs_per_vnet = p->vcs_per_vnet;
m_enable_fault_model = p->enable_fault_model;
if (m_enable_fault_model)
fault_model = p->fault_model;
// Currently Garnet only supports uniform bandwidth for all
// links and network interfaces.
for (std::vector<BasicExtLink*>::const_iterator i = p->ext_links.begin();
i != p->ext_links.end(); ++i) {
BasicExtLink* ext_link = (*i);
if (ext_link->params()->bandwidth_factor != m_ni_flit_size) {
fatal("Garnet only supports uniform bw across all links and NIs\n");
}
}
for (std::vector<BasicIntLink*>::const_iterator i = p->int_links.begin();
i != p->int_links.end(); ++i) {
BasicIntLink* int_link = (*i);
if (int_link->params()->bandwidth_factor != m_ni_flit_size) {
fatal("Garnet only supports uniform bw across all links and NIs\n");
}
}
}
void
BaseGarnetNetwork::init()
{
Network::init();
}
void
BaseGarnetNetwork::regStats()
{
Network::regStats();
m_flits_received
.init(m_virtual_networks)
.name(name() + ".flits_received")
.flags(Stats::pdf | Stats::total | Stats::nozero | Stats::oneline)
;
m_flits_injected
.init(m_virtual_networks)
.name(name() + ".flits_injected")
.flags(Stats::pdf | Stats::total | Stats::nozero | Stats::oneline)
;
m_network_latency
.init(m_virtual_networks)
.name(name() + ".network_latency")
.flags(Stats::oneline)
;
m_queueing_latency
.init(m_virtual_networks)
.name(name() + ".queueing_latency")
.flags(Stats::oneline)
;
for (int i = 0; i < m_virtual_networks; i++) {
m_flits_received.subname(i, csprintf("vnet-%i", i));
m_flits_injected.subname(i, csprintf("vnet-%i", i));
m_network_latency.subname(i, csprintf("vnet-%i", i));
m_queueing_latency.subname(i, csprintf("vnet-%i", i));
}
m_avg_vnet_latency
.name(name() + ".average_vnet_latency")
.flags(Stats::oneline);
m_avg_vnet_latency = m_network_latency / m_flits_received;
m_avg_vqueue_latency
.name(name() + ".average_vqueue_latency")
.flags(Stats::oneline);
m_avg_vqueue_latency = m_queueing_latency / m_flits_received;
m_avg_network_latency.name(name() + ".average_network_latency");
m_avg_network_latency = sum(m_network_latency) / sum(m_flits_received);
m_avg_queueing_latency.name(name() + ".average_queueing_latency");
m_avg_queueing_latency = sum(m_queueing_latency) / sum(m_flits_received);
m_avg_latency.name(name() + ".average_latency");
m_avg_latency = m_avg_network_latency + m_avg_queueing_latency;
}

View file

@ -1,94 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
/*
* This header file is used to define all configuration parameters
* required by the interconnection network.
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_BASEGARNETNETWORK_HH__
#define __MEM_RUBY_NETWORK_GARNET_BASEGARNETNETWORK_HH__
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/network/Network.hh"
#include "mem/ruby/network/fault_model/FaultModel.hh"
#include "params/BaseGarnetNetwork.hh"
class BaseGarnetNetwork : public Network
{
public:
typedef BaseGarnetNetworkParams Params;
BaseGarnetNetwork(const Params *p);
void init();
int getNiFlitSize() const { return m_ni_flit_size; }
int getVCsPerVnet() const { return m_vcs_per_vnet; }
bool isFaultModelEnabled() const { return m_enable_fault_model; }
FaultModel* fault_model;
void increment_injected_flits(int vnet) { m_flits_injected[vnet]++; }
void increment_received_flits(int vnet) { m_flits_received[vnet]++; }
void
increment_network_latency(Cycles latency, int vnet)
{
m_network_latency[vnet] += latency;
}
void
increment_queueing_latency(Cycles latency, int vnet)
{
m_queueing_latency[vnet] += latency;
}
bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
virtual void regStats();
virtual void collateStats() {}
protected:
int m_ni_flit_size;
int m_vcs_per_vnet;
bool m_enable_fault_model;
// Statistical variables
Stats::Vector m_flits_received;
Stats::Vector m_flits_injected;
Stats::Vector m_network_latency;
Stats::Vector m_queueing_latency;
Stats::Formula m_avg_vnet_latency;
Stats::Formula m_avg_vqueue_latency;
Stats::Formula m_avg_network_latency;
Stats::Formula m_avg_queueing_latency;
Stats::Formula m_avg_latency;
};
#endif // __MEM_RUBY_NETWORK_GARNET_BASEGARNETNETWORK_HH__

View file

@ -1,41 +0,0 @@
# Copyright (c) 2008 Princeton University
# Copyright (c) 2009 Advanced Micro Devices, Inc.
# 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.
#
# Authors: Steve Reinhardt
# Brad Beckmann
from m5.params import *
from Network import RubyNetwork
class BaseGarnetNetwork(RubyNetwork):
type = 'BaseGarnetNetwork'
cxx_header = "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
abstract = True
ni_flit_size = Param.Int(16, "network interface flit size in bytes")
vcs_per_vnet = Param.Int(4, "virtual channels per virtual network");
enable_fault_model = Param.Bool(False, "enable network fault model");
fault_model = Param.FaultModel(NULL, "network fault model");

View file

@ -1,41 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_NETWORKHEADER_HH__
#define __MEM_RUBY_NETWORK_GARNET_NETWORKHEADER_HH__
enum flit_type {HEAD_, BODY_, TAIL_, HEAD_TAIL_, NUM_FLIT_TYPE_};
enum VC_state_type {IDLE_, VC_AB_, ACTIVE_, NUM_VC_STATE_TYPE_};
enum VNET_type {CTRL_VNET_, DATA_VNET_, NULL_VNET_, NUM_VNET_TYPE_};
enum flit_stage {I_, VA_, SA_, ST_, LT_, NUM_FLIT_STAGE_};
#define INFINITE_ 10000
#endif // __MEM_RUBY_NETWORK_GARNET_NETWORKHEADER_HH__

View file

@ -1,39 +0,0 @@
# -*- mode:python -*-
# Copyright (c) 2009 The Hewlett-Packard Development Company
# 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.
#
# Authors: Nathan Binkert
Import('*')
if env['PROTOCOL'] == 'None':
Return()
SimObject('BaseGarnetNetwork.py')
Source('BaseGarnetNetwork.cc')

View file

@ -1,44 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_CREDIT_LINK_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_CREDIT_LINK_D_HH__
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
#include "params/CreditLink_d.hh"
class CreditLink_d : public NetworkLink_d
{
public:
typedef CreditLink_dParams Params;
CreditLink_d(const Params *p) : NetworkLink_d(p) {}
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_CREDIT_LINK_D_HH__

View file

@ -1,83 +0,0 @@
/*
* Copyright (c) 2011 Advanced Micro Devices, Inc.
* 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.
*/
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
GarnetIntLink_d::GarnetIntLink_d(const Params *p)
: BasicLink(p)
{
m_network_links[0] = p->network_links[0];
m_credit_links[0] = p->credit_links[0];
m_network_links[1] = p->network_links[1];
m_credit_links[1] = p->credit_links[1];
}
void
GarnetIntLink_d::init()
{
}
void
GarnetIntLink_d::print(std::ostream& out) const
{
out << name();
}
GarnetIntLink_d *
GarnetIntLink_dParams::create()
{
return new GarnetIntLink_d(this);
}
GarnetExtLink_d::GarnetExtLink_d(const Params *p)
: BasicLink(p)
{
m_network_links[0] = p->network_links[0];
m_credit_links[0] = p->credit_links[0];
m_network_links[1] = p->network_links[1];
m_credit_links[1] = p->credit_links[1];
}
void
GarnetExtLink_d::init()
{
}
void
GarnetExtLink_d::print(std::ostream& out) const
{
out << name();
}
GarnetExtLink_d *
GarnetExtLink_dParams::create()
{
return new GarnetExtLink_d(this);
}

View file

@ -1,92 +0,0 @@
/*
* Copyright (c) 2011 Advanced Micro Devices, Inc.
* 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.
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_LINK_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_LINK_HH__
#include <iostream>
#include <string>
#include <vector>
#include "mem/ruby/network/BasicLink.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
#include "params/GarnetIntLink_d.hh"
#include "params/GarnetExtLink_d.hh"
class GarnetIntLink_d : public BasicLink
{
public:
typedef GarnetIntLink_dParams Params;
GarnetIntLink_d(const Params *p);
void init();
void print(std::ostream& out) const;
friend class GarnetNetwork_d;
protected:
NetworkLink_d* m_network_links[2];
CreditLink_d* m_credit_links[2];
};
inline std::ostream&
operator<<(std::ostream& out, const GarnetIntLink_d& obj)
{
obj.print(out);
out << std::flush;
return out;
}
class GarnetExtLink_d : public BasicLink
{
public:
typedef GarnetExtLink_dParams Params;
GarnetExtLink_d(const Params *p);
void init();
void print(std::ostream& out) const;
friend class GarnetNetwork_d;
protected:
NetworkLink_d* m_network_links[2];
CreditLink_d* m_credit_links[2];
};
inline std::ostream&
operator<<(std::ostream& out, const GarnetExtLink_d& obj)
{
obj.print(out);
out << std::flush;
return out;
}
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_LINK_HH__

View file

@ -1,90 +0,0 @@
# Copyright (c) 2008 Princeton University
# Copyright (c) 2009 Advanced Micro Devices, Inc.
# 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.
#
# Authors: Steve Reinhardt
# Brad Beckmann
from m5.params import *
from m5.proxy import *
from ClockedObject import ClockedObject
from BasicLink import BasicIntLink, BasicExtLink
class NetworkLink_d(ClockedObject):
type = 'NetworkLink_d'
cxx_header = "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
link_id = Param.Int(Parent.link_id, "link id")
link_latency = Param.Cycles(Parent.latency, "link latency")
vcs_per_vnet = Param.Int(Parent.vcs_per_vnet,
"virtual channels per virtual network")
virt_nets = Param.Int(Parent.number_of_virtual_networks,
"number of virtual networks")
class CreditLink_d(NetworkLink_d):
type = 'CreditLink_d'
cxx_header = "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
# Interior fixed pipeline links between routers
class GarnetIntLink_d(BasicIntLink):
type = 'GarnetIntLink_d'
cxx_header = "mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.hh"
# The detailed fixed pipeline bi-directional link include two main
# forward links and two backward flow-control links, one per direction
_nls = []
# In uni-directional link
_nls.append(NetworkLink_d());
# Out uni-directional link
_nls.append(NetworkLink_d());
network_links = VectorParam.NetworkLink_d(_nls, "forward links")
_cls = []
# In uni-directional link
_cls.append(CreditLink_d());
# Out uni-directional link
_cls.append(CreditLink_d());
credit_links = VectorParam.CreditLink_d(_cls,
"backward flow-control links")
# Exterior fixed pipeline links between a router and a controller
class GarnetExtLink_d(BasicExtLink):
type = 'GarnetExtLink_d'
cxx_header = "mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.hh"
# The detailed fixed pipeline bi-directional link include two main
# forward links and two backward flow-control links, one per direction
_nls = []
# In uni-directional link
_nls.append(NetworkLink_d());
# Out uni-directional link
_nls.append(NetworkLink_d());
network_links = VectorParam.NetworkLink_d(_nls, "forward links")
_cls = []
# In uni-directional link
_cls.append(CreditLink_d());
# Out uni-directional link
_cls.append(CreditLink_d());
credit_links = VectorParam.CreditLink_d(_cls,
"backward flow-control links")

View file

@ -1,260 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include <cassert>
#include "base/cast.hh"
#include "base/stl_helpers.hh"
#include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/system/RubySystem.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
GarnetNetwork_d::GarnetNetwork_d(const Params *p)
: BaseGarnetNetwork(p)
{
m_buffers_per_data_vc = p->buffers_per_data_vc;
m_buffers_per_ctrl_vc = p->buffers_per_ctrl_vc;
m_vnet_type.resize(m_virtual_networks);
for (int i = 0 ; i < m_virtual_networks ; i++)
{
if (m_vnet_type_names[i] == "response")
m_vnet_type[i] = DATA_VNET_; // carries data (and ctrl) packets
else
m_vnet_type[i] = CTRL_VNET_; // carries only ctrl packets
}
// record the routers
for (vector<BasicRouter*>::const_iterator i = p->routers.begin();
i != p->routers.end(); ++i) {
Router_d* router = safe_cast<Router_d*>(*i);
m_routers.push_back(router);
// initialize the router's network pointers
router->init_net_ptr(this);
}
// record the network interfaces
for (vector<ClockedObject*>::const_iterator i = p->netifs.begin();
i != p->netifs.end(); ++i) {
NetworkInterface_d *ni = safe_cast<NetworkInterface_d *>(*i);
m_nis.push_back(ni);
ni->init_net_ptr(this);
}
}
void
GarnetNetwork_d::init()
{
BaseGarnetNetwork::init();
for (int i=0; i < m_nodes; i++) {
m_nis[i]->addNode(m_toNetQueues[i], m_fromNetQueues[i]);
}
// The topology pointer should have already been initialized in the
// parent network constructor
assert(m_topology_ptr != NULL);
m_topology_ptr->createLinks(this);
// FaultModel: declare each router to the fault model
if (isFaultModelEnabled()){
for (vector<Router_d*>::const_iterator i= m_routers.begin();
i != m_routers.end(); ++i) {
Router_d* router = safe_cast<Router_d*>(*i);
int router_id M5_VAR_USED =
fault_model->declare_router(router->get_num_inports(),
router->get_num_outports(),
router->get_vc_per_vnet(),
getBuffersPerDataVC(),
getBuffersPerCtrlVC());
assert(router_id == router->get_id());
router->printAggregateFaultProbability(cout);
router->printFaultVector(cout);
}
}
}
GarnetNetwork_d::~GarnetNetwork_d()
{
deletePointers(m_routers);
deletePointers(m_nis);
deletePointers(m_links);
deletePointers(m_creditlinks);
}
/*
* This function creates a link from the Network Interface (NI)
* into the Network.
* It creates a Network Link from the NI to a Router and a Credit Link from
* the Router to the NI
*/
void
GarnetNetwork_d::makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
const NetDest& routing_table_entry)
{
assert(src < m_nodes);
GarnetExtLink_d* garnet_link = safe_cast<GarnetExtLink_d*>(link);
NetworkLink_d* net_link = garnet_link->m_network_links[0];
CreditLink_d* credit_link = garnet_link->m_credit_links[0];
m_links.push_back(net_link);
m_creditlinks.push_back(credit_link);
m_routers[dest]->addInPort(net_link, credit_link);
m_nis[src]->addOutPort(net_link, credit_link);
}
/*
* This function creates a link from the Network to a NI.
* It creates a Network Link from a Router to the NI and
* a Credit Link from NI to the Router
*/
void
GarnetNetwork_d::makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
const NetDest& routing_table_entry)
{
assert(dest < m_nodes);
assert(src < m_routers.size());
assert(m_routers[src] != NULL);
GarnetExtLink_d* garnet_link = safe_cast<GarnetExtLink_d*>(link);
NetworkLink_d* net_link = garnet_link->m_network_links[1];
CreditLink_d* credit_link = garnet_link->m_credit_links[1];
m_links.push_back(net_link);
m_creditlinks.push_back(credit_link);
m_routers[src]->addOutPort(net_link, routing_table_entry,
link->m_weight, credit_link);
m_nis[dest]->addInPort(net_link, credit_link);
}
/*
* This function creates an internal network link
*/
void
GarnetNetwork_d::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
const NetDest& routing_table_entry,
PortDirection src_outport,
PortDirection dst_inport)
{
GarnetIntLink_d* garnet_link = safe_cast<GarnetIntLink_d*>(link);
NetworkLink_d* net_link = garnet_link->m_network_links[0];
CreditLink_d* credit_link = garnet_link->m_credit_links[0];
m_links.push_back(net_link);
m_creditlinks.push_back(credit_link);
m_routers[dest]->addInPort(net_link, credit_link);
m_routers[src]->addOutPort(net_link, routing_table_entry,
link->m_weight, credit_link);
}
void
GarnetNetwork_d::regStats()
{
BaseGarnetNetwork::regStats();
m_average_link_utilization.name(name() + ".avg_link_utilization");
m_average_vc_load
.init(m_virtual_networks * m_vcs_per_vnet)
.name(name() + ".avg_vc_load")
.flags(Stats::pdf | Stats::total | Stats::nozero | Stats::oneline)
;
}
void
GarnetNetwork_d::collateStats()
{
RubySystem *rs = params()->ruby_system;
double time_delta = double(curCycle() - rs->getStartCycle());
for (int i = 0; i < m_links.size(); i++) {
m_average_link_utilization +=
(double(m_links[i]->getLinkUtilization())) / time_delta;
vector<unsigned int> vc_load = m_links[i]->getVcLoad();
for (int j = 0; j < vc_load.size(); j++) {
m_average_vc_load[j] += ((double)vc_load[j] / time_delta);
}
}
// Ask the routers to collate their statistics
for (int i = 0; i < m_routers.size(); i++) {
m_routers[i]->collateStats();
}
}
void
GarnetNetwork_d::print(ostream& out) const
{
out << "[GarnetNetwork_d]";
}
GarnetNetwork_d *
GarnetNetwork_dParams::create()
{
return new GarnetNetwork_d(this);
}
uint32_t
GarnetNetwork_d::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
for (unsigned int i = 0; i < m_routers.size(); i++) {
num_functional_writes += m_routers[i]->functionalWrite(pkt);
}
for (unsigned int i = 0; i < m_nis.size(); ++i) {
num_functional_writes += m_nis[i]->functionalWrite(pkt);
}
for (unsigned int i = 0; i < m_links.size(); ++i) {
num_functional_writes += m_links[i]->functionalWrite(pkt);
}
return num_functional_writes;
}

View file

@ -1,111 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "params/GarnetNetwork_d.hh"
class FaultModel;
class NetworkInterface_d;
class Router_d;
class NetDest;
class NetworkLink_d;
class CreditLink_d;
class GarnetNetwork_d : public BaseGarnetNetwork
{
public:
typedef GarnetNetwork_dParams Params;
GarnetNetwork_d(const Params *p);
~GarnetNetwork_d();
void init();
int getBuffersPerDataVC() { return m_buffers_per_data_vc; }
int getBuffersPerCtrlVC() { return m_buffers_per_ctrl_vc; }
void collateStats();
void regStats();
void print(std::ostream& out) const;
VNET_type
get_vnet_type(int vc)
{
int vnet = vc/getVCsPerVnet();
return m_vnet_type[vnet];
}
// Methods used by Topology to setup the network
void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
const NetDest& routing_table_entry);
void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
const NetDest& routing_table_entry);
void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
const NetDest& routing_table_entry,
PortDirection src_outport,
PortDirection dst_inport);
//! Function for performing a functional write. The return value
//! indicates the number of messages that were written.
uint32_t functionalWrite(Packet *pkt);
private:
GarnetNetwork_d(const GarnetNetwork_d& obj);
GarnetNetwork_d& operator=(const GarnetNetwork_d& obj);
std::vector<VNET_type > m_vnet_type;
std::vector<Router_d *> m_routers; // All Routers in Network
std::vector<NetworkLink_d *> m_links; // All links in the network
std::vector<CreditLink_d *> m_creditlinks; // All links in net
std::vector<NetworkInterface_d *> m_nis; // All NI's in Network
int m_buffers_per_data_vc;
int m_buffers_per_ctrl_vc;
// Statistical variables for performance
Stats::Scalar m_average_link_utilization;
Stats::Vector m_average_vc_load;
};
inline std::ostream&
operator<<(std::ostream& out, const GarnetNetwork_d& obj)
{
obj.print(out);
out << std::flush;
return out;
}
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__

View file

@ -1,61 +0,0 @@
# Copyright (c) 2008 Princeton University
# Copyright (c) 2009 Advanced Micro Devices, Inc.
# 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.
#
# Authors: Steve Reinhardt
# Brad Beckmann
from m5.params import *
from m5.proxy import *
from BaseGarnetNetwork import BaseGarnetNetwork
from BasicRouter import BasicRouter
from ClockedObject import ClockedObject
class GarnetRouter_d(BasicRouter):
type = 'GarnetRouter_d'
cxx_class = 'Router_d'
cxx_header = "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
vcs_per_vnet = Param.UInt32(Parent.vcs_per_vnet,
"virtual channels per virtual network")
virt_nets = Param.UInt32(Parent.number_of_virtual_networks,
"number of virtual networks")
class GarnetNetworkInterface_d(ClockedObject):
type = 'GarnetNetworkInterface_d'
cxx_class = 'NetworkInterface_d'
cxx_header = "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh"
id = Param.UInt32("ID in relation to other network interfaces")
vcs_per_vnet = Param.UInt32(Parent.vcs_per_vnet,
"virtual channels per virtual network")
virt_nets = Param.UInt32(Parent.number_of_virtual_networks,
"number of virtual networks")
class GarnetNetwork_d(BaseGarnetNetwork):
type = 'GarnetNetwork_d'
cxx_header = "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
buffers_per_data_vc = Param.UInt32(4, "buffers per data virtual channel");
buffers_per_ctrl_vc = Param.UInt32(1, "buffers per ctrl virtual channel");

View file

@ -1,122 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
InputUnit_d::InputUnit_d(int id, Router_d *router) : Consumer(router)
{
m_id = id;
m_router = router;
m_num_vcs = m_router->get_num_vcs();
m_vc_per_vnet = m_router->get_vc_per_vnet();
m_num_buffer_reads.resize(m_num_vcs/m_vc_per_vnet);
m_num_buffer_writes.resize(m_num_vcs/m_vc_per_vnet);
for (int i = 0; i < m_num_buffer_reads.size(); i++) {
m_num_buffer_reads[i] = 0;
m_num_buffer_writes[i] = 0;
}
creditQueue = new flitBuffer_d();
// Instantiating the virtual channels
m_vcs.resize(m_num_vcs);
for (int i=0; i < m_num_vcs; i++) {
m_vcs[i] = new VirtualChannel_d(i);
}
}
InputUnit_d::~InputUnit_d()
{
delete creditQueue;
deletePointers(m_vcs);
}
void
InputUnit_d::wakeup()
{
flit_d *t_flit;
if (m_in_link->isReady(m_router->curCycle())) {
t_flit = m_in_link->consumeLink();
int vc = t_flit->get_vc();
if ((t_flit->get_type() == HEAD_) ||
(t_flit->get_type() == HEAD_TAIL_)) {
assert(m_vcs[vc]->get_state() == IDLE_);
// Do the route computation for this vc
m_router->route_req(t_flit, this, vc);
m_vcs[vc]->set_enqueue_time(m_router->curCycle());
} else {
t_flit->advance_stage(SA_, m_router->curCycle());
// Changing router latency to 2 cycles. Input Unit takes 1 cycle for wakeup.
// VCalloc, SWalloc, Sw-Xfer and output scheduling takes 1 cycle. The original
// design schedules VCallocator for head flit, and Swalloc for non-head flit.
// VCalloc now calls SWalloc directly instead of scheduling it for the next cycle,
// hence we should not allocate SWalloc, otherwise it might get called twice, once
// by the scheduler and once by VCalloc.
m_router->vcarb_req();
}
// write flit into input buffer
m_vcs[vc]->insertFlit(t_flit);
int vnet = vc/m_vc_per_vnet;
// number of writes same as reads
// any flit that is written will be read only once
m_num_buffer_writes[vnet]++;
m_num_buffer_reads[vnet]++;
}
}
uint32_t
InputUnit_d::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
for (int i=0; i < m_num_vcs; i++) {
num_functional_writes += m_vcs[i]->functionalWrite(pkt);
}
return num_functional_writes;
}
void
InputUnit_d::resetStats()
{
for (int j = 0; j < m_num_buffer_reads.size(); j++) {
m_num_buffer_reads[j] = 0;
m_num_buffer_writes[j] = 0;
}
}

View file

@ -1,182 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_INPUT_UNIT_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_INPUT_UNIT_D_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class InputUnit_d : public Consumer
{
public:
InputUnit_d(int id, Router_d *router);
~InputUnit_d();
void wakeup();
flitBuffer_d* getCreditQueue() { return creditQueue; }
void print(std::ostream& out) const {};
inline int get_inlink_id() { return m_in_link->get_id(); }
inline void
set_vc_state(VC_state_type state, int vc, Cycles curTime)
{
m_vcs[vc]->set_state(state, curTime);
}
inline void
set_enqueue_time(int invc, Cycles time)
{
m_vcs[invc]->set_enqueue_time(time);
}
inline Cycles
get_enqueue_time(int invc)
{
return m_vcs[invc]->get_enqueue_time();
}
inline void
update_credit(int in_vc, int credit)
{
m_vcs[in_vc]->update_credit(credit);
}
inline bool
has_credits(int vc)
{
return m_vcs[vc]->has_credits();
}
inline void
increment_credit(int in_vc, bool free_signal, Cycles curTime)
{
flit_d *t_flit = new flit_d(in_vc, free_signal, curTime);
creditQueue->insert(t_flit);
m_credit_link->scheduleEventAbsolute(m_router->clockEdge(Cycles(1)));
}
inline int
get_outvc(int invc)
{
return m_vcs[invc]->get_outvc();
}
inline void
updateRoute(int vc, int outport, Cycles curTime)
{
m_vcs[vc]->set_outport(outport);
m_vcs[vc]->set_state(VC_AB_, curTime);
}
inline void
grant_vc(int in_vc, int out_vc, Cycles curTime)
{
m_vcs[in_vc]->grant_vc(out_vc, curTime);
}
inline flit_d*
peekTopFlit(int vc)
{
return m_vcs[vc]->peekTopFlit();
}
inline flit_d*
getTopFlit(int vc)
{
return m_vcs[vc]->getTopFlit();
}
inline bool
need_stage(int vc, VC_state_type state, flit_stage stage, Cycles cTime)
{
return m_vcs[vc]->need_stage(state, stage, cTime);
}
inline bool
isReady(int invc, Cycles curTime)
{
return m_vcs[invc]->isReady(curTime);
}
inline int
get_route(int vc)
{
return m_vcs[vc]->get_route();
}
inline void
set_in_link(NetworkLink_d *link)
{
m_in_link = link;
}
inline void
set_credit_link(CreditLink_d *credit_link)
{
m_credit_link = credit_link;
}
double get_buf_read_count(unsigned int vnet) const
{ return m_num_buffer_reads[vnet]; }
double get_buf_write_count(unsigned int vnet) const
{ return m_num_buffer_writes[vnet]; }
uint32_t functionalWrite(Packet *pkt);
void resetStats();
private:
int m_id;
int m_num_vcs;
int m_vc_per_vnet;
Router_d *m_router;
NetworkLink_d *m_in_link;
CreditLink_d *m_credit_link;
flitBuffer_d *creditQueue;
// Virtual channels
std::vector<VirtualChannel_d *> m_vcs;
// Statistical variables
std::vector<double> m_num_buffer_writes;
std::vector<double> m_num_buffer_reads;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_INPUT_UNIT_D_HH__

View file

@ -1,394 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include <cassert>
#include <cmath>
#include "base/cast.hh"
#include "base/stl_helpers.hh"
#include "debug/RubyNetwork.hh"
#include "mem/ruby/network/MessageBuffer.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkInterface_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
#include "mem/ruby/slicc_interface/Message.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
NetworkInterface_d::NetworkInterface_d(const Params *p)
: ClockedObject(p), Consumer(this), m_id(p->id),
m_virtual_networks(p->virt_nets), m_vc_per_vnet(p->vcs_per_vnet),
m_num_vcs(m_vc_per_vnet * m_virtual_networks)
{
m_vc_round_robin = 0;
m_ni_buffers.resize(m_num_vcs);
m_ni_enqueue_time.resize(m_num_vcs);
creditQueue = new flitBuffer_d();
// instantiating the NI flit buffers
for (int i = 0; i < m_num_vcs; i++) {
m_ni_buffers[i] = new flitBuffer_d();
m_ni_enqueue_time[i] = Cycles(INFINITE_);
}
m_vc_allocator.resize(m_virtual_networks); // 1 allocator per vnet
for (int i = 0; i < m_virtual_networks; i++) {
m_vc_allocator[i] = 0;
}
}
void
NetworkInterface_d::init()
{
for (int i = 0; i < m_num_vcs; i++) {
m_out_vc_state.push_back(new OutVcState_d(i, m_net_ptr));
}
}
NetworkInterface_d::~NetworkInterface_d()
{
deletePointers(m_out_vc_state);
deletePointers(m_ni_buffers);
delete creditQueue;
delete outSrcQueue;
}
void
NetworkInterface_d::addInPort(NetworkLink_d *in_link,
CreditLink_d *credit_link)
{
inNetLink = in_link;
in_link->setLinkConsumer(this);
m_ni_credit_link = credit_link;
credit_link->setSourceQueue(creditQueue);
}
void
NetworkInterface_d::addOutPort(NetworkLink_d *out_link,
CreditLink_d *credit_link)
{
m_credit_link = credit_link;
credit_link->setLinkConsumer(this);
outNetLink = out_link;
outSrcQueue = new flitBuffer_d();
out_link->setSourceQueue(outSrcQueue);
}
void
NetworkInterface_d::addNode(vector<MessageBuffer *>& in,
vector<MessageBuffer *>& out)
{
inNode_ptr = in;
outNode_ptr = out;
for (auto& it : in) {
if (it != nullptr) {
it->setConsumer(this);
}
}
}
bool
NetworkInterface_d::flitisizeMessage(MsgPtr msg_ptr, int vnet)
{
Message *net_msg_ptr = msg_ptr.get();
NetDest net_msg_dest = net_msg_ptr->getDestination();
// gets all the destinations associated with this message.
vector<NodeID> dest_nodes = net_msg_dest.getAllDest();
// Number of flits is dependent on the link bandwidth available.
// This is expressed in terms of bytes/cycle or the flit size
int num_flits = (int) ceil((double) m_net_ptr->MessageSizeType_to_int(
net_msg_ptr->getMessageSize())/m_net_ptr->getNiFlitSize());
// loop to convert all multicast messages into unicast messages
for (int ctr = 0; ctr < dest_nodes.size(); ctr++) {
// this will return a free output virtual channel
int vc = calculateVC(vnet);
if (vc == -1) {
return false ;
}
MsgPtr new_msg_ptr = msg_ptr->clone();
NodeID destID = dest_nodes[ctr];
Message *new_net_msg_ptr = new_msg_ptr.get();
if (dest_nodes.size() > 1) {
NetDest personal_dest;
for (int m = 0; m < (int) MachineType_NUM; m++) {
if ((destID >= MachineType_base_number((MachineType) m)) &&
destID < MachineType_base_number((MachineType) (m+1))) {
// calculating the NetDest associated with this destID
personal_dest.clear();
personal_dest.add((MachineID) {(MachineType) m, (destID -
MachineType_base_number((MachineType) m))});
new_net_msg_ptr->getDestination() = personal_dest;
break;
}
}
net_msg_dest.removeNetDest(personal_dest);
// removing the destination from the original message to reflect
// that a message with this particular destination has been
// flitisized and an output vc is acquired
net_msg_ptr->getDestination().removeNetDest(personal_dest);
}
for (int i = 0; i < num_flits; i++) {
m_net_ptr->increment_injected_flits(vnet);
flit_d *fl = new flit_d(i, vc, vnet, num_flits, new_msg_ptr,
curCycle());
fl->set_delay(curCycle() - ticksToCycles(msg_ptr->getTime()));
m_ni_buffers[vc]->insert(fl);
}
m_ni_enqueue_time[vc] = curCycle();
m_out_vc_state[vc]->setState(ACTIVE_, curCycle());
}
return true ;
}
// Looking for a free output vc
int
NetworkInterface_d::calculateVC(int vnet)
{
for (int i = 0; i < m_vc_per_vnet; i++) {
int delta = m_vc_allocator[vnet];
m_vc_allocator[vnet]++;
if (m_vc_allocator[vnet] == m_vc_per_vnet)
m_vc_allocator[vnet] = 0;
if (m_out_vc_state[(vnet*m_vc_per_vnet) + delta]->isInState(
IDLE_, curCycle())) {
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. It also checks for credits being sent by the
* downstream router.
*/
void
NetworkInterface_d::wakeup()
{
DPRINTF(RubyNetwork, "m_id: %d woke up at time: %lld", m_id, curCycle());
MsgPtr msg_ptr;
Tick curTime = clockEdge();
// Checking for messages coming from the protocol
// can pick up a message/cycle for each virtual net
for (int vnet = 0; vnet < inNode_ptr.size(); ++vnet) {
MessageBuffer *b = inNode_ptr[vnet];
if (b == nullptr) {
continue;
}
while (b->isReady(curTime)) { // Is there a message waiting
msg_ptr = b->peekMsgPtr();
if (flitisizeMessage(msg_ptr, vnet)) {
b->dequeue(curTime);
} else {
break;
}
}
}
scheduleOutputLink();
checkReschedule();
/*********** Picking messages destined for this NI **********/
if (inNetLink->isReady(curCycle())) {
flit_d *t_flit = inNetLink->consumeLink();
bool free_signal = false;
if (t_flit->get_type() == TAIL_ || t_flit->get_type() == HEAD_TAIL_) {
free_signal = true;
outNode_ptr[t_flit->get_vnet()]->enqueue(
t_flit->get_msg_ptr(), curTime, cyclesToTicks(Cycles(1)));
}
// Simply send a credit back since we are not buffering
// this flit in the NI
flit_d *credit_flit = new flit_d(t_flit->get_vc(), free_signal,
curCycle());
creditQueue->insert(credit_flit);
m_ni_credit_link->
scheduleEventAbsolute(clockEdge(Cycles(1)));
int vnet = t_flit->get_vnet();
m_net_ptr->increment_received_flits(vnet);
Cycles network_delay = curCycle() - t_flit->get_enqueue_time();
Cycles queueing_delay = t_flit->get_delay();
m_net_ptr->increment_network_latency(network_delay, vnet);
m_net_ptr->increment_queueing_latency(queueing_delay, vnet);
delete t_flit;
}
/****************** Checking for credit link *******/
if (m_credit_link->isReady(curCycle())) {
flit_d *t_flit = m_credit_link->consumeLink();
m_out_vc_state[t_flit->get_vc()]->increment_credit();
if (t_flit->is_free_signal()) {
m_out_vc_state[t_flit->get_vc()]->setState(IDLE_, curCycle());
}
delete t_flit;
}
}
/** This function looks at the NI buffers
* if some buffer has flits which are ready to traverse the link in the next
* cycle, and the downstream output vc associated with this flit has buffers
* left, the link is scheduled for the next cycle
*/
void
NetworkInterface_d::scheduleOutputLink()
{
int vc = m_vc_round_robin;
m_vc_round_robin++;
if (m_vc_round_robin == m_num_vcs)
m_vc_round_robin = 0;
for (int i = 0; i < m_num_vcs; i++) {
vc++;
if (vc == m_num_vcs)
vc = 0;
// model buffer backpressure
if (m_ni_buffers[vc]->isReady(curCycle()) &&
m_out_vc_state[vc]->has_credits()) {
bool is_candidate_vc = true;
int t_vnet = get_vnet(vc);
int vc_base = t_vnet * m_vc_per_vnet;
if (m_net_ptr->isVNetOrdered(t_vnet)) {
for (int vc_offset = 0; vc_offset < m_vc_per_vnet;
vc_offset++) {
int t_vc = vc_base + vc_offset;
if (m_ni_buffers[t_vc]->isReady(curCycle())) {
if (m_ni_enqueue_time[t_vc] < m_ni_enqueue_time[vc]) {
is_candidate_vc = false;
break;
}
}
}
}
if (!is_candidate_vc)
continue;
m_out_vc_state[vc]->decrement_credit();
// Just removing the flit
flit_d *t_flit = m_ni_buffers[vc]->getTopFlit();
t_flit->set_time(curCycle() + Cycles(1));
outSrcQueue->insert(t_flit);
// schedule the out link
outNetLink->scheduleEventAbsolute(clockEdge(Cycles(1)));
if (t_flit->get_type() == TAIL_ ||
t_flit->get_type() == HEAD_TAIL_) {
m_ni_enqueue_time[vc] = Cycles(INFINITE_);
}
return;
}
}
}
int
NetworkInterface_d::get_vnet(int vc)
{
for (int i = 0; i < m_virtual_networks; i++) {
if (vc >= (i*m_vc_per_vnet) && vc < ((i+1)*m_vc_per_vnet)) {
return i;
}
}
fatal("Could not determine vc");
}
void
NetworkInterface_d::checkReschedule()
{
for (const auto& it : inNode_ptr) {
if (it == nullptr) {
continue;
}
while (it->isReady(clockEdge())) { // Is there a message waiting
scheduleEvent(Cycles(1));
return;
}
}
for (int vc = 0; vc < m_num_vcs; vc++) {
if (m_ni_buffers[vc]->isReady(curCycle() + Cycles(1))) {
scheduleEvent(Cycles(1));
return;
}
}
}
void
NetworkInterface_d::print(std::ostream& out) const
{
out << "[Network Interface]";
}
uint32_t
NetworkInterface_d::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
for (unsigned int i = 0; i < m_num_vcs; ++i) {
num_functional_writes += m_ni_buffers[i]->functionalWrite(pkt);
}
num_functional_writes += outSrcQueue->functionalWrite(pkt);
return num_functional_writes;
}
NetworkInterface_d *
GarnetNetworkInterface_dParams::create()
{
return new NetworkInterface_d(this);
}

View file

@ -1,102 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_INTERFACE_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_INTERFACE_D_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/slicc_interface/Message.hh"
#include "params/GarnetNetworkInterface_d.hh"
class MessageBuffer;
class flitBuffer_d;
class NetworkInterface_d : public ClockedObject, public Consumer
{
public:
typedef GarnetNetworkInterface_dParams Params;
NetworkInterface_d(const Params *p);
~NetworkInterface_d();
void init();
void addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link);
void addOutPort(NetworkLink_d *out_link, CreditLink_d *credit_link);
void wakeup();
void addNode(std::vector<MessageBuffer *> &inNode,
std::vector<MessageBuffer *> &outNode);
void print(std::ostream& out) const;
int get_vnet(int vc);
void init_net_ptr(GarnetNetwork_d *net_ptr) { m_net_ptr = net_ptr; }
uint32_t functionalWrite(Packet *);
private:
GarnetNetwork_d *m_net_ptr;
const NodeID M5_CLASS_VAR_USED m_id;
const int m_virtual_networks, m_vc_per_vnet, m_num_vcs;
std::vector<OutVcState_d *> m_out_vc_state;
std::vector<int> m_vc_allocator;
int m_vc_round_robin; // For round robin scheduling
flitBuffer_d *outSrcQueue; // For modelling link contention
flitBuffer_d *creditQueue;
NetworkLink_d *inNetLink;
NetworkLink_d *outNetLink;
CreditLink_d *m_credit_link;
CreditLink_d *m_ni_credit_link;
// Input Flit Buffers
// The flit buffers which will serve the Consumer
std::vector<flitBuffer_d *> m_ni_buffers;
std::vector<Cycles> m_ni_enqueue_time;
// The Message buffers that takes messages from the protocol
std::vector<MessageBuffer *> inNode_ptr;
// The Message buffers that provides messages to the protocol
std::vector<MessageBuffer *> outNode_ptr;
bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
int calculateVC(int vnet);
void scheduleOutputLink();
void checkReschedule();
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_INTERFACE_D_HH__

View file

@ -1,89 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
NetworkLink_d::NetworkLink_d(const Params *p)
: ClockedObject(p), Consumer(this), m_id(p->link_id),
m_latency(p->link_latency),
linkBuffer(new flitBuffer_d()), link_consumer(nullptr),
link_srcQueue(nullptr), m_link_utilized(0),
m_vc_load(p->vcs_per_vnet * p->virt_nets)
{
}
NetworkLink_d::~NetworkLink_d()
{
delete linkBuffer;
}
void
NetworkLink_d::setLinkConsumer(Consumer *consumer)
{
link_consumer = consumer;
}
void
NetworkLink_d::setSourceQueue(flitBuffer_d *srcQueue)
{
link_srcQueue = srcQueue;
}
void
NetworkLink_d::wakeup()
{
if (link_srcQueue->isReady(curCycle())) {
flit_d *t_flit = link_srcQueue->getTopFlit();
t_flit->set_time(curCycle() + m_latency);
linkBuffer->insert(t_flit);
link_consumer->scheduleEventAbsolute(clockEdge(m_latency));
m_link_utilized++;
m_vc_load[t_flit->get_vc()]++;
}
}
NetworkLink_d *
NetworkLink_dParams::create()
{
return new NetworkLink_d(this);
}
CreditLink_d *
CreditLink_dParams::create()
{
return new CreditLink_d(this);
}
uint32_t
NetworkLink_d::functionalWrite(Packet *pkt)
{
return linkBuffer->functionalWrite(pkt);
}

View file

@ -1,82 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_LINK_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_LINK_D_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "params/NetworkLink_d.hh"
#include "sim/clocked_object.hh"
class GarnetNetwork_d;
class NetworkLink_d : public ClockedObject, public Consumer
{
public:
typedef NetworkLink_dParams Params;
NetworkLink_d(const Params *p);
~NetworkLink_d();
void setLinkConsumer(Consumer *consumer);
void setSourceQueue(flitBuffer_d *srcQueue);
void print(std::ostream& out) const {}
int get_id() const { return m_id; }
void wakeup();
unsigned int getLinkUtilization() const { return m_link_utilized; }
const std::vector<unsigned int> & getVcLoad() const { return m_vc_load; }
inline bool isReady(Cycles curTime)
{ return linkBuffer->isReady(curTime); }
inline flit_d* peekLink() { return linkBuffer->peekTopFlit(); }
inline flit_d* consumeLink() { return linkBuffer->getTopFlit(); }
uint32_t functionalWrite(Packet *);
private:
const int m_id;
const Cycles m_latency;
flitBuffer_d *linkBuffer;
Consumer *link_consumer;
flitBuffer_d *link_srcQueue;
// Statistical variables
unsigned int m_link_utilized;
std::vector<unsigned int> m_vc_load;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_NETWORK_LINK_D_HH__

View file

@ -1,47 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.hh"
#include "mem/ruby/system/RubySystem.hh"
OutVcState_d::OutVcState_d(int id, GarnetNetwork_d *network_ptr)
: m_time(0)
{
m_id = id;
m_vc_state = IDLE_;
if (network_ptr->get_vnet_type(id) == DATA_VNET_)
m_credit_count = network_ptr->getBuffersPerDataVC();
else
m_credit_count = network_ptr->getBuffersPerCtrlVC();
assert(m_credit_count >= 1);
}

View file

@ -1,72 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUT_VC_STATE_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUT_VC_STATE_D_HH__
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class OutVcState_d
{
public:
OutVcState_d(int id, GarnetNetwork_d *network_ptr);
int get_inport() { return m_in_port; }
int get_invc() { return m_in_vc; }
int get_credit_count() { return m_credit_count; }
void set_inport(int port) { m_in_port = port; }
void set_invc(int vc) { m_in_vc = vc; }
inline bool
isInState(VC_state_type state, Cycles request_time)
{
return ((m_vc_state == state) && (request_time >= m_time) );
}
inline void
setState(VC_state_type state, Cycles time)
{
m_vc_state = state;
m_time = time;
}
inline bool has_credits() { return (m_credit_count > 0); }
inline void increment_credit() { m_credit_count++; }
inline void decrement_credit() { m_credit_count--; }
private:
int m_id ;
Cycles m_time;
VC_state_type m_vc_state;
int m_in_port;
int m_in_vc;
int m_credit_count;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUT_VC_STATE_D_HH__

View file

@ -1,116 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
OutputUnit_d::OutputUnit_d(int id, Router_d *router)
: Consumer(router)
{
m_id = id;
m_router = router;
m_num_vcs = m_router->get_num_vcs();
m_out_buffer = new flitBuffer_d();
for (int i = 0; i < m_num_vcs; i++) {
m_outvc_state.push_back(new OutVcState_d(i, m_router->get_net_ptr()));
}
}
OutputUnit_d::~OutputUnit_d()
{
delete m_out_buffer;
deletePointers(m_outvc_state);
}
void
OutputUnit_d::decrement_credit(int out_vc)
{
m_outvc_state[out_vc]->decrement_credit();
m_router->update_incredit(m_outvc_state[out_vc]->get_inport(),
m_outvc_state[out_vc]->get_invc(),
m_outvc_state[out_vc]->get_credit_count());
}
void
OutputUnit_d::wakeup()
{
if (m_credit_link->isReady(m_router->curCycle())) {
flit_d *t_flit = m_credit_link->consumeLink();
int out_vc = t_flit->get_vc();
m_outvc_state[out_vc]->increment_credit();
m_router->update_incredit(m_outvc_state[out_vc]->get_inport(),
m_outvc_state[out_vc]->get_invc(),
m_outvc_state[out_vc]->get_credit_count());
if (t_flit->is_free_signal())
set_vc_state(IDLE_, out_vc, m_router->curCycle());
delete t_flit;
}
}
flitBuffer_d*
OutputUnit_d::getOutQueue()
{
return m_out_buffer;
}
void
OutputUnit_d::set_out_link(NetworkLink_d *link)
{
m_out_link = link;
}
void
OutputUnit_d::set_credit_link(CreditLink_d *credit_link)
{
m_credit_link = credit_link;
}
void
OutputUnit_d::update_vc(int vc, int in_port, int in_vc)
{
m_outvc_state[vc]->setState(ACTIVE_, m_router->curCycle());
m_outvc_state[vc]->set_inport(in_port);
m_outvc_state[vc]->set_invc(in_vc);
m_router->update_incredit(in_port, in_vc,
m_outvc_state[vc]->get_credit_count());
}
uint32_t
OutputUnit_d::functionalWrite(Packet *pkt)
{
return m_out_buffer->functionalWrite(pkt);
}

View file

@ -1,103 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUTPUT_UNIT_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUTPUT_UNIT_D_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/OutVcState_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class OutputUnit_d : public Consumer
{
public:
OutputUnit_d(int id, Router_d *router);
~OutputUnit_d();
void set_out_link(NetworkLink_d *link);
void set_credit_link(CreditLink_d *credit_link);
void wakeup();
flitBuffer_d* getOutQueue();
void update_vc(int vc, int in_port, int in_vc);
void print(std::ostream& out) const {};
void decrement_credit(int out_vc);
int
get_credit_cnt(int vc)
{
return m_outvc_state[vc]->get_credit_count();
}
inline int
get_outlink_id()
{
return m_out_link->get_id();
}
inline void
set_vc_state(VC_state_type state, int vc, Cycles curTime)
{
m_outvc_state[vc]->setState(state, curTime);
}
inline bool
is_vc_idle(int vc, Cycles curTime)
{
return (m_outvc_state[vc]->isInState(IDLE_, curTime));
}
inline void
insert_flit(flit_d *t_flit)
{
m_out_buffer->insert(t_flit);
m_out_link->scheduleEventAbsolute(m_router->clockEdge(Cycles(1)));
}
uint32_t functionalWrite(Packet *pkt);
private:
int m_id;
int m_num_vcs;
Router_d *m_router;
NetworkLink_d *m_out_link;
CreditLink_d *m_credit_link;
flitBuffer_d *m_out_buffer; // This is for the network link to consume
std::vector<OutVcState_d *> m_outvc_state; // vc state of downstream router
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_OUTPUT_UNIT_D_HH__

View file

@ -1,277 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "base/stl_helpers.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
Router_d::Router_d(const Params *p)
: BasicRouter(p)
{
m_virtual_networks = p->virt_nets;
m_vc_per_vnet = p->vcs_per_vnet;
m_num_vcs = m_virtual_networks * m_vc_per_vnet;
m_routing_unit = new RoutingUnit_d(this);
m_vc_alloc = new VCallocator_d(this);
m_sw_alloc = new SWallocator_d(this);
m_switch = new Switch_d(this);
m_input_unit.clear();
m_output_unit.clear();
}
Router_d::~Router_d()
{
deletePointers(m_input_unit);
deletePointers(m_output_unit);
delete m_routing_unit;
delete m_vc_alloc;
delete m_sw_alloc;
delete m_switch;
}
void
Router_d::init()
{
BasicRouter::init();
m_vc_alloc->init();
m_sw_alloc->init();
m_switch->init();
}
void
Router_d::addInPort(NetworkLink_d *in_link, CreditLink_d *credit_link)
{
int port_num = m_input_unit.size();
InputUnit_d *input_unit = new InputUnit_d(port_num, this);
input_unit->set_in_link(in_link);
input_unit->set_credit_link(credit_link);
in_link->setLinkConsumer(input_unit);
credit_link->setSourceQueue(input_unit->getCreditQueue());
m_input_unit.push_back(input_unit);
}
void
Router_d::addOutPort(NetworkLink_d *out_link,
const NetDest& routing_table_entry, int link_weight,
CreditLink_d *credit_link)
{
int port_num = m_output_unit.size();
OutputUnit_d *output_unit = new OutputUnit_d(port_num, this);
output_unit->set_out_link(out_link);
output_unit->set_credit_link(credit_link);
credit_link->setLinkConsumer(output_unit);
out_link->setSourceQueue(output_unit->getOutQueue());
m_output_unit.push_back(output_unit);
m_routing_unit->addRoute(routing_table_entry);
m_routing_unit->addWeight(link_weight);
}
void
Router_d::route_req(flit_d *t_flit, InputUnit_d *in_unit, int invc)
{
m_routing_unit->RC_stage(t_flit, in_unit, invc);
}
void
Router_d::vcarb_req()
{
m_vc_alloc->scheduleEventAbsolute(clockEdge(Cycles(1)));
}
void
Router_d::swarb_req()
{
m_sw_alloc->scheduleEventAbsolute(clockEdge(Cycles(1)));
}
void
Router_d::call_sw_alloc()
{
m_sw_alloc->wakeup();
}
void
Router_d::call_switch()
{
m_switch->wakeup();
}
void
Router_d::update_incredit(int in_port, int in_vc, int credit)
{
m_input_unit[in_port]->update_credit(in_vc, credit);
}
void
Router_d::update_sw_winner(int inport, flit_d *t_flit)
{
m_switch->update_sw_winner(inport, t_flit);
m_switch->scheduleEventAbsolute(clockEdge(Cycles(1)));
}
void
Router_d::regStats()
{
BasicRouter::regStats();
m_buffer_reads
.name(name() + ".buffer_reads")
.flags(Stats::nozero)
;
m_buffer_writes
.name(name() + ".buffer_writes")
.flags(Stats::nozero)
;
m_crossbar_activity
.name(name() + ".crossbar_activity")
.flags(Stats::nozero)
;
m_sw_local_arbiter_activity
.name(name() + ".sw_local_arbiter_activity")
.flags(Stats::nozero)
;
m_sw_global_arbiter_activity
.name(name() + ".sw_global_arbiter_activity")
.flags(Stats::nozero)
;
m_vc_local_arbiter_activity
.name(name() + ".vc_local_arbiter_activity")
.flags(Stats::nozero)
;
m_vc_global_arbiter_activity
.name(name() + ".vc_global_arbiter_activity")
.flags(Stats::nozero)
;
}
void
Router_d::collateStats()
{
for (int j = 0; j < m_virtual_networks; j++) {
for (int i = 0; i < m_input_unit.size(); i++) {
m_buffer_reads += m_input_unit[i]->get_buf_read_count(j);
m_buffer_writes += m_input_unit[i]->get_buf_write_count(j);
}
m_vc_local_arbiter_activity += m_vc_alloc->get_local_arbit_count(j);
m_vc_global_arbiter_activity += m_vc_alloc->get_global_arbit_count(j);
}
m_sw_local_arbiter_activity = m_sw_alloc->get_local_arbit_count();
m_sw_global_arbiter_activity = m_sw_alloc->get_global_arbit_count();
m_crossbar_activity = m_switch->get_crossbar_count();
}
void
Router_d::resetStats()
{
for (int j = 0; j < m_virtual_networks; j++) {
for (int i = 0; i < m_input_unit.size(); i++) {
m_input_unit[i]->resetStats();
}
}
}
void
Router_d::printFaultVector(ostream& out)
{
int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
int num_fault_types = m_network_ptr->fault_model->number_of_fault_types;
float fault_vector[num_fault_types];
get_fault_vector(temperature_celcius, fault_vector);
out << "Router-" << m_id << " fault vector: " << endl;
for (int fault_type_index = 0; fault_type_index < num_fault_types;
fault_type_index++){
out << " - probability of (";
out <<
m_network_ptr->fault_model->fault_type_to_string(fault_type_index);
out << ") = ";
out << fault_vector[fault_type_index] << endl;
}
}
void
Router_d::printAggregateFaultProbability(std::ostream& out)
{
int temperature_celcius = BASELINE_TEMPERATURE_CELCIUS;
float aggregate_fault_prob;
get_aggregate_fault_probability(temperature_celcius,
&aggregate_fault_prob);
out << "Router-" << m_id << " fault probability: ";
out << aggregate_fault_prob << endl;
}
uint32_t
Router_d::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
num_functional_writes += m_switch->functionalWrite(pkt);
for (uint32_t i = 0; i < m_input_unit.size(); i++) {
num_functional_writes += m_input_unit[i]->functionalWrite(pkt);
}
for (uint32_t i = 0; i < m_output_unit.size(); i++) {
num_functional_writes += m_output_unit[i]->functionalWrite(pkt);
}
return num_functional_writes;
}
Router_d *
GarnetRouter_dParams::create()
{
return new Router_d(this);
}

View file

@ -1,134 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTER_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTER_D_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/network/BasicRouter.hh"
#include "params/GarnetRouter_d.hh"
class NetworkLink_d;
class CreditLink_d;
class InputUnit_d;
class OutputUnit_d;
class RoutingUnit_d;
class VCallocator_d;
class SWallocator_d;
class Switch_d;
class FaultModel;
class Router_d : public BasicRouter
{
public:
typedef GarnetRouter_dParams Params;
Router_d(const Params *p);
~Router_d();
void init();
void addInPort(NetworkLink_d *link, CreditLink_d *credit_link);
void addOutPort(NetworkLink_d *link, const NetDest& routing_table_entry,
int link_weight, CreditLink_d *credit_link);
int get_num_vcs() { return m_num_vcs; }
int get_num_vnets() { return m_virtual_networks; }
int get_vc_per_vnet() { return m_vc_per_vnet; }
int get_num_inports() { return m_input_unit.size(); }
int get_num_outports() { return m_output_unit.size(); }
int get_id() { return m_id; }
void init_net_ptr(GarnetNetwork_d* net_ptr)
{
m_network_ptr = net_ptr;
}
GarnetNetwork_d* get_net_ptr() { return m_network_ptr; }
std::vector<InputUnit_d *>& get_inputUnit_ref() { return m_input_unit; }
std::vector<OutputUnit_d *>& get_outputUnit_ref() { return m_output_unit; }
void update_sw_winner(int inport, flit_d *t_flit);
void update_incredit(int in_port, int in_vc, int credit);
void route_req(flit_d *t_flit, InputUnit_d* in_unit, int invc);
void vcarb_req();
void swarb_req();
void call_sw_alloc();
void call_switch();
void printFaultVector(std::ostream& out);
void printAggregateFaultProbability(std::ostream& out);
void regStats();
void collateStats();
void resetStats();
bool get_fault_vector(int temperature, float fault_vector[]){
return m_network_ptr->fault_model->fault_vector(m_id, temperature,
fault_vector);
}
bool get_aggregate_fault_probability(int temperature,
float *aggregate_fault_prob){
return m_network_ptr->fault_model->fault_prob(m_id, temperature,
aggregate_fault_prob);
}
uint32_t functionalWrite(Packet *);
private:
int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
GarnetNetwork_d *m_network_ptr;
std::vector<InputUnit_d *> m_input_unit;
std::vector<OutputUnit_d *> m_output_unit;
RoutingUnit_d *m_routing_unit;
VCallocator_d *m_vc_alloc;
SWallocator_d *m_sw_alloc;
Switch_d *m_switch;
// Statistical variables required for power computations
Stats::Scalar m_buffer_reads;
Stats::Scalar m_buffer_writes;
Stats::Scalar m_sw_local_arbiter_activity;
Stats::Scalar m_sw_global_arbiter_activity;
Stats::Scalar m_vc_local_arbiter_activity;
Stats::Scalar m_vc_global_arbiter_activity;
Stats::Scalar m_crossbar_activity;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTER_D_HH__

View file

@ -1,90 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "base/cast.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/RoutingUnit_d.hh"
#include "mem/ruby/slicc_interface/Message.hh"
RoutingUnit_d::RoutingUnit_d(Router_d *router)
{
m_router = router;
m_routing_table.clear();
m_weight_table.clear();
}
void
RoutingUnit_d::addRoute(const NetDest& routing_table_entry)
{
m_routing_table.push_back(routing_table_entry);
}
void
RoutingUnit_d::addWeight(int link_weight)
{
m_weight_table.push_back(link_weight);
}
void
RoutingUnit_d::RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc)
{
int outport = routeCompute(t_flit);
in_unit->updateRoute(invc, outport, m_router->curCycle());
t_flit->advance_stage(VA_, m_router->curCycle() + Cycles(1));
m_router->vcarb_req();
}
int
RoutingUnit_d::routeCompute(flit_d *t_flit)
{
MsgPtr msg_ptr = t_flit->get_msg_ptr();
Message *net_msg_ptr = msg_ptr.get();
NetDest msg_destination = net_msg_ptr->getDestination();
int output_link = -1;
int min_weight = INFINITE_;
for (int link = 0; link < m_routing_table.size(); link++) {
if (msg_destination.intersectionIsNotEmpty(m_routing_table[link])) {
if (m_weight_table[link] >= min_weight)
continue;
output_link = link;
min_weight = m_weight_table[link];
}
}
if (output_link == -1) {
fatal("Fatal Error:: No Route exists from this Router.");
exit(0);
}
return output_link;
}

View file

@ -1,57 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTING_UNIT_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTING_UNIT_D_HH__
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class InputUnit_d;
class Router_d;
class RoutingUnit_d
{
public:
RoutingUnit_d(Router_d *router);
void addRoute(const NetDest& routing_table_entry);
int routeCompute(flit_d *t_flit);
void addWeight(int link_weight);
void RC_stage(flit_d *t_flit, InputUnit_d *in_unit, int invc);
private:
Router_d *m_router;
std::vector<NetDest> m_routing_table;
std::vector<int> m_weight_table;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_ROUTING_UNIT_D_HH__

View file

@ -1,53 +0,0 @@
# -*- mode:python -*-
# Copyright (c) 2009 The Hewlett-Packard Development Company
# 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.
#
# Authors: Nathan Binkert
Import('*')
if env['PROTOCOL'] == 'None':
Return()
SimObject('GarnetLink_d.py')
SimObject('GarnetNetwork_d.py')
Source('GarnetLink_d.cc')
Source('GarnetNetwork_d.cc')
Source('InputUnit_d.cc')
Source('NetworkInterface_d.cc')
Source('NetworkLink_d.cc')
Source('OutVcState_d.cc')
Source('OutputUnit_d.cc')
Source('Router_d.cc')
Source('RoutingUnit_d.cc')
Source('SWallocator_d.cc')
Source('Switch_d.cc')
Source('VCallocator_d.cc')
Source('VirtualChannel_d.cc')
Source('flitBuffer_d.cc')
Source('flit_d.cc')

View file

@ -1,241 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/SWallocator_d.hh"
SWallocator_d::SWallocator_d(Router_d *router)
: Consumer(router)
{
m_router = router;
m_num_vcs = m_router->get_num_vcs();
m_vc_per_vnet = m_router->get_vc_per_vnet();
m_local_arbiter_activity = 0;
m_global_arbiter_activity = 0;
}
void
SWallocator_d::init()
{
m_input_unit = m_router->get_inputUnit_ref();
m_output_unit = m_router->get_outputUnit_ref();
m_num_inports = m_router->get_num_inports();
m_num_outports = m_router->get_num_outports();
m_round_robin_outport.resize(m_num_outports);
m_round_robin_inport.resize(m_num_inports);
m_port_req.resize(m_num_outports);
m_vc_winners.resize(m_num_outports);
for (int i = 0; i < m_num_inports; i++) {
m_round_robin_inport[i] = 0;
}
for (int i = 0; i < m_num_outports; i++) {
m_port_req[i].resize(m_num_inports);
m_vc_winners[i].resize(m_num_inports);
m_round_robin_outport[i] = 0;
for (int j = 0; j < m_num_inports; j++) {
m_port_req[i][j] = false; // [outport][inport]
}
}
}
void
SWallocator_d::wakeup()
{
arbitrate_inports(); // First stage of allocation
arbitrate_outports(); // Second stage of allocation
clear_request_vector();
check_for_wakeup();
m_router->call_switch();
}
void
SWallocator_d::arbitrate_inports()
{
// First do round robin arbitration on a set of input vc requests
for (int inport = 0; inport < m_num_inports; inport++) {
int invc = m_round_robin_inport[inport];
// Select next round robin vc candidate within valid vnet
int next_round_robin_invc = invc;
next_round_robin_invc++;
if (next_round_robin_invc >= m_num_vcs)
next_round_robin_invc = 0;
m_round_robin_inport[inport] = next_round_robin_invc;
for (int invc_iter = 0; invc_iter < m_num_vcs; invc_iter++) {
invc++;
if (invc >= m_num_vcs)
invc = 0;
if (m_input_unit[inport]->need_stage(invc, ACTIVE_, SA_,
m_router->curCycle()) &&
m_input_unit[inport]->has_credits(invc)) {
if (is_candidate_inport(inport, invc)) {
int outport = m_input_unit[inport]->get_route(invc);
m_local_arbiter_activity++;
m_port_req[outport][inport] = true;
m_vc_winners[outport][inport]= invc;
break; // got one vc winner for this port
}
}
}
}
}
bool
SWallocator_d::is_candidate_inport(int inport, int invc)
{
int outport = m_input_unit[inport]->get_route(invc);
Cycles t_enqueue_time = m_input_unit[inport]->get_enqueue_time(invc);
int t_vnet = get_vnet(invc);
int vc_base = t_vnet*m_vc_per_vnet;
if ((m_router->get_net_ptr())->isVNetOrdered(t_vnet)) {
for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) {
int temp_vc = vc_base + vc_offset;
if (m_input_unit[inport]->need_stage(temp_vc, ACTIVE_, SA_,
m_router->curCycle()) &&
(m_input_unit[inport]->get_route(temp_vc) == outport) &&
(m_input_unit[inport]->get_enqueue_time(temp_vc) <
t_enqueue_time)) {
return false;
break;
}
}
}
return true;
}
void
SWallocator_d::arbitrate_outports()
{
// Now there are a set of input vc requests for output vcs.
// Again do round robin arbitration on these requests
for (int outport = 0; outport < m_num_outports; outport++) {
int inport = m_round_robin_outport[outport];
m_round_robin_outport[outport]++;
if (m_round_robin_outport[outport] >= m_num_outports)
m_round_robin_outport[outport] = 0;
for (int inport_iter = 0; inport_iter < m_num_inports; inport_iter++) {
inport++;
if (inport >= m_num_inports)
inport = 0;
// inport has a request this cycle for outport:
if (m_port_req[outport][inport]) {
m_port_req[outport][inport] = false;
int invc = m_vc_winners[outport][inport];
int outvc = m_input_unit[inport]->get_outvc(invc);
// remove flit from Input Unit
flit_d *t_flit = m_input_unit[inport]->getTopFlit(invc);
t_flit->advance_stage(ST_, m_router->curCycle());
t_flit->set_vc(outvc);
t_flit->set_outport(outport);
t_flit->set_time(m_router->curCycle());
m_output_unit[outport]->decrement_credit(outvc);
m_router->update_sw_winner(inport, t_flit);
m_global_arbiter_activity++;
if ((t_flit->get_type() == TAIL_) ||
t_flit->get_type() == HEAD_TAIL_) {
// Send a credit back
// along with the information that this VC is now idle
m_input_unit[inport]->increment_credit(invc, true,
m_router->curCycle());
// This Input VC should now be empty
assert(!m_input_unit[inport]->
isReady(invc, m_router->curCycle()));
m_input_unit[inport]->set_vc_state(IDLE_, invc,
m_router->curCycle());
m_input_unit[inport]->set_enqueue_time(invc,
Cycles(INFINITE_));
} else {
// Send a credit back
// but do not indicate that the VC is idle
m_input_unit[inport]->increment_credit(invc, false,
m_router->curCycle());
}
break; // got a in request for this outport
}
}
}
}
void
SWallocator_d::check_for_wakeup()
{
Cycles nextCycle = m_router->curCycle() + Cycles(1);
for (int i = 0; i < m_num_inports; i++) {
for (int j = 0; j < m_num_vcs; j++) {
if (m_input_unit[i]->need_stage(j, ACTIVE_, SA_, nextCycle)) {
m_router->vcarb_req();
return;
}
}
}
}
int
SWallocator_d::get_vnet(int invc)
{
int vnet = invc/m_vc_per_vnet;
assert(vnet < m_router->get_num_vnets());
return vnet;
}
void
SWallocator_d::clear_request_vector()
{
for (int i = 0; i < m_num_outports; i++) {
for (int j = 0; j < m_num_inports; j++) {
m_port_req[i][j] = false;
}
}
}

View file

@ -1,84 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SW_ALLOCATOR_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SW_ALLOCATOR_D_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class Router_d;
class InputUnit_d;
class OutputUnit_d;
class SWallocator_d : public Consumer
{
public:
SWallocator_d(Router_d *router);
void wakeup();
void init();
void clear_request_vector();
void check_for_wakeup();
int get_vnet (int invc);
void print(std::ostream& out) const {};
void arbitrate_inports();
void arbitrate_outports();
bool is_candidate_inport(int inport, int invc);
inline double
get_local_arbit_count()
{
return m_local_arbiter_activity;
}
inline double
get_global_arbit_count()
{
return m_global_arbiter_activity;
}
private:
int m_num_inports, m_num_outports;
int m_num_vcs, m_vc_per_vnet;
double m_local_arbiter_activity, m_global_arbiter_activity;
Router_d *m_router;
std::vector<int> m_round_robin_outport;
std::vector<int> m_round_robin_inport;
std::vector<std::vector<bool> > m_port_req;
std::vector<std::vector<int> > m_vc_winners; // a list for each outport
std::vector<InputUnit_d *> m_input_unit;
std::vector<OutputUnit_d *> m_output_unit;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SW_ALLOCATOR_D_HH__

View file

@ -1,111 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "base/stl_helpers.hh"
#include "debug/RubyNetwork.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Switch_d.hh"
using m5::stl_helpers::deletePointers;
Switch_d::Switch_d(Router_d *router)
: Consumer(router)
{
m_router = router;
m_num_vcs = m_router->get_num_vcs();
m_crossbar_activity = 0;
}
Switch_d::~Switch_d()
{
deletePointers(m_switch_buffer);
}
void
Switch_d::init()
{
m_output_unit = m_router->get_outputUnit_ref();
m_num_inports = m_router->get_num_inports();
m_switch_buffer.resize(m_num_inports);
for (int i = 0; i < m_num_inports; i++) {
m_switch_buffer[i] = new flitBuffer_d();
}
}
void
Switch_d::wakeup()
{
DPRINTF(RubyNetwork, "Switch woke up at time: %lld\n",
m_router->curCycle());
for (int inport = 0; inport < m_num_inports; inport++) {
if (!m_switch_buffer[inport]->isReady(m_router->curCycle()))
continue;
flit_d *t_flit = m_switch_buffer[inport]->peekTopFlit();
if (t_flit->is_stage(ST_, m_router->curCycle())) {
int outport = t_flit->get_outport();
t_flit->advance_stage(LT_, m_router->curCycle());
t_flit->set_time(m_router->curCycle());
// This will take care of waking up the Network Link
m_output_unit[outport]->insert_flit(t_flit);
m_switch_buffer[inport]->getTopFlit();
m_crossbar_activity++;
}
}
check_for_wakeup();
}
void
Switch_d::check_for_wakeup()
{
Cycles nextCycle = m_router->curCycle() + Cycles(1);
for (int inport = 0; inport < m_num_inports; inport++) {
if (m_switch_buffer[inport]->isReady(nextCycle)) {
m_router->vcarb_req();
break;
}
}
}
uint32_t
Switch_d::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
for (uint32_t i = 0; i < m_switch_buffer.size(); ++i) {
num_functional_writes += m_switch_buffer[i]->functionalWrite(pkt);
}
return num_functional_writes;
}

View file

@ -1,70 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SWITCH_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SWITCH_D_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class Router_d;
class OutputUnit_d;
class Switch_d : public Consumer
{
public:
Switch_d(Router_d *router);
~Switch_d();
void wakeup();
void init();
void check_for_wakeup();
void print(std::ostream& out) const {};
inline void update_sw_winner(int inport, flit_d *t_flit)
{ m_switch_buffer[inport]->insert(t_flit); }
inline double get_crossbar_count() { return m_crossbar_activity; }
uint32_t functionalWrite(Packet *pkt);
private:
int m_num_vcs;
int m_num_inports;
double m_crossbar_activity;
Router_d *m_router;
std::vector<flitBuffer_d *> m_switch_buffer;
std::vector<OutputUnit_d *> m_output_unit;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_SWITCH_D_HH__

View file

@ -1,265 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/InputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/OutputUnit_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh"
#include "mem/ruby/network/garnet/fixed-pipeline/VCallocator_d.hh"
VCallocator_d::VCallocator_d(Router_d *router)
: Consumer(router)
{
m_router = router;
m_num_vcs = m_router->get_num_vcs();
m_vc_per_vnet = m_router->get_vc_per_vnet();
m_local_arbiter_activity.resize(m_num_vcs/m_vc_per_vnet);
m_global_arbiter_activity.resize(m_num_vcs/m_vc_per_vnet);
for (int i = 0; i < m_local_arbiter_activity.size(); i++) {
m_local_arbiter_activity[i] = 0;
m_global_arbiter_activity[i] = 0;
}
}
void
VCallocator_d::init()
{
m_input_unit = m_router->get_inputUnit_ref();
m_output_unit = m_router->get_outputUnit_ref();
m_num_inports = m_router->get_num_inports();
m_num_outports = m_router->get_num_outports();
m_round_robin_invc.resize(m_num_inports);
m_round_robin_outvc.resize(m_num_outports);
m_outvc_req.resize(m_num_outports);
m_outvc_is_req.resize(m_num_outports);
for (int i = 0; i < m_num_inports; i++) {
m_round_robin_invc[i].resize(m_num_vcs);
for (int j = 0; j < m_num_vcs; j++) {
m_round_robin_invc[i][j] = 0;
}
}
for (int i = 0; i < m_num_outports; i++) {
m_round_robin_outvc[i].resize(m_num_vcs);
m_outvc_req[i].resize(m_num_vcs);
m_outvc_is_req[i].resize(m_num_vcs);
for (int j = 0; j < m_num_vcs; j++) {
m_round_robin_outvc[i][j].first = 0;
m_round_robin_outvc[i][j].second = 0;
m_outvc_is_req[i][j] = false;
m_outvc_req[i][j].resize(m_num_inports);
for (int k = 0; k < m_num_inports; k++) {
m_outvc_req[i][j][k].resize(m_num_vcs);
for (int l = 0; l < m_num_vcs; l++) {
m_outvc_req[i][j][k][l] = false;
}
}
}
}
}
void
VCallocator_d::clear_request_vector()
{
for (int i = 0; i < m_num_outports; i++) {
for (int j = 0; j < m_num_vcs; j++) {
if (!m_outvc_is_req[i][j])
continue;
m_outvc_is_req[i][j] = false;
for (int k = 0; k < m_num_inports; k++) {
for (int l = 0; l < m_num_vcs; l++) {
m_outvc_req[i][j][k][l] = false;
}
}
}
}
}
void
VCallocator_d::wakeup()
{
arbitrate_invcs(); // First stage of allocation
arbitrate_outvcs(); // Second stage of allocation
clear_request_vector();
check_for_wakeup();
m_router->call_sw_alloc();
}
bool
VCallocator_d::is_invc_candidate(int inport_iter, int invc_iter)
{
int outport = m_input_unit[inport_iter]->get_route(invc_iter);
int vnet = get_vnet(invc_iter);
Cycles t_enqueue_time =
m_input_unit[inport_iter]->get_enqueue_time(invc_iter);
int invc_base = vnet*m_vc_per_vnet;
if ((m_router->get_net_ptr())->isVNetOrdered(vnet)) {
for (int vc_offset = 0; vc_offset < m_vc_per_vnet; vc_offset++) {
int temp_vc = invc_base + vc_offset;
if (m_input_unit[inport_iter]->need_stage(temp_vc, VC_AB_, VA_,
m_router->curCycle()) &&
(m_input_unit[inport_iter]->get_route(temp_vc) == outport) &&
(m_input_unit[inport_iter]->get_enqueue_time(temp_vc) <
t_enqueue_time)) {
return false;
}
}
}
return true;
}
void
VCallocator_d::select_outvc(int inport_iter, int invc_iter)
{
int outport = m_input_unit[inport_iter]->get_route(invc_iter);
int vnet = get_vnet(invc_iter);
int outvc_base = vnet*m_vc_per_vnet;
int num_vcs_per_vnet = m_vc_per_vnet;
int outvc_offset = m_round_robin_invc[inport_iter][invc_iter];
m_round_robin_invc[inport_iter][invc_iter]++;
if (m_round_robin_invc[inport_iter][invc_iter] >= num_vcs_per_vnet)
m_round_robin_invc[inport_iter][invc_iter] = 0;
for (int outvc_offset_iter = 0; outvc_offset_iter < num_vcs_per_vnet;
outvc_offset_iter++) {
outvc_offset++;
if (outvc_offset >= num_vcs_per_vnet)
outvc_offset = 0;
int outvc = outvc_base + outvc_offset;
if (m_output_unit[outport]->is_vc_idle(outvc, m_router->curCycle())) {
m_local_arbiter_activity[vnet]++;
m_outvc_req[outport][outvc][inport_iter][invc_iter] = true;
if (!m_outvc_is_req[outport][outvc])
m_outvc_is_req[outport][outvc] = true;
return; // out vc acquired
}
}
}
void
VCallocator_d::arbitrate_invcs()
{
for (int inport_iter = 0; inport_iter < m_num_inports; inport_iter++) {
for (int invc_iter = 0; invc_iter < m_num_vcs; invc_iter++) {
if (m_input_unit[inport_iter]->need_stage(invc_iter, VC_AB_,
VA_, m_router->curCycle())) {
if (!is_invc_candidate(inport_iter, invc_iter))
continue;
select_outvc(inport_iter, invc_iter);
}
}
}
}
void
VCallocator_d::arbitrate_outvcs()
{
for (int outport_iter = 0; outport_iter < m_num_outports; outport_iter++) {
for (int outvc_iter = 0; outvc_iter < m_num_vcs; outvc_iter++) {
if (!m_outvc_is_req[outport_iter][outvc_iter]) {
// No requests for this outvc in this cycle
continue;
}
int inport = m_round_robin_outvc[outport_iter][outvc_iter].first;
int invc_offset =
m_round_robin_outvc[outport_iter][outvc_iter].second;
int vnet = get_vnet(outvc_iter);
int invc_base = vnet*m_vc_per_vnet;
int num_vcs_per_vnet = m_vc_per_vnet;
m_round_robin_outvc[outport_iter][outvc_iter].second++;
if (m_round_robin_outvc[outport_iter][outvc_iter].second >=
num_vcs_per_vnet) {
m_round_robin_outvc[outport_iter][outvc_iter].second = 0;
m_round_robin_outvc[outport_iter][outvc_iter].first++;
if (m_round_robin_outvc[outport_iter][outvc_iter].first >=
m_num_inports)
m_round_robin_outvc[outport_iter][outvc_iter].first = 0;
}
for (int in_iter = 0; in_iter < m_num_inports*num_vcs_per_vnet;
in_iter++) {
invc_offset++;
if (invc_offset >= num_vcs_per_vnet) {
invc_offset = 0;
inport++;
if (inport >= m_num_inports)
inport = 0;
}
int invc = invc_base + invc_offset;
if (m_outvc_req[outport_iter][outvc_iter][inport][invc]) {
m_global_arbiter_activity[vnet]++;
m_input_unit[inport]->grant_vc(invc, outvc_iter,
m_router->curCycle());
m_output_unit[outport_iter]->update_vc(
outvc_iter, inport, invc);
break;
}
}
}
}
}
int
VCallocator_d::get_vnet(int invc)
{
int vnet = invc/m_vc_per_vnet;
assert(vnet < m_router->get_num_vnets());
return vnet;
}
void
VCallocator_d::check_for_wakeup()
{
Cycles nextCycle = m_router->curCycle() + Cycles(1);
for (int i = 0; i < m_num_inports; i++) {
for (int j = 0; j < m_num_vcs; j++) {
if (m_input_unit[i]->need_stage(j, VC_AB_, VA_, nextCycle)) {
m_router->vcarb_req();
return;
}
}
}
}

View file

@ -1,94 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VC_ALLOCATOR_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VC_ALLOCATOR_D_HH__
#include <iostream>
#include <utility>
#include <vector>
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class Router_d;
class InputUnit_d;
class OutputUnit_d;
class VCallocator_d : public Consumer
{
public:
VCallocator_d(Router_d *router);
void init();
void wakeup();
void check_for_wakeup();
void clear_request_vector();
int get_vnet(int invc);
void print(std::ostream& out) const {}
void arbitrate_invcs();
void arbitrate_outvcs();
bool is_invc_candidate(int inport_iter, int invc_iter);
void select_outvc(int inport_iter, int invc_iter);
double get_local_arbit_count(unsigned int vnet) const
{ return m_local_arbiter_activity[vnet]; }
double get_global_arbit_count(unsigned int vnet) const
{ return m_global_arbiter_activity[vnet]; }
private:
int m_num_vcs, m_vc_per_vnet;
int m_num_inports;
int m_num_outports;
Router_d *m_router;
// First stage of arbitration
// where all vcs select an output vc to contend for
std::vector<std::vector<int> > m_round_robin_invc;
// Arbiter for every output vc
std::vector<std::vector<std::pair<int, int> > > m_round_robin_outvc;
// [outport][outvc][inport][invc]
// set true in the first phase of allocation
std::vector<std::vector<std::vector<std::vector<bool> > > > m_outvc_req;
std::vector<std::vector<bool> > m_outvc_is_req;
std::vector<InputUnit_d *> m_input_unit;
std::vector<OutputUnit_d *> m_output_unit;
// Statistical variables
std::vector<double> m_local_arbiter_activity;
std::vector<double> m_global_arbiter_activity;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VC_ALLOCATOR_D_HH__

View file

@ -1,80 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/fixed-pipeline/VirtualChannel_d.hh"
VirtualChannel_d::VirtualChannel_d(int id)
: m_enqueue_time(INFINITE_)
{
m_id = id;
m_input_buffer = new flitBuffer_d();
m_vc_state.first = IDLE_;
m_vc_state.second = Cycles(0);
}
VirtualChannel_d::~VirtualChannel_d()
{
delete m_input_buffer;
}
void
VirtualChannel_d::set_outport(int outport)
{
route = outport;
}
void
VirtualChannel_d::grant_vc(int out_vc, Cycles curTime)
{
m_output_vc = out_vc;
m_vc_state.first = ACTIVE_;
m_vc_state.second = curTime;
flit_d *t_flit = m_input_buffer->peekTopFlit();
t_flit->advance_stage(SA_, curTime);
}
bool
VirtualChannel_d::need_stage(VC_state_type state, flit_stage stage,
Cycles ct)
{
if ((m_vc_state.first == state) && (ct >= m_vc_state.second)) {
if (m_input_buffer->isReady(ct)) {
flit_d *t_flit = m_input_buffer->peekTopFlit();
return(t_flit->is_stage(stage, ct)) ;
}
}
return false;
}
uint32_t
VirtualChannel_d::functionalWrite(Packet *pkt)
{
return m_input_buffer->functionalWrite(pkt);
}

View file

@ -1,100 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VIRTUAL_CHANNEL_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VIRTUAL_CHANNEL_D_HH__
#include <utility>
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class VirtualChannel_d
{
public:
VirtualChannel_d(int id);
~VirtualChannel_d();
bool need_stage(VC_state_type state, flit_stage stage, Cycles curTime);
void set_outport(int outport);
void grant_vc(int out_vc, Cycles curTime);
inline Cycles get_enqueue_time() { return m_enqueue_time; }
inline void set_enqueue_time(Cycles time) { m_enqueue_time = time; }
inline VC_state_type get_state() { return m_vc_state.first; }
inline int get_outvc() { return m_output_vc; }
inline bool has_credits() { return (m_credit_count > 0); }
inline int get_route() { return route; }
inline void update_credit(int credit) { m_credit_count = credit; }
inline void increment_credit() { m_credit_count++; }
inline bool isReady(Cycles curTime)
{
return m_input_buffer->isReady(curTime);
}
inline void
insertFlit(flit_d *t_flit)
{
m_input_buffer->insert(t_flit);
}
inline void
set_state(VC_state_type m_state, Cycles curTime)
{
m_vc_state.first = m_state;
m_vc_state.second = curTime;
}
inline flit_d*
peekTopFlit()
{
return m_input_buffer->peekTopFlit();
}
inline flit_d*
getTopFlit()
{
return m_input_buffer->getTopFlit();
}
uint32_t functionalWrite(Packet *pkt);
private:
int m_id;
flitBuffer_d *m_input_buffer;
std::pair<VC_state_type, Cycles> m_vc_state; // I/R/V/A/C
int route;
Cycles m_enqueue_time;
int m_output_vc;
int m_credit_count;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_VIRTUAL_CHANNEL_D_HH__

View file

@ -1,90 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/fixed-pipeline/flitBuffer_d.hh"
flitBuffer_d::flitBuffer_d()
{
max_size = INFINITE_;
}
flitBuffer_d::flitBuffer_d(int maximum_size)
{
max_size = maximum_size;
}
bool
flitBuffer_d::isEmpty()
{
return (m_buffer.size() == 0);
}
bool
flitBuffer_d::isReady(Cycles curTime)
{
if (m_buffer.size() != 0 ) {
flit_d *t_flit = peekTopFlit();
if (t_flit->get_time() <= curTime)
return true;
}
return false;
}
void
flitBuffer_d::print(std::ostream& out) const
{
out << "[flitBuffer: " << m_buffer.size() << "] " << std::endl;
}
bool
flitBuffer_d::isFull()
{
return (m_buffer.size() >= max_size);
}
void
flitBuffer_d::setMaxSize(int maximum)
{
max_size = maximum;
}
uint32_t
flitBuffer_d::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
for (unsigned int i = 0; i < m_buffer.size(); ++i) {
if (m_buffer[i]->functionalWrite(pkt)) {
num_functional_writes++;
}
}
return num_functional_writes;
}

View file

@ -1,90 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_FLIT_BUFFER_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_FLIT_BUFFER_D_HH__
#include <algorithm>
#include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class flitBuffer_d
{
public:
flitBuffer_d();
flitBuffer_d(int maximum_size);
bool isReady(Cycles curTime);
bool isEmpty();
void print(std::ostream& out) const;
bool isFull();
void setMaxSize(int maximum);
flit_d *
getTopFlit()
{
flit_d *f = m_buffer.front();
std::pop_heap(m_buffer.begin(), m_buffer.end(), flit_d::greater);
m_buffer.pop_back();
return f;
}
flit_d *
peekTopFlit()
{
return m_buffer.front();
}
void
insert(flit_d *flt)
{
m_buffer.push_back(flt);
std::push_heap(m_buffer.begin(), m_buffer.end(), flit_d::greater);
}
uint32_t functionalWrite(Packet *pkt);
private:
std::vector<flit_d *> m_buffer;
int max_size;
};
inline std::ostream&
operator<<(std::ostream& out, const flitBuffer_d& obj)
{
obj.print(out);
out << std::flush;
return out;
}
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_FLIT_BUFFER_D_HH__

View file

@ -1,83 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/fixed-pipeline/flit_d.hh"
flit_d::flit_d(int id, int vc, int vnet, int size, MsgPtr msg_ptr,
Cycles curTime)
{
m_size = size;
m_msg_ptr = msg_ptr;
m_enqueue_time = curTime;
m_time = curTime;
m_id = id;
m_vnet = vnet;
m_vc = vc;
m_stage.first = I_;
m_stage.second = m_time;
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_;
}
flit_d::flit_d(int vc, bool is_free_signal, Cycles curTime)
{
m_id = 0;
m_vc = vc;
m_is_free_signal = is_free_signal;
m_time = curTime;
}
void
flit_d::print(std::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 << "]";
}
bool
flit_d::functionalWrite(Packet *pkt)
{
Message *msg = m_msg_ptr.get();
return msg->functionalWrite(pkt);
}

View file

@ -1,115 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_FLIT_D_HH__
#define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_FLIT_D_HH__
#include <cassert>
#include <iostream>
#include "base/types.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/slicc_interface/Message.hh"
class flit_d
{
public:
flit_d(int id, int vc, int vnet, int size, MsgPtr msg_ptr, Cycles curTime);
flit_d(int vc, bool is_free_signal, Cycles curTime);
void set_outport(int port) { m_outport = port; }
int get_outport() {return m_outport; }
void print(std::ostream& out) const;
bool is_free_signal() { return m_is_free_signal; }
int get_size() { return m_size; }
Cycles get_enqueue_time() { return m_enqueue_time; }
int get_id() { return m_id; }
Cycles get_time() { return m_time; }
void set_time(Cycles time) { m_time = time; }
int get_vnet() { return m_vnet; }
int get_vc() { return m_vc; }
void set_vc(int vc) { m_vc = vc; }
MsgPtr& get_msg_ptr() { return m_msg_ptr; }
flit_type get_type() { return m_type; }
bool
is_stage(flit_stage t_stage, Cycles curTime)
{
return (m_stage.first == t_stage &&
curTime >= m_stage.second);
}
void
advance_stage(flit_stage t_stage, Cycles newTime)
{
m_stage.first = t_stage;
m_stage.second = newTime;
}
std::pair<flit_stage, Cycles> get_stage() { return m_stage; }
void set_delay(Cycles delay) { src_delay = delay; }
Cycles get_delay() { return src_delay; }
static bool
greater(flit_d* n1, flit_d* 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());
}
}
bool functionalWrite(Packet *pkt);
private:
int m_id;
int m_vnet;
int m_vc;
int m_size;
bool m_is_free_signal;
Cycles m_enqueue_time, m_time;
flit_type m_type;
MsgPtr m_msg_ptr;
int m_outport;
Cycles src_delay;
std::pair<flit_stage, Cycles> m_stage;
};
inline std::ostream&
operator<<(std::ostream& out, const flit_d& obj)
{
obj.print(out);
out << std::flush;
return out;
}
#endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_FLIT_D_HH__

View file

@ -1,49 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_FLEXIBLE_CONSUMER_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_FLEXIBLE_CONSUMER_HH__
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class FlexibleConsumer : public Consumer
{
public:
FlexibleConsumer(ClockedObject *em) : Consumer(em) {}
virtual bool isBufferNotFull(int vc, int inport) { return true; }
virtual void grant_vc(int out_port, int vc, Cycles grant_time) {}
virtual void release_vc(int out_port, int vc, Cycles release_time) {}
virtual void request_vc(int vc, int in_port, NetDest destination,
Cycles request_time) {}
};
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_FLEXIBLE_CONSUMER_HH__

View file

@ -1,78 +0,0 @@
/*
* Copyright (c) 2011 Advanced Micro Devices, Inc.
* 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.
*/
#include "mem/ruby/network/garnet/flexible-pipeline/GarnetLink.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
GarnetIntLink::GarnetIntLink(const Params *p)
: BasicLink(p)
{
m_network_links[0] = p->network_links[0];
m_network_links[1] = p->network_links[1];
}
void
GarnetIntLink::init()
{
}
void
GarnetIntLink::print(std::ostream& out) const
{
out << name();
}
GarnetIntLink *
GarnetIntLinkParams::create()
{
return new GarnetIntLink(this);
}
GarnetExtLink::GarnetExtLink(const Params *p)
: BasicLink(p)
{
m_network_links[0] = p->network_links[0];
m_network_links[1] = p->network_links[1];
}
void
GarnetExtLink::init()
{
}
void
GarnetExtLink::print(std::ostream& out) const
{
out << name();
}
GarnetExtLink *
GarnetExtLinkParams::create()
{
return new GarnetExtLink(this);
}

View file

@ -1,89 +0,0 @@
/*
* Copyright (c) 2011 Advanced Micro Devices, Inc.
* 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.
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_LINK_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_LINK_HH__
#include <iostream>
#include <string>
#include <vector>
#include "mem/ruby/network/BasicLink.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
#include "params/GarnetIntLink.hh"
#include "params/GarnetExtLink.hh"
class GarnetIntLink : public BasicLink
{
public:
typedef GarnetIntLinkParams Params;
GarnetIntLink(const Params *p);
void init();
void print(std::ostream& out) const;
friend class GarnetNetwork;
protected:
NetworkLink* m_network_links[2];
};
inline std::ostream&
operator<<(std::ostream& out, const GarnetIntLink& obj)
{
obj.print(out);
out << std::flush;
return out;
}
class GarnetExtLink : public BasicLink
{
public:
typedef GarnetExtLinkParams Params;
GarnetExtLink(const Params *p);
void init();
void print(std::ostream& out) const;
friend class GarnetNetwork;
protected:
NetworkLink* m_network_links[2];
};
inline std::ostream&
operator<<(std::ostream& out, const GarnetExtLink& obj)
{
obj.print(out);
out << std::flush;
return out;
}
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_LINK_HH__

View file

@ -1,72 +0,0 @@
# Copyright (c) 2008 Princeton University
# Copyright (c) 2009 Advanced Micro Devices, Inc.
# 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.
#
# Authors: Steve Reinhardt
# Brad Beckmann
from m5.params import *
from m5.proxy import *
from ClockedObject import ClockedObject
from BasicLink import BasicIntLink, BasicExtLink
class NetworkLink(ClockedObject):
type = 'NetworkLink'
cxx_header = "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
link_id = Param.Int(Parent.link_id, "link id")
link_latency = Param.Cycles(Parent.latency, "link latency")
vcs_per_vnet = Param.Int(Parent.vcs_per_vnet,
"virtual channels per virtual network")
virt_nets = Param.Int(Parent.number_of_virtual_networks,
"number of virtual networks")
channel_width = Param.Int(Parent.bandwidth_factor,
"channel width == bw factor")
# Interior fixed pipeline links between routers
class GarnetIntLink(BasicIntLink):
type = 'GarnetIntLink'
cxx_header = "mem/ruby/network/garnet/flexible-pipeline/GarnetLink.hh"
# The flexible pipeline bi-directional link only include two main
# forward links and no backward flow-control links
nls = []
# In uni-directional link
nls.append(NetworkLink());
# Out uni-directional link
nls.append(NetworkLink());
network_links = VectorParam.NetworkLink(nls, "forward links")
# Exterior fixed pipeline links between a router and a controller
class GarnetExtLink(BasicExtLink):
type = 'GarnetExtLink'
cxx_header = "mem/ruby/network/garnet/flexible-pipeline/GarnetLink.hh"
# The flexible pipeline bi-directional link only include two main
# forward links and no backward flow-control links
nls = []
# In uni-directional link
nls.append(NetworkLink());
# Out uni-directional link
nls.append(NetworkLink());
network_links = VectorParam.NetworkLink(nls, "forward links")

View file

@ -1,240 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include <cassert>
#include "base/cast.hh"
#include "base/stl_helpers.hh"
#include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/network/BasicLink.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/GarnetLink.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/Router.hh"
#include "mem/ruby/system/RubySystem.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
GarnetNetwork::GarnetNetwork(const Params *p)
: BaseGarnetNetwork(p)
{
m_buffer_size = p->buffer_size;
m_number_of_pipe_stages = p->number_of_pipe_stages;
// record the routers
for (vector<BasicRouter*>::const_iterator i = p->routers.begin();
i != p->routers.end(); ++i) {
Router* router = safe_cast<Router*>(*i);
m_routers.push_back(router);
}
for (int i=0; i < m_nodes; i++) {
NetworkInterface *ni = safe_cast<NetworkInterface *>(p->netifs[i]);
m_nis.push_back(ni);
}
}
void
GarnetNetwork::init()
{
BaseGarnetNetwork::init();
// Setup the network switches
assert (m_topology_ptr!=NULL);
// initialize the router's network pointers
for (vector<Router*>::const_iterator i = m_routers.begin();
i != m_routers.end(); ++i) {
Router* router = safe_cast<Router*>(*i);
router->init_net_ptr(this);
}
for (int i=0; i < m_nodes; i++) {
m_nis[i]->init_net_ptr(this);
m_nis[i]->addNode(m_toNetQueues[i], m_fromNetQueues[i]);
}
m_topology_ptr->createLinks(this);
}
GarnetNetwork::~GarnetNetwork()
{
deletePointers(m_routers);
deletePointers(m_nis);
deletePointers(m_links);
}
void
GarnetNetwork::makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
const NetDest& routing_table_entry)
{
assert(src < m_nodes);
GarnetExtLink* garnet_link = safe_cast<GarnetExtLink*>(link);
NetworkLink *net_link = garnet_link->m_network_links[0];
net_link->init_net_ptr(this);
m_links.push_back(net_link);
m_routers[dest]->addInPort(net_link);
m_nis[src]->addOutPort(net_link);
}
void
GarnetNetwork::makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
const NetDest& routing_table_entry)
{
assert(dest < m_nodes);
assert(src < m_routers.size());
assert(m_routers[src] != NULL);
GarnetExtLink* garnet_link = safe_cast<GarnetExtLink*>(link);
NetworkLink *net_link = garnet_link->m_network_links[1];
net_link->init_net_ptr(this);
m_links.push_back(net_link);
m_routers[src]->addOutPort(net_link, routing_table_entry,
link->m_weight);
m_nis[dest]->addInPort(net_link);
}
void
GarnetNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
const NetDest& routing_table_entry,
PortDirection src_outport,
PortDirection dst_inport)
{
GarnetIntLink* garnet_link = safe_cast<GarnetIntLink*>(link);
NetworkLink *net_link = garnet_link->m_network_links[0];
net_link->init_net_ptr(this);
m_links.push_back(net_link);
m_routers[dest]->addInPort(net_link);
m_routers[src]->addOutPort(net_link, routing_table_entry,
link->m_weight);
}
/*
* Go through all the routers, network interfaces and the interconnecting
* links for reading/writing all the messages.
*/
bool
GarnetNetwork::functionalRead(Packet *pkt)
{
for (unsigned int i = 0; i < m_routers.size(); i++) {
if (m_routers[i]->functionalRead(pkt)) {
return true;
}
}
for (unsigned int i = 0; i < m_nis.size(); ++i) {
if (m_nis[i]->functionalRead(pkt)) {
return true;
}
}
for (unsigned int i = 0; i < m_links.size(); ++i) {
if (m_links[i]->functionalRead(pkt)) {
return true;
}
}
return false;
}
uint32_t
GarnetNetwork::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
for (unsigned int i = 0; i < m_routers.size(); i++) {
num_functional_writes += m_routers[i]->functionalWrite(pkt);
}
for (unsigned int i = 0; i < m_nis.size(); ++i) {
num_functional_writes += m_nis[i]->functionalWrite(pkt);
}
for (unsigned int i = 0; i < m_links.size(); ++i) {
num_functional_writes += m_links[i]->functionalWrite(pkt);
}
return num_functional_writes;
}
void
GarnetNetwork::regStats()
{
BaseGarnetNetwork::regStats();
m_average_link_utilization.name(name() + ".avg_link_utilization");
m_average_vc_load
.init(m_virtual_networks * m_vcs_per_vnet)
.name(name() + ".avg_vc_load")
.flags(Stats::pdf | Stats::total | Stats::nozero)
;
for (int i = 0; i < m_virtual_networks * m_vcs_per_vnet; i++) {
m_average_vc_load
.subname(i, csprintf(".%i", i))
.flags(Stats::nozero)
;
}
}
void
GarnetNetwork::collateStats()
{
RubySystem *rs = params()->ruby_system;
double time_delta = double(curCycle() - rs->getStartCycle());
for (int i = 0; i < m_links.size(); i++) {
m_average_link_utilization +=
(double(m_links[i]->getLinkUtilization())) / time_delta;
vector<unsigned int> vc_load = m_links[i]->getVcLoad();
for (int j = 0; j < vc_load.size(); j++) {
m_average_vc_load[j] += vc_load[j];
}
}
}
void
GarnetNetwork::print(ostream& out) const
{
out << "[GarnetNetwork]";
}
GarnetNetwork *
GarnetNetworkParams::create()
{
return new GarnetNetwork(this);
}

View file

@ -1,104 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_GARNET_NETWORK_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_GARNET_NETWORK_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "params/GarnetNetwork.hh"
class NetworkInterface;
class Router;
class NetDest;
class NetworkLink;
class GarnetNetwork : public BaseGarnetNetwork
{
public:
typedef GarnetNetworkParams Params;
GarnetNetwork(const Params *p);
~GarnetNetwork();
void init();
int getBufferSize() { return m_buffer_size; }
int getNumPipeStages() {return m_number_of_pipe_stages; }
void collateStats();
void regStats();
void print(std::ostream& out) const;
// Methods used by Topology to setup the network
void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
const NetDest& routing_table_entry);
void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
const NetDest& routing_table_entry);
void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
const NetDest& routing_table_entry,
PortDirection src_outport,
PortDirection dst_inport);
//! Function for performing a functional read. The return value
//! indicates if a message was found that had the required address.
bool functionalRead(Packet *pkt);
//! Function for performing a functional write. The return value
//! indicates the number of messages that were written.
uint32_t functionalWrite(Packet *pkt);
private:
GarnetNetwork(const GarnetNetwork& obj);
GarnetNetwork& operator=(const GarnetNetwork& obj);
std::vector<Router *> m_routers; // All Routers in Network
std::vector<NetworkLink *> m_links; // All links in network
std::vector<NetworkInterface *> m_nis; // All NI's in Network
int m_buffer_size;
int m_number_of_pipe_stages;
// Statistical variables
Stats::Scalar m_average_link_utilization;
Stats::Vector m_average_vc_load;
};
inline std::ostream&
operator<<(std::ostream& out, const GarnetNetwork& obj)
{
obj.print(out);
out << std::flush;
return out;
}
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_GARNET_NETWORK_HH__

View file

@ -1,62 +0,0 @@
# Copyright (c) 2008 Princeton University
# Copyright (c) 2009 Advanced Micro Devices, Inc.
# 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.
#
# Authors: Steve Reinhardt
# Brad Beckmann
from m5.params import *
from m5.proxy import *
from BaseGarnetNetwork import BaseGarnetNetwork
from BasicRouter import BasicRouter
from ClockedObject import ClockedObject
class GarnetRouter(BasicRouter):
type = 'GarnetRouter'
cxx_class = 'Router'
cxx_header = "mem/ruby/network/garnet/flexible-pipeline/Router.hh"
vcs_per_vnet = Param.Int(Parent.vcs_per_vnet,
"virtual channels per virtual network")
virt_nets = Param.Int(Parent.number_of_virtual_networks,
"number of virtual networks")
class GarnetNetworkInterface(ClockedObject):
type = 'GarnetNetworkInterface'
cxx_class = 'NetworkInterface'
cxx_header = "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh"
id = Param.UInt32("ID in relation to other network interfaces")
vcs_per_vnet = Param.UInt32(Parent.vcs_per_vnet,
"virtual channels per virtual network")
virt_nets = Param.UInt32(Parent.number_of_virtual_networks,
"number of virtual networks")
class GarnetNetwork(BaseGarnetNetwork):
type = 'GarnetNetwork'
cxx_header = "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
buffer_size = Param.UInt32(0,
"default buffer size; 0 indicates infinite buffering");
number_of_pipe_stages = Param.UInt32(4, "router pipeline stages");

View file

@ -1,76 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/flexible-pipeline/InVcState.hh"
InVcState::InVcState(int id)
{
m_id = id;
m_vc_state = IDLE_;
}
bool
InVcState::isInState(VC_state_type state, Cycles 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, Cycles time)
{
m_vc_state = state;
m_time = time;
}
void
InVcState::grant_vc(int out_vc, Cycles 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;
}

View file

@ -1,57 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_IN_VC_STATE_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_IN_VC_STATE_HH__
#include "base/types.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class InVcState
{
public:
InVcState(int id);
void setRoute(int route);
void setState(VC_state_type state, Cycles time);
int get_outport();
int get_outvc();
void grant_vc(int out_vc, Cycles grant_time);
bool isInState(VC_state_type state, Cycles time);
private:
int m_id;
int m_route;
int m_output_vc;
VC_state_type m_vc_state;
Cycles m_time;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_IN_VC_STATE_HH__

View file

@ -1,384 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include <cassert>
#include <cmath>
#include "base/cast.hh"
#include "base/stl_helpers.hh"
#include "debug/RubyNetwork.hh"
#include "mem/ruby/network/MessageBuffer.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh"
#include "mem/ruby/slicc_interface/Message.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
NetworkInterface::NetworkInterface(const Params *p)
: ClockedObject(p), FlexibleConsumer(this)
{
m_id = p->id;
m_virtual_networks = p->virt_nets;
m_vc_per_vnet = p->vcs_per_vnet;
m_num_vcs = m_vc_per_vnet*m_virtual_networks;
m_vc_round_robin = 0;
// instantiating the NI flit buffers
m_ni_buffers.resize(m_num_vcs);
for (int i =0; i < m_num_vcs; i++)
m_ni_buffers[i] = new flitBuffer();
m_vc_allocator.resize(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.push_back(new OutVcState(i));
}
}
NetworkInterface::~NetworkInterface()
{
deletePointers(m_out_vc_state);
deletePointers(m_ni_buffers);
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)
{
inNode_ptr = in;
outNode_ptr = out;
for (auto& it: in) {
if (it != nullptr) {
it->setConsumer(this);
}
}
}
void
NetworkInterface::request_vc(int in_vc, int in_port, NetDest destination,
Cycles request_time)
{
inNetLink->grant_vc_link(in_vc, request_time);
}
bool
NetworkInterface::flitisizeMessage(MsgPtr msg_ptr, int vnet)
{
Message *net_msg_ptr = msg_ptr.get();
NetDest net_msg_dest = net_msg_ptr->getDestination();
// get all the destinations associated with this message.
vector<NodeID> dest_nodes = net_msg_dest.getAllDest();
// Number of flits is dependent on the link bandwidth available.
// This is expressed in terms of bytes/cycle or the flit size
int num_flits = (int) ceil((double) m_net_ptr->MessageSizeType_to_int(
net_msg_ptr->getMessageSize())/m_net_ptr->getNiFlitSize());
// loop to convert all multicast messages into unicast messages
for (int ctr = 0; ctr < dest_nodes.size(); ctr++) {
int vc = calculateVC(vnet); // this will return a free output vc
if (vc == -1) {
// did not find a free output vc
return false ;
}
MsgPtr new_msg_ptr = msg_ptr->clone();
NodeID destID = dest_nodes[ctr];
Message *new_net_msg_ptr = new_msg_ptr.get();
if (dest_nodes.size() > 1) {
NetDest personal_dest;
for (int m = 0; m < (int) MachineType_NUM; m++) {
if ((destID >= MachineType_base_number((MachineType) m)) &&
destID < MachineType_base_number((MachineType) (m+1))) {
// calculating the NetDest associated with this destID
personal_dest.clear();
personal_dest.add((MachineID) {(MachineType) m, (destID -
MachineType_base_number((MachineType) m))});
new_net_msg_ptr->getDestination() = personal_dest;
break;
}
}
net_msg_dest.removeNetDest(personal_dest);
// removing the destination from the original message to reflect
// that a message with this particular destination has been
// flitisized and an output vc is acquired
net_msg_ptr->getDestination().removeNetDest(personal_dest);
}
for (int i = 0; i < num_flits; i++) {
m_net_ptr->increment_injected_flits(vnet);
flit *fl = new flit(i, vc, vnet, num_flits, new_msg_ptr,
curCycle());
fl->set_delay(curCycle() - ticksToCycles(msg_ptr->getTime()));
m_ni_buffers[vc]->insert(fl);
}
m_out_vc_state[vc]->setState(VC_AB_, curCycle());
// setting an output vc request for the next hop.
// This flit will be ready to traverse the link and into the next hop
// only when an output vc is acquired at the next hop
outNetLink->request_vc_link(
vc, new_net_msg_ptr->getDestination(), curCycle());
}
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, Cycles grant_time)
{
assert(m_out_vc_state[vc]->isInState(VC_AB_, grant_time));
m_out_vc_state[vc]->grant_vc(grant_time);
scheduleEvent(Cycles(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, Cycles release_time)
{
assert(m_out_vc_state[vc]->isInState(ACTIVE_, release_time));
m_out_vc_state[vc]->setState(IDLE_, release_time);
scheduleEvent(Cycles(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_, curCycle())) {
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
// can pick up a message/cycle for each virtual net
for (int vnet = 0; vnet < inNode_ptr.size(); ++vnet) {
MessageBuffer *b = inNode_ptr[vnet];
if (b == nullptr) {
continue;
}
while (b->isReady(clockEdge())) { // Is there a message waiting
msg_ptr = b->peekMsgPtr();
if (flitisizeMessage(msg_ptr, vnet)) {
b->dequeue(clockEdge());
} 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_) {
DPRINTF(RubyNetwork, "m_id: %d, Message delivered at time: %lld\n",
m_id, curCycle());
outNode_ptr[t_flit->get_vnet()]->enqueue(
t_flit->get_msg_ptr(), clockEdge(), cyclesToTicks(Cycles(1)));
// signal the upstream router that this vc can be freed now
inNetLink->release_vc_link(t_flit->get_vc(),
curCycle() + Cycles(1));
}
int vnet = t_flit->get_vnet();
m_net_ptr->increment_received_flits(vnet);
Cycles network_delay = curCycle() - t_flit->get_creation_time();
Cycles queueing_delay = t_flit->get_delay();
m_net_ptr->increment_network_latency(network_delay, vnet);
m_net_ptr->increment_queueing_latency(queueing_delay, vnet);
delete t_flit;
}
}
/* This function looks 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(curCycle())) {
if (m_out_vc_state[vc]->isInState(ACTIVE_, curCycle()) &&
outNetLink->isBufferNotFull_link(vc)) { // buffer backpressure
// Just removing the flit
flit *t_flit = m_ni_buffers[vc]->getTopFlit();
t_flit->set_time(curCycle() + Cycles(1));
outSrcQueue->insert(t_flit);
// schedule the out link
outNetLink->
scheduleEventAbsolute(clockEdge(Cycles(1)));
return;
}
}
}
}
void
NetworkInterface::checkReschedule()
{
for (const auto& it : inNode_ptr) {
if (it == nullptr) {
continue;
}
while (it->isReady(clockEdge())) { // Is there a message waiting
scheduleEvent(Cycles(1));
return;
}
}
for (int vc = 0; vc < m_num_vcs; vc++) {
if (m_ni_buffers[vc]->isReady(curCycle() + Cycles(1))) {
scheduleEvent(Cycles(1));
return;
}
}
}
bool
NetworkInterface::functionalRead(Packet *pkt)
{
// Go through the internal buffers
for (unsigned int i = 0; i < m_ni_buffers.size(); ++i) {
if (m_ni_buffers[i]->functionalRead(pkt)) {
return true;
}
}
// Go through the buffer between this network interface and the router
if (outSrcQueue->functionalRead(pkt)) {
return true;
}
return false;
}
uint32_t
NetworkInterface::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
for (unsigned int i = 0; i < m_ni_buffers.size(); ++i) {
num_functional_writes += m_ni_buffers[i]->functionalWrite(pkt);
}
num_functional_writes += outSrcQueue->functionalWrite(pkt);
return num_functional_writes;
}
void
NetworkInterface::print(std::ostream& out) const
{
out << "[Network Interface]";
}
NetworkInterface *
GarnetNetworkInterfaceParams::create()
{
return new NetworkInterface(this);
}

View file

@ -1,106 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_NETWORK_INTERFACE_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_NETWORK_INTERFACE_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/slicc_interface/Message.hh"
#include "params/GarnetNetworkInterface.hh"
class MessageBuffer;
class flitBuffer;
class NetworkInterface : public ClockedObject, public FlexibleConsumer
{
public:
typedef GarnetNetworkInterfaceParams Params;
NetworkInterface(const Params *p);
~NetworkInterface();
void addInPort(NetworkLink *in_link);
void addOutPort(NetworkLink *out_link);
void addNode(std::vector<MessageBuffer *> &inNode,
std::vector<MessageBuffer *> &outNode);
void wakeup();
void grant_vc(int out_port, int vc, Cycles grant_time);
void release_vc(int out_port, int vc, Cycles release_time);
bool isBufferNotFull(int vc, int inport) { return true; }
void request_vc(int in_vc, int in_port, NetDest destination,
Cycles request_time);
void print(std::ostream& out) const;
bool functionalRead(Packet *);
uint32_t functionalWrite(Packet *);
void init_net_ptr(GarnetNetwork* net_ptr) { m_net_ptr = net_ptr; }
private:
GarnetNetwork *m_net_ptr;
uint32_t m_virtual_networks, m_num_vcs, m_vc_per_vnet;
NodeID m_id;
std::vector<OutVcState *> m_out_vc_state;
std::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
// The flit buffers which will serve the Consumer
std::vector<flitBuffer *> m_ni_buffers;
// The Message buffers that takes messages from the protocol
std::vector<MessageBuffer *> inNode_ptr;
// The Message buffers that provides messages to the protocol
std::vector<MessageBuffer *> outNode_ptr;
bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
int calculateVC(int vnet);
void scheduleOutputLink();
void checkReschedule();
};
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_NETWORK_INTERFACE_HH__

View file

@ -1,151 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
NetworkLink::NetworkLink(const Params *p)
: ClockedObject(p), Consumer(this), m_id(p->link_id),
m_latency(p->link_latency), m_in_port(0), m_out_port(0),
linkBuffer(new flitBuffer()), link_consumer(nullptr),
link_source(nullptr), link_srcQueue(nullptr), m_link_utilized(0),
m_vc_load(p->virt_nets * p->vcs_per_vnet)
{
}
NetworkLink::~NetworkLink()
{
delete linkBuffer;
}
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, Cycles 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, Cycles grant_time)
{
link_source->grant_vc(m_out_port, vc, grant_time);
}
void
NetworkLink::release_vc_link(int vc, Cycles release_time)
{
link_source->release_vc(m_out_port, vc, release_time);
}
bool
NetworkLink::isReady()
{
return linkBuffer->isReady(curCycle());
}
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(curCycle()))
return;
flit *t_flit = link_srcQueue->getTopFlit();
t_flit->set_time(curCycle() + m_latency);
linkBuffer->insert(t_flit);
link_consumer->scheduleEventAbsolute(clockEdge(m_latency));
m_link_utilized++;
m_vc_load[t_flit->get_vc()]++;
}
flit*
NetworkLink::peekLink()
{
return linkBuffer->peekTopFlit();
}
flit*
NetworkLink::consumeLink()
{
return linkBuffer->getTopFlit();
}
bool
NetworkLink::functionalRead(Packet *pkt)
{
return linkBuffer->functionalRead(pkt);
}
uint32_t
NetworkLink::functionalWrite(Packet *pkt)
{
return linkBuffer->functionalWrite(pkt);
}
NetworkLink *
NetworkLinkParams::create()
{
return new NetworkLink(this);
}

View file

@ -1,96 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_NETWORK_LINK_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_NETWORK_LINK_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "params/NetworkLink.hh"
#include "sim/clocked_object.hh"
class GarnetNetwork;
class NetworkLink : public ClockedObject, public Consumer
{
public:
typedef NetworkLinkParams Params;
NetworkLink(const Params *p);
~NetworkLink();
void setLinkConsumer(FlexibleConsumer *consumer);
void setSourceQueue(flitBuffer *srcQueue);
flit *peekLink();
flit *consumeLink();
void print(std::ostream& out) const {}
bool is_vc_ready(flit *t_flit);
int get_id() const { return m_id; }
void setInPort(int port);
void setOutPort(int port);
void wakeup();
bool isReady();
void grant_vc_link(int vc, Cycles grant_time);
void release_vc_link(int vc, Cycles release_time);
void request_vc_link(int vc, NetDest destination, Cycles request_time);
bool isBufferNotFull_link(int vc);
void setSource(FlexibleConsumer *source);
void init_net_ptr(GarnetNetwork* net_ptr) { m_net_ptr = net_ptr; }
unsigned int getLinkUtilization() const { return m_link_utilized; }
const std::vector<unsigned int> & getVcLoad() const { return m_vc_load; }
bool functionalRead(Packet *);
uint32_t functionalWrite(Packet *);
private:
int m_id;
Cycles m_latency;
int m_in_port, m_out_port;
GarnetNetwork *m_net_ptr;
flitBuffer *linkBuffer;
FlexibleConsumer *link_consumer;
FlexibleConsumer *link_source;
flitBuffer *link_srcQueue;
// Statistical variables
unsigned int m_link_utilized;
std::vector<unsigned int> m_vc_load;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_NETWORK_LINK_HH__

View file

@ -1,58 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh"
OutVcState::OutVcState(int id)
: m_time(0)
{
m_id = id;
m_vc_state = IDLE_;
}
bool
OutVcState::isInState(VC_state_type state, Cycles request_time)
{
return ((m_vc_state == state) && (request_time >= m_time));
}
void
OutVcState::grant_vc(Cycles grant_time)
{
m_time = grant_time;
m_vc_state = ACTIVE_;
}
void
OutVcState::setState(VC_state_type state, Cycles time)
{
m_vc_state = state;
m_time = time;
}

View file

@ -1,52 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_OUT_VC_STATE_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_OUT_VC_STATE_HH__
#include "base/types.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class OutVcState
{
public:
OutVcState(int id);
bool isInState(VC_state_type state, Cycles request_time);
void setState(VC_state_type state, Cycles time);
void grant_vc(Cycles grant_time);
private:
int m_id ;
Cycles m_time;
VC_state_type m_vc_state;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_OUT_VC_STATE_HH__

View file

@ -1,448 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "base/cast.hh"
#include "base/stl_helpers.hh"
#include "debug/RubyNetwork.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/InVcState.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/Router.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh"
#include "mem/ruby/slicc_interface/Message.hh"
using namespace std;
using m5::stl_helpers::deletePointers;
Router::Router(const Params *p)
: BasicRouter(p), FlexibleConsumer(this)
{
m_virtual_networks = p->virt_nets;
m_vc_per_vnet = p->vcs_per_vnet;
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++) {
deletePointers(m_in_vc_state[i]);
}
for (int i = 0; i < m_out_link.size(); i++) {
deletePointers(m_out_vc_state[i]);
deletePointers(m_router_buffers[i]);
}
deletePointers(m_out_src_queue);
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.push_back(new InVcState(i));
in_vc_vector[i]->setState(IDLE_, curCycle());
}
m_in_vc_state.push_back(in_vc_vector);
m_in_link.push_back(in_link);
in_link->setLinkConsumer(this);
in_link->setInPort(port);
int start = 0;
m_round_robin_invc.push_back(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.push_back(start);
m_out_src_queue.push_back(new flitBuffer());
m_out_link.push_back(out_link);
m_routing_table.push_back(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++) {
int buffer_size = m_net_ptr->getBufferSize();
if (buffer_size > 0) // finite size
intermediateQueues.push_back(new flitBuffer(buffer_size));
else // infinite size
intermediateQueues.push_back(new flitBuffer());
}
m_router_buffers.push_back(intermediateQueues);
vector<OutVcState *> out_vc_vector;
for (int i = 0; i < m_num_vcs; i++) {
out_vc_vector.push_back(new OutVcState(i));
out_vc_vector[i]->setState(IDLE_, curCycle());
}
m_out_vc_state.push_back(out_vc_vector);
m_link_weights.push_back(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,
Cycles 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 >= curCycle());
if (request_time > curCycle())
m_vc_arbiter->scheduleEventAbsolute(clockPeriod() * 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] = get_next_round_robin_vc(invc);
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_, curCycle())) {
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_, curCycle())) {
in_vc_state->grant_vc(valid_vcs[valid_vc_iter],
curCycle());
m_in_link[inport]->grant_vc_link(invc, curCycle());
m_out_vc_state[outport][valid_vcs[valid_vc_iter]]
->setState(VC_AB_, curCycle());
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.push_back(base+offset);
}
break;
}
}
return vc_list;
}
void
Router::grant_vc(int out_port, int vc, Cycles 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);
scheduleEvent(Cycles(1));
}
void
Router::release_vc(int out_port, int vc, Cycles 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);
scheduleEvent(Cycles(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(m_net_ptr->getNumPipeStages() >= 1);
// Subtract 1 as 1 cycle will be consumed in scheduling the output link
m_flit->set_time(curCycle() + Cycles((m_net_ptr->getNumPipeStages() - 1)));
m_flit->set_vc(outvc);
m_router_buffers[outport][outvc]->insert(m_flit);
if (m_net_ptr->getNumPipeStages() > 1)
scheduleEvent(Cycles(m_net_ptr->getNumPipeStages() - 1));
if ((m_flit->get_type() == HEAD_) || (m_flit->get_type() == HEAD_TAIL_)) {
Message *nm = m_flit->get_msg_ptr().get();
NetDest destination = nm->getDestination();
if (m_net_ptr->getNumPipeStages() > 1) {
m_out_vc_state[outport][outvc]->setState(VC_AB_, curCycle() +
Cycles(1));
m_out_link[outport]->request_vc_link(outvc, destination,
curCycle() + Cycles(1));
} else {
m_out_vc_state[outport][outvc]->setState(VC_AB_, curCycle());
m_out_link[outport]->request_vc_link(outvc, destination,
curCycle());
}
}
if ((m_flit->get_type() == TAIL_) || (m_flit->get_type() == HEAD_TAIL_)) {
m_in_vc_state[inport][invc]->setState(IDLE_, curCycle() + Cycles(1));
m_in_link[inport]->release_vc_link(invc, curCycle() + Cycles(1));
}
}
void
Router::wakeup()
{
flit *t_flit;
// This is for round-robin scheduling of incoming ports
int incoming_port = m_round_robin_start;
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;
// checking the incoming link
if (m_in_link[incoming_port]->isReady()) {
DPRINTF(RubyNetwork, "m_id: %d, Time: %lld\n", m_id, curCycle());
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] = get_next_round_robin_vc(vc_tolookat);
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(curCycle())) {
// models buffer backpressure
if (m_out_vc_state[port][vc_tolookat]->isInState(ACTIVE_,
curCycle()) &&
m_out_link[port]->isBufferNotFull_link(vc_tolookat)) {
flit *t_flit =
m_router_buffers[port][vc_tolookat]->getTopFlit();
t_flit->set_time(curCycle() + Cycles(1));
m_out_src_queue[port]->insert(t_flit);
m_out_link[port]->
scheduleEventAbsolute(clockEdge(Cycles(1)));
break; // done for this port
}
}
}
}
}
int
Router::get_vnet(int vc) const
{
int vnet = vc/m_vc_per_vnet;
assert(vnet < m_virtual_networks);
return vnet;
}
int
Router::get_next_round_robin_vc(int vc) const
{
vc++;
if (vc == m_num_vcs)
vc = 0;
return vc;
}
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]->isReady(curCycle() + Cycles(1))) {
scheduleEvent(Cycles(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_, curCycle() +
Cycles(1))) {
m_vc_arbiter->scheduleEventAbsolute(clockEdge(Cycles(1)));
return;
}
}
}
}
bool
Router::functionalRead(Packet *pkt)
{
// Access the buffers in the router for performing a functional read
for (unsigned int i = 0; i < m_router_buffers.size(); i++) {
for (unsigned int j = 0; j < m_router_buffers[i].size(); ++j) {
if (m_router_buffers[i][j]->functionalRead(pkt)) {
return true;
}
}
}
// Access the link queues for performing a functional read
for (unsigned int i = 0; i < m_out_src_queue.size(); i++) {
if (m_out_src_queue[i]->functionalRead(pkt)) {
return true;
}
}
return false;
}
uint32_t
Router::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
// Access the buffers in the router for performing a functional write
for (unsigned int i = 0; i < m_router_buffers.size(); i++) {
for (unsigned int j = 0; j < m_router_buffers[i].size(); ++j) {
num_functional_writes +=
m_router_buffers[i][j]->functionalWrite(pkt);
}
}
// Access the link queues for performing a functional write
for (unsigned int i = 0; i < m_out_src_queue.size(); i++) {
num_functional_writes += m_out_src_queue[i]->functionalWrite(pkt);
}
return num_functional_writes;
}
void
Router::print(ostream& out) const
{
out << "[Router]";
}
Router *
GarnetRouterParams::create()
{
return new Router(this);
}

View file

@ -1,110 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_ROUTER_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_ROUTER_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/common/NetDest.hh"
#include "mem/ruby/network/BasicRouter.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/FlexibleConsumer.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/InVcState.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/OutVcState.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "params/GarnetRouter.hh"
class VCarbiter;
class Router : public BasicRouter, public FlexibleConsumer
{
public:
typedef GarnetRouterParams Params;
Router(const Params *p);
~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,
Cycles request_time);
bool isBufferNotFull(int vc, int inport);
void grant_vc(int out_port, int vc, Cycles grant_time);
void release_vc(int out_port, int vc, Cycles release_time);
void vc_arbitrate();
void print(std::ostream& out) const;
void init_net_ptr(GarnetNetwork* net_ptr)
{
m_net_ptr = net_ptr;
}
bool functionalRead(Packet *);
uint32_t functionalWrite(Packet *);
private:
int m_virtual_networks, m_num_vcs, m_vc_per_vnet;
GarnetNetwork *m_net_ptr;
std::vector<int> m_vc_round_robin; // For scheduling of out source queues
int m_round_robin_inport, m_round_robin_start; // for vc arbitration
std::vector<int> m_round_robin_invc; // For vc arbitration of each outport
// These are essentially output buffers
std::vector<std::vector<flitBuffer *> > m_router_buffers;
// These are source queues for the output link
std::vector<flitBuffer *> m_out_src_queue;
std::vector<NetworkLink *> m_in_link;
std::vector<NetworkLink *> m_out_link;
std::vector<std::vector<InVcState *> > m_in_vc_state;
std::vector<std::vector<OutVcState *> > m_out_vc_state;
std::vector<NetDest> m_routing_table;
std::vector<int> m_link_weights;
VCarbiter *m_vc_arbiter;
int getRoute(NetDest destination);
std::vector<int> get_valid_vcs(int invc);
void routeCompute(flit *m_flit, int inport);
void checkReschedule();
void check_arbiter_reschedule();
void scheduleOutputLinks();
int get_vnet(int vc) const;
int get_next_round_robin_vc(int vc) const;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_ROUTER_HH__

View file

@ -1,48 +0,0 @@
# -*- mode:python -*-
# Copyright (c) 2009 The Hewlett-Packard Development Company
# 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.
#
# Authors: Nathan Binkert
Import('*')
if env['PROTOCOL'] == 'None':
Return()
SimObject('GarnetLink.py')
SimObject('GarnetNetwork.py')
Source('GarnetLink.cc')
Source('GarnetNetwork.cc')
Source('InVcState.cc')
Source('NetworkInterface.cc')
Source('NetworkLink.cc')
Source('OutVcState.cc')
Source('Router.cc')
Source('VCarbiter.cc')
Source('flit.cc')
Source('flitBuffer.cc')

View file

@ -1,45 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/flexible-pipeline/Router.hh"
#include "mem/ruby/network/garnet/flexible-pipeline/VCarbiter.hh"
VCarbiter::VCarbiter(Router *router)
: Consumer(router)
{
m_router = router;
}
void
VCarbiter::wakeup()
{
m_router->vc_arbitrate();
}

View file

@ -1,54 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_VC_ARBITER_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_VC_ARBITER_HH__
#include <iostream>
#include "mem/ruby/common/Consumer.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class Router;
class VCarbiter : public Consumer
{
public:
VCarbiter(Router *router);
~VCarbiter() {}
void print(std::ostream& out) const {}
void wakeup();
private:
Router *m_router;
};
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_VC_ARBITER_HH__

View file

@ -1,75 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include "mem/ruby/network/garnet/flexible-pipeline/flit.hh"
flit::flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr, Cycles curTime)
: m_id(id), m_vnet(vnet), m_vc(vc), m_size(size), m_creation_time(curTime)
{
m_msg_ptr = msg_ptr;
m_time = curTime;
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_;
}
void
flit::print(std::ostream& out) const
{
out << "[flit:: ";
out << "Id=" << m_id << " ";
out << "Type=" << m_type << " ";
out << "Vnet=" << m_vnet << " ";
out << "VC=" << m_vc << " ";
out << "Creation Time=" << m_creation_time << " ";
out << "]";
}
bool
flit::functionalRead(Packet *pkt)
{
Message *msg = m_msg_ptr.get();
return msg->functionalRead(pkt);
}
bool
flit::functionalWrite(Packet *pkt)
{
Message *msg = m_msg_ptr.get();
return msg->functionalWrite(pkt);
}

View file

@ -1,93 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include <cassert>
#include <iostream>
#include "base/types.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
#include "mem/ruby/slicc_interface/Message.hh"
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_FLIT_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_FLIT_HH__
class flit
{
public:
flit(int id, int vc, int vnet, int size, MsgPtr msg_ptr, Cycles curTime);
int get_size() const { return m_size; }
int get_id() const { return m_id; }
Cycles get_time() const { return m_time; }
Cycles get_creation_time() const { return m_creation_time; }
void set_time(Cycles time) { m_time = time; }
int get_vnet() const { return m_vnet; }
int get_vc() const { return m_vc; }
void set_vc(int vc) { m_vc = vc; }
MsgPtr& get_msg_ptr() { return m_msg_ptr; }
flit_type get_type() const { return m_type; }
void set_delay(Cycles delay) { src_delay = delay; }
Cycles get_delay() const { return src_delay; }
void print(std::ostream& out) const;
static bool
greater(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());
}
bool functionalRead(Packet *pkt);
bool functionalWrite(Packet *pkt);
private:
const int m_id;
const int m_vnet;
int m_vc;
const int m_size;
const Cycles m_creation_time;
Cycles m_time;
flit_type m_type;
MsgPtr m_msg_ptr;
Cycles src_delay;
};
inline std::ostream&
operator<<(std::ostream& out, const flit& obj)
{
obj.print(out);
out << std::flush;
return out;
}
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_FLIT_HH__

View file

@ -1,127 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#include <algorithm>
#include "mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh"
using namespace std;
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(Cycles curTime)
{
if (m_buffer.size() != 0 ) {
flit *t_flit = m_buffer.front();
if (t_flit->get_time() <= curTime)
return true;
}
return false;
}
bool
flitBuffer::isFull()
{
return (m_buffer.size() >= max_size);
}
void
flitBuffer::setMaxSize(int maximum)
{
max_size = maximum;
}
flit*
flitBuffer:: getTopFlit()
{
flit *f = m_buffer.front();
pop_heap(m_buffer.begin(), m_buffer.end(), flit::greater);
m_buffer.pop_back();
return f;
}
flit*
flitBuffer::peekTopFlit()
{
return m_buffer.front();
}
void
flitBuffer::insert(flit *flt)
{
m_buffer.push_back(flt);
push_heap(m_buffer.begin(), m_buffer.end(), flit::greater);
}
void
flitBuffer::print(std::ostream& out) const
{
out << "[flitBuffer: ";
out << m_buffer.size() << "] " << std::endl;
}
bool
flitBuffer::functionalRead(Packet *pkt)
{
for (unsigned int i = 0; i < m_buffer.size(); ++i) {
if (m_buffer[i]->functionalRead(pkt)) {
return true;
}
}
return false;
}
uint32_t
flitBuffer::functionalWrite(Packet *pkt)
{
uint32_t num_functional_writes = 0;
for (unsigned int i = 0; i < m_buffer.size(); ++i) {
if (m_buffer[i]->functionalWrite(pkt)) {
num_functional_writes++;
}
}
return num_functional_writes;
}

View file

@ -1,71 +0,0 @@
/*
* Copyright (c) 2008 Princeton University
* 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.
*
* Authors: Niket Agarwal
*/
#ifndef __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_FLIT_BUFFER_HH__
#define __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_FLIT_BUFFER_HH__
#include <iostream>
#include <vector>
#include "mem/ruby/network/garnet/flexible-pipeline/flit.hh"
#include "mem/ruby/network/garnet/NetworkHeader.hh"
class flitBuffer
{
public:
flitBuffer();
flitBuffer(int maximum_size);
bool isReady(Cycles curTime);
bool isFull();
bool isEmpty();
void setMaxSize(int maximum);
flit *getTopFlit();
flit *peekTopFlit();
void insert(flit *flt);
void print(std::ostream& out) const;
bool functionalRead(Packet *);
uint32_t functionalWrite(Packet *);
private:
std::vector<flit *> m_buffer;
int max_size;
};
inline std::ostream&
operator<<(std::ostream& out, const flitBuffer& obj)
{
obj.print(out);
out << std::flush;
return out;
}
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_FLIT_BUFFER_HH__