Discussion:
[gem5-dev] Change in gem5/gem5[master]: mem-cache: Add compression and decompression calls
(too old to reply)
Daniel Carvalho (Gerrit)
2018-06-19 16:11:16 UTC
Permalink
Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/11410


Change subject: mem-cache: Add compression and decompression calls
......................................................................

mem-cache: Add compression and decompression calls

Add a compressor to the base cache class and compress within
block allocation and decompress on writebacks.

Change-Id: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
---
M src/mem/cache/Cache.py
M src/mem/cache/base.cc
M src/mem/cache/base.hh
M src/mem/cache/superblock_blk.cc
M src/mem/cache/superblock_blk.hh
M src/mem/cache/tags/Tags.py
M src/mem/cache/tags/base.hh
M src/mem/cache/tags/compressed_tags.cc
8 files changed, 92 insertions(+), 8 deletions(-)



diff --git a/src/mem/cache/Cache.py b/src/mem/cache/Cache.py
index 47fe2b6..10e9125 100644
--- a/src/mem/cache/Cache.py
+++ b/src/mem/cache/Cache.py
@@ -41,6 +41,7 @@

from m5.params import *
from m5.proxy import *
+from Compressors import *
from MemObject import MemObject
from Prefetcher import BasePrefetcher
from ReplacementPolicies import *
@@ -85,6 +86,8 @@
replacement_policy = Param.BaseReplacementPolicy(LRURP(),
"Replacement policy")

+ compressor = Param.BaseCacheCompressor(NoCompressor(),
+ "Cache compressor.")
max_compression_ratio = Param.Int(1,
"Maximum number of compressed blocks per tag.")

diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index 32cffac..78c1fdc 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -57,6 +57,7 @@
#include "mem/cache/mshr.hh"
#include "mem/cache/prefetch/base.hh"
#include "mem/cache/queue_entry.hh"
+#include "mem/cache/superblock_blk.hh"
#include "params/BaseCache.hh"
#include "sim/core.hh"

@@ -81,6 +82,7 @@
mshrQueue("MSHRs", p->mshrs, 0, p->demand_mshr_reserve), // see below
writeBuffer("write buffer", p->write_buffers, p->mshrs), // see below
tags(p->tags),
+ compressor(p->compressor),
prefetcher(p->prefetcher),
prefetchOnAccess(p->prefetch_on_access),
writebackClean(p->writeback_clean),
@@ -917,6 +919,15 @@
// that can modify its value.
blk = tags->accessBlock(pkt->getAddr(), pkt->isSecure(), lat);

+ // The compressor is called to decompress data on accesses. Although
+ // the data is stored uncompressed, even if a compressor is used, the
+ // compression and decompression methods are called to calculate the
+ // amount of cycles used.
+ if (blk && blk->isCompressed()){
+ CompressionBlk* compression_blk =
static_cast<CompressionBlk*>(blk);
+ lat +=
compressor->decompress(compression_blk->getCompressionData());
+ }
+
DPRINTF(Cache, "%s for %s %s\n", __func__, pkt->print(),
blk ? "hit " + blk->print() : "miss");

@@ -1224,9 +1235,17 @@
// Get secure bit
const bool is_secure = pkt->isSecure();

+ // The compressor is called to compress data before insertion.
+ // Although in Gem5 the data is stored uncompressed, even if a
compressor
+ // is used, the compression/decompression methods are called to
+ // calculate the amount of cycles needed on insertions.
+ std::unique_ptr<CompressionData> compression_data =
+ compressor->compress(pkt->getConstPtr<uint64_t>());
+
// Find replacement victim
std::vector<CacheBlk*> evict_blks;
- CacheBlk *victim = tags->findVictim(addr, is_secure, nullptr,
evict_blks);
+ CacheBlk *victim = tags->findVictim(addr, is_secure,
+ compression_data.get(),
evict_blks);

// It is valid to return nullptr if there is no victim
if (!victim)
@@ -1275,7 +1294,6 @@
}

// Insert new block at victimized entry
- std::unique_ptr<CompressionData> compression_data;
tags->insertBlock(addr, is_secure, pkt->req->masterId(),
pkt->req->taskId(), compression_data, victim);

@@ -1329,6 +1347,14 @@
pkt->allocate();
pkt->setDataFromBlock(blk->data, blkSize);

+ // When a block is compressed, it must first be decompressed before
being
+ // accessed. This adds to the packet latency
+ if (blk->isCompressed()) {
+ CompressionBlk* compression_blk =
static_cast<CompressionBlk*>(blk);
+ pkt->headerDelay += compressor->decompress(
+ compression_blk->getCompressionData());
+ }
+
return pkt;
}

