masks_sizes = VectorParam.Unsigned([Self.offset_bits, Self.offset_bits],
"Size, in number of bits, of each mask")
-class BloomFilterBulk(BloomFilterBase):
- type = 'BloomFilterBulk'
- cxx_class = 'BloomFilter::Bulk'
- cxx_header = "base/filters/bulk_bloom_filter.hh"
-
class BloomFilterLSBCounting(BloomFilterBase):
type = 'BloomFilterLSBCounting'
cxx_class = 'BloomFilter::LSBCounting'
skip_bits = Param.Int(2, "Offset from block number")
is_parallel = Param.Bool(False, "Whether hashing is done in parallel")
+class BloomFilterBulk(BloomFilterMultiBitSel):
+ type = 'BloomFilterBulk'
+ cxx_class = 'BloomFilter::Bulk'
+ cxx_header = "base/filters/bulk_bloom_filter.hh"
+
class BloomFilterH3(BloomFilterMultiBitSel):
type = 'BloomFilterH3'
cxx_class = 'BloomFilter::H3'
#include "base/filters/bulk_bloom_filter.hh"
-#include <vector>
-
#include <limits>
#include "base/bitfield.hh"
+#include "base/logging.hh"
#include "params/BloomFilterBulk.hh"
namespace BloomFilter {
Bulk::Bulk(const BloomFilterBulkParams* p)
- : Base(p), sectorBits(sizeBits - 1)
+ : MultiBitSel(p), sectorBits(floorLog2(parFilterSize))
{
+ fatal_if((numHashes * sectorBits) >
+ (std::numeric_limits<Addr>::digits - offsetBits),
+ "Sectors need more bits than available");
}
Bulk::~Bulk()
{
}
-void
-Bulk::set(Addr addr)
+int
+Bulk::hash(Addr addr, int hash_number) const
{
- // c0 contains the cache index bits
- int c0 = bits(addr, offsetBits + sectorBits - 1, offsetBits);
- // c1 contains the lower sectorBits permuted bits
- //Address permuted_bits = permute(addr);
- int c1 = bits(addr, (offsetBits + 2 * sectorBits) - 1,
- offsetBits + sectorBits);
- //assert(c0 < (filter_size/2));
- //assert(c0 + (filter_size/2) < filter_size);
- //assert(c1 < (filter_size/2));
- // set v0 bit
- filter[c0 + (filter.size()/2)] = 1;
- // set v1 bit
- filter[c1] = 1;
-}
+ addr = permute(addr);
-bool
-Bulk::isSet(Addr addr) const
-{
- // c0 contains the cache index bits
- const int filter_size = filter.size();
- int c0 = bits(addr, offsetBits + sectorBits - 1, offsetBits);
- // c1 contains the lower 10 permuted bits
- //Address permuted_bits = permute(addr);
- int c1 = bits(addr, (offsetBits + 2 * sectorBits) - 1,
- offsetBits + sectorBits);
- //assert(c0 < (filter_size/2));
- //assert(c0 + (filter_size/2) < filter_size);
- //assert(c1 < (filter_size/2));
- // set v0 bit
- std::vector<int> temp_filter(filter.size(), 0);
- temp_filter[c0 + (filter_size/2)] = 1;
- // set v1 bit
- temp_filter[c1] = 1;
-
- // perform filter intersection. If any c part is 0, no possibility
- // of address being in signature. get first c intersection part
- bool zero = false;
- for (int i = 0; i < filter_size/2; ++i){
- // get intersection of signatures
- temp_filter[i] = temp_filter[i] && filter[i];
- zero = zero || temp_filter[i];
- }
- zero = !zero;
- if (zero) {
- // one section is zero, no possiblility of address in signature
- // reset bits we just set
- temp_filter[c0 + (filter_size / 2)] = 0;
- temp_filter[c1] = 0;
- return false;
- }
-
- // check second section
- zero = false;
- for (int i = filter_size / 2; i < filter_size; ++i) {
- // get intersection of signatures
- temp_filter[i] = temp_filter[i] && filter[i];
- zero = zero || temp_filter[i];
- }
- zero = !zero;
- if (zero) {
- // one section is zero, no possiblility of address in signature
- temp_filter[c0 + (filter_size / 2)] = 0;
- temp_filter[c1] = 0;
- return false;
- }
- // one section has at least one bit set
- temp_filter[c0 + (filter_size / 2)] = 0;
- temp_filter[c1] = 0;
- return true;
-}
+ // Get the sector-based c index
+ int c = bits(addr, (offsetBits + (hash_number + 1) * sectorBits) - 1,
+ offsetBits + hash_number * sectorBits);
+ assert(c < filter.size()/numHashes);
-int
-Bulk::getCount(Addr addr) const
-{
- // TODO as in the multi-hashed filters
- return 0;
+ // Transform the sector-based c index into a filder index (v)
+ c += (numHashes - 1 - hash_number) * (filter.size()/numHashes);
+ assert(c < filter.size());
+
+ return c;
}
Addr
-Bulk::hash(Addr addr) const
+Bulk::permute(Addr addr) const
{
// permutes the original address bits according to Table 5
Addr part1 = bits(addr, offsetBits + 6, offsetBits),
#ifndef __BASE_FILTERS_BULK_BLOOM_FILTER_HH__
#define __BASE_FILTERS_BULK_BLOOM_FILTER_HH__
-#include "base/filters/base.hh"
+#include "base/filters/multi_bit_sel_bloom_filter.hh"
struct BloomFilterBulkParams;
/**
* Implementation of the bloom filter, as described in "Bulk Disambiguation of
* Speculative Threads in Multiprocessors", by Ceze, Luis, et al.
+ * The number of hashes indicates the number of c bitfields.
*/
-class Bulk : public Base
+class Bulk : public MultiBitSel
{
public:
Bulk(const BloomFilterBulkParams* p);
~Bulk();
- void set(Addr addr) override;
-
- bool isSet(Addr addr) const override;
- int getCount(Addr addr) const override;
+ protected:
+ int hash(Addr addr, int hash_number) const override;
private:
/** Permutes the address to generate its signature. */
- Addr hash(Addr addr) const;
+ Addr permute(Addr addr) const;
- // split the filter bits in half, c0 and c1
+ /**
+ * Number of bits used per sector. The filter is split into sectors,
+ * each of which with its own hash function. When an address is hashed
+ * all sectors are parsed to generate c indexes. These indexes are then
+ * used to find the respective v indexes in the main filter.
+ */
const int sectorBits;
};