Daniel Carvalho has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/21146 )

Change subject: mem-cache: Use shouldAllocate() instead of CPack's decompress()
......................................................................

mem-cache: Use shouldAllocate() instead of CPack's decompress()

Split decompression functionality using the proper function to
determine if a dictionary entry should be allocated after
decompression or not.

Change-Id: I4995304f4c4508c03c9fc1685f04511622969556
Signed-off-by: Daniel R. Carvalho <oda...@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21146
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Nikos Nikoleris <nikos.nikole...@arm.com>
Reviewed-by: Bobby R. Bruce <bbr...@ucdavis.edu>
Maintainer: Nikos Nikoleris <nikos.nikole...@arm.com>
---
M src/mem/cache/compressors/cpack.cc
M src/mem/cache/compressors/cpack.hh
2 files changed, 23 insertions(+), 31 deletions(-)

Approvals:
  Nikos Nikoleris: Looks good to me, approved; Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/mem/cache/compressors/cpack.cc b/src/mem/cache/compressors/cpack.cc
index 1192963..625bedc 100644
--- a/src/mem/cache/compressors/cpack.cc
+++ b/src/mem/cache/compressors/cpack.cc
@@ -159,8 +159,6 @@
 uint32_t
 CPack::decompressWord(const Pattern* pattern)
 {
-    std::array<uint8_t, 4> data;
-
     // Search for matching entry
     std::vector<std::array<uint8_t, 4>>::iterator entry_it =
         dictionary.begin();
@@ -168,7 +166,8 @@

     // Decompress the match. If the decompressed value must be added to
     // the dictionary, do it
-    if (pattern->decompress(*entry_it, data)) {
+    const std::array<uint8_t, 4> data = pattern->decompress(*entry_it);
+    if (pattern->shouldAllocate()) {
         dictionary[numEntries++] = data;
     }

diff --git a/src/mem/cache/compressors/cpack.hh b/src/mem/cache/compressors/cpack.hh
index 664a376..1a271ee 100644
--- a/src/mem/cache/compressors/cpack.hh
+++ b/src/mem/cache/compressors/cpack.hh
@@ -357,11 +357,10 @@
      * its data.
      *
      * @param dict_bytes The bytes in the corresponding matching entry.
-     * @param data The decompressed pattern.
-     * @return Whether entry should be added to dictionary or not.
+     * @return The decompressed pattern.
      */
-    virtual bool decompress(const std::array<uint8_t, 4> dict_bytes,
-                            std::array<uint8_t, 4>& data) const = 0;
+    virtual std::array<uint8_t, 4> decompress(
+        const std::array<uint8_t, 4> dict_bytes) const = 0;
 };

 class CPack::PatternZZZZ : public Pattern
@@ -378,11 +377,10 @@
                (bytes[0] == 0);
     }

-    bool decompress(const std::array<uint8_t, 4> dict_bytes,
-                    std::array<uint8_t, 4>& data) const override
+    std::array<uint8_t, 4>
+    decompress(const std::array<uint8_t, 4> dict_bytes) const override
     {
-        data = {0, 0, 0, 0};
-        return false;
+        return {0, 0, 0, 0};
     }
 };

@@ -407,11 +405,10 @@
         return true;
     }

-    bool decompress(const std::array<uint8_t, 4> dict_bytes,
-                    std::array<uint8_t, 4>& data) const override
+    std::array<uint8_t, 4>
+    decompress(const std::array<uint8_t, 4> dict_bytes) const override
     {
-        data = bytes;
-        return true;
+        return bytes;
     }
 };

@@ -428,11 +425,10 @@
         return (bytes == dict_bytes) && (match_location >= 0);
     }

-    bool decompress(const std::array<uint8_t, 4> dict_bytes,
-                    std::array<uint8_t, 4>& data) const override
+    std::array<uint8_t, 4>
+    decompress(const std::array<uint8_t, 4> dict_bytes) const override
     {
-        data = dict_bytes;
-        return true;
+        return dict_bytes;
     }
 };

@@ -461,11 +457,10 @@

     }

-    bool decompress(const std::array<uint8_t, 4> dict_bytes,
-                    std::array<uint8_t, 4>& data) const override
+    std::array<uint8_t, 4>
+    decompress(const std::array<uint8_t, 4> dict_bytes) const override
     {
-        data = {byte0, byte1, dict_bytes[2], dict_bytes[3]};
-        return true;
+        return {byte0, byte1, dict_bytes[2], dict_bytes[3]};
     }
 };

@@ -489,11 +484,10 @@
                (bytes[0] != 0);
     }

-    bool decompress(const std::array<uint8_t, 4> dict_bytes,
-                    std::array<uint8_t, 4>& data) const override
+    std::array<uint8_t, 4>
+    decompress(const std::array<uint8_t, 4> dict_bytes) const override
     {
-        data = {byte, 0, 0, 0};
-        return false;
+        return {byte, 0, 0, 0};
     }
 };

@@ -519,11 +513,10 @@
                (match_location >= 0);
     }

-    bool decompress(const std::array<uint8_t, 4> dict_bytes,
-                    std::array<uint8_t, 4>& data) const override
+    std::array<uint8_t, 4>
+    decompress(const std::array<uint8_t, 4> dict_bytes) const override
     {
-        data = {byte, dict_bytes[1], dict_bytes[2], dict_bytes[3]};
-        return true;
+        return {byte, dict_bytes[1], dict_bytes[2], dict_bytes[3]};
     }
 };


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/21146
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: I4995304f4c4508c03c9fc1685f04511622969556
Gerrit-Change-Number: 21146
Gerrit-PatchSet: 4
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to