Daniel Carvalho has submitted this change and it was merged. ( https://gem5-review.googlesource.com/9661 )

Change subject: mem-cache: Use Packet functions to write data blocks
......................................................................

mem-cache: Use Packet functions to write data blocks

Instead of using raw memcpy, use the proper writer functions
from the Packet class in Cache.

Fixed typos in comments of these functions.

Change-Id: I156a00989c6cbaa73763349006a37a18243d6ed4
Reviewed-on: https://gem5-review.googlesource.com/9661
Reviewed-by: Jason Lowe-Power <[email protected]>
Reviewed-by: Nikos Nikoleris <[email protected]>
Maintainer: Nikos Nikoleris <[email protected]>
---
M src/mem/cache/cache.cc
M src/mem/packet.hh
2 files changed, 14 insertions(+), 11 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Nikos Nikoleris: Looks good to me, approved; Looks good to me, approved



diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc
index c03b5b2..28c4343 100644
--- a/src/mem/cache/cache.cc
+++ b/src/mem/cache/cache.cc
@@ -416,7 +416,7 @@
         }
         // nothing else to do; writeback doesn't expect response
         assert(!pkt->needsResponse());
-        std::memcpy(blk->data, pkt->getConstPtr<uint8_t>(), blkSize);
+        pkt->writeDataToBlock(blk->data, blkSize);
         DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print());
         incHitCount(pkt);
         // populate the time when the block will be ready to access.
@@ -477,7 +477,7 @@
         }
         // nothing else to do; writeback doesn't expect response
         assert(!pkt->needsResponse());
-        std::memcpy(blk->data, pkt->getConstPtr<uint8_t>(), blkSize);
+        pkt->writeDataToBlock(blk->data, blkSize);
         DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print());

         incHitCount(pkt);
@@ -1684,7 +1684,7 @@
     blk->status &= ~BlkDirty;

     pkt->allocate();
-    std::memcpy(pkt->getPtr<uint8_t>(), blk->data, blkSize);
+    pkt->setDataFromBlock(blk->data, blkSize);

     return pkt;
 }
@@ -1722,7 +1722,7 @@
     blk->status &= ~BlkDirty;

     pkt->allocate();
-    std::memcpy(pkt->getPtr<uint8_t>(), blk->data, blkSize);
+    pkt->setDataFromBlock(blk->data, blkSize);

     return pkt;
 }
@@ -1970,7 +1970,7 @@
         assert(pkt->hasData());
         assert(pkt->getSize() == blkSize);

-        std::memcpy(blk->data, pkt->getConstPtr<uint8_t>(), blkSize);
+        pkt->writeDataToBlock(blk->data, blkSize);
     }
     // We pay for fillLatency here.
     blk->whenReady = clockEdge() + fillLatency * clockPeriod() +
diff --git a/src/mem/packet.hh b/src/mem/packet.hh
index 66625b3..b5b882c 100644
--- a/src/mem/packet.hh
+++ b/src/mem/packet.hh
@@ -324,10 +324,10 @@

   private:
    /**
-    * A pointer to the data being transfered.  It can be differnt
-    * sizes at each level of the heirarchy so it belongs in the
+    * A pointer to the data being transferred. It can be different
+    * sizes at each level of the hierarchy so it belongs to the
     * packet, not request. This may or may not be populated when a
-    * responder recieves the packet. If not populated it memory should
+    * responder receives the packet. If not populated memory should
     * be allocated.
     */
     PacketDataPtr data;
@@ -1096,8 +1096,8 @@
     }

     /**
-     * Copy data from the packet to the provided block pointer, which
-     * is aligned to the given block size.
+     * Copy data from the packet to the memory at the provided pointer.
+     * @param p Pointer to which data will be copied.
      */
     void
     writeData(uint8_t *p) const
@@ -1106,7 +1106,10 @@
     }

     /**
-     * Copy data from the packet to the memory at the provided pointer.
+     * Copy data from the packet to the provided block pointer, which
+     * is aligned to the given block size.
+     * @param blk_data Pointer to block to which data will be copied.
+     * @param blkSize Block size in bytes.
      */
     void
     writeDataToBlock(uint8_t *blk_data, int blkSize) const

--
To view, visit https://gem5-review.googlesource.com/9661
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: I156a00989c6cbaa73763349006a37a18243d6ed4
Gerrit-Change-Number: 9661
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to