mem-ruby: Fix MultiGrainBloomFilter accessing
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Wed, 8 May 2019 20:18:27 +0000 (22:18 +0200)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Sat, 6 Jul 2019 22:55:32 +0000 (22:55 +0000)
When accessing the page filter the page hash should be used
instead of the hash of the base filter.

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

index d91eb7fd0e51f805005d55a6a5f2a0a0a1bf9a20..150e0a561274de84864103d2023c3e2596fa8b72 100644 (file)
@@ -54,21 +54,23 @@ MultiGrainBloomFilter::clear()
 void
 MultiGrainBloomFilter::set(Addr addr)
 {
-    int i = hash(addr);
-    assert(i < filter.size());
-    assert(pageHash(addr) < pageFilter.size());
-    filter[i] = 1;
-    pageFilter[i] = 1;
+    const int index = hash(addr);
+    assert(index < filter.size());
+    filter[index] = 1;
 
+    const int page_index = pageHash(addr);
+    assert(page_index < pageFilter.size());
+    pageFilter[page_index] = 1;
 }
 
 int
 MultiGrainBloomFilter::getCount(Addr addr) const
 {
-    int i = hash(addr);
-    assert(i < filter.size());
-    assert(pageHash(addr) < pageFilter.size());
-    return filter[i] + pageFilter[i];
+    const int index = hash(addr);
+    const int page_index = pageHash(addr);
+    assert(index < filter.size());
+    assert(page_index < pageFilter.size());
+    return filter[index] + pageFilter[page_index];
 }
 
 int