changeset 0edf1445cf4d in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=0edf1445cf4d
description:
mem: Make the buses multi layered
This patch makes the buses multi layered, and effectively creates a
crossbar structure with distributed contention ports at the
destination ports. Before this patch, a bus could have a single
request, response and snoop response in flight at any time, and with
these changes there can be as many requests as connected slaves (bus
master ports), and as many responses as connected masters (bus slave
ports).
Together with address interleaving, this patch enables us to create
high-throughput memory interconnects, e.g. 50+ GByte/s.
diffstat:
src/mem/bus.cc | 81 ++++++++++++++++++++++-----------------------
src/mem/bus.hh | 35 +++++++-----------
src/mem/coherent_bus.cc | 74 ++++++++++++++++++++++++++++-------------
src/mem/coherent_bus.hh | 13 +++++--
src/mem/noncoherent_bus.cc | 46 ++++++++++++++++++-------
src/mem/noncoherent_bus.hh | 10 +++-
6 files changed, 151 insertions(+), 108 deletions(-)
diffs (truncated from 660 to 300 lines):
diff -r 19a76cedd4ea -r 0edf1445cf4d src/mem/bus.cc
--- a/src/mem/bus.cc Thu May 30 12:54:00 2013 -0400
+++ b/src/mem/bus.cc Thu May 30 12:54:01 2013 -0400
@@ -156,18 +156,17 @@
offset;
}
-template <typename PortClass>
-BaseBus::Layer<PortClass>::Layer(BaseBus& _bus, const std::string& _name,
- uint16_t num_dest_ports) :
- Drainable(),
- bus(_bus), _name(_name), state(IDLE), drainManager(NULL),
- retryingPort(NULL), waitingForPeer(num_dest_ports, NULL),
+template <typename SrcType, typename DstType>
+BaseBus::Layer<SrcType,DstType>::Layer(DstType& _port, BaseBus& _bus,
+ const std::string& _name) :
+ port(_port), bus(_bus), _name(_name), state(IDLE), drainManager(NULL),
+ retryingPort(NULL), waitingForPeer(NULL),
releaseEvent(this)
{
}
-template <typename PortClass>
-void BaseBus::Layer<PortClass>::occupyLayer(Tick until)
+template <typename SrcType, typename DstType>
+void BaseBus::Layer<SrcType,DstType>::occupyLayer(Tick until)
{
// ensure the state is busy at this point, as the bus should
// transition from idle as soon as it has decided to forward the
@@ -186,21 +185,21 @@
curTick(), until);
}
-template <typename PortClass>
+template <typename SrcType, typename DstType>
bool
-BaseBus::Layer<PortClass>::tryTiming(PortClass* port, PortID dest_port_id)
+BaseBus::Layer<SrcType,DstType>::tryTiming(SrcType* src_port)
{
- // first we see if the bus is busy, next we check if we are in a
+ // first we see if the layer is busy, next we check if we are in a
// retry with a port other than the current one, lastly we check
// if the destination port is already engaged in a transaction
// waiting for a retry from the peer
- if (state == BUSY || (state == RETRY && port != retryingPort) ||
- waitingForPeer[dest_port_id] != NULL) {
+ if (state == BUSY || (state == RETRY && src_port != retryingPort) ||
+ waitingForPeer != NULL) {
// put the port at the end of the retry list waiting for the
// layer to be freed up (and in the case of a busy peer, for
// that transaction to go through, and then the bus to free
// up)
- waitingForLayer.push_back(port);
+ waitingForLayer.push_back(src_port);
return false;
}
@@ -213,9 +212,9 @@
return true;
}
-template <typename PortClass>
+template <typename SrcType, typename DstType>
void
-BaseBus::Layer<PortClass>::succeededTiming(Tick busy_time)
+BaseBus::Layer<SrcType,DstType>::succeededTiming(Tick busy_time)
{
// we should have gone from idle or retry to busy in the tryTiming
// test
@@ -225,19 +224,19 @@
occupyLayer(busy_time);
}
-template <typename PortClass>
+template <typename SrcType, typename DstType>
void
-BaseBus::Layer<PortClass>::failedTiming(PortClass* src_port,
- PortID dest_port_id, Tick busy_time)
+BaseBus::Layer<SrcType,DstType>::failedTiming(SrcType* src_port,
+ Tick busy_time)
{
// ensure no one got in between and tried to send something to
// this port
- assert(waitingForPeer[dest_port_id] == NULL);
+ assert(waitingForPeer == NULL);
// if the source port is the current retrying one or not, we have
// failed in forwarding and should track that we are now waiting
// for the peer to send a retry
- waitingForPeer[dest_port_id] = src_port;
+ waitingForPeer = src_port;
// we should have gone from idle or retry to busy in the tryTiming
// test
@@ -247,9 +246,9 @@
occupyLayer(busy_time);
}
-template <typename PortClass>
+template <typename SrcType, typename DstType>
void
-BaseBus::Layer<PortClass>::releaseLayer()
+BaseBus::Layer<SrcType,DstType>::releaseLayer()
{
// releasing the bus means we should now be idle
assert(state == BUSY);
@@ -270,9 +269,9 @@
}
}
-template <typename PortClass>
+template <typename SrcType, typename DstType>
void
-BaseBus::Layer<PortClass>::retryWaiting()
+BaseBus::Layer<SrcType,DstType>::retryWaiting()
{
// this should never be called with no one waiting
assert(!waitingForLayer.empty());
@@ -306,23 +305,21 @@
}
}
-template <typename PortClass>
+template <typename SrcType, typename DstType>
void
-BaseBus::Layer<PortClass>::recvRetry(PortID port_id)
+BaseBus::Layer<SrcType,DstType>::recvRetry()
{
// we should never get a retry without having failed to forward
// something to this port
- assert(waitingForPeer[port_id] != NULL);
+ assert(waitingForPeer != NULL);
- // find the port where the failed packet originated and remove the
- // item from the waiting list
- PortClass* retry_port = waitingForPeer[port_id];
- waitingForPeer[port_id] = NULL;
+ // add the port where the failed packet originated to the front of
+ // the waiting ports for the layer, this allows us to call retry
+ // on the port immediately if the bus layer is idle
+ waitingForLayer.push_front(waitingForPeer);
- // add this port at the front of the waiting ports for the layer,
- // this allows us to call retry on the port immediately if the bus
- // layer is idle
- waitingForLayer.push_front(retry_port);
+ // we are no longer waiting for the peer
+ waitingForPeer = NULL;
// if the bus layer is idle, retry this port straight away, if we
// are busy, then simply let the port wait for its turn
@@ -606,9 +603,9 @@
}
}
-template <typename PortClass>
+template <typename SrcType, typename DstType>
unsigned int
-BaseBus::Layer<PortClass>::drain(DrainManager *dm)
+BaseBus::Layer<SrcType,DstType>::drain(DrainManager *dm)
{
//We should check that we're not "doing" anything, and that noone is
//waiting. We might be idle but have someone waiting if the device we
@@ -621,9 +618,9 @@
return 0;
}
-template <typename PortClass>
+template <typename SrcType, typename DstType>
void
-BaseBus::Layer<PortClass>::regStats()
+BaseBus::Layer<SrcType,DstType>::regStats()
{
using namespace Stats;
@@ -646,5 +643,5 @@
* file, but since there are only two given options (MasterPort and
* SlavePort) it seems a bit excessive at this point.
*/
-template class BaseBus::Layer<SlavePort>;
-template class BaseBus::Layer<MasterPort>;
+template class BaseBus::Layer<SlavePort,MasterPort>;
+template class BaseBus::Layer<MasterPort,SlavePort>;
diff -r 19a76cedd4ea -r 0edf1445cf4d src/mem/bus.hh
--- a/src/mem/bus.hh Thu May 30 12:54:00 2013 -0400
+++ b/src/mem/bus.hh Thu May 30 12:54:01 2013 -0400
@@ -93,7 +93,7 @@
* a request layer has a retry list containing slave ports,
* whereas a response layer holds master ports.
*/
- template <typename PortClass>
+ template <typename SrcType, typename DstType>
class Layer : public Drainable
{
@@ -103,11 +103,11 @@
* Create a bus layer and give it a name. The bus layer uses
* the bus an event manager.
*
+ * @param _port destination port the layer converges at
* @param _bus the bus this layer belongs to
* @param _name the layer's name
- * @param num_dest_ports number of destination ports
*/
- Layer(BaseBus& _bus, const std::string& _name, uint16_t
num_dest_ports);
+ Layer(DstType& _port, BaseBus& _bus, const std::string& _name);
/**
* Drain according to the normal semantics, so that the bus
@@ -133,11 +133,10 @@
* updated accordingly.
*
* @param port Source port presenting the packet
- * @param dest_port_id Destination port id
*
* @return True if the bus layer accepts the packet
*/
- bool tryTiming(PortClass* port, PortID dest_port_id);
+ bool tryTiming(SrcType* src_port);
/**
* Deal with a destination port accepting a packet by potentially
@@ -155,11 +154,9 @@
* accordingly.
*
* @param src_port Source port
- * @param dest_port_id Destination port id
* @param busy_time Time to spend as a result of a failed send
*/
- void failedTiming(PortClass* src_port, PortID dest_port_id,
- Tick busy_time);
+ void failedTiming(SrcType* src_port, Tick busy_time);
/** Occupy the bus layer until until */
void occupyLayer(Tick until);
@@ -174,10 +171,8 @@
* Handle a retry from a neighbouring module. This wraps
* retryWaiting by verifying that there are ports waiting
* before calling retryWaiting.
- *
- * @param port_id Id of the port that received the retry
*/
- void recvRetry(PortID port_id);
+ void recvRetry();
/**
* Register stats for the layer
@@ -186,6 +181,9 @@
private:
+ /** The destination port this layer converges at. */
+ DstType& port;
+
/** The bus this layer is a part of. */
BaseBus& bus;
@@ -220,7 +218,7 @@
* A deque of ports that retry should be called on because
* the original send was delayed due to a busy layer.
*/
- std::deque<PortClass*> waitingForLayer;
+ std::deque<SrcType*> waitingForLayer;
/**
* Port that we are currently in the process of telling to
@@ -228,18 +226,13 @@
* transaction. This is a valid port when in the retry state,
* and NULL when in busy or idle.
*/
- PortClass* retryingPort;
+ SrcType* retryingPort;
/**
- * A vector that tracks who is waiting for the retry when
- * receiving it from a peer. The vector indices are port ids
- * of the outgoing ports for the specific layer. The values
- * are the incoming ports that tried to forward something to
- * the outgoing port, but was told to wait and is now waiting
- * for a retry. If no port is waiting NULL is stored on the
- * location in question.
+ * Track who is waiting for the retry when receiving it from a
+ * peer. If no port is waiting NULL is stored.
*/
- std::vector<PortClass*> waitingForPeer;
+ SrcType* waitingForPeer;
/**
* Release the bus layer after being occupied and return to an
diff -r 19a76cedd4ea -r 0edf1445cf4d src/mem/coherent_bus.cc
--- a/src/mem/coherent_bus.cc Thu May 30 12:54:00 2013 -0400
+++ b/src/mem/coherent_bus.cc Thu May 30 12:54:01 2013 -0400
@@ -55,14 +55,7 @@
#include "sim/system.hh"
CoherentBus::CoherentBus(const CoherentBusParams *p)
- : BaseBus(p),
- reqLayer(*this, ".reqLayer", p->port_master_connection_count +
- p->port_default_connection_count),
- respLayer(*this, ".respLayer", p->port_slave_connection_count),
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev