Discussion:
[gem5-dev] Change in gem5/gem5[master]: mem-cache: Create BDI Compressor
(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/11412


Change subject: mem-cache: Create BDI Compressor
......................................................................

mem-cache: Create BDI Compressor

Implement Base-Delta-Immediate compression, as described in
'Base-Delta-Immediate Compression: Practical Data Compression
for On-Chip Caches'

Change-Id: I7980c340ab53a086b748f4b2108de4adc775fac8
---
M src/mem/cache/compressors/Compressors.py
M src/mem/cache/compressors/SConscript
A src/mem/cache/compressors/bdi.cc
A src/mem/cache/compressors/bdi.hh
4 files changed, 830 insertions(+), 0 deletions(-)



diff --git a/src/mem/cache/compressors/Compressors.py
b/src/mem/cache/compressors/Compressors.py
index 1901758..3730875 100644
--- a/src/mem/cache/compressors/Compressors.py
+++ b/src/mem/cache/compressors/Compressors.py
@@ -38,6 +38,15 @@
line_size = Param.Int(Parent.cache_line_size,
"Cache line size in bytes")

+class BDI(BaseCacheCompressor):
+ type = 'BDI'
+ cxx_class = 'BDI'
+ cxx_header = "mem/cache/compressors/bdi.hh"
+
+ use_more_compressors = Param.Bool(True, "True if should use all
possible" \
+ "combinations of base and delta for the compressors. False if
using" \
+ "only the lowest possible delta size for each base size.");
+
class CPack(BaseCacheCompressor):
type = 'CPack'
cxx_class = 'CPack'
diff --git a/src/mem/cache/compressors/SConscript
b/src/mem/cache/compressors/SConscript
index 8c05f16..274016d 100644
--- a/src/mem/cache/compressors/SConscript
+++ b/src/mem/cache/compressors/SConscript
@@ -33,5 +33,6 @@
SimObject('Compressors.py')

Source('base.cc')
+Source('bdi.cc')
Source('cpack.cc')
Source('no_compressor.cc')
diff --git a/src/mem/cache/compressors/bdi.cc
b/src/mem/cache/compressors/bdi.cc
new file mode 100644
index 0000000..aee1d52
--- /dev/null
+++ b/src/mem/cache/compressors/bdi.cc
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2018 Inria
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Daniel Carvalho
+ */
+
+/** @file
+ * Implementation of the BDI cache compressor.
+ */
+
+#include "mem/cache/compressors/bdi.hh"
+
+#include <algorithm>
+#include <climits>
+#include <cstdint>
+
+#include "debug/CacheComp.hh"
+#include "params/BDI.hh"
+#include "sim/byteswap.hh"
+
+// Number of bytes in a qword
+#define BYTES_PER_QWORD 8
+
+// Declare BDI encoding names
+const char* BDI::ENCODING_NAMES[9] =
+ {"Zero", "Repeated Values", "Base8_1", "Base8_2", "Base8_4", "Base4_1",
+ "Base4_2", "Base2_1", "Uncompressed"};
+
+BDI::BDICompData::BDICompData()
+ : CompressionData(), _encoding(UNCOMPRESSED), _encodingName("")
+{
+}
+
+void
+BDI::BDICompData::setEncoding(const uint8_t enc)
+{
+ _encoding = enc;
+ _encodingName = ENCODING_NAMES[enc];
+}
+
+uint8_t
+BDI::BDICompData::getEncoding() const
+{
+ return _encoding;
+}
+
+std::string
+BDI::BDICompData::getName() const
+{
+ return _encodingName;
+}
+
+BDI::BDICompDataZeros::BDICompDataZeros()
+ : BDICompData()
+{
+ // Set ZERO encoding
+ setEncoding(ZERO);
+
+ // Calculate compressed size
+ calculateCompressedSize();
+}
+
+uint64_t
+BDI::BDICompDataZeros::access(const int index) const
+{
+ return 0;
+}
+
+void
+BDI::BDICompDataZeros::calculateCompressedSize()
+{
+ // Number of bits used by Encoding
+ std::size_t size = 4;
+
+ setSize(size);
+}
+
+BDI::BDICompDataRep::BDICompDataRep(const uint64_t rep_value)
+ : BDICompData()
+{
+ // Set base value
+ base = rep_value;
+
+ // Set REP_VALUES encoding
+ setEncoding(REP_VALUES);
+
+ // Calculate compressed size
+ calculateCompressedSize();
+}
+
+uint64_t
+BDI::BDICompDataRep::access(const int index) const
+{
+ return base;
+}
+
+void
+BDI::BDICompDataRep::calculateCompressedSize()
+{
+ // Number of bits used by Encoding
+ std::size_t size = 4;
+
+ // Number of bits used by Base
+ size += sizeof(base)*CHAR_BIT;
+
+ setSize(size);
+}
+
+BDI::BDICompDataUncompressed::BDICompDataUncompressed(
+ const uint64_t* cache_line, const std::size_t line_size)
+ : BDICompData(), lineSize(line_size),
+ _cacheLine(cache_line, cache_line + line_size/CHAR_BIT)
+{
+ // Set UNCOMPRESSED encoding
+ setEncoding(UNCOMPRESSED);
+
+ // Calculate compressed size
+ calculateCompressedSize();
+}
+
+uint64_t
+BDI::BDICompDataUncompressed::access(const int index) const
+{
+ return _cacheLine[index];
+}
+
+void
+BDI::BDICompDataUncompressed::calculateCompressedSize()
+{
+ // Number of bits used by Encoding
+ std::size_t size = 4;
+
+ // Number of bits used by uncompressed line
+ size += lineSize*CHAR_BIT;
+
+ setSize(size);
+}
+
+template <class TB, class TD>
+BDI::BDICompDataBaseDelta<TB, TD>::BDICompDataBaseDelta(
+ const uint64_t* cache_line, const std::size_t line_size,
+ const std::size_t max_num_bases)
+ : BDICompData(), maxNumBases(max_num_bases)
+{
+ // Reserve the maximum possible size for the vectors
+ bases.reserve(maxNumBases);
+ bitMask.reserve(maxNumBases);
+ deltas.reserve(line_size/sizeof(TD));
+
+ // Push virtual base 0 to bases list
+ bases.push_back(0);
+
+ // Try to compress using given base and delta sizes
+ if (compress(cache_line, line_size)) {
+ calculateCompressedSize();
+ // If failed to compress, return uncompressed size
+ } else {
+ BDICompDataUncompressed bdi_data(cache_line, line_size);
+ CompressionData::setSize(bdi_data.getSize());
+ }
+}
+
+template <class TB, class TD>
+void
+BDI::BDICompDataBaseDelta<TB, TD>::calculateCompressedSize()
+{
+ // Number of bits used by Encoding
+ std::size_t size = 4;
+
+ // Number of bits used by BitMask
+ size += bitMask.size();
+
+ // Number of bits used by Bases. bases[0] is implicit in a hardware
+ // implementation, therefore its size is 0
+ size += (maxNumBases-1)*sizeof(TB)*CHAR_BIT;
+
+ // Number of bits used by Deltas
+ size += deltas.size()*sizeof(TD)*CHAR_BIT;
+
+ CompressionData::setSize(size);
+}
+
+template <class TB, class TD>
+bool
+BDI::BDICompDataBaseDelta<TB, TD>::addBase(const TB base)
+{
+ // Can't add base if reached limit of number of bases
+ if (bases.size() >= maxNumBases) {
+ return false;
+ }
+
+ // Push new base to end of bases list
+ bases.push_back(base);
+
+ // New delta is 0, as it is a difference between the new base and
itself
+ addDelta(bases.size() - 1, 0);
+
+ return true;
+}
+
+template <class TB, class TD>
+void
+BDI::BDICompDataBaseDelta<TB, TD>::addDelta(const std::size_t base_index,
+ const TD delta)
+{
+ // Insert new delta with respect to the given base
+ bitMask.push_back(base_index);
+
+ // Insert new delta
+ deltas.push_back(delta);
+}
+
+template <class TB, class TD> bool
+BDI::BDICompDataBaseDelta<TB, TD>::compress(const uint64_t* cache_line,
+ const std::size_t line_size)
+{
+ // Shift through all values according to base size
+ for (std::size_t byte_start = 0; byte_start < line_size;
+ byte_start += sizeof(TB))
+ {
+ // Get current value
+ TB curValue;
+ std::memcpy(&curValue, ((uint8_t*)cache_line) + byte_start,
+ sizeof(TB));
+
+ // Iterate through all bases to search for a valid delta
+ bool foundDelta = false;
+ for (std::size_t b = 0; b < bases.size(); b++){
+ // Calculate delta
+ typename std::make_signed<TB>::type delta = curValue -
bases[b];
+
+ // Check if the delta is within the limits of the delta size
+ typename std::make_signed<TB>::type limit =
+ ULLONG_MAX>>((BYTES_PER_QWORD-sizeof(TD))*CHAR_BIT+1);
+ if ((delta >= -limit) && (delta <= limit)){
+ addDelta(b, delta);
+ foundDelta = true;
+ break;
+ }
+ }
+
+ // If number of bases is insufficient, add new base and insert
delta
+ // respective to it
+ if (!foundDelta){
+ // If can't add new base, line is uncompressible using given
+ // encoding
+ if (!addBase(curValue)) return false;
+ }
+ }
+
+ return true;
+}
+
+template <class TB, class TD>
+uint64_t
+BDI::BDICompDataBaseDelta<TB, TD>::access(const int index) const
+{
+ // Get relationship between the size of a uint64_t base and size of TB
+ std::size_t size_diff = sizeof(uint64_t)/sizeof(TB);
+ int shift = sizeof(TB)*CHAR_BIT;
+ // Add delta in corresponding index to the base
+ uint64_t value = 0;
+ for (int i = size_diff-1; i >= 0; i--){
+ value <<= shift;
+ value |= static_cast<uint64_t>((bases[bitMask[size_diff*index +
i]] +
+ deltas[size_diff*index + i])&
+ (ULLONG_MAX>>((BYTES_PER_QWORD-sizeof(TB))*CHAR_BIT)));
+ }
+
+ return value;
+}
+
+BDI::BDI(const Params *p)
+ : BaseCacheCompressor(p), useMoreCompressors(p->use_more_compressors),
+ qwordsPerCacheLine(lineSize/BYTES_PER_QWORD)
+{
+}
+
+bool
+BDI::isZeroPackable(const uint64_t* cache_line) const
+{
+ return std::all_of(cache_line, cache_line + qwordsPerCacheLine,
+ [](const uint64_t entry){return entry == 0;});
+}
+
+bool
+BDI::isSameValuePackable(const uint64_t* cache_line) const
+{
+ // We don't want to copy the whole array to the lambda expression
+ const uint64_t rep_value = cache_line[0];
+ return std::all_of(cache_line, cache_line + qwordsPerCacheLine,
+ [rep_value](const uint64_t entry)
+ {return entry == rep_value;});
+}
+
+Cycles
+BDI::decompress(const CompressionData* comp_data, uint64_t* cache_line)
+{
+ // Decompress and go back to host endianness
+ for (std::size_t i = 0; i < qwordsPerCacheLine; i++)
+ cache_line[i] = static_cast<const
BDICompData*>(comp_data)->access(i);
+
+ // @todo Return decompression latency
+ return Cycles(0);
+}
+
+std::unique_ptr<CompressionData>
+BDI::compress(const uint64_t* cache_line, Cycles& lat)
+{
+ std::unique_ptr<BDICompData> bdi_data;
+
+ // Check if it is a zero line
+ if (isZeroPackable(cache_line)){
+ bdi_data = std::unique_ptr<BDICompData>(new BDICompDataZeros());
+ // Check if all values in the line are the same
+ } else if (isSameValuePackable(cache_line)){
+ bdi_data = std::unique_ptr<BDICompData>(
+ new BDICompDataRep(cache_line[0]));
+ } else {
+ // Initialize compressed data as an uncompressed instance
+ bdi_data = std::unique_ptr<BDICompData>(
+ new BDICompDataUncompressed(cache_line, lineSize));
+
+ // Check which base-delta size combination is the best. This could
be
+ // improved by giving priority to trying the compressor that would
+ // generate the smallest compression size. This way we wouldn't
need
+ // to waste simulation time with all possible combinations
+ for (int base_size = 8; base_size > 1; base_size/=2){
+ // If using more compressors, parse all delta sizes from 1 to
one
+ // size smaller than the base size, otherwise just parse
highest
+ // possible delta. When we only instantiate one delta size per
+ // base size, we use less area and energy, at the cost of lower
+ // compression efficiency
+ std::size_t initial_delta_size =
+ useMoreCompressors ? 1 : base_size/2;
+
+ // Parse possible delta size values
+ for (std::size_t delta_size = initial_delta_size;
+ delta_size < base_size; delta_size*=2)
+ {
+ std::unique_ptr<BDICompData> temp_data;
+
+ // Get the compression result for the current combination
+ if ((base_size == 8)&&(delta_size == 4)){
+ temp_data = std::unique_ptr<BDICompData>(
+ new BDICompDataBaseDelta<uint64_t, int32_t>(
+ cache_line, lineSize));
+ temp_data->setEncoding(BASE8_4);
+ } else if ((base_size == 8)&&(delta_size == 2)){
+ temp_data = std::unique_ptr<BDICompData>(
+ new BDICompDataBaseDelta<uint64_t, int16_t>(
+ cache_line, lineSize));
+ temp_data->setEncoding(BASE8_2);
+ } else if ((base_size == 8)&&(delta_size == 1)){
+ temp_data = std::unique_ptr<BDICompData>(
+ new BDICompDataBaseDelta<uint64_t, int8_t>(
+ cache_line, lineSize));
+ temp_data->setEncoding(BASE8_1);
+ } else if ((base_size == 4)&&(delta_size == 2)){
+ temp_data = std::unique_ptr<BDICompData>(
+ new BDICompDataBaseDelta<uint32_t, int16_t>(
+ cache_line, lineSize));
+ temp_data->setEncoding(BASE4_2);
+ } else if ((base_size == 4)&&(delta_size == 1)){
+ temp_data = std::unique_ptr<BDICompData>(
+ new BDICompDataBaseDelta<uint32_t, int8_t>(
+ cache_line, lineSize));
+ temp_data->setEncoding(BASE4_1);
+ } else if ((base_size == 2)&&(delta_size == 1)){
+ temp_data = std::unique_ptr<BDICompData>(
+ new BDICompDataBaseDelta<uint16_t, int8_t>(
+ cache_line, lineSize));
+ temp_data->setEncoding(BASE2_1);
+ } else {
+ fatal("Invalid combination of base and delta sizes.");
+ }
+
+ // Check if new compression is better
+ if (bdi_data->getSize() > temp_data->getSize()){
+ bdi_data = std::move(temp_data);
+ }
+
+ // Clear temp pointer
+ temp_data.reset(nullptr);
+ }
+ }
+ }
+
+ // @todo Set compression latency
+ lat = Cycles(0);
+
+ // Print debug information
+ DPRINTF(CacheComp, "BDI: Compressed cache line to encoding %s (%d
bits)\n",
+ bdi_data->getName(), bdi_data->getSize());
+
+ return bdi_data;
+}
+
+BDI*
+BDIParams::create()
+{
+ return new BDI(this);
+}
diff --git a/src/mem/cache/compressors/bdi.hh
b/src/mem/cache/compressors/bdi.hh
new file mode 100644
index 0000000..b6c3e25
--- /dev/null
+++ b/src/mem/cache/compressors/bdi.hh
@@ -0,0 +1,393 @@
+/*
+ * Copyright (c) 2018 Inria
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Daniel Carvalho
+ */
+
+/** @file
+ * Definition of "Base-Delta-Immediate Compression: Practical Data
Compression
+ * for On-Chip Caches".
+ */
+
+#ifndef __MEM_CACHE_COMPRESSORS_BDI_HH__
+#define __MEM_CACHE_COMPRESSORS_BDI_HH__
+
+#include <cstdint>
+#include <vector>
+
+#include "base/types.hh"
+#include "mem/cache/compressors/base.hh"
+
+struct BDIParams;
+
+/**
+ * Default maximum number of bases in the original BDI.
+ */
+#define BDI_DEFAULT_MAX_NUM_BASES 2
+
+class BDI : public BaseCacheCompressor
+{
+ protected:
+ /**
+ * Forward declaration of comp data classes.
+ */
+ class BDICompData;
+ class BDICompDataZeros;
+ class BDICompDataRep;
+ class BDICompDataUncompressed;
+ template <class TB, class TD> class BDICompDataBaseDelta;
+
+ /**
+ * The possible encoding values.
+ */
+ enum ENCODING {ZERO, REP_VALUES, BASE8_1, BASE8_2, BASE8_4, BASE4_1,
+ BASE4_2, BASE2_1, UNCOMPRESSED};
+
+ /**
+ * The respective encoding names. They are indexed by the ENCODING
enum.
+ */
+ static const char* ENCODING_NAMES[9];
+
+ /**
+ * If set, create multiple compressor instances for each possible
+ * combination of base and delta size. Otherwise, just create a
+ * compressor for each base size with the highest available delta
+ * size. This can be used to save area and power (having less
+ * compressors). True by default.
+ */
+ const bool useMoreCompressors;
+
+ /**
+ * Number of qwords in a cache line
+ */
+ const std::size_t qwordsPerCacheLine;
+
+ /**
+ * Check if the cache line consists of only zero values.
+ *
+ * @param cache_line The cache line.
+ * @return True if it is a ZERO cache line.
+ */
+ bool isZeroPackable(const uint64_t* cache_line) const;
+
+ /**
+ * Check if the cache line consists only of same values.
+ *
+ * @param cache_line The cache line.
+ * @return True if it is a REP_VALUES cache line.
+ */
+ bool isSameValuePackable(const uint64_t* cache_line) const;
+
+ public:
+ /** Convenience typedef. */
+ typedef BDIParams Params;
+
+ /**
+ * Default constructor.
+ */
+ BDI(const Params *p);
+
+ /**
+ * Default destructor.
+ */
+ ~BDI() = default;
+
+ /**
+ * Apply compression.
+ *
+ * @param cache_line The cache line to be compressed.
+ * @param Compression latency in number of cycles.
+ * @return Cache line after compression.
+ */
+ std::unique_ptr<CompressionData> compress(const uint64_t* cache_line,
+ Cycles& lat) override;
+
+ /**
+ * Decompress data.
+ *
+ * @param comp_data Compressed cache line.
+ * @param cache_line The cache line to be decompressed.
+ * @return Decompression latency in number of cycles.
+ */
+ Cycles decompress(const CompressionData* comp_data, uint64_t*
cache_line)
+
override;
+};
+
+/**
+ * Template for the BDI compression data. BDI compressed data containing
the
+ * UNCOMPRESSED encoding.
+ */
+class BDI::BDICompData : public CompressionData
+{
+ private:
+ /**
+ * Data encoding.
+ * @sa BDI
+ */
+ uint8_t _encoding;
+
+ /**
+ * Encoding name.
+ */
+ std::string _encodingName;
+
+ protected:
+ /**
+ * Calculate and set compressed data size.
+ * Each BDI extension generates compressed data with different sizes.
+ */
+ virtual void calculateCompressedSize() = 0;
+
+ public:
+ /**
+ * Default constructor.
+ */
+ BDICompData();
+
+ /**
+ * Default destructor.
+ */
+ virtual ~BDICompData() = default;
+
+ /**
+ * Get and decompress data at given index.
+ *
+ * @param index The index of the compressed data.
+ * @return Decompressed data for the given index.
+ */
+ virtual uint64_t access(const int index) const = 0;
+
+ /**
+ * Set encoding and name this comp data with its proper encoding name.
+ *
+ * @param enc Encoding value.
+ */
+ void setEncoding(const uint8_t enc);
+
+ /**
+ * Get encoding.
+ *
+ * @return The encoding.
+ */
+ uint8_t getEncoding() const;
+
+ /**
+ * Get encoding name.
+ *
+ * @return The encoding name.
+ */
+ std::string getName() const;
+};
+
+/**
+ * BDI compressed data containing the ZERO encoding.
+ */
+class BDI::BDICompDataZeros : public BDICompData
+{
+ protected:
+ /**
+ * Calculate compressed data size using ZERO encoding.
+ */
+ void calculateCompressedSize() override;
+
+ public:
+ /**
+ * Default constructor.
+ */
+ BDICompDataZeros();
+
+ /**
+ * Get and decompress data at given index (should return 0).
+ *
+ * @param index The index of the compressed data.
+ * @return Decompressed data for the given index.
+ */
+ uint64_t access(const int index) const override;
+};
+
+/**
+ * BDI compressed data containing the REP_VALUES encoding.
+ */
+class BDI::BDICompDataRep : public BDICompData
+{
+ private:
+ /**
+ * The repeated value.
+ */
+ uint64_t base;
+
+ protected:
+ /**
+ * Calculate compressed data size using REP_VALUES encoding.
+ */
+ void calculateCompressedSize() override;
+
+ public:
+ /**
+ * Default constructor.
+ *
+ * @param rep_value The repeated value.
+ */
+ BDICompDataRep(const uint64_t rep_value);
+
+ /**
+ * Get and decompress data at given index (should return the same
+ * value as cacheLine[0]).
+ *
+ * @param index The index of the compressed data.
+ * @return Decompressed data for the given index.
+ */
+ uint64_t access(const int index) const override;
+};
+
+/**
+ * BDI compressed data containing the UNCOMPRESSED encoding.
+ */
+class BDI::BDICompDataUncompressed : public BDICompData
+{
+ private:
+ /**
+ * Uncompressed cache line size (in bytes).
+ */
+ const std::size_t lineSize;
+
+ /**
+ * The compressed data is the original cache line.
+ */
+ const std::vector<uint64_t> _cacheLine;
+
+ protected:
+ /**
+ * Calculate compressed data size using UNCOMPRESSED encoding.
+ */
+ void calculateCompressedSize() override;
+
+ public:
+ /**
+ * Default constructor.
+ *
+ * @param cache_line The data on which compression was applied.
+ * @param line_size Size of a cache line in bytes.
+ */
+ BDICompDataUncompressed(const uint64_t* cache_line,
+ const std::size_t line_size);
+
+ /**
+ * Get and decompress data at given index (should return the same
+ * value as _cacheLine[index]).
+ *
+ * @param index The index of the compressed data.
+ * @return Decompressed data for the given index.
+ */
+ uint64_t access(const int index) const override;
+};
+
+/**
+ * Template class for BDI compressed data containing all the BASE_DELTA
+ * encodings.
+ *
+ * @tparam TB Type of a base entry.
+ * @tparam TD Type of a delta entry.
+*/
+template <class TB, class TD>
+class BDI::BDICompDataBaseDelta : public BDICompData
+{
+ protected:
+ /**
+ * Maximum number of bases.
+ */
+ const std::size_t maxNumBases;
+
+ /**
+ * Bit mask to differentiate between the bases.
+ */
+ std::vector<uint8_t> bitMask;
+
+ /**
+ * Bases. bases[0] is 0 and is not stored in a hardware implementation.
+ */
+ std::vector<TB> bases;
+
+ /**
+ * Array of deltas (or immediate values).
+ */
+ std::vector<TD> deltas;
+
+ /**
+ * Add a base to the bases vector.
+ *
+ * @param base The base to be added.
+ * @return True on success, false if already used all base slots.
+ */
+ bool addBase(const TB base);
+
+ /**
+ * Add a delta to the deltas vector
+ *
+ * @param base_index Base to which the delta refers.
+ * @param delta The delta value.
+ */
+ void addDelta(const std::size_t base_index, const TD delta);
+
+ /**
+ * Apply base delta compression using range of delta sizes
+ * [start_delta_size, end_delta_size].
+ *
+ * @param cache_line The data on which compression was applied.
+ * @param line_size Size of a cache line in bytes.
+ * @return True on success.
+ */
+ bool compress(const uint64_t* cache_line, const std::size_t line_size);
+
+ /**
+ * Calculate compressed data size using number of bases, the base size
and
+ * the delta size.
+ */
+ void calculateCompressedSize() override;
+
+ public:
+ /**
+ * Default constructor.
+ *
+ * @param cache_line The data on which compression was applied.
+ * @param line_size Size of a cache line in bytes.
+ * @param max_num_bases Maximum number of bases allowed to be stored.
+ */
+ BDICompDataBaseDelta(const uint64_t* cache_line,
+ const std::size_t line_size,
+ const std::size_t max_num_bases = BDI_DEFAULT_MAX_NUM_BASES);
+
+ /**
+ * Get and decompress data at given index.
+ *
+ * @param index The index of the compressed data.
+ * @return Decompressed data for the given index.
+ */
+ uint64_t access(const int index) const override;
+};
+
+#endif //__MEM_CACHE_COMPRESSORS_BDI_HH__
--
To view, visit https://gem5-review.googlesource.com/11412
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: I7980c340ab53a086b748f4b2108de4adc775fac8
Gerrit-Change-Number: 11412
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/11412

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

Change subject: mem-cache: Create BDI Compressor
......................................................................

mem-cache: Create BDI Compressor

Implement Base-Delta-Immediate compression, as described in
'Base-Delta-Immediate Compression: Practical Data Compression
for On-Chip Caches'

Change-Id: I7980c340ab53a086b748f4b2108de4adc775fac8
---
M src/mem/cache/compressors/Compressors.py
M src/mem/cache/compressors/SConscript
A src/mem/cache/compressors/bdi.cc
A src/mem/cache/compressors/bdi.hh
4 files changed, 860 insertions(+), 0 deletions(-)
--
To view, visit https://gem5-review.googlesource.com/11412
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: I7980c340ab53a086b748f4b2108de4adc775fac8
Gerrit-Change-Number: 11412
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-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/+/11412

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

Change subject: mem-cache: Create BDI Compressor
......................................................................

mem-cache: Create BDI Compressor

Implement Base-Delta-Immediate compression, as described in
'Base-Delta-Immediate Compression: Practical Data Compression
for On-Chip Caches'

Change-Id: I7980c340ab53a086b748f4b2108de4adc775fac8
---
M src/mem/cache/compressors/Compressors.py
M src/mem/cache/compressors/SConscript
A src/mem/cache/compressors/bdi.cc
A src/mem/cache/compressors/bdi.hh
4 files changed, 907 insertions(+), 0 deletions(-)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/11412
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: I7980c340ab53a086b748f4b2108de4adc775fac8
Gerrit-Change-Number: 11412
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/+/11412

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

Change subject: mem-cache: Create BDI Compressor
......................................................................

mem-cache: Create BDI Compressor

Implement Base-Delta-Immediate compression, as described in
'Base-Delta-Immediate Compression: Practical Data Compression
for On-Chip Caches'

Change-Id: I7980c340ab53a086b748f4b2108de4adc775fac8
---
M src/mem/cache/compressors/Compressors.py
M src/mem/cache/compressors/SConscript
A src/mem/cache/compressors/bdi.cc
A src/mem/cache/compressors/bdi.hh
4 files changed, 906 insertions(+), 0 deletions(-)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/11412
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: I7980c340ab53a086b748f4b2108de4adc775fac8
Gerrit-Change-Number: 11412
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-17 13:34:49 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/+/11412

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

Change subject: mem-cache: Create BDI Compressor
......................................................................

mem-cache: Create BDI Compressor

Implement Base-Delta-Immediate compression, as described in
'Base-Delta-Immediate Compression: Practical Data Compression
for On-Chip Caches'

Change-Id: I7980c340ab53a086b748f4b2108de4adc775fac8
---
M src/mem/cache/compressors/Compressors.py
M src/mem/cache/compressors/SConscript
A src/mem/cache/compressors/bdi.cc
A src/mem/cache/compressors/bdi.hh
4 files changed, 930 insertions(+), 0 deletions(-)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/11412
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: I7980c340ab53a086b748f4b2108de4adc775fac8
Gerrit-Change-Number: 11412
Gerrit-PatchSet: 7
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, Gennady Pekhimenko,

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

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

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

Change subject: mem-cache: Create BDI Compressor
......................................................................

mem-cache: Create BDI Compressor

Implement Base-Delta-Immediate compression, as described in
'Base-Delta-Immediate Compression: Practical Data Compression
for On-Chip Caches'

Change-Id: I7980c340ab53a086b748f4b2108de4adc775fac8
---
M src/mem/cache/compressors/Compressors.py
M src/mem/cache/compressors/SConscript
A src/mem/cache/compressors/bdi.cc
A src/mem/cache/compressors/bdi.hh
4 files changed, 933 insertions(+), 0 deletions(-)
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/11412
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: I7980c340ab53a086b748f4b2108de4adc775fac8
Gerrit-Change-Number: 11412
Gerrit-PatchSet: 8
Gerrit-Owner: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Daniel Carvalho <***@yahoo.com.br>
Gerrit-Reviewer: Gennady Pekhimenko <***@gmail.com>
Gerrit-Reviewer: Jason Lowe-Power <***@lowepower.com>
Gerrit-Reviewer: Nikos Nikoleris <***@arm.com>
Gerrit-MessageType: newpatchset
Continue reading on narkive:
Loading...