@@ -1368,6 +1394,14 @@
pkt->allocate();
pkt->setDataFromBlock(blk->data, blkSize);

+ // When a block is compressed, it must first be decompressed before
being
+ // accessed. This adds to the packet latency
+ if (blk->isCompressed()) {
+ CompressionBlk* compression_blk =
static_cast<CompressionBlk*>(blk);
+ pkt->headerDelay += compressor->decompress(
+ compression_blk->getCompressionData());
+ }
+
return pkt;
}

diff --git a/src/mem/cache/base.hh b/src/mem/cache/base.hh
index 4ba256b..3b432bc 100644
--- a/src/mem/cache/base.hh
+++ b/src/mem/cache/base.hh
@@ -78,6 +78,7 @@
#include "sim/sim_exit.hh"
#include "sim/system.hh"

+class BaseCacheCompressor;
class BaseMasterPort;
class BasePrefetcher;
class BaseSlavePort;
@@ -320,6 +321,9 @@
/** Tag and data Storage */
BaseTags *tags;

+ /** Compression method being used. */
+ BaseCacheCompressor* compressor;
+
/** Prefetcher */
BasePrefetcher *prefetcher;

diff --git a/src/mem/cache/superblock_blk.cc
b/src/mem/cache/superblock_blk.cc
index b7e8f48..8f8e916 100644
--- a/src/mem/cache/superblock_blk.cc
+++ b/src/mem/cache/superblock_blk.cc
@@ -42,7 +42,8 @@
#include "base/logging.hh"

CompressionBlk::CompressionBlk()
- : CacheBlk(), _superblock(nullptr), _superblockOffset(0)
+ : CacheBlk(), _superblock(nullptr), _superblockOffset(0),
+ _compressionData(nullptr)
{
}

@@ -78,9 +79,23 @@
}

void
+CompressionBlk::setCompressionData(
+ std::unique_ptr<CompressionData>& compression_data)
+{
+ _compressionData = std::move(compression_data);
+}
+
+const CompressionData*
+CompressionBlk::getCompressionData() const
+{
+ return _compressionData.get();
+}
+
+void
CompressionBlk::insert(const Addr tag, const bool is_secure,
const bool is_compressed,
- const int src_master_ID, const uint32_t task_ID)
+ const int src_master_ID, const uint32_t task_ID,
+ std::unique_ptr<CompressionData>& compression_data)
{
// Make sure it is not overwriting another superblock
panic_if((_superblock && _superblock->isValid()) &&
@@ -92,6 +107,9 @@

// Set superblock tag
_superblock->setTag(tag);
+
+ // Set compression data
+ setCompressionData(compression_data);
}

bool
diff --git a/src/mem/cache/superblock_blk.hh
b/src/mem/cache/superblock_blk.hh
index 64bc1cb..1931978 100644
--- a/src/mem/cache/superblock_blk.hh
+++ b/src/mem/cache/superblock_blk.hh
@@ -40,6 +40,7 @@
#include <vector>

#include "mem/cache/blk.hh"
+#include "mem/cache/compressors/base.hh"
#include "mem/cache/replacement_policies/base.hh"

class SuperblockBlk;
@@ -61,6 +62,19 @@
*/
int _superblockOffset;

+ /**
+ * Data contained by this block in a compressed format.
+ */
+ std::unique_ptr<CompressionData> _compressionData;
+
+ /**
+ * Set data as compressed by the chosen compression method.
+ *
+ * @param compression_data The compression data.
+ */
+ void setCompressionData(
+ std::unique_ptr<CompressionData>& compression_data);
+
public:
CompressionBlk();
CompressionBlk(const CompressionBlk&) = delete;
@@ -103,6 +117,13 @@
Addr getTag() const;

/**
+ * Get compression data.
+ *
+ * @return The compression data.
+ */
+ const CompressionData* getCompressionData() const;
+
+ /**
* Set member variables when a block insertion occurs. Resets reference
* count to 1 (the insertion counts as a reference), and touch block if
* it hadn't been touched previously. Sets the insertion tick to the
@@ -113,9 +134,11 @@
* @param is_compressed Whether the data has been compressed or not.
* @param src_master_ID The source requestor ID.
* @param task_ID The new task ID.
+ * @param compression_data The compression data.
*/
void insert(const Addr tag, const bool is_secure, const bool
is_compressed,
- const int src_master_ID, const uint32_t task_ID);
+ const int src_master_ID, const uint32_t task_ID,
+ std::unique_ptr<CompressionData>& compression_data);
};

