2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
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.
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.
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"
42 GenericBloomFilter::GenericBloomFilter(string config
)
48 split_first(config
, head
, tail
, '_');
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
);
70 GenericBloomFilter::~GenericBloomFilter()
76 GenericBloomFilter::clear()
82 GenericBloomFilter::increment(const Address
& addr
)
84 m_filter
->increment(addr
);
88 GenericBloomFilter::decrement(const Address
& addr
)
90 m_filter
->decrement(addr
);
94 GenericBloomFilter::merge(GenericBloomFilter
* other_filter
)
96 m_filter
->merge(other_filter
->getFilter());
100 GenericBloomFilter::set(const Address
& addr
)
106 GenericBloomFilter::unset(const Address
& addr
)
108 m_filter
->unset(addr
);
112 GenericBloomFilter::isSet(const Address
& addr
)
114 return m_filter
->isSet(addr
);
118 GenericBloomFilter::getCount(const Address
& addr
)
120 return m_filter
->getCount(addr
);
124 GenericBloomFilter::getTotalCount()
126 return m_filter
->getTotalCount();
130 GenericBloomFilter::getIndex(const Address
& addr
)
132 return m_filter
->getIndex(addr
);
136 GenericBloomFilter::readBit(const int index
)
138 return m_filter
->readBit(index
);
142 GenericBloomFilter::writeBit(const int index
, const int value
)
144 m_filter
->writeBit(index
, value
);
148 GenericBloomFilter::print(ostream
& out
) const
150 return m_filter
->print(out
);