mem-ruby: Parameterize block size in Bloom Filters

Substitute all occurrences of Ruby's block size by a
Python configurable offset.

Change-Id: If4913e842921447deda943b0482fb0c78a44c275
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18737
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Daniel R. Carvalho
2019-05-07 08:51:06 +02:00
committed by Daniel Carvalho
parent aa1b00ee89
commit 24ff97e0d7
9 changed files with 34 additions and 44 deletions

View File

@@ -42,6 +42,9 @@
class AbstractBloomFilter : public SimObject
{
protected:
/** Number of LSB bits to ignore from the the addresses. */
const unsigned offsetBits;
/** The filter itself. */
std::vector<int> filter;
@@ -56,8 +59,8 @@ class AbstractBloomFilter : public SimObject
* Create and clear the filter.
*/
AbstractBloomFilter(const AbstractBloomFilterParams* p)
: SimObject(p), filter(p->size), sizeBits(floorLog2(p->size)),
setThreshold(p->threshold)
: SimObject(p), offsetBits(p->offset_bits), filter(p->size),
sizeBits(floorLog2(p->size)), setThreshold(p->threshold)
{
clear();
}

View File

@@ -29,7 +29,6 @@
#include "mem/ruby/filters/BlockBloomFilter.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/system/RubySystem.hh"
#include "params/BlockBloomFilter.hh"
BlockBloomFilter::BlockBloomFilter(const BlockBloomFilterParams* p)
@@ -65,13 +64,10 @@ BlockBloomFilter::hash(Addr addr) const
// Pull out some bit field ==> B1
// Pull out additional bits, not the same as B1 ==> B2
// XOR B1 and B2 to get hash index
Addr block_bits = bitSelect(addr, RubySystem::getBlockSizeBits(),
2 * RubySystem::getBlockSizeBits() - 1);
Addr block_bits = bitSelect(addr, offsetBits, 2 * offsetBits - 1);
int offset = 5;
Addr other_bits = bitSelect(addr,
2 * RubySystem::getBlockSizeBits() + offset,
2 * RubySystem::getBlockSizeBits() + offset +
sizeBits - 1);
Addr other_bits = bitSelect(addr, 2 * offsetBits + offset,
2 * offsetBits + offset + sizeBits - 1);
int index = block_bits ^ other_bits;
assert(index < filter.size());
return index;

View File

@@ -37,6 +37,9 @@ class AbstractBloomFilter(SimObject):
size = Param.Int(4096, "Number of entries in the filter")
# By default assume that bloom filters are used for 64-byte cache lines
offset_bits = Param.Unsigned(6, "Number of bits in a cache line offset")
# Most of the filters are booleans, and thus saturate on 1
threshold = Param.Int(1, "Value at which an entry is considered as set")

View File

@@ -29,7 +29,6 @@
#include "mem/ruby/filters/BulkBloomFilter.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/system/RubySystem.hh"
#include "params/BulkBloomFilter.hh"
BulkBloomFilter::BulkBloomFilter(const BulkBloomFilterParams* p)
@@ -46,12 +45,11 @@ BulkBloomFilter::set(Addr addr)
{
// c0 contains the cache index bits
int set_bits = sectorBits;
int block_bits = RubySystem::getBlockSizeBits();
int c0 = bitSelect(addr, block_bits, block_bits + set_bits - 1);
int c0 = bitSelect(addr, offsetBits, offsetBits + set_bits - 1);
// c1 contains the lower sectorBits permuted bits
//Address permuted_bits = permute(addr);
//int c1 = permuted_bits.bitSelect(0, set_bits-1);
int c1 = bitSelect(addr, block_bits+set_bits, (block_bits+2*set_bits) - 1);
int c1 = bitSelect(addr, offsetBits+set_bits, (offsetBits+2*set_bits) - 1);
//assert(c0 < (filter_size/2));
//assert(c0 + (filter_size/2) < filter_size);
//assert(c1 < (filter_size/2));
@@ -67,12 +65,11 @@ BulkBloomFilter::isSet(Addr addr) const
// c0 contains the cache index bits
const int filter_size = filter.size();
int set_bits = sectorBits;
int block_bits = RubySystem::getBlockSizeBits();
int c0 = bitSelect(addr, block_bits, block_bits + set_bits - 1);
int c0 = bitSelect(addr, offsetBits, offsetBits + set_bits - 1);
// c1 contains the lower 10 permuted bits
//Address permuted_bits = permute(addr);
//int c1 = permuted_bits.bitSelect(0, set_bits-1);
int c1 = bitSelect(addr, block_bits+set_bits, (block_bits+2*set_bits) - 1);
int c1 = bitSelect(addr, offsetBits+set_bits, (offsetBits+2*set_bits) - 1);
//assert(c0 < (filter_size/2));
//assert(c0 + (filter_size/2) < filter_size);
//assert(c1 < (filter_size/2));
@@ -130,18 +127,17 @@ Addr
BulkBloomFilter::hash(Addr addr) const
{
// permutes the original address bits according to Table 5
int block_offset = RubySystem::getBlockSizeBits();
Addr part1 = bitSelect(addr, block_offset, block_offset + 6),
part2 = bitSelect(addr, block_offset + 9, block_offset + 9),
part3 = bitSelect(addr, block_offset + 11, block_offset + 11),
part4 = bitSelect(addr, block_offset + 17, block_offset + 17),
part5 = bitSelect(addr, block_offset + 7, block_offset + 8),
part6 = bitSelect(addr, block_offset + 10, block_offset + 10),
part7 = bitSelect(addr, block_offset + 12, block_offset + 12),
part8 = bitSelect(addr, block_offset + 13, block_offset + 13),
part9 = bitSelect(addr, block_offset + 15, block_offset + 16),
part10 = bitSelect(addr, block_offset + 18, block_offset + 20),
part11 = bitSelect(addr, block_offset + 14, block_offset + 14);
Addr part1 = bitSelect(addr, offsetBits, offsetBits + 6),
part2 = bitSelect(addr, offsetBits + 9, offsetBits + 9),
part3 = bitSelect(addr, offsetBits + 11, offsetBits + 11),
part4 = bitSelect(addr, offsetBits + 17, offsetBits + 17),
part5 = bitSelect(addr, offsetBits + 7, offsetBits + 8),
part6 = bitSelect(addr, offsetBits + 10, offsetBits + 10),
part7 = bitSelect(addr, offsetBits + 12, offsetBits + 12),
part8 = bitSelect(addr, offsetBits + 13, offsetBits + 13),
part9 = bitSelect(addr, offsetBits + 15, offsetBits + 16),
part10 = bitSelect(addr, offsetBits + 18, offsetBits + 20),
part11 = bitSelect(addr, offsetBits + 14, offsetBits + 14);
Addr result =
(part1 << 14) | (part2 << 13) | (part3 << 12) | (part4 << 11) |
@@ -151,7 +147,7 @@ BulkBloomFilter::hash(Addr addr) const
// assume 32 bit addresses (both virtual and physical)
// select the remaining high-order 11 bits
Addr remaining_bits =
bitSelect(addr, block_offset + 21, 31) << 21;
bitSelect(addr, offsetBits + 21, 31) << 21;
result = result | remaining_bits;
return result;

View File

@@ -396,7 +396,7 @@ H3BloomFilter::getCount(Addr addr) const
int
H3BloomFilter::hash(Addr addr, int hash_number) const
{
uint64_t x = makeLineAddress(addr);
uint64_t x = maskLowOrderBits(addr, offsetBits);
int y = hashH3(x, hash_number);
if (isParallel) {

View File

@@ -29,7 +29,6 @@
#include "mem/ruby/filters/LSB_CountingBloomFilter.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/system/RubySystem.hh"
#include "params/LSB_CountingBloomFilter.hh"
LSB_CountingBloomFilter::LSB_CountingBloomFilter(
@@ -67,9 +66,7 @@ LSB_CountingBloomFilter::getCount(Addr addr) const
int
LSB_CountingBloomFilter::hash(Addr addr) const
{
return bitSelect(addr, RubySystem::getBlockSizeBits(),
RubySystem::getBlockSizeBits() +
sizeBits - 1);
return bitSelect(addr, offsetBits, offsetBits + sizeBits - 1);
}
LSB_CountingBloomFilter*

View File

@@ -76,7 +76,7 @@ MultiBitSelBloomFilter::getCount(Addr addr) const
int
MultiBitSelBloomFilter::hash(Addr addr, int hash_number) const
{
uint64_t x = (makeLineAddress(addr) >> skipBits);
uint64_t x = (maskLowOrderBits(addr, offsetBits) >> skipBits);
int y = hashBitsel(x, hash_number, numHashes, 30, sizeBits);
//36-bit addresses, 6-bit cache lines

View File

@@ -29,7 +29,6 @@
#include "mem/ruby/filters/MultiGrainBloomFilter.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/system/RubySystem.hh"
#include "params/MultiGrainBloomFilter.hh"
MultiGrainBloomFilter::MultiGrainBloomFilter(
@@ -88,15 +87,13 @@ int
MultiGrainBloomFilter::hash(Addr addr) const
{
// grap a chunk of bits after byte offset
return bitSelect(addr, RubySystem::getBlockSizeBits(),
RubySystem::getBlockSizeBits() +
sizeBits - 1);
return bitSelect(addr, offsetBits, offsetBits + sizeBits - 1);
}
int
MultiGrainBloomFilter::pageHash(Addr addr) const
{
int bits = RubySystem::getBlockSizeBits() + sizeBits - 1;
int bits = offsetBits + sizeBits - 1;
// grap a chunk of bits after first chunk
return bitSelect(addr, bits, bits + pageFilterSizeBits - 1);

View File

@@ -29,7 +29,6 @@
#include "mem/ruby/filters/NonCountingBloomFilter.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/system/RubySystem.hh"
#include "params/NonCountingBloomFilter.hh"
NonCountingBloomFilter::NonCountingBloomFilter(
@@ -73,9 +72,8 @@ NonCountingBloomFilter::getCount(Addr addr) const
int
NonCountingBloomFilter::hash(Addr addr) const
{
return bitSelect(addr, RubySystem::getBlockSizeBits() + skipBits,
RubySystem::getBlockSizeBits() + skipBits +
sizeBits - 1);
return bitSelect(addr, offsetBits + skipBits,
offsetBits + skipBits + sizeBits - 1);
}
NonCountingBloomFilter*