Hashmap fixes
1 unresolved thread
1 unresolved thread
Adds functionality to grow a hashmap, can be used to pre-allocate elements when the final size is known.
Fixes overflows on re-hashing, although I'm not too sure how to test this in practice.
Implements #587 (closed).
Edited by Matthieu Schaller
Merge request reports
Activity
I ran the EAGLE-25 on 32 MPI ranks triggering FOF every 500 steps in 10 separate runs and they all completed succesfully. I think this is all fine.
Maybe @pdraper has other tests to suggest?
assigned to @pdraper
I did:
diff --git a/src/hashmap.c b/src/hashmap.c index 3ebf927..e8fc11f 100644 --- a/src/hashmap.c +++ b/src/hashmap.c @@ -309,6 +309,9 @@ void hashmap_grow(hashmap_t *m, size_t new_size) { If this happens, store the offending element in the strays buffer for now. */ else { + + message("HASHMAP OVERFLOW"); + /* (Re)allocate strays buffer? */ if (strays_count == strays_size) { hashmap_element_t *temp_buff; @@ -338,10 +341,15 @@ void hashmap_grow(hashmap_t *m, size_t new_size) { /* If we have any strays, add them back to the hashmap. This will inevitably trigger a rehashing, but that's not our problem. */ if (strays_count) { + + message("HASHMAP STRAY ELIMINATION"); + for (size_t k = 0; k < strays_count; k++) { hashmap_put(m, strays[k].key, strays[k].value); } swift_free("hashmap_strays", strays); + + message("HASHMAP DEALT WITH ALL STRAYS"); } }
It happened twice in all my runs. We survived in both cases.
All good for me unless @nnrw56 wants to pick up on my suggestion above to initialise the hash maps to 1000 or so.
changed milestone to %Paris
mentioned in commit a3c1cc83
Please register or sign in to reply