diff --git a/CMakeLists.txt b/CMakeLists.txt index c773753..071c38c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,10 @@ if (PHMAP_BUILD_TESTS) endif() if (PHMAP_BUILD_EXAMPLES) + if(NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-null-sentinel -Wswitch-default -Wno-unused") + endif() + set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) diff --git a/examples/bench.cc b/examples/bench.cc index 83ca520..bbfcc3c 100644 --- a/examples/bench.cc +++ b/examples/bench.cc @@ -218,7 +218,7 @@ void outmem(const char* test, int64_t cnt, uint64_t mem, bool final = false) } static bool all_done = false; -static int64_t num_keys[16] = { 0 }; +static int64_t s_num_keys[16] = { 0 }; static int64_t loop_idx = 0; static int64_t inner_cnt = 0; static const char *test = "random"; @@ -230,7 +230,7 @@ void _fill_random_inner(int64_t cnt, HT &hash, RSU &rsu) for (int64_t i=0; i threads[num_threads]; - auto thread_fn = [&hash, cnt, num_threads](int64_t thread_idx, RSU rsu) { + auto thread_fn = [&hash, cnt, num_threads](size_t thread_idx, RSU rsu_) { #if MT_SUPPORT size_t modulo = hash.subcnt() / num_threads; // subcnt() returns the number of submaps for (int64_t i=0; ijoin(); } @@ -284,7 +284,7 @@ size_t total_num_keys() { size_t n = 0; for (int i=0; i<16; ++i) - n += num_keys[i]; + n += s_num_keys[i]; return n; } @@ -301,7 +301,7 @@ Timer _fill_random2(int64_t cnt, HT &hash) inner_cnt = cnt / num_loops; for (int i=0; i<16; ++i) - num_keys[i] = 0; + s_num_keys[i] = 0; for (loop_idx=0; loop_idx('A')] = to_num[static_cast('a')] = 0; + to_num[static_cast('C')] = to_num[static_cast('c')] = 1; + to_num[static_cast('T')] = to_num[static_cast('t')] = 2; + to_num[static_cast('G')] = to_num[static_cast('g')] = 3; } } const cfg; @@ -193,7 +193,7 @@ void WriteFrequencies(const Cfg::Data& input) for(const auto& i: frequencies) freq.insert({i.second, i.first}); - const unsigned sum = (unsigned)input.size() + 1 - size; + const unsigned sum = static_cast(input.size()) + 1 - size; for(const auto& i : freq) std::cout << i.second << ' ' << (sum ? double(100 * i.first) / sum : 0.0) << '\n'; std::cout << '\n'; @@ -213,8 +213,8 @@ int main() Cfg::Data data; std::array buf; - while(fgets(buf.data(), (int)buf.size(), stdin) && memcmp(">THREE", buf.data(), 6)); - while(fgets(buf.data(), (int)buf.size(), stdin) && buf.front() != '>') { + while(fgets(buf.data(), static_cast(buf.size()), stdin) && memcmp(">THREE", buf.data(), 6)); + while(fgets(buf.data(), static_cast(buf.size()), stdin) && buf.front() != '>') { if(buf.front() != ';'){ auto i = std::find(buf.begin(), buf.end(), '\n'); data.insert(data.end(), buf.begin(), i); @@ -232,5 +232,5 @@ int main() WriteCount<4>(data, "GGTA"); WriteCount<6>(data, "GGTATT"); WriteCount<12>(data, "GGTATTTTAATT"); - WriteCount<18>(data, "GGTATTTTAATTTATAGT"); + WriteCount<18>(data, "GGTATTTTAATTTATAGT"); } diff --git a/parallel_hashmap/meminfo.h b/parallel_hashmap/meminfo.h index cfaa108..872f3c6 100644 --- a/parallel_hashmap/meminfo.h +++ b/parallel_hashmap/meminfo.h @@ -28,6 +28,11 @@ namespace spp { + uint64_t GetSystemMemory(); + uint64_t GetTotalMemoryUsed(); + uint64_t GetProcessMemoryUsed(); + uint64_t GetPhysicalMemory(); + uint64_t GetSystemMemory() { #ifdef SPP_WIN diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index f91ecc2..e80279f 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -153,7 +153,7 @@ struct Hash { inline size_t operator()(const T *val) const noexcept { - return (size_t)(const uintptr_t)val; + return static_cast(reinterpret_cast(val)); } }; @@ -460,16 +460,23 @@ inline size_t HashSeed(const ctrl_t* ctrl) { return reinterpret_cast(ctrl) >> 12; } +#ifdef PHMAP_NON_DETERMINISTIC + inline size_t H1(size_t hash, const ctrl_t* ctrl) { - return (hash >> 7) -#if PHMAP_NON_DETERMINISTIC - // use ctrl_ pointer to add entropy to ensure - // non-deterministic iteration order. - ^ HashSeed(ctrl) -#endif - ; // last seven bits stored in the control bytes + // use ctrl_ pointer to add entropy to ensure + // non-deterministic iteration order. + return (hash >> 7) ^ HashSeed(ctrl); } +#else + +inline size_t H1(size_t hash, const ctrl_t* ) { + return (hash >> 7); +} + +#endif + + inline ctrl_t H2(size_t hash) { return hash & 0x7F; } inline bool IsEmpty(ctrl_t c) { return c == kEmpty; } @@ -488,11 +495,16 @@ inline bool IsEmptyOrDeleted(ctrl_t c) { return c < kSentinel; } // -------------------------------------------------------------------------- inline __m128i _mm_cmpgt_epi8_fixed(__m128i a, __m128i b) { #if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Woverflow" + if (std::is_unsigned::value) { const __m128i mask = _mm_set1_epi8(0x80); const __m128i diff = _mm_subs_epi8(b, a); return _mm_cmpeq_epi8(_mm_and_si128(diff, mask), mask); } + + #pragma GCC diagnostic pop #endif return _mm_cmpgt_epi8(a, b); } @@ -740,25 +752,24 @@ struct HashtablezInfo void PrepareForSampling() {} }; -inline void RecordRehashSlow(HashtablezInfo* info, size_t total_probe_length) {} +inline void RecordRehashSlow(HashtablezInfo*, size_t ) {} -static inline void RecordInsertSlow(HashtablezInfo* info, size_t hash, - size_t distance_from_desired) {} +static inline void RecordInsertSlow(HashtablezInfo* , size_t, size_t ) {} -static inline void RecordEraseSlow(HashtablezInfo* info) {} +static inline void RecordEraseSlow(HashtablezInfo*) {} -static inline HashtablezInfo* SampleSlow(int64_t* next_sample) { return nullptr; } -static inline void UnsampleSlow(HashtablezInfo* info) {} +static inline HashtablezInfo* SampleSlow(int64_t*) { return nullptr; } +static inline void UnsampleSlow(HashtablezInfo* ) {} class HashtablezInfoHandle { public: - inline void RecordStorageChanged(size_t size, size_t capacity) {} - inline void RecordRehash(size_t total_probe_length) {} - inline void RecordInsert(size_t hash, size_t distance_from_desired) {} + inline void RecordStorageChanged(size_t , size_t ) {} + inline void RecordRehash(size_t ) {} + inline void RecordInsert(size_t , size_t ) {} inline void RecordErase() {} - friend inline void swap(HashtablezInfoHandle& lhs, - HashtablezInfoHandle& rhs) {} + friend inline void swap(HashtablezInfoHandle& , + HashtablezInfoHandle& ) noexcept {} }; static inline HashtablezInfoHandle Sample() { return HashtablezInfoHandle(); } @@ -769,16 +780,16 @@ public: // Returns a global Sampler. static HashtablezSampler& Global() { static HashtablezSampler hzs; return hzs; } HashtablezInfo* Register() { static HashtablezInfo info; return &info; } - void Unregister(HashtablezInfo* sample) {} + void Unregister(HashtablezInfo* ) {} using DisposeCallback = void (*)(const HashtablezInfo&); - DisposeCallback SetDisposeCallback(DisposeCallback f) { return nullptr; } - int64_t Iterate(const std::function& f) { return 0; } + DisposeCallback SetDisposeCallback(DisposeCallback ) { return nullptr; } + int64_t Iterate(const std::function& ) { return 0; } }; -static inline void SetHashtablezEnabled(bool enabled) {} -static inline void SetHashtablezSampleParameter(int32_t rate) {} -static inline void SetHashtablezMaxSamples(int32_t max) {} +static inline void SetHashtablezEnabled(bool ) {} +static inline void SetHashtablezSampleParameter(int32_t ) {} +static inline void SetHashtablezMaxSamples(int32_t ) {} namespace memory_internal { @@ -1855,7 +1866,8 @@ public: if (a.size() != b.size()) return false; const raw_hash_set* outer = &a; const raw_hash_set* inner = &b; - if (outer->capacity() > inner->capacity()) std::swap(outer, inner); + if (outer->capacity() > inner->capacity()) + std::swap(outer, inner); for (const value_type& elem : *outer) if (!inner->has_element(elem)) return false; return true; @@ -2724,17 +2736,17 @@ public: std::is_nothrow_default_constructible::value) {} explicit parallel_hash_set(size_t bucket_count, - const hasher& hash = hasher(), + const hasher& hash_param = hasher(), const key_equal& eq = key_equal(), const allocator_type& alloc = allocator_type()) { for (auto& inner : sets_) - inner.set_ = EmbeddedSet(bucket_count / N, hash, eq, alloc); + inner.set_ = EmbeddedSet(bucket_count / N, hash_param, eq, alloc); } parallel_hash_set(size_t bucket_count, - const hasher& hash, + const hasher& hash_param, const allocator_type& alloc) - : parallel_hash_set(bucket_count, hash, key_equal(), alloc) {} + : parallel_hash_set(bucket_count, hash_param, key_equal(), alloc) {} parallel_hash_set(size_t bucket_count, const allocator_type& alloc) : parallel_hash_set(bucket_count, hasher(), key_equal(), alloc) {} @@ -2744,16 +2756,16 @@ public: template parallel_hash_set(InputIter first, InputIter last, size_t bucket_count = 0, - const hasher& hash = hasher(), const key_equal& eq = key_equal(), + const hasher& hash_param = hasher(), const key_equal& eq = key_equal(), const allocator_type& alloc = allocator_type()) - : parallel_hash_set(bucket_count, hash, eq, alloc) { + : parallel_hash_set(bucket_count, hash_param, eq, alloc) { insert(first, last); } template parallel_hash_set(InputIter first, InputIter last, size_t bucket_count, - const hasher& hash, const allocator_type& alloc) - : parallel_hash_set(first, last, bucket_count, hash, key_equal(), alloc) {} + const hasher& hash_param, const allocator_type& alloc) + : parallel_hash_set(first, last, bucket_count, hash_param, key_equal(), alloc) {} template parallel_hash_set(InputIter first, InputIter last, size_t bucket_count, @@ -2788,23 +2800,23 @@ public: // -------------------------------------------------------------------- template = 0, RequiresInsertable = 0> parallel_hash_set(std::initializer_list init, size_t bucket_count = 0, - const hasher& hash = hasher(), const key_equal& eq = key_equal(), + const hasher& hash_param = hasher(), const key_equal& eq = key_equal(), const allocator_type& alloc = allocator_type()) - : parallel_hash_set(init.begin(), init.end(), bucket_count, hash, eq, alloc) {} + : parallel_hash_set(init.begin(), init.end(), bucket_count, hash_param, eq, alloc) {} parallel_hash_set(std::initializer_list init, size_t bucket_count = 0, - const hasher& hash = hasher(), const key_equal& eq = key_equal(), + const hasher& hash_param = hasher(), const key_equal& eq = key_equal(), const allocator_type& alloc = allocator_type()) - : parallel_hash_set(init.begin(), init.end(), bucket_count, hash, eq, alloc) {} + : parallel_hash_set(init.begin(), init.end(), bucket_count, hash_param, eq, alloc) {} template = 0, RequiresInsertable = 0> parallel_hash_set(std::initializer_list init, size_t bucket_count, - const hasher& hash, const allocator_type& alloc) - : parallel_hash_set(init, bucket_count, hash, key_equal(), alloc) {} + const hasher& hash_param, const allocator_type& alloc) + : parallel_hash_set(init, bucket_count, hash_param, key_equal(), alloc) {} parallel_hash_set(std::initializer_list init, size_t bucket_count, - const hasher& hash, const allocator_type& alloc) - : parallel_hash_set(init, bucket_count, hash, key_equal(), alloc) {} + const hasher& hash_param, const allocator_type& alloc) + : parallel_hash_set(init, bucket_count, hash_param, key_equal(), alloc) {} template = 0, RequiresInsertable = 0> parallel_hash_set(std::initializer_list init, size_t bucket_count, @@ -2982,13 +2994,13 @@ public: insert_return_type insert(node_type&& node) { if (!node) return {end(), false, node_type()}; - auto& key = node.key(); - size_t hash = HashElement{hash_ref()}(key); - Inner& inner = sets_[subidx(hash)]; - auto& set = inner.set_; + auto& key = node.key(); + size_t hashval = HashElement{hash_ref()}(key); + Inner& inner = sets_[subidx(hashval)]; + auto& set = inner.set_; typename Lockable::UniqueLock m(inner); - auto res = set.insert(std::move(node), hash); + auto res = set.insert(std::move(node), hashval); return { make_iterator(&inner, res.position), res.inserted, res.inserted ? node_type() : std::move(res.node) }; @@ -3009,11 +3021,11 @@ public: template std::pair emplace_decomposable(const K& key, Args&&... args) { - size_t hash = HashElement{hash_ref()}(key); - Inner& inner = sets_[subidx(hash)]; - auto& set = inner.set_; + size_t hashval = HashElement{hash_ref()}(key); + Inner& inner = sets_[subidx(hashval)]; + auto& set = inner.set_; typename Lockable::UniqueLock m(inner); - return make_rv(&inner, set.emplace_decomposable(key, hash, std::forward(args)...)); + return make_rv(&inner, set.emplace_decomposable(key, hashval, std::forward(args)...)); } struct EmplaceDecomposable @@ -3055,12 +3067,12 @@ public: PolicyTraits::construct(&alloc_ref(), slot, std::forward(args)...); const auto& elem = PolicyTraits::element(slot); - size_t hash = HashElement{hash_ref()}(PolicyTraits::key(slot)); - Inner& inner = sets_[subidx(hash)]; - auto& set = inner.set_; + size_t hashval = HashElement{hash_ref()}(PolicyTraits::key(slot)); + Inner& inner = sets_[subidx(hashval)]; + auto& set = inner.set_; typename Lockable::UniqueLock m(inner); typename EmbeddedSet::template InsertSlotWithHash f { - inner, std::move(*slot), hash}; + inner, std::move(*slot), hashval}; return make_rv(PolicyTraits::apply(f, elem)); } @@ -3084,11 +3096,11 @@ public: template iterator lazy_emplace(const key_arg& key, F&& f) { - auto hash = HashElement{hash_ref()}(key); - Inner& inner = sets_[subidx(hash)]; + auto hashval = HashElement{hash_ref()}(key); + Inner& inner = sets_[subidx(hashval)]; auto& set = inner.set_; typename Lockable::UniqueLock m(inner); - return make_iterator(&inner, set.lazy_emplace(key, hash, std::forward(f))); + return make_iterator(&inner, set.lazy_emplace(key, hashval, std::forward(f))); } // Extension API: support for heterogeneous keys. @@ -3103,11 +3115,11 @@ public: // -------------------------------------------------------------------- template size_type erase(const key_arg& key) { - auto hash = HashElement{hash_ref()}(key); - Inner& inner = sets_[subidx(hash)]; + auto hashval = HashElement{hash_ref()}(key); + Inner& inner = sets_[subidx(hashval)]; auto& set = inner.set_; typename Lockable::UpgradeLock m(inner); - auto it = set.find(key, hash); + auto it = set.find(key, hashval); if (it == set.end()) return 0; @@ -3231,11 +3243,11 @@ public: void prefetch(const key_arg& key) const { (void)key; #if 0 && defined(__GNUC__) - size_t hash = HashElement{hash_ref()}(key); - const Inner& inner = sets_[subidx(hash)]; + size_t hashval = HashElement{hash_ref()}(key); + const Inner& inner = sets_[subidx(hashval)]; const auto& set = inner.set_; typename Lockable::UniqueLock m(inner); - set.prefetch_hash(hash); + set.prefetch_hash(hashval); #endif // __GNUC__ } @@ -3248,11 +3260,11 @@ public: // called heterogeneous key support. // -------------------------------------------------------------------- template - iterator find(const key_arg& key, size_t hash) { - Inner& inner = sets_[subidx(hash)]; + iterator find(const key_arg& key, size_t hashval) { + Inner& inner = sets_[subidx(hashval)]; auto& set = inner.set_; typename Lockable::SharedLock m(inner); - auto it = set.find(key, hash); + auto it = set.find(key, hashval); return make_iterator(&inner, it); } @@ -3262,8 +3274,8 @@ public: } template - const_iterator find(const key_arg& key, size_t hash) const { - return const_cast(this)->find(key, hash); + const_iterator find(const key_arg& key, size_t hashval) const { + return const_cast(this)->find(key, hashval); } template @@ -3381,11 +3393,11 @@ private: } bool has_element(const value_type& elem) const { - size_t hash = PolicyTraits::apply(HashElement{hash_ref()}, elem); - Inner& inner = sets_[subidx(hash)]; - auto& set = inner.set_; + size_t hashval = PolicyTraits::apply(HashElement{hash_ref()}, elem); + Inner& inner = sets_[subidx(hashval)]; + auto& set = inner.set_; typename Lockable::SharedLock m(const_cast(inner)); - return set.has_element(elem, hash); + return set.has_element(elem, hashval); } // TODO(alkis): Optimize this assuming *this and that don't overlap. @@ -3406,11 +3418,11 @@ protected: template std::tuple find_or_prepare_insert(const K& key, typename Lockable::UniqueLock &mutexlock) { - auto hash = HashElement{hash_ref()}(key); - Inner& inner = sets_[subidx(hash)]; + auto hashval = HashElement{hash_ref()}(key); + Inner& inner = sets_[subidx(hashval)]; auto& set = inner.set_; mutexlock = std::move(typename Lockable::UniqueLock(inner)); - auto p = set.find_or_prepare_insert(key, hash); // std::pair + auto p = set.find_or_prepare_insert(key, hashval); // std::pair return std::make_tuple(&inner, p.first, p.second); } diff --git a/parallel_hashmap/phmap_base.h b/parallel_hashmap/phmap_base.h index 21d2804..f21ae52 100644 --- a/parallel_hashmap/phmap_base.h +++ b/parallel_hashmap/phmap_base.h @@ -3077,11 +3077,9 @@ bool LessThanImpl(Span a, Span b) { // https://bugs.llvm.org/show_bug.cgi?id=27538. template struct IsConvertibleHelper { - private: static std::true_type testval(To); static std::false_type testval(...); - public: using type = decltype(testval(std::declval())); }; diff --git a/parallel_hashmap/phmap_bits.h b/parallel_hashmap/phmap_bits.h index df953fb..6bd2f0e 100644 --- a/parallel_hashmap/phmap_bits.h +++ b/parallel_hashmap/phmap_bits.h @@ -467,6 +467,11 @@ PHMAP_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero32(uint32_t n) { #define PHMAP_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; } #endif +#if defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpedantic" +#endif + #ifdef PHMAP_HAVE_INTRINSIC_INT128 inline uint64_t umul128(uint64_t a, uint64_t b, uint64_t* high) { @@ -486,6 +491,10 @@ PHMAP_BASE_INTERNAL_FORCEINLINE int CountTrailingZerosNonZero32(uint32_t n) { #endif #endif +#if defined(__GNUC__) + #pragma GCC diagnostic pop +#endif + #if defined(__GNUC__) // Cache line alignment #if defined(__i386__) || defined(__x86_64__) diff --git a/parallel_hashmap/phmap_config.h b/parallel_hashmap/phmap_config.h index 00fec95..b1563b4 100644 --- a/parallel_hashmap/phmap_config.h +++ b/parallel_hashmap/phmap_config.h @@ -311,6 +311,10 @@ #define PHMAP_HAVE_STD_STRING_VIEW 1 #endif +#ifndef PHMAP_HAVE_STD_STRING_VIEW + #define PHMAP_HAVE_STD_STRING_VIEW 0 +#endif + // In debug mode, MSVC 2017's std::variant throws a EXCEPTION_ACCESS_VIOLATION // SEH exception from emplace for variant when constructing the // struct can throw. This defeats some of variant_test and diff --git a/tests/flat_hash_map_test.cc b/tests/flat_hash_map_test.cc index 11857a2..d477ec9 100644 --- a/tests/flat_hash_map_test.cc +++ b/tests/flat_hash_map_test.cc @@ -69,7 +69,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(THIS_TEST_NAME, ModifiersTest, MapTypes); TEST(THIS_TEST_NAME, StandardLayout) { struct Int { - explicit Int(size_t value) : value(value) {} + explicit Int(size_t val) : value(val) {} Int() : value(0) { ADD_FAILURE(); } Int(const Int& other) : value(other.value) { ADD_FAILURE(); } Int(Int&&) = default; @@ -121,8 +121,8 @@ TEST(THIS_TEST_NAME, IteratesMsan) { // avoid creating expensive key elements when the item is already present in the // map. struct LazyInt { - explicit LazyInt(size_t value, int* tracker) - : value(value), tracker(tracker) {} + explicit LazyInt(size_t val, int* tracker_) + : value(val), tracker(tracker_) {} explicit operator size_t() const { ++*tracker; @@ -162,7 +162,7 @@ TEST(THIS_TEST_NAME, PtrKet) { int a, b; hash.insert(H::value_type(&a, true)); hash.insert(H::value_type(&b, false)); -}; +} TEST(THIS_TEST_NAME, LazyKeyPattern) { // hashes are only guaranteed in opt mode, we use assertions to track internal diff --git a/tests/hash_generator_testing.h b/tests/hash_generator_testing.h index f3462af..d6e8bea 100644 --- a/tests/hash_generator_testing.h +++ b/tests/hash_generator_testing.h @@ -67,6 +67,8 @@ namespace }; } // namespace +std::mt19937_64* GetSharedRng(); // declaration + std::mt19937_64* GetSharedRng() { RandomDeviceSeedSeq seed_seq; static auto* rng = new std::mt19937_64(seed_seq); diff --git a/tests/node_hash_map_test.cc b/tests/node_hash_map_test.cc index 102ce5b..77b0cab 100644 --- a/tests/node_hash_map_test.cc +++ b/tests/node_hash_map_test.cc @@ -143,7 +143,7 @@ TEST(FlatHashMap, MoveOnlyKey) { } struct NonMovableKey { - explicit NonMovableKey(int i) : i(i) {} + explicit NonMovableKey(int i_) : i(i_) {} NonMovableKey(NonMovableKey&&) = delete; int i; }; diff --git a/tests/raw_hash_set_test.cc b/tests/raw_hash_set_test.cc index e17f0c0..4f3a3ae 100644 --- a/tests/raw_hash_set_test.cc +++ b/tests/raw_hash_set_test.cc @@ -604,7 +604,7 @@ TEST(Table, Contains2) { int decompose_constructed; struct DecomposeType { - DecomposeType(int i) : i(i) { // NOLINT + DecomposeType(int i_) : i(i_) { // NOLINT ++decompose_constructed; } @@ -1096,6 +1096,11 @@ ProbeStats CollectProbeStatsOnKeysXoredWithSeed(const std::vector& keys return stats; } +#if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wswitch" +#endif + ExpectedStats XorSeedExpectedStats() { constexpr bool kRandomizesInserts = #if NDEBUG @@ -1107,35 +1112,41 @@ ExpectedStats XorSeedExpectedStats() { // The effective load factor is larger in non-opt mode because we insert // elements out of order. switch (container_internal::Group::kWidth) { - case 8: + case 8: if (kRandomizesInserts) { - return {0.05, - 1.0, - {{0.95, 0.5}}, - {{0.95, 0}, {0.99, 2}, {0.999, 4}, {0.9999, 10}}}; + return {0.05, + 1.0, + {{0.95, 0.5}}, + {{0.95, 0}, {0.99, 2}, {0.999, 4}, {0.9999, 10}}}; } else { - return {0.05, - 2.0, - {{0.95, 0.1}}, - {{0.95, 0}, {0.99, 2}, {0.999, 4}, {0.9999, 10}}}; + return {0.05, + 2.0, + {{0.95, 0.1}}, + {{0.95, 0}, {0.99, 2}, {0.999, 4}, {0.9999, 10}}}; } - case 16: + case 16: + default: if (kRandomizesInserts) { - return {0.1, - 1.0, - {{0.95, 0.1}}, - {{0.95, 0}, {0.99, 1}, {0.999, 8}, {0.9999, 15}}}; + return {0.1, + 1.0, + {{0.95, 0.1}}, + {{0.95, 0}, {0.99, 1}, {0.999, 8}, {0.9999, 15}}}; } else { - return {0.05, - 1.0, - {{0.95, 0.05}}, - {{0.95, 0}, {0.99, 1}, {0.999, 4}, {0.9999, 10}}}; + return {0.05, + 1.0, + {{0.95, 0.05}}, + {{0.95, 0}, {0.99, 1}, {0.999, 4}, {0.9999, 10}}}; } } //PHMAP_RAW_LOG(FATAL, "%s", "Unknown Group width"); return {}; } +#if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic pop +#endif + + TEST(Table, DISABLED_EnsureNonQuadraticTopNXorSeedByProbeSeqLength) { ProbeStatsPerSize stats; std::vector sizes = {Group::kWidth << 5, Group::kWidth << 10}; @@ -1190,6 +1201,11 @@ ProbeStats CollectProbeStatsOnLinearlyTransformedKeys( return stats; } +#if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wswitch" +#endif + ExpectedStats LinearTransformExpectedStats() { constexpr bool kRandomizesInserts = #if NDEBUG @@ -1201,35 +1217,40 @@ ExpectedStats LinearTransformExpectedStats() { // The effective load factor is larger in non-opt mode because we insert // elements out of order. switch (container_internal::Group::kWidth) { - case 8: + case 8: if (kRandomizesInserts) { - return {0.1, - 0.5, - {{0.95, 0.3}}, - {{0.95, 0}, {0.99, 1}, {0.999, 8}, {0.9999, 15}}}; + return {0.1, + 0.5, + {{0.95, 0.3}}, + {{0.95, 0}, {0.99, 1}, {0.999, 8}, {0.9999, 15}}}; } else { - return {0.15, - 0.5, - {{0.95, 0.3}}, - {{0.95, 0}, {0.99, 3}, {0.999, 15}, {0.9999, 25}}}; + return {0.15, + 0.5, + {{0.95, 0.3}}, + {{0.95, 0}, {0.99, 3}, {0.999, 15}, {0.9999, 25}}}; } - case 16: + case 16: + default: if (kRandomizesInserts) { - return {0.1, - 0.4, - {{0.95, 0.3}}, - {{0.95, 0}, {0.99, 1}, {0.999, 8}, {0.9999, 15}}}; + return {0.1, + 0.4, + {{0.95, 0.3}}, + {{0.95, 0}, {0.99, 1}, {0.999, 8}, {0.9999, 15}}}; } else { - return {0.05, - 0.2, - {{0.95, 0.1}}, - {{0.95, 0}, {0.99, 1}, {0.999, 6}, {0.9999, 10}}}; + return {0.05, + 0.2, + {{0.95, 0.1}}, + {{0.95, 0}, {0.99, 1}, {0.999, 6}, {0.9999, 10}}}; } } //PHMAP_RAW_LOG(FATAL, "%s", "Unknown Group width"); return {}; } +#if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic pop +#endif + TEST(Table, DISABLED_EnsureNonQuadraticTopNLinearTransformByProbeSeqLength) { ProbeStatsPerSize stats; std::vector sizes = {Group::kWidth << 5, Group::kWidth << 10};