# 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'
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");
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<Results>(i, std::move(temp_comp_data),
temp_decomp_lat, blkSize));
max_comp_lat = std::max(max_comp_lat, comp_lat);
/** List of sub-compressors. */
std::vector<Base*> 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;