/**
diff --git a/src/mem/cache/tags/Tags.py b/src/mem/cache/tags/Tags.py
index 46f4339..81d12bb 100644
--- a/src/mem/cache/tags/Tags.py
+++ b/src/mem/cache/tags/Tags.py
@@ -38,6 +38,7 @@
from m5.params import *
from m5.proxy import *
from ClockedObject import ClockedObject
+from Compressors import *

class BaseTags(ClockedObject):
type = 'BaseTags'
diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh
index 2a874ef..c4888bc 100644
--- a/src/mem/cache/tags/base.hh
+++ b/src/mem/cache/tags/base.hh
@@ -283,6 +283,7 @@
* @param is_secure True if the target memory space is secure.
* @param compression_data Compressed data of new block to allocate.
* @param evict_blks Cache blocks to be evicted.
+ * @param compression_data Compressed data of new block to co-allocate.
* @return Cache block to be replaced.
*/
virtual CacheBlk* findVictim(Addr addr, const bool is_secure,
diff --git a/src/mem/cache/tags/compressed_tags.cc
b/src/mem/cache/tags/compressed_tags.cc
index 71ecf79..b736d26 100644
--- a/src/mem/cache/tags/compressed_tags.cc
+++ b/src/mem/cache/tags/compressed_tags.cc
@@ -155,8 +155,8 @@
const Addr tag = extractTag(addr);

// The address can only be mapped to a specific location of a
superblock
- // due to superblocks being composed of contiguous-address entries
- // @todo this may not be true for other compressed cache organizations
+ // due to superblocks being composed of contiguous-address entries.
+ // This may not be true for other compressed cache organizations
const Addr offset = extractSuperblockOffset(addr);

// Find all possible superblock locations for the given address
@@ -302,7 +302,7 @@
// Set block's metadata. We always store compressed blocks when
possible
compression_blk->insert(extractTag(addr), is_secure,
false, /** @todo Determine compression status.
*/
- src_master_ID, task_ID);
+ src_master_ID, task_ID, compression_data);

// When a block is inserted, the tag is only a newly used tag if the
// superblock was not previously present in the cache.
--
To view, visit https://gem5-review.googlesource.com/11410
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: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
Gerrit-Change-Number: 11410
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <***@yahoo.com.br>
Gerrit-MessageType: newchange
Daniel Carvalho (Gerrit)
2018-06-22 13:53:37 UTC
Permalink
Hello Jason Lowe-Power, Nikos Nikoleris,

I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/11410

