Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/36579 )
Change subject: mem-cache: Add data expansion and compaction checking
functions
......................................................................
mem-cache: Add data expansion and compaction checking functions
Data expansion and compaction are determined according to the compaction
method being used. Therefore, do the verification on the blocks instead
of the cache.
Change-Id: I652418a5f4c6d5b946a9925d6287a995f262f02a
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/mem/cache/base.cc
M src/mem/cache/tags/super_blk.cc
M src/mem/cache/tags/super_blk.hh
3 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index 39f06b8..2e43c6c 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -849,10 +849,6 @@
compressor->compress(data, compression_lat, decompression_lat);
std::size_t compression_size = comp_data->getSizeBits();
- // If block's compression factor increased, it may not be
co-allocatable
- // anymore. If so, some blocks might need to be evicted to make room
for
- // the bigger block
-
// Get previous compressed size
CompressionBlk* compression_blk = static_cast<CompressionBlk*>(blk);
M5_VAR_USED const std::size_t prev_size =
compression_blk->getSizeBits();
@@ -867,16 +863,17 @@
// there is nothing to do. Otherwise we may be facing a data expansion
// (block passing from more compressed to less compressed state), or a
// data contraction (less to more).
- const bool was_compressed = compression_blk->isCompressed();
bool is_data_expansion = false;
bool is_data_contraction = false;
+ const int size_change =
+ compression_blk->checkExpansionContraction(compression_size);
string op_name = "";
- if (was_compressed && !is_co_allocatable) {
- is_data_expansion = true;
+ if (size_change == 1) {
op_name = "expansion";
- } else if (moveContractions && !was_compressed && is_co_allocatable) {
- is_data_contraction = true;
+ is_data_expansion = true;
+ } else if ((size_change == -1) && moveContractions) {
op_name = "contraction";
+ is_data_contraction = true;
}
// If block changed compression state, it was possibly co-allocated
with
diff --git a/src/mem/cache/tags/super_blk.cc
b/src/mem/cache/tags/super_blk.cc
index a6d8afb..0f3cc3a 100644
--- a/src/mem/cache/tags/super_blk.cc
+++ b/src/mem/cache/tags/super_blk.cc
@@ -114,6 +114,21 @@
setUncompressed();
}
+int
+CompressionBlk::checkExpansionContraction(const std::size_t size) const
+{
+ // @todo As of now only two states are supported: compressed to its
+ // maximum compression, and uncompressed. Support for intermediate
+ // states (e.g., if MaxCR=4, 2/4 and 3/4 of the blkSize) should be
added
+ const SuperBlk* superblock =
+ static_cast<const SuperBlk*>(getSectorBlock());
+ const bool prev_compressed = isCompressed();
+ const bool new_compressed = superblock->canCoAllocate(size);
+ // Expansion: 1. Contraction: -1. Same size: 0.
+ return (prev_compressed == new_compressed) ? 0 :
+ ((prev_compressed & !new_compressed) ? 1 : -1);
+}
+
std::string
CompressionBlk::print() const
{
diff --git a/src/mem/cache/tags/super_blk.hh
b/src/mem/cache/tags/super_blk.hh
index d7abe18..6c7c727 100644
--- a/src/mem/cache/tags/super_blk.hh
+++ b/src/mem/cache/tags/super_blk.hh
@@ -126,6 +126,19 @@
void invalidate() override;
/**
+ * Determines if changing the size of the block will cause a data
+ * expansion (new size is bigger) or contraction (new size is smaller).
+ * Sizes are not necessarily compared at at bit granularities (e.g., 20
+ * bits is considered equal to 23 bits when blocks use 32-bit spaces as
+ * minimum allocation units).
+ *
+ * @param size The new compressed size.
+ * @return Type of size change, if any. -1 indicates data contraction,
+ * 1 means data expansion, and 0 means they are equal.
+ */
+ int checkExpansionContraction(const std::size_t size) const;
+
+ /**
* Pretty-print sector offset and other CacheBlk information.
*
* @return string with basic state information
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/36579
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: I652418a5f4c6d5b946a9925d6287a995f262f02a
Gerrit-Change-Number: 36579
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s