Skip to content

Commit

Permalink
Minor changes, mostly formatting and avoiding nvcc warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Mar 16, 2024
1 parent 50fa648 commit 7ef2e73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
FetchContent_Declare(
parallel-hashmap
GIT_REPOSITORY https://github.com/greg7mdp/parallel-hashmap.git
GIT_TAG v1.3.8 # adjust tag/branch/commit as needed
GIT_TAG v1.3.12 # adjust tag/branch/commit as needed
)
FetchContent_MakeAvailable(parallel-hashmap)
Expand Down
19 changes: 10 additions & 9 deletions parallel_hashmap/phmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,23 @@ constexpr bool IsNoThrowSwappable(std::false_type /* is_swappable */) {
// --------------------------------------------------------------------------
template <typename T>
uint32_t TrailingZeros(T x) {
uint32_t res;
PHMAP_IF_CONSTEXPR(sizeof(T) == 8)
return base_internal::CountTrailingZerosNonZero64(static_cast<uint64_t>(x));
res = base_internal::CountTrailingZerosNonZero64(static_cast<uint64_t>(x));
else
return base_internal::CountTrailingZerosNonZero32(static_cast<uint32_t>(x));
PHMAP_BUILTIN_UNREACHABLE();
res = base_internal::CountTrailingZerosNonZero32(static_cast<uint32_t>(x));
return res;
}

// --------------------------------------------------------------------------
template <typename T>
uint32_t LeadingZeros(T x) {
uint32_t res;
PHMAP_IF_CONSTEXPR(sizeof(T) == 8)
return base_internal::CountLeadingZeros64(static_cast<uint64_t>(x));
res = base_internal::CountLeadingZeros64(static_cast<uint64_t>(x));
else
return base_internal::CountLeadingZeros32(static_cast<uint32_t>(x));
res = base_internal::CountLeadingZeros32(static_cast<uint32_t>(x));
return res;
}

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -575,8 +578,7 @@ inline size_t CapacityToGrowth(size_t capacity)
assert(IsValidCapacity(capacity));
// `capacity*7/8`
PHMAP_IF_CONSTEXPR (Group::kWidth == 8) {
if (capacity == 7)
{
if (capacity == 7) {
// x-x/8 does not work when x==7.
return 6;
}
Expand All @@ -592,8 +594,7 @@ inline size_t GrowthToLowerboundCapacity(size_t growth)
{
// `growth*8/7`
PHMAP_IF_CONSTEXPR (Group::kWidth == 8) {
if (growth == 7)
{
if (growth == 7) {
// x+(x-1)/7 does not work when x==7.
return 8;
}
Expand Down

0 comments on commit 7ef2e73

Please sign in to comment.