Skip to content

Commit

Permalink
dbg: add infinite loop detecting assertion to compact_hash_map
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSeemaier committed May 8, 2024
1 parent ce25a1d commit 9ed1d20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions kaminpar-common/datastructures/compact_hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ template <typename Type> class CompactHashMap {
std::size_t cur_pos = start_pos;
MutType cur_entry;

[[maybe_unused]] int full_detector = 0;
do {
cur_pos = hash(cur_pos + 1);
KASSERT(
cur_pos != start_pos || ((full_detector++) == 0),
"hash table full: invariant violated, might loop endlessly ..."
);

cur_entry = read_pos(cur_pos);

if (cur_entry == 0 || movable(decode_key(cur_entry), cur_pos, hole_pos)) {
Expand Down Expand Up @@ -131,8 +137,14 @@ template <typename Type> class CompactHashMap {
std::size_t pos = key - 1;
MutType entry;

[[maybe_unused]] int full_detector = 0;
do {
pos = hash(pos + 1);
KASSERT(
pos != key || ((full_detector++) == 0),
"hash table full and key not found: invariant violated, might loop endlessly ..."
);

entry = read_pos(pos);
} while (entry != 0 && decode_key(entry) != key);

Expand Down
1 change: 1 addition & 0 deletions kaminpar-shm/presets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Context create_largek_fm_context() {
};

ctx.refinement.kway_fm.gain_cache_strategy = GainCacheStrategy::LARGE_K;
// ctx.refinement.kway_fm.unlock_locally_moved_nodes = false; // @todo make this the default?

return ctx;
}
Expand Down

0 comments on commit 9ed1d20

Please sign in to comment.