Skip to content

Commit 4be9e87

Browse files
committed
Fixing the problems with the pull request.
1 parent b180e85 commit 4be9e87

File tree

6 files changed

+45
-78
lines changed

6 files changed

+45
-78
lines changed

benchmarks/bulk-insert-and-query.cc

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,12 @@ int main(int argc, char * argv[]) {
737737
cout << setw(NAME_WIDTH) << names[a] << cf << endl;
738738
}
739739
a = 31;
740-
// if (algorithmId == a || algorithmId < 0 || (algos.find(a) != algos.end())) {
741-
// auto cf = FilterBenchmark<
742-
// VQFilter<uint64_t, SimpleMixSplit>>(
743-
// add_count, to_add, intersectionsize, mixed_sets, true, false);
744-
// cout << setw(NAME_WIDTH) << names[a] << cf << endl;
745-
// }
740+
if (algorithmId == a || algorithmId < 0 || (algos.find(a) != algos.end())) {
741+
auto cf = FilterBenchmark<
742+
VQFilter<uint64_t, SimpleMixSplit>>(
743+
add_count, to_add, intersectionsize, mixed_sets, true, false);
744+
cout << setw(NAME_WIDTH) << names[a] << cf << endl;
745+
}
746746
#endif
747747
#ifdef __PF_AVX512__
748748
a = 32;
@@ -774,23 +774,6 @@ int main(int argc, char * argv[]) {
774774
add_count, to_add, intersectionsize, mixed_sets, false, false);
775775
cout << setw(NAME_WIDTH) << names[a] << cf << endl;
776776
}
777-
/*
778-
a = 38;
779-
if (algorithmId == a || algorithmId < 0 || (algos.find(a) != algos.end())) {
780-
using prefix_l2 = Prefix_Filter<TrivialFilter>;
781-
auto cf = FilterBenchmark<Prefix_Filter<prefix_l2>>(add_count, to_add, intersectionsize, mixed_sets, false, false);
782-
cout << setw(NAME_WIDTH) << names[a] << cf << endl;
783-
}
784-
a = 39;
785-
if (algorithmId == a || algorithmId < 0 || (algos.find(a) != algos.end())) {
786-
using prefix_l2 = Prefix_Filter<TrivialFilter>;
787-
using prefix_l3 = Prefix_Filter<prefix_l2>;
788-
using prefix_l4 = Prefix_Filter<prefix_l3>;
789-
790-
auto cf = FilterBenchmark<prefix_l4>(add_count, to_add, intersectionsize, mixed_sets, false, false);
791-
cout << setw(NAME_WIDTH) << names[a] << cf << endl;
792-
}
793-
*/
794777
#endif
795778

796779
// Bloom ----------------------------------------------------------

