Daniel Carvalho has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/33294 )
Change subject: mem-cache: Create Compressor namespace
......................................................................
mem-cache: Create Compressor namespace
Creation of the Compressor namespace. It encapsulates all the cache
compressors, and other classes used by them.
The following classes have been renamed:
BaseCacheCompressor -> Base
PerfectCompressor - Perfect
RepeatedQwordsCompressor -> RepeatedQwords
ZeroCompressor -> Zero
BaseDictionaryCompressor and DictionaryCompressor were not renamed
because the there is a high probability that users may want to
create a Dictionary class that encompasses the dictionary contained
by these compressors.
To apply this patch one must force recompilation (e.g., by deleting
it) of build/<arch>/params/BaseCache.hh (and any other files that
were previously using these compressors).
Change-Id: I78cb3b6fb8e3e50a52a04268e0e08dd664d81230
Signed-off-by: Daniel R. Carvalho <oda...@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33294
Reviewed-by: Nikos Nikoleris <nikos.nikole...@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikole...@arm.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/mem/cache/base.hh
M src/mem/cache/compressors/Compressors.py
M src/mem/cache/compressors/base.cc
M src/mem/cache/compressors/base.hh
M src/mem/cache/compressors/base_delta.cc
M src/mem/cache/compressors/base_delta.hh
M src/mem/cache/compressors/base_delta_impl.hh
M src/mem/cache/compressors/base_dictionary_compressor.cc
M src/mem/cache/compressors/cpack.cc
M src/mem/cache/compressors/cpack.hh
M src/mem/cache/compressors/dictionary_compressor.hh
M src/mem/cache/compressors/dictionary_compressor_impl.hh
M src/mem/cache/compressors/fpcd.cc
M src/mem/cache/compressors/fpcd.hh
M src/mem/cache/compressors/multi.cc
M src/mem/cache/compressors/multi.hh
M src/mem/cache/compressors/perfect.cc
M src/mem/cache/compressors/perfect.hh
M src/mem/cache/compressors/repeated_qwords.cc
M src/mem/cache/compressors/repeated_qwords.hh
M src/mem/cache/compressors/zero.cc
M src/mem/cache/compressors/zero.hh
22 files changed, 231 insertions(+), 165 deletions(-)
Approvals:
Nikos Nikoleris: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/mem/cache/base.hh b/src/mem/cache/base.hh
index 3efc7c7..d30de3f 100644
--- a/src/mem/cache/base.hh
+++ b/src/mem/cache/base.hh
@@ -320,7 +320,7 @@
BaseTags *tags;
/** Compression method being used. */
- BaseCacheCompressor* compressor;
+ Compressor::Base* compressor;
/** Prefetcher */
Prefetcher::Base *prefetcher;
diff --git a/src/mem/cache/compressors/Compressors.py
b/src/mem/cache/compressors/Compressors.py
index eb1952a..46050f6 100644
--- a/src/mem/cache/compressors/Compressors.py
+++ b/src/mem/cache/compressors/Compressors.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Inria
+# Copyright (c) 2018-2020 Inria
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,7 @@
class BaseCacheCompressor(SimObject):
type = 'BaseCacheCompressor'
abstract = True
+ cxx_class = 'Compressor::Base'
cxx_header = "mem/cache/compressors/base.hh"
block_size = Param.Int(Parent.cache_line_size, "Block size in bytes")
@@ -41,6 +42,7 @@
class BaseDictionaryCompressor(BaseCacheCompressor):
type = 'BaseDictionaryCompressor'
abstract = True
+ cxx_class = 'Compressor::BaseDictionaryCompressor'
cxx_header = "mem/cache/compressors/dictionary_compressor.hh"
dictionary_size = Param.Int(Parent.cache_line_size,
@@ -48,49 +50,49 @@
class Base64Delta8(BaseDictionaryCompressor):
type = 'Base64Delta8'
- cxx_class = 'Base64Delta8'
+ cxx_class = 'Compressor::Base64Delta8'
cxx_header = "mem/cache/compressors/base_delta.hh"
class Base64Delta16(BaseDictionaryCompressor):
type = 'Base64Delta16'
- cxx_class = 'Base64Delta16'
+ cxx_class = 'Compressor::Base64Delta16'
cxx_header = "mem/cache/compressors/base_delta.hh"
class Base64Delta32(BaseDictionaryCompressor):
type = 'Base64Delta32'
- cxx_class = 'Base64Delta32'
+ cxx_class = 'Compressor::Base64Delta32'
cxx_header = "mem/cache/compressors/base_delta.hh"
class Base32Delta8(BaseDictionaryCompressor):
type = 'Base32Delta8'
- cxx_class = 'Base32Delta8'
+ cxx_class = 'Compressor::Base32Delta8'
cxx_header = "mem/cache/compressors/base_delta.hh"
class Base32Delta16(BaseDictionaryCompressor):
type = 'Base32Delta16'
- cxx_class = 'Base32Delta16'
+ cxx_class = 'Compressor::Base32Delta16'
cxx_header = "mem/cache/compressors/base_delta.hh"
class Base16Delta8(BaseDictionaryCompressor):
type = 'Base16Delta8'
- cxx_class = 'Base16Delta8'
+ cxx_class = 'Compressor::Base16Delta8'
cxx_header = "mem/cache/compressors/base_delta.hh"
class CPack(BaseDictionaryCompressor):
type = 'CPack'
- cxx_class = 'CPack'
+ cxx_class = 'Compressor::CPack'
cxx_header = "mem/cache/compressors/cpack.hh"
class FPCD(BaseDictionaryCompressor):
type = 'FPCD'
- cxx_class = 'FPCD'
+ cxx_class = 'Compressor::FPCD'
cxx_header = "mem/cache/compressors/fpcd.hh"
dictionary_size = 2
class MultiCompressor(BaseCacheCompressor):
type = 'MultiCompressor'
- cxx_class = 'MultiCompressor'
+ cxx_class = 'Compressor::Multi'
cxx_header = "mem/cache/compressors/multi.hh"
# Dummy default compressor list. This might not be an optimal choice,
@@ -100,7 +102,7 @@
class PerfectCompressor(BaseCacheCompressor):
type = 'PerfectCompressor'
- cxx_class = 'PerfectCompressor'
+ cxx_class = 'Compressor::Perfect'
cxx_header = "mem/cache/compressors/perfect.hh"
max_compression_ratio = Param.Int(2,
@@ -112,12 +114,12 @@
class RepeatedQwordsCompressor(BaseDictionaryCompressor):
type = 'RepeatedQwordsCompressor'
- cxx_class = 'RepeatedQwordsCompressor'
+ cxx_class = 'Compressor::RepeatedQwords'
cxx_header = "mem/cache/compressors/repeated_qwords.hh"
class ZeroCompressor(BaseDictionaryCompressor):
type = 'ZeroCompressor'
- cxx_class = 'ZeroCompressor'
+ cxx_class = 'Compressor::Zero'
cxx_header = "mem/cache/compressors/zero.hh"
class BDI(MultiCompressor):
diff --git a/src/mem/cache/compressors/base.cc
b/src/mem/cache/compressors/base.cc
index d08a5b9..f8fda81 100644
--- a/src/mem/cache/compressors/base.cc
+++ b/src/mem/cache/compressors/base.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 Inria
+ * Copyright (c) 2018-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,37 +42,39 @@
#include "mem/cache/tags/super_blk.hh"
#include "params/BaseCacheCompressor.hh"
+namespace Compressor {
+
// Uncomment this line if debugging compression
//#define DEBUG_COMPRESSION
-BaseCacheCompressor::CompressionData::CompressionData()
+Base::CompressionData::CompressionData()
: _size(0)
{
}
-BaseCacheCompressor::CompressionData::~CompressionData()
+Base::CompressionData::~CompressionData()
{
}
void
-BaseCacheCompressor::CompressionData::setSizeBits(std::size_t size)
+Base::CompressionData::setSizeBits(std::size_t size)
{
_size = size;
}
std::size_t
-BaseCacheCompressor::CompressionData::getSizeBits() const
+Base::CompressionData::getSizeBits() const
{
return _size;
}
std::size_t
-BaseCacheCompressor::CompressionData::getSize() const
+Base::CompressionData::getSize() const
{
return std::ceil(_size/8);
}
-BaseCacheCompressor::BaseCacheCompressor(const Params *p)
+Base::Base(const Params *p)
: SimObject(p), blkSize(p->block_size), sizeThreshold(p->size_threshold),
stats(*this)
{
@@ -80,7 +82,7 @@
}
void
-BaseCacheCompressor::compress(const uint64_t* data, Cycles& comp_lat,
+Base::compress(const uint64_t* data, Cycles& comp_lat,
Cycles& decomp_lat, std::size_t&
comp_size_bits)
{
// Apply compression
@@ -119,7 +121,7 @@
}
Cycles
-BaseCacheCompressor::getDecompressionLatency(const CacheBlk* blk)
+Base::getDecompressionLatency(const CacheBlk* blk)
{
const CompressionBlk* comp_blk = static_cast<const
CompressionBlk*>(blk);
@@ -137,7 +139,7 @@
}
void
-BaseCacheCompressor::setDecompressionLatency(CacheBlk* blk, const Cycles
lat)
+Base::setDecompressionLatency(CacheBlk* blk, const Cycles lat)
{
// Sanity check
assert(blk != nullptr);
@@ -147,7 +149,7 @@
}
void
-BaseCacheCompressor::setSizeBits(CacheBlk* blk, const std::size_t
size_bits)
+Base::setSizeBits(CacheBlk* blk, const std::size_t size_bits)
{
// Sanity check
assert(blk != nullptr);
@@ -156,8 +158,7 @@
static_cast<CompressionBlk*>(blk)->setSizeBits(size_bits);
}
-BaseCacheCompressor::BaseCacheCompressorStats::BaseCacheCompressorStats(
- BaseCacheCompressor& _compressor)
+Base::BaseStats::BaseStats(Base& _compressor)
: Stats::Group(&_compressor), compressor(_compressor),
compressions(this, "compressions",
"Total number of compressions"),
@@ -173,7 +174,7 @@
}
void
-BaseCacheCompressor::BaseCacheCompressorStats::regStats()
+Base::BaseStats::regStats()
{
Stats::Group::regStats();
@@ -189,3 +190,4 @@
avgCompressionSizeBits = compressionSizeBits / compressions;
}
+} // namespace Compressor
diff --git a/src/mem/cache/compressors/base.hh
b/src/mem/cache/compressors/base.hh
index 61233c3..87cb0fc 100644
--- a/src/mem/cache/compressors/base.hh
+++ b/src/mem/cache/compressors/base.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 Inria
+ * Copyright (c) 2018-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,18 +45,20 @@
class CacheBlk;
struct BaseCacheCompressorParams;
+namespace Compressor {
+
/**
* Base cache compressor interface. Every cache compressor must implement a
* compression and a decompression method.
*/
-class BaseCacheCompressor : public SimObject
+class Base : public SimObject
{
protected:
/**
* This compressor must be able to access the protected functions of
* its sub-compressors.
*/
- friend class MultiCompressor;
+ friend class Multi;
/**
* Forward declaration of compression data. Every new compressor must
@@ -75,11 +77,11 @@
*/
const std::size_t sizeThreshold;
- struct BaseCacheCompressorStats : public Stats::Group
+ struct BaseStats : public Stats::Group
{
- const BaseCacheCompressor& compressor;
+ const Base& compressor;
- BaseCacheCompressorStats(BaseCacheCompressor& compressor);
+ BaseStats(Base& compressor);
void regStats() override;
@@ -124,18 +126,9 @@
uint64_t* cache_line) = 0;
public:
- /** Convenience typedef. */
- typedef BaseCacheCompressorParams Params;
-
- /**
- * Default constructor.
- */
- BaseCacheCompressor(const Params *p);
-
- /**
- * Default destructor.
- */
- virtual ~BaseCacheCompressor() {};
+ typedef BaseCacheCompressorParams Params;
+ Base(const Params *p);
+ virtual ~Base() = default;
/**
* Apply the compression process to the cache line. Ignores compression
@@ -174,7 +167,8 @@
static void setSizeBits(CacheBlk* blk, const std::size_t size_bits);
};
-class BaseCacheCompressor::CompressionData {
+class Base::CompressionData
+{
private:
/**
* Compressed cache line size (in bits).
@@ -214,4 +208,6 @@
std::size_t getSize() const;
};
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_BASE_HH__
diff --git a/src/mem/cache/compressors/base_delta.cc
b/src/mem/cache/compressors/base_delta.cc
index 5af3b38..2d0aafe 100644
--- a/src/mem/cache/compressors/base_delta.cc
+++ b/src/mem/cache/compressors/base_delta.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,6 +39,8 @@
#include "params/Base64Delta32.hh"
#include "params/Base64Delta8.hh"
+namespace Compressor {
+
Base64Delta8::Base64Delta8(const Params *p)
: BaseDelta<uint64_t, 8>(p)
{
@@ -69,38 +71,40 @@
{
}
-Base64Delta8*
+} // namespace Compressor
+
+Compressor::Base64Delta8*
Base64Delta8Params::create()
{
- return new Base64Delta8(this);
+ return new Compressor::Base64Delta8(this);
}
-Base64Delta16*
+Compressor::Base64Delta16*
Base64Delta16Params::create()
{
- return new Base64Delta16(this);
+ return new Compressor::Base64Delta16(this);
}
-Base64Delta32*
+Compressor::Base64Delta32*
Base64Delta32Params::create()
{
- return new Base64Delta32(this);
+ return new Compressor::Base64Delta32(this);
}
-Base32Delta8*
+Compressor::Base32Delta8*
Base32Delta8Params::create()
{
- return new Base32Delta8(this);
+ return new Compressor::Base32Delta8(this);
}
-Base32Delta16*
+Compressor::Base32Delta16*
Base32Delta16Params::create()
{
- return new Base32Delta16(this);
+ return new Compressor::Base32Delta16(this);
}
-Base16Delta8*
+Compressor::Base16Delta8*
Base16Delta8Params::create()
{
- return new Base16Delta8(this);
+ return new Compressor::Base16Delta8(this);
}
diff --git a/src/mem/cache/compressors/base_delta.hh
b/src/mem/cache/compressors/base_delta.hh
index 6c54acd..1e4b70e 100644
--- a/src/mem/cache/compressors/base_delta.hh
+++ b/src/mem/cache/compressors/base_delta.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,6 +49,8 @@
struct Base32Delta16Params;
struct Base16Delta8Params;
+namespace Compressor {
+
/**
* Base class for all base-delta-immediate compressors. Although not
proposed
* like this in the original paper, the sub-compressors of BDI are
dictionary
@@ -113,7 +115,7 @@
void addToDictionary(DictionaryEntry data) override;
- std::unique_ptr<BaseCacheCompressor::CompressionData>
+ std::unique_ptr<Base::CompressionData>
compress(const uint64_t* data, Cycles& comp_lat,
Cycles& decomp_lat) override;
@@ -201,4 +203,6 @@
~Base16Delta8() = default;
};
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_BASE_DELTA_HH__
diff --git a/src/mem/cache/compressors/base_delta_impl.hh
b/src/mem/cache/compressors/base_delta_impl.hh
index fb3dfec..97ab1cf 100644
--- a/src/mem/cache/compressors/base_delta_impl.hh
+++ b/src/mem/cache/compressors/base_delta_impl.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,8 @@
#include "mem/cache/compressors/base_delta.hh"
#include "mem/cache/compressors/dictionary_compressor_impl.hh"
+namespace Compressor {
+
template <class BaseType, std::size_t DeltaSizeBits>
BaseDelta<BaseType, DeltaSizeBits>::BaseDelta(const Params *p)
: DictionaryCompressor<BaseType>(p)
@@ -64,11 +66,11 @@
}
template <class BaseType, std::size_t DeltaSizeBits>
-std::unique_ptr<BaseCacheCompressor::CompressionData>
+std::unique_ptr<Base::CompressionData>
BaseDelta<BaseType, DeltaSizeBits>::compress(const uint64_t* data,
Cycles& comp_lat, Cycles& decomp_lat)
{
- std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data =
+ std::unique_ptr<Base::CompressionData> comp_data =
DictionaryCompressor<BaseType>::compress(data);
// If there are more bases than the maximum, the compressor failed.
@@ -98,4 +100,6 @@
return comp_data;
}
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_BASE_DELTA_IMPL_HH__
diff --git a/src/mem/cache/compressors/base_dictionary_compressor.cc
b/src/mem/cache/compressors/base_dictionary_compressor.cc
index e454bbd..d6af8ee 100644
--- a/src/mem/cache/compressors/base_dictionary_compressor.cc
+++ b/src/mem/cache/compressors/base_dictionary_compressor.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019 Inria
+ * Copyright (c) 2018-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,15 +34,17 @@
#include "mem/cache/compressors/dictionary_compressor.hh"
#include "params/BaseDictionaryCompressor.hh"
+namespace Compressor {
+
BaseDictionaryCompressor::BaseDictionaryCompressor(const Params *p)
- : BaseCacheCompressor(p), dictionarySize(p->dictionary_size),
numEntries(0)
+ : Base(p), dictionarySize(p->dictionary_size), numEntries(0)
{
}
void
BaseDictionaryCompressor::regStats()
{
- BaseCacheCompressor::regStats();
+ Base::regStats();
// We store the frequency of each pattern
patternStats
@@ -57,3 +59,5 @@
getName(i));
}
}
+
+} // namespace Compressor
diff --git a/src/mem/cache/compressors/cpack.cc
b/src/mem/cache/compressors/cpack.cc
index b99bf62..40e983a 100644
--- a/src/mem/cache/compressors/cpack.cc
+++ b/src/mem/cache/compressors/cpack.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019 Inria
+ * Copyright (c) 2018-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,8 @@
#include "mem/cache/compressors/dictionary_compressor_impl.hh"
#include "params/CPack.hh"
+namespace Compressor {
+
CPack::CPack(const Params *p)
: DictionaryCompressor<uint32_t>(p)
{
@@ -47,10 +49,10 @@
dictionary[numEntries++] = data;
}
-std::unique_ptr<BaseCacheCompressor::CompressionData>
+std::unique_ptr<Base::CompressionData>
CPack::compress(const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat)
{
- std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data =
+ std::unique_ptr<Base::CompressionData> comp_data =
DictionaryCompressor<uint32_t>::compress(data);
// Set compression latency (Accounts for pattern matching, length
@@ -64,8 +66,10 @@
return comp_data;
}
-CPack*
+} // namespace Compressor
+
+Compressor::CPack*
CPackParams::create()
{
- return new CPack(this);
+ return new Compressor::CPack(this);
}
diff --git a/src/mem/cache/compressors/cpack.hh
b/src/mem/cache/compressors/cpack.hh
index a7ffe11..2925b54 100644
--- a/src/mem/cache/compressors/cpack.hh
+++ b/src/mem/cache/compressors/cpack.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019 Inria
+ * Copyright (c) 2018-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,8 @@
struct CPackParams;
+namespace Compressor {
+
class CPack : public DictionaryCompressor<uint32_t>
{
private:
@@ -104,7 +106,7 @@
* @param decomp_lat Decompression latency in number of cycles.
* @return Cache line after compression.
*/
- std::unique_ptr<BaseCacheCompressor::CompressionData> compress(
+ std::unique_ptr<Base::CompressionData> compress(
const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat)
override;
public:
@@ -178,4 +180,6 @@
}
};
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_CPACK_HH__
diff --git a/src/mem/cache/compressors/dictionary_compressor.hh
b/src/mem/cache/compressors/dictionary_compressor.hh
index 06a90cb..fce79d5 100644
--- a/src/mem/cache/compressors/dictionary_compressor.hh
+++ b/src/mem/cache/compressors/dictionary_compressor.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019 Inria
+ * Copyright (c) 2018-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,7 +56,9 @@
struct BaseDictionaryCompressorParams;
-class BaseDictionaryCompressor : public BaseCacheCompressor
+namespace Compressor {
+
+class BaseDictionaryCompressor : public Base
{
protected:
/** Dictionary size. */
@@ -225,8 +227,7 @@
* @param data The cache line to be compressed.
* @return Cache line after compression.
*/
- std::unique_ptr<BaseCacheCompressor::CompressionData> compress(
- const uint64_t* data);
+ std::unique_ptr<Base::CompressionData> compress(const uint64_t* data);
using BaseDictionaryCompressor::compress;
@@ -725,4 +726,6 @@
}
};
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_DICTIONARY_COMPRESSOR_HH__
diff --git a/src/mem/cache/compressors/dictionary_compressor_impl.hh
b/src/mem/cache/compressors/dictionary_compressor_impl.hh
index d771d52..0b486e3 100644
--- a/src/mem/cache/compressors/dictionary_compressor_impl.hh
+++ b/src/mem/cache/compressors/dictionary_compressor_impl.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019 Inria
+ * Copyright (c) 2018-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,8 @@
#include "mem/cache/compressors/dictionary_compressor.hh"
#include "params/BaseDictionaryCompressor.hh"
+namespace Compressor {
+
template <class T>
DictionaryCompressor<T>::CompData::CompData()
: CompressionData()
@@ -113,10 +115,10 @@
}
template <class T>
-std::unique_ptr<BaseCacheCompressor::CompressionData>
+std::unique_ptr<Base::CompressionData>
DictionaryCompressor<T>::compress(const uint64_t* data)
{
- std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data =
+ std::unique_ptr<Base::CompressionData> comp_data =
std::unique_ptr<CompData>(new CompData());
// Reset dictionary
@@ -209,4 +211,6 @@
return value;
}
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_DICTIONARY_COMPRESSOR_IMPL_HH__
diff --git a/src/mem/cache/compressors/fpcd.cc
b/src/mem/cache/compressors/fpcd.cc
index e3529e5..ba46379 100644
--- a/src/mem/cache/compressors/fpcd.cc
+++ b/src/mem/cache/compressors/fpcd.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,8 @@
#include "mem/cache/compressors/dictionary_compressor_impl.hh"
#include "params/FPCD.hh"
+namespace Compressor {
+
FPCD::FPCD(const Params *p)
: DictionaryCompressor<uint32_t>(p)
{
@@ -52,10 +54,10 @@
}
}
-std::unique_ptr<BaseCacheCompressor::CompressionData>
+std::unique_ptr<Base::CompressionData>
FPCD::compress(const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat)
{
- std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data =
+ std::unique_ptr<Base::CompressionData> comp_data =
DictionaryCompressor<uint32_t>::compress(data);
// Set compression latency (Accounts for zero checks, ones check, match
@@ -71,8 +73,10 @@
return comp_data;
}
-FPCD*
+} // namespace Compressor
+
+Compressor::FPCD*
FPCDParams::create()
{
- return new FPCD(this);
+ return new Compressor::FPCD(this);
}
diff --git a/src/mem/cache/compressors/fpcd.hh
b/src/mem/cache/compressors/fpcd.hh
index 61785bc..8aed461 100644
--- a/src/mem/cache/compressors/fpcd.hh
+++ b/src/mem/cache/compressors/fpcd.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,6 +49,8 @@
struct FPCDParams;
+namespace Compressor {
+
class FPCD : public DictionaryCompressor<uint32_t>
{
private:
@@ -137,7 +139,7 @@
void addToDictionary(DictionaryEntry data) override;
- std::unique_ptr<BaseCacheCompressor::CompressionData> compress(
+ std::unique_ptr<Base::CompressionData> compress(
const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat)
override;
public:
@@ -318,4 +320,6 @@
}
};
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_FPCD_HH__
diff --git a/src/mem/cache/compressors/multi.cc
b/src/mem/cache/compressors/multi.cc
index d1e7fbc..f42602e 100644
--- a/src/mem/cache/compressors/multi.cc
+++ b/src/mem/cache/compressors/multi.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,45 +41,47 @@
#include "debug/CacheComp.hh"
#include "params/MultiCompressor.hh"
-MultiCompressor::MultiCompData::MultiCompData(unsigned index,
- std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data)
+namespace Compressor {
+
+Multi::MultiCompData::MultiCompData(unsigned index,
+ std::unique_ptr<Base::CompressionData> comp_data)
: CompressionData(), index(index), compData(std::move(comp_data))
{
setSizeBits(compData->getSizeBits());
}
uint8_t
-MultiCompressor::MultiCompData::getIndex() const
+Multi::MultiCompData::getIndex() const
{
return index;
}
-MultiCompressor::MultiCompressor(const Params *p)
- : BaseCacheCompressor(p), compressors(p->compressors)
+Multi::Multi(const Params *p)
+ : Base(p), compressors(p->compressors)
{
fatal_if(compressors.size() == 0, "There must be at least one
compressor");
}
-MultiCompressor::~MultiCompressor()
+Multi::~Multi()
{
for (auto& compressor : compressors) {
delete compressor;
}
}
-std::unique_ptr<BaseCacheCompressor::CompressionData>
-MultiCompressor::compress(const uint64_t* cache_line, Cycles& comp_lat,
+std::unique_ptr<Base::CompressionData>
+Multi::compress(const uint64_t* cache_line, Cycles& comp_lat,
Cycles& decomp_lat)
{
struct Results
{
unsigned index;
- std::unique_ptr<BaseCacheCompressor::CompressionData> compData;
+ std::unique_ptr<Base::CompressionData> compData;
Cycles decompLat;
uint8_t compressionFactor;
Results(unsigned index,
- std::unique_ptr<BaseCacheCompressor::CompressionData>
comp_data,
+ std::unique_ptr<Base::CompressionData> comp_data,
Cycles decomp_lat, std::size_t blk_size)
: index(index), compData(std::move(comp_data)),
decompLat(decomp_lat)
@@ -147,7 +149,7 @@
}
void
-MultiCompressor::decompress(const CompressionData* comp_data,
+Multi::decompress(const CompressionData* comp_data,
uint64_t* cache_line)
{
const MultiCompData* casted_comp_data =
@@ -157,9 +159,9 @@
}
void
-MultiCompressor::regStats()
+Multi::regStats()
{
- BaseCacheCompressor::regStats();
+ Base::regStats();
rankStats
.init(compressors.size(), compressors.size())
@@ -177,8 +179,10 @@
}
}
-MultiCompressor*
+} // namespace Compressor
+
+Compressor::Multi*
MultiCompressorParams::create()
{
- return new MultiCompressor(this);
+ return new Compressor::Multi(this);
}
diff --git a/src/mem/cache/compressors/multi.hh
b/src/mem/cache/compressors/multi.hh
index 3c96d4d..db4f376 100644
--- a/src/mem/cache/compressors/multi.hh
+++ b/src/mem/cache/compressors/multi.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,9 @@
struct MultiCompressorParams;
-class MultiCompressor : public BaseCacheCompressor
+namespace Compressor {
+
+class Multi : public Base
{
protected:
/**
@@ -53,7 +55,7 @@
class MultiCompData;
/** List of sub-compressors. */
- std::vector<BaseCacheCompressor*> compressors;
+ std::vector<Base*> compressors;
/**
* @defgroup CompressionStats Compression specific statistics.
@@ -68,24 +70,19 @@
*/
public:
- /** Convenience typedef. */
- typedef MultiCompressorParams Params;
-
- /** Default constructor. */
- MultiCompressor(const Params *p);
-
- /** Default destructor. */
- ~MultiCompressor();
+ typedef MultiCompressorParams Params;
+ Multi(const Params *p);
+ ~Multi();
void regStats() override;
- std::unique_ptr<BaseCacheCompressor::CompressionData> compress(
+ std::unique_ptr<Base::CompressionData> compress(
const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat)
override;
void decompress(const CompressionData* comp_data, uint64_t* data)
override;
};
-class MultiCompressor::MultiCompData : public CompressionData
+class Multi::MultiCompData : public CompressionData
{
private:
/** Index of the compressor that provided these compression results. */
@@ -93,7 +90,7 @@
public:
/** Compression data of the best compressor. */
- std::unique_ptr<BaseCacheCompressor::CompressionData> compData;
+ std::unique_ptr<Base::CompressionData> compData;
/**
* Default constructor.
@@ -102,7 +99,7 @@
* @param comp_data Compression data of the best compressor.
*/
MultiCompData(unsigned index,
- std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data);
+ std::unique_ptr<Base::CompressionData> comp_data);
/** Default destructor. */
~MultiCompData() = default;
@@ -111,4 +108,6 @@
uint8_t getIndex() const;
};
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_MULTI_HH__
diff --git a/src/mem/cache/compressors/perfect.cc
b/src/mem/cache/compressors/perfect.cc
index b53e1f9..41a7e6d 100644
--- a/src/mem/cache/compressors/perfect.cc
+++ b/src/mem/cache/compressors/perfect.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,26 +38,28 @@
#include "debug/CacheComp.hh"
#include "params/PerfectCompressor.hh"
-PerfectCompressor::CompData::CompData(const uint64_t* data,
+namespace Compressor {
+
+Perfect::CompData::CompData(const uint64_t* data,
std::size_t num_entries)
: CompressionData(), entries(data, data + num_entries)
{
}
-PerfectCompressor::PerfectCompressor(const Params *p)
- : BaseCacheCompressor(p),
+Perfect::Perfect(const Params *p)
+ : Base(p),
compressedSize(8 * blkSize / p->max_compression_ratio),
compressionLatency(p->compression_latency),
decompressionLatency(p->decompression_latency)
{
}
-std::unique_ptr<BaseCacheCompressor::CompressionData>
-PerfectCompressor::compress(const uint64_t* cache_line, Cycles& comp_lat,
+std::unique_ptr<Base::CompressionData>
+Perfect::compress(const uint64_t* cache_line, Cycles& comp_lat,
Cycles& decomp_lat)
{
// Compress every word sequentially
- std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data(
+ std::unique_ptr<Base::CompressionData> comp_data(
new CompData(cache_line, blkSize/8));
// Set relevant metadata
@@ -69,7 +71,7 @@
}
void
-PerfectCompressor::decompress(const CompressionData* comp_data,
+Perfect::decompress(const CompressionData* comp_data,
uint64_t* data)
{
// Decompress every entry sequentially
@@ -79,8 +81,10 @@
std::copy(entries.begin(), entries.end(), data);
}
-PerfectCompressor*
+} // namespace Compressor
+
+Compressor::Perfect*
PerfectCompressorParams::create()
{
- return new PerfectCompressor(this);
+ return new Compressor::Perfect(this);
}
diff --git a/src/mem/cache/compressors/perfect.hh
b/src/mem/cache/compressors/perfect.hh
index 0ef8d13..e279ec6 100644
--- a/src/mem/cache/compressors/perfect.hh
+++ b/src/mem/cache/compressors/perfect.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,9 @@
struct PerfectCompressorParams;
-class PerfectCompressor : public BaseCacheCompressor
+namespace Compressor {
+
+class Perfect : public Base
{
protected:
class CompData;
@@ -64,11 +66,11 @@
public:
typedef PerfectCompressorParams Params;
- PerfectCompressor(const Params *p);
- ~PerfectCompressor() {};
+ Perfect(const Params *p);
+ ~Perfect() = default;
};
-class PerfectCompressor::CompData : public CompressionData
+class Perfect::CompData : public CompressionData
{
public:
/** The original data is simply copied over to this vector. */
@@ -84,4 +86,6 @@
~CompData() = default;
};
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_PERFECT_COMPRESSOR_HH__
diff --git a/src/mem/cache/compressors/repeated_qwords.cc
b/src/mem/cache/compressors/repeated_qwords.cc
index a51c05f..db19b26 100644
--- a/src/mem/cache/compressors/repeated_qwords.cc
+++ b/src/mem/cache/compressors/repeated_qwords.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,23 +38,25 @@
#include "mem/cache/compressors/dictionary_compressor_impl.hh"
#include "params/RepeatedQwordsCompressor.hh"
-RepeatedQwordsCompressor::RepeatedQwordsCompressor(const Params *p)
+namespace Compressor {
+
+RepeatedQwords::RepeatedQwords(const Params *p)
: DictionaryCompressor<uint64_t>(p)
{
}
void
-RepeatedQwordsCompressor::addToDictionary(DictionaryEntry data)
+RepeatedQwords::addToDictionary(DictionaryEntry data)
{
assert(numEntries < dictionarySize);
dictionary[numEntries++] = data;
}
-std::unique_ptr<BaseCacheCompressor::CompressionData>
-RepeatedQwordsCompressor::compress(const uint64_t* data, Cycles& comp_lat,
+std::unique_ptr<Base::CompressionData>
+RepeatedQwords::compress(const uint64_t* data, Cycles& comp_lat,
Cycles& decomp_lat)
{
- std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data =
+ std::unique_ptr<Base::CompressionData> comp_data =
DictionaryCompressor::compress(data);
// Since there is a single value repeated over and over, there should
be
@@ -75,8 +77,10 @@
return comp_data;
}
-RepeatedQwordsCompressor*
+} // namespace Compressor
+
+Compressor::RepeatedQwords*
RepeatedQwordsCompressorParams::create()
{
- return new RepeatedQwordsCompressor(this);
+ return new Compressor::RepeatedQwords(this);
}
diff --git a/src/mem/cache/compressors/repeated_qwords.hh
b/src/mem/cache/compressors/repeated_qwords.hh
index 3af63dc..c361900 100644
--- a/src/mem/cache/compressors/repeated_qwords.hh
+++ b/src/mem/cache/compressors/repeated_qwords.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,9 @@
struct RepeatedQwordsCompressorParams;
-class RepeatedQwordsCompressor : public DictionaryCompressor<uint64_t>
+namespace Compressor {
+
+class RepeatedQwords : public DictionaryCompressor<uint64_t>
{
protected:
using DictionaryEntry =
DictionaryCompressor<uint64_t>::DictionaryEntry;
@@ -89,16 +91,16 @@
void addToDictionary(DictionaryEntry data) override;
- std::unique_ptr<BaseCacheCompressor::CompressionData> compress(
+ std::unique_ptr<Base::CompressionData> compress(
const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat)
override;
public:
typedef RepeatedQwordsCompressorParams Params;
- RepeatedQwordsCompressor(const Params *p);
- ~RepeatedQwordsCompressor() = default;
+ RepeatedQwords(const Params *p);
+ ~RepeatedQwords() = default;
};
-class RepeatedQwordsCompressor::PatternX
+class RepeatedQwords::PatternX
: public DictionaryCompressor::UncompressedPattern
{
public:
@@ -108,7 +110,7 @@
}
};
-class RepeatedQwordsCompressor::PatternM
+class RepeatedQwords::PatternM
: public
DictionaryCompressor::LocatedMaskedPattern<0xFFFFFFFFFFFFFFFF, 0>
{
public:
@@ -119,4 +121,6 @@
}
};
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_REPEATED_QWORDS_HH__
diff --git a/src/mem/cache/compressors/zero.cc
b/src/mem/cache/compressors/zero.cc
index 45675e6..db80679 100644
--- a/src/mem/cache/compressors/zero.cc
+++ b/src/mem/cache/compressors/zero.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,23 +38,25 @@
#include "mem/cache/compressors/dictionary_compressor_impl.hh"
#include "params/ZeroCompressor.hh"
-ZeroCompressor::ZeroCompressor(const Params *p)
+namespace Compressor {
+
+Zero::Zero(const Params *p)
: DictionaryCompressor<uint64_t>(p)
{
}
void
-ZeroCompressor::addToDictionary(DictionaryEntry data)
+Zero::addToDictionary(DictionaryEntry data)
{
assert(numEntries < dictionarySize);
dictionary[numEntries++] = data;
}
-std::unique_ptr<BaseCacheCompressor::CompressionData>
-ZeroCompressor::compress(const uint64_t* data, Cycles& comp_lat,
+std::unique_ptr<Base::CompressionData>
+Zero::compress(const uint64_t* data, Cycles& comp_lat,
Cycles& decomp_lat)
{
- std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data =
+ std::unique_ptr<Base::CompressionData> comp_data =
DictionaryCompressor::compress(data);
// If there is any non-zero entry, the compressor failed
@@ -73,8 +75,10 @@
return comp_data;
}
-ZeroCompressor*
+} // namespace Compressor
+
+Compressor::Zero*
ZeroCompressorParams::create()
{
- return new ZeroCompressor(this);
+ return new Compressor::Zero(this);
}
diff --git a/src/mem/cache/compressors/zero.hh
b/src/mem/cache/compressors/zero.hh
index dd9ca06..f45a639 100644
--- a/src/mem/cache/compressors/zero.hh
+++ b/src/mem/cache/compressors/zero.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Inria
+ * Copyright (c) 2019-2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,9 @@
struct ZeroCompressorParams;
-class ZeroCompressor : public DictionaryCompressor<uint64_t>
+namespace Compressor {
+
+class Zero : public DictionaryCompressor<uint64_t>
{
protected:
using DictionaryEntry =
DictionaryCompressor<uint64_t>::DictionaryEntry;
@@ -89,16 +91,16 @@
void addToDictionary(DictionaryEntry data) override;
- std::unique_ptr<BaseCacheCompressor::CompressionData> compress(
+ std::unique_ptr<Base::CompressionData> compress(
const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat)
override;
public:
typedef ZeroCompressorParams Params;
- ZeroCompressor(const Params *p);
- ~ZeroCompressor() = default;
+ Zero(const Params *p);
+ ~Zero() = default;
};
-class ZeroCompressor::PatternX
+class Zero::PatternX
: public DictionaryCompressor::UncompressedPattern
{
public:
@@ -109,7 +111,7 @@
}
};
-class ZeroCompressor::PatternZ
+class Zero::PatternZ
: public DictionaryCompressor::MaskedValuePattern<0,
0xFFFFFFFFFFFFFFFF>
{
public:
@@ -120,4 +122,6 @@
}
};
+} // namespace Compressor
+
#endif //__MEM_CACHE_COMPRESSORS_ZERO_HH__
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/33294
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I78cb3b6fb8e3e50a52a04268e0e08dd664d81230
Gerrit-Change-Number: 33294
Gerrit-PatchSet: 2
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s