114262Sodanrc@yahoo.com.br/*
214262Sodanrc@yahoo.com.br * Copyright (c) 2019 Inria
314262Sodanrc@yahoo.com.br * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
414262Sodanrc@yahoo.com.br * All rights reserved.
514262Sodanrc@yahoo.com.br *
614262Sodanrc@yahoo.com.br * Redistribution and use in source and binary forms, with or without
714262Sodanrc@yahoo.com.br * modification, are permitted provided that the following conditions are
814262Sodanrc@yahoo.com.br * met: redistributions of source code must retain the above copyright
914262Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer;
1014262Sodanrc@yahoo.com.br * redistributions in binary form must reproduce the above copyright
1114262Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer in the
1214262Sodanrc@yahoo.com.br * documentation and/or other materials provided with the distribution;
1314262Sodanrc@yahoo.com.br * neither the name of the copyright holders nor the names of its
1414262Sodanrc@yahoo.com.br * contributors may be used to endorse or promote products derived from
1514262Sodanrc@yahoo.com.br * this software without specific prior written permission.
1614262Sodanrc@yahoo.com.br *
1714262Sodanrc@yahoo.com.br * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1814262Sodanrc@yahoo.com.br * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1914262Sodanrc@yahoo.com.br * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2014262Sodanrc@yahoo.com.br * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2114262Sodanrc@yahoo.com.br * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2214262Sodanrc@yahoo.com.br * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2314262Sodanrc@yahoo.com.br * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2414262Sodanrc@yahoo.com.br * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2514262Sodanrc@yahoo.com.br * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2614262Sodanrc@yahoo.com.br * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2714262Sodanrc@yahoo.com.br * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2814262Sodanrc@yahoo.com.br *
2914262Sodanrc@yahoo.com.br * Authors: Daniel Carvalho
3014262Sodanrc@yahoo.com.br */
3114262Sodanrc@yahoo.com.br
3214262Sodanrc@yahoo.com.br#ifndef __BASE_FILTERS_MULTI_BIT_SEL_BLOOM_FILTER_HH__
3314262Sodanrc@yahoo.com.br#define __BASE_FILTERS_MULTI_BIT_SEL_BLOOM_FILTER_HH__
3414262Sodanrc@yahoo.com.br
3514262Sodanrc@yahoo.com.br#include "base/filters/base.hh"
3614262Sodanrc@yahoo.com.br
3714262Sodanrc@yahoo.com.brstruct BloomFilterMultiBitSelParams;
3814262Sodanrc@yahoo.com.br
3914262Sodanrc@yahoo.com.brnamespace BloomFilter {
4014262Sodanrc@yahoo.com.br
4114262Sodanrc@yahoo.com.br/**
4214262Sodanrc@yahoo.com.br * The MultiBitSel Bloom Filter associates an address to multiple entries
4314262Sodanrc@yahoo.com.br * through the use of multiple hash functions.
4414262Sodanrc@yahoo.com.br */
4514262Sodanrc@yahoo.com.brclass MultiBitSel : public Base
4614262Sodanrc@yahoo.com.br{
4714262Sodanrc@yahoo.com.br  public:
4814262Sodanrc@yahoo.com.br    MultiBitSel(const BloomFilterMultiBitSelParams* p);
4914262Sodanrc@yahoo.com.br    ~MultiBitSel();
5014262Sodanrc@yahoo.com.br
5114262Sodanrc@yahoo.com.br    void set(Addr addr) override;
5214262Sodanrc@yahoo.com.br    int getCount(Addr addr) const override;
5314262Sodanrc@yahoo.com.br
5414262Sodanrc@yahoo.com.br  protected:
5514262Sodanrc@yahoo.com.br    /**
5614262Sodanrc@yahoo.com.br     * Apply the selected the hash functions to an address.
5714262Sodanrc@yahoo.com.br     *
5814262Sodanrc@yahoo.com.br     * @param addr The address to hash.
5914262Sodanrc@yahoo.com.br     * @param hash_number Index of the hash function to be used.
6014262Sodanrc@yahoo.com.br     */
6114262Sodanrc@yahoo.com.br    virtual int hash(Addr addr, int hash_number) const;
6214262Sodanrc@yahoo.com.br
6314262Sodanrc@yahoo.com.br    /** Number of hashes. */
6414262Sodanrc@yahoo.com.br    const int numHashes;
6514262Sodanrc@yahoo.com.br
6614262Sodanrc@yahoo.com.br    /** Size of the filter when doing parallel hashing. */
6714262Sodanrc@yahoo.com.br    const int parFilterSize;
6814262Sodanrc@yahoo.com.br
6914262Sodanrc@yahoo.com.br    /** Whether hashing should be performed in parallel. */
7014262Sodanrc@yahoo.com.br    const bool isParallel;
7114262Sodanrc@yahoo.com.br
7214262Sodanrc@yahoo.com.br  private:
7314262Sodanrc@yahoo.com.br    /**
7414262Sodanrc@yahoo.com.br     * Bit offset from block number. Used to simulate bit selection hashing
7514262Sodanrc@yahoo.com.br     * on larger than cache-line granularities, by skipping some bits.
7614262Sodanrc@yahoo.com.br     */
7714262Sodanrc@yahoo.com.br    const int skipBits;
7814262Sodanrc@yahoo.com.br};
7914262Sodanrc@yahoo.com.br
8014262Sodanrc@yahoo.com.br} // namespace BloomFilter
8114262Sodanrc@yahoo.com.br
8214262Sodanrc@yahoo.com.br#endif // __BASE_FILTERS_MULTI_BIT_SEL_BLOOM_FILTER_HH__
83