Tuan Ta has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/16768

Change subject: ruby: support atomic memory requests in Sequencer
......................................................................

ruby: support atomic memory requests in Sequencer

This patch adds support to execute atomic memory (AMO) requests in Sequencer. AMO operations are applied to L1 cache blocks right after L1 receives data. Old
data are written back to the memory packet and returned to CPU.

Change-Id: Iec8a0e8d60f12fc2b4d33db910233f3f90adc3be
---
M src/mem/protocol/MI_example-cache.sm
M src/mem/ruby/system/Sequencer.cc
2 files changed, 31 insertions(+), 2 deletions(-)



diff --git a/src/mem/protocol/MI_example-cache.sm b/src/mem/protocol/MI_example-cache.sm
index b8036c1..34ea3f0 100644
--- a/src/mem/protocol/MI_example-cache.sm
+++ b/src/mem/protocol/MI_example-cache.sm
@@ -122,7 +122,10 @@
       return Event:Load;
     } else if (type == RubyRequestType:IFETCH) {
       return Event:Ifetch;
- } else if ((type == RubyRequestType:ST) || (type == RubyRequestType:ATOMIC)) {
+    } else if ((type == RubyRequestType:ST) ||
+               (type == RubyRequestType:ATOMIC) ||
+               (type == RubyRequestType:ATOMIC_NO_RETURN) ||
+               (type == RubyRequestType:ATOMIC_RETURN)) {
       return Event:Store;
     } else {
       error("Invalid RubyRequestType");
diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc
index 41ec6ea..a884981 100644
--- a/src/mem/ruby/system/Sequencer.cc
+++ b/src/mem/ruby/system/Sequencer.cc
@@ -197,7 +197,10 @@
         (request_type == RubyRequestType_Store_Conditional) ||
         (request_type == RubyRequestType_Locked_RMW_Read) ||
         (request_type == RubyRequestType_Locked_RMW_Write) ||
-        (request_type == RubyRequestType_FLUSH)) {
+        (request_type == RubyRequestType_FLUSH) ||
+        (request_type == RubyRequestType_ATOMIC) ||
+        (request_type == RubyRequestType_ATOMIC_RETURN) ||
+        (request_type == RubyRequestType_ATOMIC_NO_RETURN)) {

         // Check if there is any outstanding read request for the same
         // cache line.
@@ -376,6 +379,8 @@

     assert((request->m_type == RubyRequestType_ST) ||
            (request->m_type == RubyRequestType_ATOMIC) ||
+           (request->m_type == RubyRequestType_ATOMIC_RETURN) ||
+           (request->m_type == RubyRequestType_ATOMIC_NO_RETURN) ||
            (request->m_type == RubyRequestType_RMW_Read) ||
            (request->m_type == RubyRequestType_RMW_Write) ||
            (request->m_type == RubyRequestType_Load_Linked) ||
@@ -487,6 +492,25 @@
             data.setData(&overwrite_val[0],
                          getOffset(request_address), pkt->getSize());
             DPRINTF(RubySequencer, "swap data %s\n", data);
+        } else if (pkt->isAtomicOp()) {
+            std::vector<uint8_t> overwrite_val(pkt->getSize());
+
+            // copy cache data into overwrite_val
+            memcpy(&overwrite_val[0],
+ data.getData(getOffset(request_address), pkt->getSize()),
+                   pkt->getSize());
+
+            // execute AMO operation on overwrite_val
+            (*(pkt->getAtomicOp()))(&overwrite_val[0]);
+
+            // return cache data to the packet
+            pkt->setData(data.getData(getOffset(request_address),
+                         pkt->getSize()));
+
+            // update the cache data to overwrite_val
+            data.setData(&overwrite_val[0],
+                         getOffset(request_address), pkt->getSize());
+            DPRINTF(RubySequencer, "amo set data %s\n", data);
} else if (type != RubyRequestType_Store_Conditional || llscSuccess) {
             // Types of stores set the actual data here, apart from
             // failed Store Conditional requests
@@ -603,6 +627,8 @@
                     primary_type = secondary_type = RubyRequestType_LD;
                 }
             }
+        } else if (pkt->cmd == MemCmd::SwapReq && pkt->isAtomicOp()) {
+            primary_type = secondary_type = RubyRequestType_ATOMIC_RETURN;
         } else if (pkt->isFlush()) {
           primary_type = secondary_type = RubyRequestType_FLUSH;
         } else {

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/16768
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Iec8a0e8d60f12fc2b4d33db910233f3f90adc3be
Gerrit-Change-Number: 16768
Gerrit-PatchSet: 1
Gerrit-Owner: Tuan Ta <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to