gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 namespace bloom_filter
46 {
47 
48 class Base : public SimObject
49 {
50  protected:
52  const unsigned offsetBits;
53 
56 
58  const int sizeBits;
59 
61  const int setThreshold;
62 
63  public:
67  Base(const BloomFilterBaseParams &p)
68  : SimObject(p), offsetBits(p.offset_bits),
69  filter(p.size, SatCounter8(p.num_bits)),
70  sizeBits(floorLog2(p.size)), setThreshold(p.threshold)
71  {
72  clear();
73  }
74  virtual ~Base() {};
75 
79  virtual void clear()
80  {
81  for (auto& entry : filter) {
82  entry.reset();
83  }
84  }
85 
92  virtual void
93  merge(const Base* other)
94  {
95  assert(filter.size() == other->filter.size());
96  for (int i = 0; i < filter.size(); ++i){
97  filter[i] += other->filter[i];
98  }
99  }
100 
107  virtual void set(Addr addr) = 0;
108 
116  virtual void unset(Addr addr) {};
117 
125  virtual bool
126  isSet(Addr addr) const
127  {
128  return getCount(addr) >= setThreshold;
129  }
130 
137  virtual int getCount(Addr addr) const { return 0; }
138 
144  virtual int getTotalCount() const
145  {
146  int count = 0;
147  for (const auto& entry : filter) {
148  count += entry;
149  }
150  return count;
151  }
152 };
153 
154 } // namespace bloom_filter
155 } // namespace gem5
156 
157 #endif // __BASE_FILTERS_BASE_HH__
gem5::bloom_filter::Base::filter
std::vector< SatCounter8 > filter
The filter itself.
Definition: base.hh:55
gem5::bloom_filter::Base::getTotalCount
virtual int getTotalCount() const
Get the total value stored in the filter entries.
Definition: base.hh:144
gem5::bloom_filter::Base
Definition: base.hh:48
gem5::bloom_filter::Base::offsetBits
const unsigned offsetBits
Number of LSB bits to ignore from the the addresses.
Definition: base.hh:52
gem5::bloom_filter::Base::sizeBits
const int sizeBits
Number of bits needed to represent the size of the filter.
Definition: base.hh:58
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:116
gem5::GenericSatCounter< uint8_t >
gem5::bloom_filter::Base::Base
Base(const BloomFilterBaseParams &p)
Create and clear the filter.
Definition: base.hh:67
gem5::bloom_filter::Base::~Base
virtual ~Base()
Definition: base.hh:74
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
sim_object.hh
gem5::X86ISA::count
count
Definition: misc.hh:710
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:93
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::bloom_filter::Base::clear
virtual void clear()
Clear the filter by resetting all values.
Definition: base.hh:79
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:137
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: gpu_translation_state.hh:37
gem5::bloom_filter::Base::setThreshold
const int setThreshold
Threshold at which a filter entry starts being considered as set.
Definition: base.hh:61
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:126
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Sun Jul 30 2023 01:56:51 for gem5 by doxygen 1.8.17