diff --git a/src/stdgpu/impl/unordered_base_detail.cuh b/src/stdgpu/impl/unordered_base_detail.cuh index a772f246f..8b16d10e3 100644 --- a/src/stdgpu/impl/unordered_base_detail.cuh +++ b/src/stdgpu/impl/unordered_base_detail.cuh @@ -1203,9 +1203,10 @@ unordered_base::createDevic index_t bucket_count = static_cast( bit_ceil(static_cast(std::ceil(static_cast(capacity) / default_max_load_factor())))); - // excess count is estimated by the expected collision count and conservatively lowered since entries falling into - // regular buckets are already included here - index_t excess_count = std::max(1, expected_collisions(bucket_count, capacity) * 2 / 3); + // excess count is estimated by the expected collision count: + // - Conservatively lower the amount since entries falling into regular buckets are already included here + // - Increase amount by 1 since insertion expects a non-empty excess list also in case of no collision + index_t excess_count = std::max(1, expected_collisions(bucket_count, capacity) * 2 / 3 + 1); index_t total_count = bucket_count + excess_count;