Skip to content

Commit

Permalink
unordered_map,unordered_set: Replace internal next_pow2 function by c…
Browse files Browse the repository at this point in the history
…eil2
  • Loading branch information
stotko committed Feb 18, 2020
1 parent 3babe05 commit c964a08
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/stdgpu/impl/unordered_base_detail.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,6 @@ namespace stdgpu
namespace detail
{

inline index_t
next_pow2(const index_t capacity)
{
STDGPU_EXPECTS(capacity > 0);

index_t result = static_cast<index_t>(1) << static_cast<index_t>(std::ceil(std::log2(capacity)));

STDGPU_ENSURES(result >= capacity);
STDGPU_ENSURES(ispow2<std::size_t>(static_cast<std::size_t>(result)));

return result;
}


inline index_t
expected_collisions(const index_t bucket_count,
const index_t capacity)
Expand Down Expand Up @@ -1038,7 +1024,7 @@ unordered_base<Key, Value, KeyFromValue, Hash, KeyEqual>::createDeviceObject(con
STDGPU_EXPECTS(capacity > 0);

// bucket count depends on default max load factor
index_t bucket_count = next_pow2(static_cast<index_t>(std::ceil(static_cast<float>(capacity) / default_max_load_factor())));
index_t bucket_count = static_cast<index_t>(stdgpu::ceil2(static_cast<std::size_t>(std::ceil(static_cast<float>(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<index_t>(1, expected_collisions(bucket_count, capacity) * 2 / 3);
Expand Down

0 comments on commit c964a08

Please sign in to comment.