Not all Bloom Filters had their union functionality implemented.
This change adds them.
Change-Id: I86af18d3c5eabd0da8280b57a88789b3af803c04
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18872
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
}
}
- /** Merges the contents of both filters into this'. */
- virtual void merge(const AbstractBloomFilter* other) {}
+ /**
+ * Merges the contents of both filters into this' (Bloom Filter union).
+ * Both must have the same number of entries.
+ *
+ * @param other The other bloom filter to merge with.
+ */
+ virtual void
+ merge(const AbstractBloomFilter* other)
+ {
+ assert(filter.size() == other->filter.size());
+ for (int i = 0; i < filter.size(); ++i){
+ filter[i] |= other->filter[i];
+ }
+ }
/**
* Perform the filter specific function to set the corresponding
{
}
-void
-H3BloomFilter::merge(const AbstractBloomFilter *other)
-{
- auto* cast_other = static_cast<const H3BloomFilter*>(other);
- assert(filter.size() == cast_other->filter.size());
- for (int i = 0; i < filter.size(); ++i){
- filter[i] |= cast_other->filter[i];
- }
-}
-
void
H3BloomFilter::set(Addr addr)
{
H3BloomFilter(const H3BloomFilterParams* p);
~H3BloomFilter();
- void merge(const AbstractBloomFilter* other) override;
void set(Addr addr) override;
int getCount(Addr addr) const override;
{
}
+void
+LSB_CountingBloomFilter::merge(const AbstractBloomFilter* other)
+{
+ auto* cast_other = static_cast<const LSB_CountingBloomFilter*>(other);
+ assert(filter.size() == cast_other->filter.size());
+ for (int i = 0; i < filter.size(); ++i){
+ if (filter[i] < maxValue - cast_other->filter[i]) {
+ filter[i] += cast_other->filter[i];
+ } else {
+ filter[i] = maxValue;
+ }
+ }
+}
+
void
LSB_CountingBloomFilter::set(Addr addr)
{
LSB_CountingBloomFilter(const LSB_CountingBloomFilterParams* p);
~LSB_CountingBloomFilter();
+ void merge(const AbstractBloomFilter* other) override;
void set(Addr addr) override;
void unset(Addr addr) override;
{
}
-void
-MultiBitSelBloomFilter::merge(const AbstractBloomFilter *other)
-{
- auto cast_other = static_cast<const MultiBitSelBloomFilter*>(other);
- assert(filter.size() == cast_other->filter.size());
- for (int i = 0; i < filter.size(); ++i){
- filter[i] |= cast_other->filter[i];
- }
-}
-
void
MultiBitSelBloomFilter::set(Addr addr)
{
MultiBitSelBloomFilter(const MultiBitSelBloomFilterParams* p);
~MultiBitSelBloomFilter();
- void merge(const AbstractBloomFilter* other) override;
void set(Addr addr) override;
int getCount(Addr addr) const override;