to look at the new patch set (#2).

Change subject: mem-cache: Add compression and decompression calls
......................................................................

mem-cache: Add compression and decompression calls

Add a compressor to the base cache class and compress within
block allocation and decompress on writebacks.

Change-Id: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
---
M src/mem/cache/Cache.py
M src/mem/cache/base.cc
M src/mem/cache/base.hh
M src/mem/cache/superblock_blk.cc
M src/mem/cache/superblock_blk.hh
M src/mem/cache/tags/compressed_tags.cc
M src/mem/cache/tags/compressed_tags.hh
7 files changed, 171 insertions(+), 4 deletions(-)
--
To view, visit https://gem5-review.googlesource.com/11410
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: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
Gerrit-Change-Number: 11410
Gerrit-PatchSet: 2
Gerrit-Owner: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Jason Lowe-Power <***@lowepower.com>
Gerrit-Reviewer: Nikos Nikoleris <***@arm.com>
Gerrit-MessageType: newpatchset
Daniel Carvalho (Gerrit)
2018-06-28 09:30:17 UTC
Permalink
Hello Jason Lowe-Power, Nikos Nikoleris,

I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/11410

to look at the new patch set (#3).

Change subject: mem-cache: Add compression and decompression calls
......................................................................

mem-cache: Add compression and decompression calls

Add a compressor to the base cache class and compress within
block allocation and decompress on writebacks. This change
does not implement data expansion (fat writes) yet.

Change-Id: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
---
M src/mem/cache/Cache.py
M src/mem/cache/base.cc
M src/mem/cache/base.hh
M src/mem/cache/superblock_blk.cc
M src/mem/cache/superblock_blk.hh
M src/mem/cache/tags/compressed_tags.cc
M src/mem/cache/tags/compressed_tags.hh
7 files changed, 186 insertions(+), 4 deletions(-)
--
To view, visit https://gem5-review.googlesource.com/11410
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: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
Gerrit-Change-Number: 11410
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Jason Lowe-Power <***@lowepower.com>
Gerrit-Reviewer: Nikos Nikoleris <***@arm.com>
Gerrit-MessageType: newpatchset
Daniel Carvalho (Gerrit)
2018-08-16 09:38:13 UTC
Permalink
Hello Jason Lowe-Power, Nikos Nikoleris,

I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/c/public/gem5/+/11410

to look at the new patch set (#4).

Change subject: mem-cache: Add compression and decompression calls
......................................................................

mem-cache: Add compression and decompression calls

Add a compressor to the base cache class and compress within
block allocation and decompress on writebacks. This change
does not implement data expansion (fat writes) yet.

Change-Id: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
---
M src/mem/cache/Cache.py
M src/mem/cache/base.cc
M src/mem/cache/base.hh
M src/mem/cache/tags/compressed_tags.cc
M src/mem/cache/tags/compressed_tags.hh
5 files changed, 123 insertions(+), 3 deletions(-)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/11410
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: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
Gerrit-Change-Number: 11410
Gerrit-PatchSet: 4
Gerrit-Owner: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Jason Lowe-Power <***@lowepower.com>
Gerrit-Reviewer: Nikos Nikoleris <***@arm.com>
Gerrit-MessageType: newpatchset
Daniel Carvalho (Gerrit)
2018-10-04 16:20:10 UTC
Permalink
Hello Jason Lowe-Power, Nikos Nikoleris,

I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/c/public/gem5/+/11410

to look at the new patch set (#5).

Change subject: mem-cache: Add compression and decompression calls
......................................................................

mem-cache: Add compression and decompression calls

Add a compressor to the base cache class and compress within
block allocation and decompress on writebacks. This change
does not implement data expansion (fat writes) yet.

Change-Id: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
---
M src/mem/cache/Cache.py
M src/mem/cache/base.cc
M src/mem/cache/base.hh
M src/mem/cache/tags/compressed_tags.cc
M src/mem/cache/tags/compressed_tags.hh
5 files changed, 109 insertions(+), 1 deletion(-)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/11410
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: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
Gerrit-Change-Number: 11410
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Jason Lowe-Power <***@lowepower.com>
Gerrit-Reviewer: Nikos Nikoleris <***@arm.com>
Gerrit-MessageType: newpatchset
Daniel Carvalho (Gerrit)
2018-10-12 09:36:05 UTC
Permalink
Hello Jason Lowe-Power, Nikos Nikoleris,

I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/c/public/gem5/+/11410

to look at the new patch set (#6).

Change subject: mem-cache: Add compression and decompression calls
......................................................................

mem-cache: Add compression and decompression calls

Add a compressor to the base cache class and compress within
block allocation and decompress on writebacks. This change
does not implement data expansion (fat writes) yet.

Change-Id: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
---
M src/mem/cache/Cache.py
M src/mem/cache/base.cc
M src/mem/cache/base.hh
M src/mem/cache/tags/compressed_tags.cc
M src/mem/cache/tags/compressed_tags.hh
5 files changed, 109 insertions(+), 1 deletion(-)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/11410
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: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
Gerrit-Change-Number: 11410
Gerrit-PatchSet: 6
Gerrit-Owner: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Jason Lowe-Power <***@lowepower.com>
Gerrit-Reviewer: Nikos Nikoleris <***@arm.com>
Gerrit-MessageType: newpatchset
Daniel Carvalho (Gerrit)
2018-10-23 12:27:54 UTC
Permalink
Hello Jason Lowe-Power, Nikos Nikoleris,

I'd like you to reexamine a change. Please visit

https://gem5-review.googlesource.com/c/public/gem5/+/11410

to look at the new patch set (#8).

Change subject: mem-cache: Add compression and decompression calls
......................................................................

mem-cache: Add compression and decompression calls

Add a compressor to the base cache class and compress within
block allocation and decompress on writebacks.

This change does not implement data expansion (fat writes) yet,
nor it adds the decompression latency to the block access time.

Change-Id: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
---
M src/mem/cache/Cache.py
M src/mem/cache/base.cc
M src/mem/cache/base.hh
M src/mem/cache/tags/compressed_tags.cc
M src/mem/cache/tags/compressed_tags.hh
5 files changed, 103 insertions(+), 1 deletion(-)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/11410
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: Ie36db65f7487c9b05ec4aedebc2c7651b4cb4821
Gerrit-Change-Number: 11410
Gerrit-PatchSet: 8
Gerrit-Owner: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Jason Lowe-Power <***@lowepower.com>
Gerrit-Reviewer: Nikos Nikoleris <***@arm.com>
Gerrit-MessageType: newpatchset
Continue reading on narkive:
Loading...