diff --git a/doc/new_release.md b/doc/new_release.md index 99ff1dc..df35625 100644 --- a/doc/new_release.md +++ b/doc/new_release.md @@ -1,25 +1,26 @@ - update version in `phmap_config.h` - update version in `CITATION.cff` - update version in comment on top of `CMakeLists.txt` +- update all versions # in `doc/new_release.md`. - git commit - git push - create the new release on github (tag `v2.0.0` - use semantic versioning) -- download the tar.gz from github, and use `sha256sum parallel-hashmap-1.4.0.tar.gz` on linux to get the sha256 +- download the tar.gz from github, and use `sha256sum parallel-hashmap-2.0.0.tar.gz` on linux to get the sha256 ## conan - use [forked repo](https://github.com/greg7mdp/conan-center-index) - sync fork in github - git checkout conan-io:master -- git checkout -b phmap_1.4.0 +- git checkout -b phmap_2.0.0 - update: `recipes/parallel-hashmap/all/conandata.yml` and `recipes/parallel-hashmap/config.yml` - sudo pip install conan -U - cd recipes/parallel-hashmap/all -- *does not work* conan create conanfile.py parallel-hashmap/1.4.0@ -pr:b=default -pr:h=default - update version in `recipes/parallel-hashmap/all/conanfile.py` +- *does not work* conan create conanfile.py parallel-hashmap/2.0.0@ -pr:b=default -pr:h=default + *no version??* update version in `recipes/parallel-hashmap/all/conanfile.py` - git diff -- git commit -am "[parallel-hashmap] Bump version to 1.4.0" -- git push origin phmap_1.4.0 +- git commit -am "[parallel-hashmap] Bump version to 2.0.0" +- git push origin phmap_2.0.0 - create PR like [this](https://github.com/conan-io/conan-center-index/pull/13161) @@ -27,10 +28,11 @@ - use [forked repo](https://github.com/greg7mdp/vcpkg) - sync fork in github -- git checkout -b phmap_1.4.0 -- update ports/gtl/portfile.cmake (the sha512) and ports/gtl/vcpkg.json +- `git checkout -b phmap_2.0.0` +- update ports/parallel-hashmap/portfile.cmake (the sha512) and ports/parallel-hashmap/vcpkg.json (the version #) - commit -- vcpkg x-add-version --all --overwrite-version ## (or ./vcpkg.exe --no-dry-run upgrade ) +- `./bootstrap-vcpkg.sh` +- `vcpkg x-add-version --all --overwrite-version` ## (or `./vcpkg.exe --no-dry-run upgrade` ) - commit - push - create PR diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index 5397d76..cfa7066 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -555,7 +555,7 @@ inline bool IsValidCapacity(size_t n) { return ((n + 1) & n) == 0 && n > 0; } // FULL -> DELETED // -------------------------------------------------------------------------- inline void ConvertDeletedToEmptyAndFullToDeleted( - ctrl_t* ctrl, size_t capacity) + ctrl_t* PHMAP_RESTRICT ctrl, size_t capacity) { assert(ctrl[capacity] == kSentinel); assert(IsValidCapacity(capacity)); @@ -1857,20 +1857,22 @@ private: friend struct phmap::priv::hashtable_debug_internal::HashtableDebugAccess; template - bool find_impl(const key_arg& key, size_t hashval, size_t& offset) { + bool find_impl(const key_arg& PHMAP_RESTRICT key, size_t hashval, size_t& PHMAP_RESTRICT offset) { + auto ctrl_ptr = ctrl_; PHMAP_IF_CONSTEXPR (!std_alloc_t::value) { // ctrl_ could be nullptr - if (!ctrl_) + if (!ctrl_ptr) return false; } auto seq = probe(hashval); + auto slots_ptr = slots_; while (true) { - Group g{ ctrl_ + seq.offset() }; + Group g{ ctrl_ptr + seq.offset() }; for (uint32_t i : g.Match((h2_t)H2(hashval))) { offset = seq.offset((size_t)i); if (PHMAP_PREDICT_TRUE(PolicyTraits::apply( EqualElement{key, eq_ref()}, - PolicyTraits::element(slots_ + offset)))) + PolicyTraits::element(slots_ptr + offset)))) return true; } if (PHMAP_PREDICT_TRUE(g.MatchEmpty())) @@ -2034,9 +2036,11 @@ private: std::is_same::value)) { // node map, or not trivially destructible... we need to iterate and destroy values one by one // std::cout << "either this is a node map or " << type_name() << " is not trivially_destructible\n"; - for (size_t i = 0; i != capacity_; ++i) { - if (IsFull(ctrl_[i])) { - PolicyTraits::destroy(&alloc_ref(), slots_ + i); + auto slots_ptr = slots_; + auto ctrl_ptr = ctrl_; + for (size_t i = 0, cnt = capacity_; i != cnt; ++i) { + if (IsFull(ctrl_ptr[i])) { + PolicyTraits::destroy(&alloc_ref(), slots_ptr + i); } } } @@ -2153,7 +2157,7 @@ private: } } - bool has_element(const value_type& elem, size_t hashval) const { + bool has_element(const value_type& PHMAP_RESTRICT elem, size_t hashval) const { PHMAP_IF_CONSTEXPR (!std_alloc_t::value) { // ctrl_ could be nullptr if (!ctrl_) @@ -2220,19 +2224,21 @@ private: protected: template - size_t _find_key(const K& key, size_t hashval) { + size_t _find_key(const K& PHMAP_RESTRICT key, size_t hashval) { + auto ctrl_ptr = ctrl_; PHMAP_IF_CONSTEXPR (!std_alloc_t::value) { // ctrl_ could be nullptr - if (!ctrl_) + if (!ctrl_ptr) return (size_t)-1; } auto seq = probe(hashval); + auto slots_ptr = slots_; while (true) { - Group g{ctrl_ + seq.offset()}; + Group g{ctrl_ptr + seq.offset()}; for (uint32_t i : g.Match((h2_t)H2(hashval))) { if (PHMAP_PREDICT_TRUE(PolicyTraits::apply( EqualElement{key, eq_ref()}, - PolicyTraits::element(slots_ + seq.offset((size_t)i))))) + PolicyTraits::element(slots_ptr + seq.offset((size_t)i))))) return seq.offset((size_t)i); } if (PHMAP_PREDICT_TRUE(g.MatchEmpty())) break; diff --git a/parallel_hashmap/phmap_config.h b/parallel_hashmap/phmap_config.h index b2fb0b8..a9726a6 100644 --- a/parallel_hashmap/phmap_config.h +++ b/parallel_hashmap/phmap_config.h @@ -661,6 +661,17 @@ #define PHMAP_BUILTIN_UNREACHABLE() (void)0 #endif +// ---------------------------------------------------------------------- +// RESTRICT +// ---------------------------------------------------------------------- +#if (defined(__GNUC__) && (__GNUC__ > 3)) || defined(__clang__) + #define PHMAP_RESTRICT __restrict__ +#elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define PHMAP_RESTRICT __restrict +#else + #define PHMAP_RESTRICT +#endif + // ---------------------------------------------------------------------- // base/macros.h // ----------------------------------------------------------------------