Skip to content

Commit 3a0b20e

Browse files
committed
unordered_map,unordered_set: Increase excess size
1 parent 1523669 commit 3a0b20e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/stdgpu/impl/unordered_base_detail.cuh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,9 +1203,9 @@ unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual, Allocator>::createDevic
12031203
bit_ceil(static_cast<std::size_t>(std::ceil(static_cast<float>(capacity) / default_max_load_factor()))));
12041204

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

12101210
index_t total_count = bucket_count + excess_count;
12111211

tests/stdgpu/unordered_datastructure.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, insert_multiple_while_full)
14301430

14311431
TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, insert_while_excess_empty)
14321432
{
1433-
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(2);
1433+
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(1);
14341434

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

15931593
TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, insert_parallel_while_excess_empty)
15941594
{
1595-
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(2);
1595+
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(1);
15961596

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

16891689
TEST_F(STDGPU_UNORDERED_DATASTRUCTURE_TEST_CLASS, emplace_parallel_while_excess_empty)
16901690
{
1691-
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(2);
1691+
test_unordered_datastructure tiny_hash_datastructure = test_unordered_datastructure::createDeviceObject(1);
16921692

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

0 commit comments

Comments
 (0)