mem-ruby: Replace string parameter in MultiBitSelBloomFilter
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Mon, 6 May 2019 16:23:34 +0000 (18:23 +0200)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Sun, 12 May 2019 17:22:01 +0000 (17:22 +0000)
Replace string parameter from MultiBitSelBloomFilter's constructor
by their tokenized counterparts.

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

index e2ca4d08c94c16209cf465cd6854a97a96dd8e36..cee28db04eda63e4880590f86ad90a3f8382d16b 100644 (file)
 
 #include "base/intmath.hh"
 #include "base/logging.hh"
-#include "base/str.hh"
 
 using namespace std;
 
-MultiBitSelBloomFilter::MultiBitSelBloomFilter(string str)
+MultiBitSelBloomFilter::MultiBitSelBloomFilter(std::size_t filter_size,
+    int num_hashes, int skip_bits, bool is_parallel)
+    : m_filter_size(filter_size), m_num_hashes(num_hashes),
+      m_filter_size_bits(floorLog2(m_filter_size)), m_skip_bits(skip_bits),
+      m_par_filter_size(m_filter_size / m_num_hashes),
+      m_par_filter_size_bits(floorLog2(m_par_filter_size)),
+      isParallel(is_parallel)
 {
-    vector<string> items;
-    tokenize(items, str, '_');
-    assert(items.size() == 4);
-
-    // head contains filter size, tail contains bit offset from block number
-    m_filter_size = atoi(items[0].c_str());
-    m_num_hashes = atoi(items[1].c_str());
-    m_skip_bits = atoi(items[2].c_str());
-
-    if (items[3] == "Regular") {
-        isParallel = false;
-    } else if (items[3] == "Parallel") {
-        isParallel = true;
-    } else {
-        panic("ERROR: Incorrect config string for MultiBitSel Bloom! :%s",
-              str);
-    }
-
-    m_filter_size_bits = floorLog2(m_filter_size);
-
-    m_par_filter_size = m_filter_size / m_num_hashes;
-    m_par_filter_size_bits = floorLog2(m_par_filter_size);
-
     m_filter.resize(m_filter_size);
     clear();
 }
index b4fac06710901b48e3462b29c2e1cb38d6c12d06..23d970a2e9ccdd94b858fe350502fa3ae726c98c 100644 (file)
@@ -30,7 +30,6 @@
 #define __MEM_RUBY_FILTERS_MULTIBITSELBLOOMFILTER_HH__
 
 #include <iostream>
-#include <string>
 #include <vector>
 
 #include "mem/ruby/common/Address.hh"
@@ -40,7 +39,8 @@
 class MultiBitSelBloomFilter : public AbstractBloomFilter
 {
   public:
-    MultiBitSelBloomFilter(std::string config);
+    MultiBitSelBloomFilter(std::size_t filter_size, int num_hashes,
+                           int skip_bits, bool is_parallel);
     ~MultiBitSelBloomFilter();
 
     void clear();
@@ -75,6 +75,7 @@ class MultiBitSelBloomFilter : public AbstractBloomFilter
     int m_filter_size;
     int m_num_hashes;
     int m_filter_size_bits;
+    // Bit offset from block number
     int m_skip_bits;
 
     int m_par_filter_size;