Skip to content

Commit

Permalink
unordered_map,unordered_set: Increase excess size
Browse files Browse the repository at this point in the history
  • Loading branch information
stotko committed Oct 22, 2024
1 parent 1523669 commit 3a0b20e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/stdgpu/impl/unordered_base_detail.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -1203,9 +1203,9 @@ unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual, Allocator>::createDevic
bit_ceil(static_cast<std::size_t>(std::ceil(static_cast<float>(capacity) / default_max_load_factor()))));

// excess count is estimated by the expected collision count:
// - Conservatively lower the amount since entries falling into regular buckets are already included here
// - Keep the amount although it also counts bucket elements as this is based on assuming a uniform distribution
// - Increase amount by 1 since insertion expects a non-empty excess list also in case of no collision
index_t excess_count = expected_collisions(bucket_count, capacity) * 2 / 3 + 1;
index_t excess_count = expected_collisions(bucket_count, capacity) + 1;

index_t total_count = bucket_count + excess_count;

Expand Down
6 changes: 3 additions & 3 deletions tests/stdgpu/unordered_datastructure.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, insert_multiple_while_full)

TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, insert_while_excess_empty)
{
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(2);
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(1);

// Fill tiny hash table
const test_unordered_datastructure::key_type position_1(1, 2, 3);
Expand Down Expand Up @@ -1592,7 +1592,7 @@ TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, insert_parallel_while_one_free

TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, insert_parallel_while_excess_empty)
{
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(2);
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(1);

// Fill tiny hash table
const test_unordered_datastructure::key_type position_1(1, 2, 3);
Expand Down Expand Up @@ -1688,7 +1688,7 @@ TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, emplace_parallel_while_one_fre

TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, emplace_parallel_while_excess_empty)
{
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(2);
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(1);

// Fill tiny hash table
const test_unordered_datastructure::key_type position_1(1, 2, 3);
Expand Down

0 comments on commit 3a0b20e

Please sign in to comment.