Skip to content

Commit

Permalink
[MISC] Do not process favourite child
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Sep 1, 2023
1 parent f423f0d commit 9297d5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/hibf/layout/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct graph
size_t parent_bin_index{};
size_t max_bin_index{};
size_t number_of_technical_bins{};
std::optional<uint32_t> favourite_child_idx{std::nullopt};
std::optional<size_t> favourite_child_idx{std::nullopt};
std::vector<layout::layout::user_bin> remaining_records{}; // non-merged bins (either split or single)

// Doesn't work, because the type is incomplete. To compare node, a comparison for the children member is needed.
Expand Down
26 changes: 14 additions & 12 deletions src/hierarchical_interleaved_bloom_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ size_t hierarchical_build(hierarchical_interleaved_bloom_filter & hibf,
std::vector<size_t> indices(children.size());
std::iota(indices.begin(), indices.end(), size_t{});

// We do not want to process the favourite child. It has already been processed prior.
// https://godbolt.org/z/6Yav7hrG1
if (current_node.favourite_child_idx.has_value())
std::erase(indices, current_node.favourite_child_idx.value());

Check warning on line 95 in src/hierarchical_interleaved_bloom_filter.cpp

View check run for this annotation

Codecov / codecov/patch

src/hierarchical_interleaved_bloom_filter.cpp#L94-L95

Added lines #L94 - L95 were not covered by tests

if (is_root)
{
// Shuffle indices: More likely to not block each other. Optimal: Interleave
Expand All @@ -105,19 +110,16 @@ size_t hierarchical_build(hierarchical_interleaved_bloom_filter & hibf,
{
auto & child = children[index];

if (index != current_node.favourite_child_idx.value_or(-1))
robin_hood::unordered_flat_set<uint64_t> kmers{};
size_t const ibf_pos = hierarchical_build(hibf, kmers, child, data, false);
auto parent_bin_index = child.parent_bin_index;
{
robin_hood::unordered_flat_set<uint64_t> kmers{};
size_t const ibf_pos = hierarchical_build(hibf, kmers, child, data, false);
auto parent_bin_index = child.parent_bin_index;
{
size_t const mutex_id{parent_bin_index / 64};
std::lock_guard<std::mutex> guard{local_ibf_mutex[mutex_id]};
ibf_positions[parent_bin_index] = ibf_pos;
insert_into_ibf(kmers, 1, parent_bin_index, ibf, data.fill_ibf_timer);
if (!is_root)
update_parent_kmers(parent_kmers, kmers, data.merge_kmers_timer);
}
size_t const mutex_id{parent_bin_index / 64};
std::lock_guard<std::mutex> guard{local_ibf_mutex[mutex_id]};
ibf_positions[parent_bin_index] = ibf_pos;
insert_into_ibf(kmers, 1, parent_bin_index, ibf, data.fill_ibf_timer);
if (!is_root)
update_parent_kmers(parent_kmers, kmers, data.merge_kmers_timer);
}
}
};
Expand Down

0 comments on commit 9297d5e

Please sign in to comment.