From: Daniel R. Carvalho Date: Wed, 10 Jun 2020 15:00:42 +0000 (+0200) Subject: mem-cache: Add encoding bits to the data of multi compressors X-Git-Tag: v20.1.0.0~186 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=35f77329e8f19ee050b1710c650147cb317931b7;p=gem5.git mem-cache: Add encoding bits to the data of multi compressors When compressing using a multi-compressor, one must be able to identify which sub-compressor should be used to decompress data. This can be achieved by either adding encoding bits to block's tag or data entry. It was previously assumed that these encoding bits would be added to the tag, but now make it a parameter that defaults to the data entry. Change-Id: Id322425e7a6ad59cb2ec7a4167a43de4c55c482c Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33380 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris Tested-by: kokoro --- diff --git a/src/mem/cache/compressors/Compressors.py b/src/mem/cache/compressors/Compressors.py index 1c47ac10f..f7e8a7d8c 100644 --- a/src/mem/cache/compressors/Compressors.py +++ b/src/mem/cache/compressors/Compressors.py @@ -113,6 +113,9 @@ class MultiCompressor(BaseCacheCompressor): # since these compressors have many overlapping patterns compressors = VectorParam.BaseCacheCompressor([CPack(), FPCD()], "Array of compressors") + encoding_in_tags = Param.Bool(False, "If set the bits to inform which " + "sub-compressor compressed some data are added to its corresponding " + "tag entry.") class PerfectCompressor(BaseCacheCompressor): type = 'PerfectCompressor' diff --git a/src/mem/cache/compressors/multi.cc b/src/mem/cache/compressors/multi.cc index 51dbc2ba4..bb98dcd54 100644 --- a/src/mem/cache/compressors/multi.cc +++ b/src/mem/cache/compressors/multi.cc @@ -59,6 +59,8 @@ Multi::MultiCompData::getIndex() const Multi::Multi(const Params *p) : Base(p), compressors(p->compressors), + numEncodingBits(p->encoding_in_tags ? 0 : + std::log2(alignToPowerOfTwo(compressors.size()))), multiStats(stats, *this) { fatal_if(compressors.size() == 0, "There must be at least one compressor"); @@ -128,6 +130,8 @@ Multi::compress(const std::vector& chunks, Cycles& comp_lat, Cycles temp_decomp_lat; auto temp_comp_data = compressors[i]->compress(data, comp_lat, temp_decomp_lat); + temp_comp_data->setSizeBits(temp_comp_data->getSizeBits() + + numEncodingBits); results.push(std::make_shared(i, std::move(temp_comp_data), temp_decomp_lat, blkSize)); max_comp_lat = std::max(max_comp_lat, comp_lat); diff --git a/src/mem/cache/compressors/multi.hh b/src/mem/cache/compressors/multi.hh index 095dd0335..868682feb 100644 --- a/src/mem/cache/compressors/multi.hh +++ b/src/mem/cache/compressors/multi.hh @@ -58,6 +58,23 @@ class Multi : public Base /** List of sub-compressors. */ std::vector compressors; + /** + * An encoding is associated to each sub-compressor to inform which + * sub-compressor to use when decompressing data. This information can + * be added either to the tag entry, in which case no extra bits are + * added to the compressed data (numEncodingBits = 0), or to the + * compressed data itself. + * + * There is no encoding reserved for the uncompressed case; it is assumed + * that an "is compressed" bit is stored in the tags. Therefore, even if + * storing the encoding within the compressed data, these extra bits are + * not added when the data is uncompressible. + * + * These extra bits are taken into account when thresholding the + * compressed data's size. + */ + const std::size_t numEncodingBits; + struct MultiStats : public Stats::Group { const Multi& compressor;