ruby: change advance_stage for flit_d
[gem5.git] / src / mem / ruby / filters / GenericBloomFilter.cc
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
29 #include "base/str.hh"
30 #include "mem/ruby/common/Address.hh"
31 #include "mem/ruby/filters/BlockBloomFilter.hh"
32 #include "mem/ruby/filters/BulkBloomFilter.hh"
33 #include "mem/ruby/filters/GenericBloomFilter.hh"
34 #include "mem/ruby/filters/H3BloomFilter.hh"
35 #include "mem/ruby/filters/LSB_CountingBloomFilter.hh"
36 #include "mem/ruby/filters/MultiBitSelBloomFilter.hh"
37 #include "mem/ruby/filters/MultiGrainBloomFilter.hh"
38 #include "mem/ruby/filters/NonCountingBloomFilter.hh"
39
40 using namespace std;
41
42 GenericBloomFilter::GenericBloomFilter(string config)
43 {
44 string head, tail;
45 #ifndef NDEBUG
46 bool success =
47 #endif
48 split_first(config, head, tail, '_');
49 assert(success);
50
51 if (head == "LSB_Counting" ) {
52 m_filter = new LSB_CountingBloomFilter(tail);
53 } else if(head == "NonCounting" ) {
54 m_filter = new NonCountingBloomFilter(tail);
55 } else if(head == "Bulk" ) {
56 m_filter = new BulkBloomFilter(tail);
57 } else if(head == "Block") {
58 m_filter = new BlockBloomFilter(tail);
59 } else if(head == "Multigrain"){
60 m_filter = new MultiGrainBloomFilter(tail);
61 } else if(head == "MultiBitSel"){
62 m_filter = new MultiBitSelBloomFilter(tail);
63 } else if(head == "H3"){
64 m_filter = new H3BloomFilter(tail);
65 } else {
66 assert(0);
67 }
68 }
69
70 GenericBloomFilter::~GenericBloomFilter()
71 {
72 delete m_filter;
73 }
74
75 void
76 GenericBloomFilter::clear()
77 {
78 m_filter->clear();
79 }
80
81 void
82 GenericBloomFilter::increment(const Address& addr)
83 {
84 m_filter->increment(addr);
85 }
86
87 void
88 GenericBloomFilter::decrement(const Address& addr)
89 {
90 m_filter->decrement(addr);
91 }
92
93 void
94 GenericBloomFilter::merge(GenericBloomFilter * other_filter)
95 {
96 m_filter->merge(other_filter->getFilter());
97 }
98
99 void
100 GenericBloomFilter::set(const Address& addr)
101 {
102 m_filter->set(addr);
103 }
104
105 void
106 GenericBloomFilter::unset(const Address& addr)
107 {
108 m_filter->unset(addr);
109 }
110
111 bool
112 GenericBloomFilter::isSet(const Address& addr)
113 {
114 return m_filter->isSet(addr);
115 }
116
117 int
118 GenericBloomFilter::getCount(const Address& addr)
119 {
120 return m_filter->getCount(addr);
121 }
122
123 int
124 GenericBloomFilter::getTotalCount()
125 {
126 return m_filter->getTotalCount();
127 }
128
129 int
130 GenericBloomFilter::getIndex(const Address& addr)
131 {
132 return m_filter->getIndex(addr);
133 }
134
135 int
136 GenericBloomFilter::readBit(const int index)
137 {
138 return m_filter->readBit(index);
139 }
140
141 void
142 GenericBloomFilter::writeBit(const int index, const int value)
143 {
144 m_filter->writeBit(index, value);
145 }
146
147 void
148 GenericBloomFilter::print(ostream& out) const
149 {
150 return m_filter->print(out);
151 }
152
153