Skip to content

Commit 8bb8d26

Browse files
committed
Reorganize the code: use SimpleMixSplit instead of TwoIndependentMultiplyShift #18
1 parent c077580 commit 8bb8d26

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

src/gqf/gqf_cpp.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ enum Status {
2525
};
2626

2727
template <typename ItemType, size_t bits_per_item,
28-
typename HashFamily = TwoIndependentMultiplyShift>
28+
typename HashFamily = SimpleMixSplit>
2929
class GQFilter {
3030

3131
QF qf;
@@ -49,17 +49,11 @@ class GQFilter {
4949
uint64_t nhashbits = qbits + 8;
5050
mask = (1ULL << nhashbits) - 1;
5151

52-
// std::cout << "(CQF: nslots " << nslots << " nhashbits " << nhashbits << " n " << n << " bitsPerItem " << bitsPerItem << ")\n";
53-
54-
// if (!qf_malloc(&qf, nslots, nhashbits, 0, QF_HASH_INVERTIBLE, 0)) {
55-
// if (!qf_malloc(&qf, nslots, nhashbits, 0, QF_HASH_DEFAULT, 0)) {
5652
if (!qf_malloc(&qf, nslots, nhashbits, 0, QF_HASH_NONE, 0)) {
5753
std::cout << "Can't allocate CQF.\n";
5854
abort();
5955
}
6056

61-
// qf_set_auto_resize(&qf, true);
62-
6357
bytesUsed = qf.metadata->total_size_in_bytes;
6458
bitsPerItem = (double) bytesUsed / n;
6559

src/gqf/gqf_hashutil.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed )
4646

4747
switch(len & 7)
4848
{
49-
case 7: h ^= (uint64_t)data2[6] << 48;
50-
case 6: h ^= (uint64_t)data2[5] << 40;
51-
case 5: h ^= (uint64_t)data2[4] << 32;
52-
case 4: h ^= (uint64_t)data2[3] << 24;
53-
case 3: h ^= (uint64_t)data2[2] << 16;
54-
case 2: h ^= (uint64_t)data2[1] << 8;
49+
case 7: h ^= (uint64_t)data2[6] << 48; do {} while (0); /* fallthrough */
50+
case 6: h ^= (uint64_t)data2[5] << 40; do {} while (0); /* fallthrough */
51+
case 5: h ^= (uint64_t)data2[4] << 32; do {} while (0); /* fallthrough */
52+
case 4: h ^= (uint64_t)data2[3] << 24; do {} while (0); /* fallthrough */
53+
case 3: h ^= (uint64_t)data2[2] << 16; do {} while (0); /* fallthrough */
54+
case 2: h ^= (uint64_t)data2[1] << 8; do {} while (0); /* fallthrough */
5555
case 1: h ^= (uint64_t)data2[0];
5656
h *= m;
5757
};
@@ -99,10 +99,10 @@ uint64_t MurmurHash64B ( const void * key, int len, unsigned int seed )
9999

100100
switch(len)
101101
{
102-
case 3: h2 ^= ((unsigned char*)data)[2] << 16;
103-
case 2: h2 ^= ((unsigned char*)data)[1] << 8;
102+
case 3: h2 ^= ((unsigned char*)data)[2] << 16; do {} while (0); /* fallthrough */
103+
case 2: h2 ^= ((unsigned char*)data)[1] << 8; do {} while (0); /* fallthrough */
104104
case 1: h2 ^= ((unsigned char*)data)[0];
105-
h2 *= m;
105+
h2 *= m; do {} while (0); /* fallthrough */
106106
};
107107

108108
h1 ^= h2 >> 18; h1 *= m;

src/morton/block.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ struct Block{ // Assuming block size is a multiple of atom_t's size in bytes
165165
// How many bits spilled over into atom1
166166
uint16_t spillover = (global_index + field_width_bits) % atom_size_bits;
167167
spillover = (atom1 - atom0) ? spillover : 0; // Compare and swap ins?
168-
//std::cout << "Spillover is " << spillover << std::endl;
169168

170169
// May be different than the default read mask if field_width_bits
171170
// differs from what is stored in the struct
@@ -402,7 +401,6 @@ struct Block{ // Assuming block size is a multiple of atom_t's size in bytes
402401
memcpy(source_address, &item, field_width_bytes);
403402
}
404403

405-
__attribute__((optimize("unroll-loops")))
406404
INLINE void add_cross_left_displace(uint64_t raw_offset_bits,
407405
uint64_t field_width_bits, uint64_t index, atom_t item){
408406
uint64_t global_index = index * field_width_bits + raw_offset_bits;
@@ -420,8 +418,6 @@ struct Block{ // Assuming block size is a multiple of atom_t's size in bytes
420418
for(uint64_t atom = 1; atom < atoms_per_block; atom++){
421419
shifted_block._block_storage[atom] |= _block_storage[atom - 1] >> (atom_size_bits - field_width_bits);
422420
}
423-
//std::cout << "Block before shift: " << block_storage_as_bit_string(entry_size_bits) << std::endl;
424-
//std::cout << "Block after shift: " << shifted_block.block_storage_as_bit_string(entry_size_bits) << std::endl;
425421

426422
// Clear the entire atom
427423
constexpr atom_t full_clear_mask = static_cast<atom_t>(0);
@@ -482,8 +478,6 @@ struct Block{ // Assuming block size is a multiple of atom_t's size in bytes
482478
for(uint64_t atom = 1; atom < atoms_per_block; atom++){
483479
shifted_block._block_storage[atom - 1] |= _block_storage[atom] << (atom_size_bits - field_width_bits);
484480
}
485-
//std::cout << "Block before shift: " << block_storage_as_bit_string(entry_size_bits) << std::endl;
486-
//std::cout << "Block after shift: " << shifted_block.block_storage_as_bit_string(entry_size_bits) << std::endl;
487481

488482
// What follows is a merge operation that is exactly the same as
489483
// what appears in add_cross_left_displace

0 commit comments

Comments
 (0)