From 7ef2e733416953b222851f9a360d7fc72d068ee5 Mon Sep 17 00:00:00 2001 From: greg7mdp <greg7mdp@gmail.com> Date: Sat, 16 Mar 2024 16:30:31 -0400 Subject: [PATCH] Minor changes, mostly formatting and avoiding nvcc warnings. --- CMakeLists.txt | 2 +- parallel_hashmap/phmap.h | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d247c28..9179b7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index e59b02a..d9a5b7b 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -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; } // -------------------------------------------------------------------------- @@ -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; } @@ -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; }