mem-cache: Generate error on compression misconfiguration
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Mon, 21 Dec 2020 01:15:23 +0000 (22:15 -0300)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Tue, 22 Dec 2020 16:03:34 +0000 (16:03 +0000)
Compressed caches must use the compressed tags, otherwise a
seg fault will be generated. Besides, if no compressor is
assigned; yet compressed tags are used, data is not compressed.

Generate an error for the first case, and a warning for the
second.

Change-Id: Iac5474ed919163ce38a8c4e8efd9727e5b3d8417
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38635
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/mem/cache/base.cc

index 5fc3456642810bd30ff1bc05833994cc8a097487..3181a0c1b3068d1cec256b0665cf501bceff193f 100644 (file)
@@ -56,6 +56,7 @@
 #include "mem/cache/mshr.hh"
 #include "mem/cache/prefetch/base.hh"
 #include "mem/cache/queue_entry.hh"
+#include "mem/cache/tags/compressed_tags.hh"
 #include "mem/cache/tags/super_blk.hh"
 #include "params/BaseCache.hh"
 #include "params/WriteAllocator.hh"
@@ -123,6 +124,12 @@ BaseCache::BaseCache(const BaseCacheParams &p, unsigned blk_size)
     tags->tagsInit();
     if (prefetcher)
         prefetcher->setCache(this);
+
+    fatal_if(compressor && !dynamic_cast<CompressedTags*>(tags),
+        "The tags of compressed cache %s must derive from CompressedTags",
+        name());
+    warn_if(!compressor && dynamic_cast<CompressedTags*>(tags),
+        "Compressed cache %s does not have a compression algorithm", name());
     if (compressor)
         compressor->setCache(this);
 }