ruby: support functional accesses in garnet flexible network
authorNilay Vaish <nilay@cs.wisc.edu>
Sat, 10 Nov 2012 23:18:01 +0000 (17:18 -0600)
committerNilay Vaish <nilay@cs.wisc.edu>
Sat, 10 Nov 2012 23:18:01 +0000 (17:18 -0600)
13 files changed:
src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.cc
src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh
src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.cc
src/mem/ruby/network/garnet/flexible-pipeline/NetworkInterface.hh
src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.cc
src/mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh
src/mem/ruby/network/garnet/flexible-pipeline/Router.cc
src/mem/ruby/network/garnet/flexible-pipeline/Router.hh
src/mem/ruby/network/garnet/flexible-pipeline/flit.cc
src/mem/ruby/network/garnet/flexible-pipeline/flit.hh
src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.cc
src/mem/ruby/network/garnet/flexible-pipeline/flitBuffer.hh
src/mem/ruby/network/simple/Switch.cc

index e8aca533a610caba553d99ca1d85eb202e554b5d..9916f4ba561d493761a271990a00e452dd12efa1 100644 (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
 {
index 27c381ba3506ee1acad16ee67f5fd7f8d49413bb..1db4c9874582b139814093b7ad9e3dfcb64fd2b5 100644 (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__
-
index 824acce80f33ab2b4832be35571124df585671fa..99cb44871b1381d66dc9a91d33e2fe4fe9ec3984 100644 (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
 {
index e7035f51abcccf87f448810234d6dcc73f21f56f..bcacb3f2e41e57cc6c5f9086d6d4be0b2ebf056c 100644 (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;
index 3908d34c311014801d636273d78ed76ab3fd70bf..86f44b91881032fed14d4bb5edb998da0eb280ba 100644 (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()
 {
index 5b0cd5aae937eef005a65f36718ee3a1ba7e4c1c..d28fd27fc1e106628ce0fbcad25eecaf7da1a259 100644 (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;
index 44dd6a50159a93a33c6c85d1b135897f8c165ef1..8e064a01fc8e195374909c0114852abc3dd3dfc0 100644 (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
 {
index 93578b597532faf7b9288101adbfccd390883044..988ec3a559f24299361d518fd9fcde548708a64d 100644 (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;
index 80b93172a141721068d01edcab3c1e9469fca428..161625978c0c292868e3df6c4f26dccf155b627b 100644 (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);
+}
index 83a6f82aa0a0107ad5a3db863fa067bd15318d01..66cd604abfc41113cf9d99dc69b712619fffe2a2 100644 (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;
index 7fed6076226c8f12562b4ea31d96d5615f96ce77..9446c812a111bbe3bb37e31207e602724056a31d 100644 (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;
+}
index e5628e93e6d2650db804a1b8013093ef97176351..3170c6c78398ab6f46da72afcf41deeafc34d771 100644 (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;
index a0a27f7581a8fa85a7bbc7988a560abc5e42a5ba..1bb944f915a1bb60175f3f54f93243eb611e8205 100644 (file)
@@ -217,6 +217,7 @@ Switch::print(std::ostream& out) const
     // FIXME printing
     out << "[Switch]";
 }
+
 bool
 Switch::functionalRead(Packet *pkt)
 {