gem5  v21.2.0.0
base.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Inria
3  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef __BASE_FILTERS_BASE_HH__
31 #define __BASE_FILTERS_BASE_HH__
32 
33 #include <vector>
34 
35 #include "base/compiler.hh"
36 #include "base/intmath.hh"
37 #include "base/sat_counter.hh"
38 #include "base/types.hh"
39 #include "params/BloomFilterBase.hh"
40 #include "sim/sim_object.hh"
41 
42 namespace gem5
43 {
44 
45 GEM5_DEPRECATED_NAMESPACE(BloomFilter, bloom_filter);
46 namespace bloom_filter
47 {
48 
49 class Base : public SimObject
50 {
51  protected:
53  const unsigned offsetBits;
54 
57 
59  const int sizeBits;
60 
62  const int setThreshold;
63 
64  public:
68  Base(const BloomFilterBaseParams &p)
69  : SimObject(p), offsetBits(p.offset_bits),
70  filter(p.size, SatCounter8(p.num_bits)),
71  sizeBits(floorLog2(p.size)), setThreshold(p.threshold)
72  {
73  clear();
74  }
75  virtual ~Base() {};
76 
80  virtual void clear()
81  {
82  for (auto& entry : filter) {
83  entry.reset();
84  }
85  }
86 
93  virtual void
94  merge(const Base* other)
95  {
96  assert(filter.size() == other->filter.size());
97  for (int i = 0; i < filter.size(); ++i){
98  filter[i] += other->filter[i];
99  }
100  }
101 
108  virtual void set(Addr addr) = 0;
109 
117  virtual void unset(Addr addr) {};
118 
126  virtual bool
127  isSet(Addr addr) const
128  {
129  return getCount(addr) >= setThreshold;
130  }
131 
138  virtual int getCount(Addr addr) const { return 0; }
139 
145  virtual int getTotalCount() const
146  {
147  int count = 0;
148  for (const auto& entry : filter) {
149  count += entry;
150  }
151  return count;
152  }
153 };
154 
155 } // namespace bloom_filter
156 } // namespace gem5
157 
158 #endif // __BASE_FILTERS_BASE_HH__
gem5::bloom_filter::Base::filter
std::vector< SatCounter8 > filter
The filter itself.
Definition: base.hh:56
gem5::bloom_filter::Base::getTotalCount
virtual int getTotalCount() const
Get the total value stored in the filter entries.
Definition: base.hh:145
gem5::bloom_filter::Base
Definition: base.hh:49
gem5::bloom_filter::Base::offsetBits
const unsigned offsetBits
Number of LSB bits to ignore from the the addresses.
Definition: base.hh:53
gem5::bloom_filter::Base::sizeBits
const int sizeBits
Number of bits needed to represent the size of the filter.
Definition: base.hh:59
gem5::floorLog2
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
Definition: intmath.hh:59
std::vector
STL vector class.
Definition: stl.hh:37
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
sat_counter.hh
gem5::bloom_filter::Base::unset
virtual void unset(Addr addr)
Perform the filter specific function to clear the corresponding entries (can be multiple) of an addre...
Definition: base.hh:117
gem5::GenericSatCounter< uint8_t >
gem5::bloom_filter::Base::Base
Base(const BloomFilterBaseParams &p)
Create and clear the filter.
Definition: base.hh:68
gem5::bloom_filter::Base::~Base
virtual ~Base()
Definition: base.hh:75
sim_object.hh
gem5::X86ISA::count
count
Definition: misc.hh:709
gem5::bloom_filter::Base::merge
virtual void merge(const Base *other)
Merges the contents of both filters into this' (Bloom Filter union).
Definition: base.hh:94
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
compiler.hh
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::bloom_filter::Base::clear
virtual void clear()
Clear the filter by resetting all values.
Definition: base.hh:80
gem5::bloom_filter::Base::getCount
virtual int getCount(Addr addr) const
Get the value stored in the corresponding filter entry of an address.
Definition: base.hh:138
gem5::bloom_filter::Base::set
virtual void set(Addr addr)=0
Perform the filter specific function to set the corresponding entries (can be multiple) of an address...
types.hh
intmath.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::bloom_filter::Base::setThreshold
const int setThreshold
Threshold at which a filter entry starts being considered as set.
Definition: base.hh:62
gem5::bloom_filter::Base::isSet
virtual bool isSet(Addr addr) const
Check if the corresponding filter entries of an address should be considered as set.
Definition: base.hh:127
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Tue Dec 21 2021 11:34:24 for gem5 by doxygen 1.8.17