ruby: support functional accesses in garnet flexible network

This commit is contained in:
Nilay Vaish 2012-11-10 17:18:01 -06:00
parent 1492ab066d
commit 90c45c29fe
13 changed files with 194 additions and 1 deletions

View file

@ -192,6 +192,54 @@ GarnetNetwork::checkNetworkAllocation(NodeID id, bool ordered,
m_in_use[network_num] = true;
}
/*
* 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_router_ptr_vector.size(); i++) {
if (m_router_ptr_vector[i]->functionalRead(pkt)) {
return true;
}
}
for (unsigned int i = 0; i < m_ni_ptr_vector.size(); ++i) {
if (m_ni_ptr_vector[i]->functionalRead(pkt)) {
return true;
}
}
for (unsigned int i = 0; i < m_link_ptr_vector.size(); ++i) {
if (m_link_ptr_vector[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_router_ptr_vector.size(); i++) {
num_functional_writes += m_router_ptr_vector[i]->functionalWrite(pkt);
}
for (unsigned int i = 0; i < m_ni_ptr_vector.size(); ++i) {
num_functional_writes += m_ni_ptr_vector[i]->functionalWrite(pkt);
}
for (unsigned int i = 0; i < m_link_ptr_vector.size(); ++i) {
num_functional_writes += m_link_ptr_vector[i]->functionalWrite(pkt);
}
return num_functional_writes;
}
void
GarnetNetwork::printLinkStats(ostream& out) const
{

View file

@ -81,6 +81,14 @@ class GarnetNetwork : public BaseGarnetNetwork
const NetDest& routing_table_entry,
bool isReconfiguration);
//! 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:
void checkNetworkAllocation(NodeID id, bool ordered, int network_num,
std::string vnet_type);
@ -105,4 +113,3 @@ operator<<(std::ostream& out, const GarnetNetwork& obj)
}
#endif // __MEM_RUBY_NETWORK_GARNET_FLEXIBLE_PIPELINE_GARNET_NETWORK_HH__

View file

@ -338,6 +338,36 @@ NetworkInterface::checkReschedule()
}
}
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
{

View file

@ -72,6 +72,9 @@ class NetworkInterface : public FlexibleConsumer
void print(std::ostream& out) const;
bool functionalRead(Packet *);
uint32_t functionalWrite(Packet *);
private:
GarnetNetwork *m_net_ptr;
int m_virtual_networks, m_num_vcs, m_vc_per_vnet;

View file

@ -157,6 +157,18 @@ 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()
{

View file

@ -77,6 +77,9 @@ class NetworkLink : public SimObject, public FlexibleConsumer
m_net_ptr = net_ptr;
}
bool functionalRead(Packet *);
uint32_t functionalWrite(Packet *);
protected:
int m_id, m_latency;
int m_in_port, m_out_port;

View file

@ -415,6 +415,48 @@ Router::check_arbiter_reschedule()
}
}
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
{

View file

@ -74,6 +74,9 @@ class Router : public BasicRouter, public FlexibleConsumer
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;

View file

@ -135,3 +135,17 @@ flit::print(std::ostream& out) const
out << "Enqueue Time=" << m_enqueue_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

@ -66,6 +66,9 @@ class flit
return (n1->get_time() > n2->get_time());
}
bool functionalRead(Packet *pkt);
bool functionalWrite(Packet *pkt);
private:
int m_id;
int m_vnet;

View file

@ -112,3 +112,27 @@ 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

@ -53,6 +53,9 @@ class flitBuffer
void insert(flit *flt);
void print(std::ostream& out) const;
bool functionalRead(Packet *);
uint32_t functionalWrite(Packet *);
private:
std::vector<flit *> m_buffer;
int size, max_size;

View file

@ -217,6 +217,7 @@ Switch::print(std::ostream& out) const
// FIXME printing
out << "[Switch]";
}
bool
Switch::functionalRead(Packet *pkt)
{