gem5  v20.0.0.3
bulk_bloom_filter.cc
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 
31 
32 #include <limits>
33 
34 #include "base/bitfield.hh"
35 #include "base/logging.hh"
36 #include "params/BloomFilterBulk.hh"
37 
38 namespace BloomFilter {
39 
40 Bulk::Bulk(const BloomFilterBulkParams* p)
41  : MultiBitSel(p), sectorBits(floorLog2(parFilterSize))
42 {
44  (std::numeric_limits<Addr>::digits - offsetBits),
45  "Sectors need more bits than available");
46 }
47 
49 {
50 }
51 
52 int
53 Bulk::hash(Addr addr, int hash_number) const
54 {
55  addr = permute(addr);
56 
57  // Get the sector-based c index
58  int c = bits(addr, (offsetBits + (hash_number + 1) * sectorBits) - 1,
59  offsetBits + hash_number * sectorBits);
60  assert(c < filter.size()/numHashes);
61 
62  // Transform the sector-based c index into a filder index (v)
63  c += (numHashes - 1 - hash_number) * (filter.size()/numHashes);
64  assert(c < filter.size());
65 
66  return c;
67 }
68 
69 Addr
71 {
72  // permutes the original address bits according to Table 5
73  Addr part1 = bits(addr, offsetBits + 6, offsetBits),
74  part2 = bits(addr, offsetBits + 9),
75  part3 = bits(addr, offsetBits + 11),
76  part4 = bits(addr, offsetBits + 17),
77  part5 = bits(addr, offsetBits + 8, offsetBits + 7),
78  part6 = bits(addr, offsetBits + 10),
79  part7 = bits(addr, offsetBits + 12),
80  part8 = bits(addr, offsetBits + 13),
81  part9 = bits(addr, offsetBits + 16, offsetBits + 15),
82  part10 = bits(addr, offsetBits + 20, offsetBits + 18),
83  part11 = bits(addr, offsetBits + 14);
84 
85  Addr result =
86  (part1 << 14) | (part2 << 13) | (part3 << 12) | (part4 << 11) |
87  (part5 << 9) | (part6 << 8) | (part7 << 7) | (part8 << 6) |
88  (part9 << 4) | (part10 << 1) | (part11);
89 
90  // Select the remaining high-order bits
91  Addr remaining_bits = bits(addr, std::numeric_limits<Addr>::digits - 1,
92  offsetBits + 21) << 21;
93  result = result | remaining_bits;
94 
95  return result;
96 }
97 
98 } // namespace BloomFilter
99 
101 BloomFilterBulkParams::create()
102 {
103  return new BloomFilter::Bulk(this);
104 }
105 
int hash(Addr addr, int hash_number) const override
Apply the selected the hash functions to an address.
Implementation of the bloom filter, as described in "Bulk Disambiguation of Speculative Threads in Mu...
ip6_addr_t addr
Definition: inet.hh:330
std::vector< SatCounter > filter
The filter itself.
Definition: base.hh:50
std::enable_if< std::is_integral< T >::value, int >::type floorLog2(T x)
Definition: intmath.hh:57
The MultiBitSel Bloom Filter associates an address to multiple entries through the use of multiple ha...
const unsigned offsetBits
Number of LSB bits to ignore from the the addresses.
Definition: base.hh:47
Addr permute(Addr addr) const
Permutes the address to generate its signature.
const int sectorBits
Number of bits used per sector.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:199
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Bitfield< 29 > c
T bits(T val, int first, int last)
Extract the bitfield from position &#39;first&#39; to &#39;last&#39; (inclusive) from &#39;val&#39; and right justify it...
Definition: bitfield.hh:71
const int numHashes
Number of hashes.
Bitfield< 0 > p
Bulk(const BloomFilterBulkParams *p)

Generated on Fri Jul 3 2020 15:52:59 for gem5 by doxygen 1.8.13