benchmarks/filterapi.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
#include "vqf_cpp.h"
2828
#include "simd-block.h"
2929
#endif
30-
#define __PF_AVX512__ (__AVX512CD__ & __AVX512DQ__ &__AVX512DQ__ &__AVX512DQ__)
30+
#define __PF_AVX512__ (__AVX512BW__ & __AVX512VL__ & __AVX512CD__ & __AVX512DQ__)
3131
#ifdef __PF_AVX512__
3232
#include "prefix/min_pd256.hpp"
33-
#include "tcShortcut/TC-shortcut.hpp"
33+
#include "tc-shortcut/tc-shortcut.hpp"
3434
#endif
3535
#include "simd-block-fixed-fpp.h"
3636
#include "ribbon_impl.h"
@@ -225,7 +225,6 @@ struct FilterAPI<TC_shortcut<HashFamily>> {
225225
static void Add(uint64_t key, Table *table) {
226226
if (!table->insert(key)) {
227227
std::cout << table->info() << std::endl;
228-
// std::cout << "max_load: \t" << 0.945 << std::endl;
229228
throw std::logic_error(table->get_name() + " is too small to hold all of the elements");
230229
}
231230
}
@@ -299,7 +298,7 @@ inline size_t get_l2_slots<SimdBlockFilterFixed<>>(size_t l1_items, const double
299298
}
300299

301300

302-
template<typename Table, typename HashFamily = TwoIndependentMultiplyShift>
301+
template<typename Table, typename HashFamily = hashing::TwoIndependentMultiplyShift>
303302
class Prefix_Filter {
304303
const size_t filter_max_capacity;
305304
const size_t number_of_pd;
@@ -326,7 +325,6 @@ class Prefix_Filter {
326325
}
327326

328327
constexpr uint64_t pd256_plus_init_header = (((INT64_C(1) << min_pd::QUOTS) - 1) << 6) | 32;
329-
// std_fill<__m256i *, __m256i>(pd_array, pd_array + number_of_pd, __m256i{0, 0, 0, 0});
330328
for (size_t i = 0; i < number_of_pd; i++){
331329
pd_array[i] = __m256i{pd256_plus_init_header, 0, 0, 0};
332330
}

src/cuckoo/printutil.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66

77
namespace cuckoofilter {
88

9-
// std::string PrintUtil::bytes_to_hex(const char *data, size_t len) {
10-
// std::string hexstr = "";
11-
// static const char hexes[] = "0123456789ABCDEF ";
9+
std::string PrintUtil::bytes_to_hex(const char *data, size_t len) {
10+
std::string hexstr = "";
11+
static const char hexes[] = "0123456789ABCDEF ";
1212

13-
// for (size_t i = 0; i < len; i++) {
14-
// unsigned char c = data[i];
15-
// hexstr.push_back(hexes[c >> 4]);
16-
// hexstr.push_back(hexes[c & 0xf]);
17-
// hexstr.push_back(hexes[16]);
18-
// }
19-
// return hexstr;
20-
// };
13+
for (size_t i = 0; i < len; i++) {
14+
unsigned char c = data[i];
15+
hexstr.push_back(hexes[c >> 4]);
16+
hexstr.push_back(hexes[c & 0xf]);
17+
hexstr.push_back(hexes[16]);
18+
}
19+
return hexstr;
20+
};
2121

22-
// std::string PrintUtil::bytes_to_hex(const std::string &s) {
23-
// return bytes_to_hex((const char *)s.data(), s.size());
24-
// };
22+
std::string PrintUtil::bytes_to_hex(const std::string &s) {
23+
return bytes_to_hex((const char *)s.data(), s.size());
24+
};
2525

2626
} // namespace cuckoofilter

src/hashutil.h

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,31 @@
66
#include <sys/types.h>
77

88
#include <string>
9-
#include <fstream>
109

1110
#include <random>
1211

1312
namespace hashing {
13+
// See Martin Dietzfelbinger, "Universal hashing and k-wise independent random
14+
// variables via integer arithmetic without primes".
1415

15-
inline size_t sysrandom(void *dst, size_t dstlen) {
16-
char *buffer = reinterpret_cast<char *>(dst);
17-
std::ifstream stream("/dev/urandom", std::ios_base::binary | std::ios_base::in);
18-
stream.read(buffer, dstlen);
19-
20-
return dstlen;
16+
class TwoIndependentMultiplyShift {
17+
unsigned __int128 multiply_, add_;
18+
public:
19+
TwoIndependentMultiplyShift() {
20+
::std::random_device random;
21+
for (auto v : {&multiply_, &add_}) {
22+
*v = random();
23+
for (int i = 1; i <= 4; ++i) {
24+
*v = *v << 32;
25+
*v |= random();
26+
}
2127
}
22-
23-
// See Martin Dietzfelbinger, "Universal hashing and k-wise independent random
24-
// variables via integer arithmetic without primes".
25-
class TwoIndependentMultiplyShift {
26-
unsigned __int128 multiply_, add_;
27-
28-
public:
29-
TwoIndependentMultiplyShift() {
30-
std::uint_least64_t seed;
31-
sysrandom(&seed, sizeof(seed));
32-
std::mt19937_64 rng(seed);
33-
std::uniform_int_distribution<uint64_t> dist(0, UINT64_MAX);
34-
35-
for (auto v : {&multiply_, &add_}) {
36-
for (size_t i = 0; i < 8; i++) {
37-
unsigned __int128 hi = dist(rng);
38-
unsigned __int128 lo = dist(rng);
39-
*v ^= (hi << 64) | lo;
40-
}
41-
}
42-
}
43-
44-
inline uint64_t operator()(uint64_t key) const {
45-
return (add_ + multiply_ * static_cast<decltype(multiply_)>(key)) >> 64;
46-
}
47-
};
28+
}
29+
inline uint64_t operator()(uint64_t key) const {
30+
return (add_ + multiply_ * static_cast<decltype(multiply_)>(key)) >> 64;
31+
}
32+
33+
};
4834

4935

5036
class SimpleMixSplit {
@@ -74,4 +60,4 @@ class SimpleMixSplit {
7460

7561
}
7662

77-
#endif // CUCKOO_FILTER_HASHUTIL_H_
63+
#endif // CUCKOO_FILTER_HASHUTIL_H_
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "hashutil.h"
77
#include "./tc-sym.hpp"
88

9-
template <typename HashFamily = TwoIndependentMultiplyShift>
9+
template <typename HashFamily = hashing::TwoIndependentMultiplyShift>
1010
class TC_shortcut {
1111
HashFamily h0;
1212
size_t capacity{0};
@@ -280,7 +280,7 @@ class TC_shortcut {
280280
}
281281

282282
auto get_name() const -> std::string {
283-
return "TC-shortcut";
283+
return "tc-shortcut";
284284
}
285285

286286
auto get_cap() const -> size_t {

0 commit comments

Comments
 (0)