gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiGrainBloomFilter.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
30 
31 #include "base/intmath.hh"
32 #include "base/str.hh"
34 
35 using namespace std;
36 
38 {
39  // head contains size of 1st bloom filter, tail contains size of
40  // 2nd bloom filter
41  m_filter_size = head;
42  m_filter_size_bits = floorLog2(m_filter_size);
43 
44  m_page_filter_size = tail;
45  m_page_filter_size_bits = floorLog2(m_page_filter_size);
46 
47  m_filter.resize(m_filter_size);
48  m_page_filter.resize(m_page_filter_size);
49  clear();
50 }
51 
53 {
54 }
55 
56 void
58 {
59  for (int i = 0; i < m_filter_size; i++) {
60  m_filter[i] = 0;
61  }
62  for (int i=0; i < m_page_filter_size; ++i){
63  m_page_filter[i] = 0;
64  }
65 }
66 
67 void
69 {
70  // Not used
71 }
72 
73 
74 void
76 {
77  // Not used
78 }
79 
80 void
82 {
83  // TODO
84 }
85 
86 void
88 {
89  int i = get_block_index(addr);
90  assert(i < m_filter_size);
91  assert(get_page_index(addr) < m_page_filter_size);
92  m_filter[i] = 1;
93  m_page_filter[i] = 1;
94 
95 }
96 
97 void
99 {
100  // not used
101 }
102 
103 bool
105 {
106  int i = get_block_index(addr);
107  assert(i < m_filter_size);
108  assert(get_page_index(addr) < m_page_filter_size);
109  // we have to have both indices set
110  return (m_filter[i] && m_page_filter[i]);
111 }
112 
113 int
115 {
116  // not used
117  return 0;
118 }
119 
120 int
122 {
123  int count = 0;
124 
125  for (int i = 0; i < m_filter_size; i++) {
126  count += m_filter[i];
127  }
128 
129  for (int i=0; i < m_page_filter_size; ++i) {
130  count += m_page_filter[i] = 0;
131  }
132 
133  return count;
134 }
135 
136 int
138 {
139  return 0;
140  // TODO
141 }
142 
143 int
145 {
146  return 0;
147  // TODO
148 }
149 
150 void
151 MultiGrainBloomFilter::writeBit(const int index, const int value)
152 {
153  // TODO
154 }
155 
156 void
157 MultiGrainBloomFilter::print(ostream& out) const
158 {
159 }
160 
161 int
163 {
164  // grap a chunk of bits after byte offset
167  m_filter_size_bits - 1);
168 }
169 
170 int
172 {
173  int bits = RubySystem::getBlockSizeBits() + m_filter_size_bits - 1;
174 
175  // grap a chunk of bits after first chunk
176  return bitSelect(addr, bits, bits + m_page_filter_size_bits - 1);
177 }
178 
179 
180 
181 
count
Definition: misc.hh:704
Bitfield< 30, 0 > index
Addr bitSelect(Addr addr, unsigned int small, unsigned int big)
Definition: Address.cc:34
Bitfield< 7 > i
Definition: miscregs.hh:1378
ip6_addr_t addr
Definition: inet.hh:335
MultiGrainBloomFilter(int head, int tail)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void merge(AbstractBloomFilter *other_filter)
int readBit(const int index)
int floorLog2(unsigned x)
Definition: intmath.hh:100
void writeBit(const int index, const int value)
void print(std::ostream &out) const
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
Definition: bitfield.hh:67
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:75

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6