mem-cache: Add an uncompressed pattern to compressors
The uncompressed pattern always stores the original data, and therefore it is always successful. All of the derived classes of the dictionary compressor must have this pattern as the last pattern of the pattern factory. Change-Id: I2a38fd56630d88ef8b918220dc4c2824a196a8a2 Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21149 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
7a8debf0fa
commit
7973e49187
23
src/mem/cache/compressors/cpack.hh
vendored
23
src/mem/cache/compressors/cpack.hh
vendored
@@ -145,31 +145,12 @@ class CPack::PatternZZZZ : public DictionaryCompressor::Pattern
|
||||
}
|
||||
};
|
||||
|
||||
class CPack::PatternXXXX : public DictionaryCompressor::Pattern
|
||||
class CPack::PatternXXXX : public UncompressedPattern
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* A copy of the word.
|
||||
*/
|
||||
const DictionaryEntry bytes;
|
||||
|
||||
public:
|
||||
PatternXXXX(const DictionaryEntry bytes, const int match_location)
|
||||
: Pattern(XXXX, 0x1, 2, 4, 0, true), bytes(bytes) {}
|
||||
|
||||
static bool isPattern(const DictionaryEntry& bytes,
|
||||
const DictionaryEntry& dict_bytes,
|
||||
const int match_location)
|
||||
: UncompressedPattern(XXXX, 0x1, 2, match_location, bytes)
|
||||
{
|
||||
// It can always be an unmatch, as it is set to this class when other
|
||||
// patterns fail
|
||||
return true;
|
||||
}
|
||||
|
||||
DictionaryEntry
|
||||
decompress(const DictionaryEntry dict_bytes) const override
|
||||
{
|
||||
return bytes;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ class DictionaryCompressor : public BaseDictionaryCompressor
|
||||
|
||||
// Forward declaration of a pattern
|
||||
class Pattern;
|
||||
class UncompressedPattern;
|
||||
|
||||
/** Convenience typedef for a dictionary entry. */
|
||||
typedef std::array<uint8_t, sizeof(T)> DictionaryEntry;
|
||||
@@ -150,15 +151,23 @@ class DictionaryCompressor : public BaseDictionaryCompressor
|
||||
}
|
||||
};
|
||||
|
||||
/** Specialization to end the recursion. */
|
||||
/**
|
||||
* Specialization to end the recursion. This must be called when all
|
||||
* other patterns failed, and there is no choice but to leave data
|
||||
* uncompressed. As such, this pattern must inherit from the uncompressed
|
||||
* pattern.
|
||||
*/
|
||||
template <class Head>
|
||||
struct Factory<Head>
|
||||
{
|
||||
static_assert(std::is_base_of<UncompressedPattern, Head>::value,
|
||||
"The last pattern must always be derived from the uncompressed "
|
||||
"pattern.");
|
||||
|
||||
static std::unique_ptr<Pattern>
|
||||
getPattern(const DictionaryEntry& bytes,
|
||||
const DictionaryEntry& dict_bytes, const int match_location)
|
||||
{
|
||||
// Instantiate last pattern. Should be the XXXX pattern.
|
||||
return std::unique_ptr<Pattern>(new Head(bytes, match_location));
|
||||
}
|
||||
};
|
||||
@@ -371,4 +380,44 @@ class DictionaryCompressor<T>::CompData : public CompressionData
|
||||
virtual void addEntry(std::unique_ptr<Pattern>);
|
||||
};
|
||||
|
||||
/**
|
||||
* A pattern containing the original uncompressed data. This should be the
|
||||
* worst case of every pattern factory, where if all other patterns fail,
|
||||
* an instance of this pattern is created.
|
||||
*/
|
||||
template <class T>
|
||||
class DictionaryCompressor<T>::UncompressedPattern
|
||||
: public DictionaryCompressor<T>::Pattern
|
||||
{
|
||||
private:
|
||||
/** A copy of the original data. */
|
||||
const DictionaryEntry data;
|
||||
|
||||
public:
|
||||
UncompressedPattern(const int number,
|
||||
const uint64_t code,
|
||||
const uint64_t metadata_length,
|
||||
const int match_location,
|
||||
const DictionaryEntry bytes)
|
||||
: DictionaryCompressor<T>::Pattern(number, code, metadata_length,
|
||||
sizeof(T), match_location, true),
|
||||
data(bytes)
|
||||
{
|
||||
}
|
||||
|
||||
static bool
|
||||
isPattern(const DictionaryEntry& bytes, const DictionaryEntry& dict_bytes,
|
||||
const int match_location)
|
||||
{
|
||||
// An entry can always be uncompressed
|
||||
return true;
|
||||
}
|
||||
|
||||
DictionaryEntry
|
||||
decompress(const DictionaryEntry dict_bytes) const override
|
||||
{
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //__MEM_CACHE_COMPRESSORS_DICTIONARY_COMPRESSOR_HH__
|
||||
|
||||
Reference in New Issue
Block a user