Skip to content

Commit

Permalink
sync phmap
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Jul 22, 2023
1 parent b90164e commit 42fba64
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 22 deletions.
2 changes: 1 addition & 1 deletion include/bela/__phmap/VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
https://github.com/greg7mdp/parallel-hashmap.git
79cbd2dafd5aab3829064d1b48b71137623d8ff2
77cab8192a879e5d27188f97e8f2080dd7e36ca8
16 changes: 8 additions & 8 deletions include/bela/__phmap/btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace phmap {
bool, std::is_copy_constructible<
type_traits_internal::SingleMemberUnion<T>>::value &&
std::is_trivially_destructible<T>::value> {};

#if 0
template <class T>
struct IsTriviallyMoveAssignableReference : std::false_type {};

Expand All @@ -119,7 +119,7 @@ namespace phmap {
template <class T>
struct IsTriviallyMoveAssignableReference<T&&>
: std::is_trivially_move_assignable<T>::type {};

#endif
} // namespace type_traits_internal


Expand Down Expand Up @@ -148,8 +148,8 @@ namespace phmap {

public:
static constexpr bool kValue =
(std::is_trivially_copyable<ExtentsRemoved>::value || !kIsCopyOrMoveConstructible) &&
(std::is_trivially_copy_assignable<ExtentsRemoved>::value || !kIsCopyOrMoveAssignable) &&
(phmap::is_trivially_copyable<ExtentsRemoved>::value || !kIsCopyOrMoveConstructible) &&
(phmap::is_trivially_copy_assignable<ExtentsRemoved>::value || !kIsCopyOrMoveAssignable) &&
(kIsCopyOrMoveConstructible || kIsCopyOrMoveAssignable) &&
std::is_trivially_destructible<ExtentsRemoved>::value &&
// We need to check for this explicitly because otherwise we'll say
Expand Down Expand Up @@ -3321,8 +3321,8 @@ namespace priv {
// ----------------
template <typename K = key_type>
size_type count(const key_arg<K> &key) const {
auto equal_range = this->equal_range(key);
return std::distance(equal_range.first, equal_range.second);
auto er = this->equal_range(key);
return std::distance(er.first, er.second);
}
template <typename K = key_type>
iterator find(const key_arg<K> &key) {
Expand Down Expand Up @@ -3362,8 +3362,8 @@ namespace priv {
}
template <typename K = key_type>
size_type erase(const key_arg<K> &key) {
auto equal_range = this->equal_range(key);
return tree_.erase_range(equal_range.first, equal_range.second).first;
auto er = this->equal_range(key);
return tree_.erase_range(er.first, er.second).first;
}
node_type extract(iterator position) {
// Use Move instead of Transfer, because the rebalancing code expects to
Expand Down
12 changes: 6 additions & 6 deletions include/bela/__phmap/phmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -2271,14 +2271,14 @@ class raw_hash_set
}

// Reset all ctrl bytes back to kEmpty, except the sentinel.
void reset_ctrl(size_t capacity) {
std::memset(ctrl_, kEmpty, capacity + Group::kWidth);
ctrl_[capacity] = kSentinel;
SanitizerPoisonMemoryRegion(slots_, sizeof(slot_type) * capacity);
void reset_ctrl(size_t new_capacity) {
std::memset(ctrl_, kEmpty, new_capacity + Group::kWidth);
ctrl_[new_capacity] = kSentinel;
SanitizerPoisonMemoryRegion(slots_, sizeof(slot_type) * new_capacity);
}

void reset_growth_left(size_t capacity) {
growth_left() = CapacityToGrowth(capacity) - size_;
void reset_growth_left(size_t new_capacity) {
growth_left() = CapacityToGrowth(new_capacity) - size_;
}

size_t& growth_left() { return std::get<0>(settings_); }
Expand Down
43 changes: 39 additions & 4 deletions include/bela/__phmap/phmap_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,36 @@ struct disjunction<> : std::false_type {};
template <typename T>
struct negation : std::integral_constant<bool, !T::value> {};

#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) && !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
#define PHMAP_OLD_GCC 1
#else
#define PHMAP_OLD_GCC 0
#endif

#if PHMAP_OLD_GCC
template <typename T>
struct is_trivially_copy_constructible
: std::integral_constant<bool,
__has_trivial_copy(typename std::remove_reference<T>::type) &&
std::is_copy_constructible<T>::value &&
std::is_trivially_destructible<T>::value> {};

template <typename T>
struct is_trivially_copy_assignable :
std::integral_constant<bool,
__has_trivial_assign(typename std::remove_reference<T>::type) &&
phmap::is_copy_assignable<T>::value> {};

template <typename T>
struct is_trivially_copyable :
std::integral_constant<bool, __has_trivial_copy(typename std::remove_reference<T>::type)> {};

#else
template <typename T> using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
template <typename T> using is_trivially_copy_assignable = std::is_trivially_copy_assignable<T>;
template <typename T> using is_trivially_copyable = std::is_trivially_copyable<T>;
#endif

// -----------------------------------------------------------------------------
// C++14 "_t" trait aliases
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -1788,8 +1818,8 @@ class optional_data_base : public optional_data_dtor_base<T>
// supported now, so we use is_trivially_* traits instead.
template <typename T,
bool unused =
std::is_trivially_copy_constructible<T>::value &&
std::is_trivially_copy_assignable<typename std::remove_cv<T>::type>::value &&
phmap::is_trivially_copy_constructible<T>::value &&
phmap::is_trivially_copy_assignable<typename std::remove_cv<T>::type>::value &&
std::is_trivially_destructible<T>::value>
class optional_data;

Expand Down Expand Up @@ -2021,6 +2051,11 @@ struct optional_hash_base<T, decltype(std::hash<phmap::remove_const_t<T> >()(
// -----------------------------------------------------------------------------
// phmap::optional class definition
// -----------------------------------------------------------------------------
#if PHMAP_OLD_GCC
#define PHMAP_OPTIONAL_NOEXCEPT
#else
#define PHMAP_OPTIONAL_NOEXCEPT noexcept
#endif

template <typename T>
class optional : private optional_internal::optional_data<T>,
Expand All @@ -2047,7 +2082,7 @@ class optional : private optional_internal::optional_data<T>,
optional(const optional& src) = default;

// Move constructor, standard semantics
optional(optional&& src) noexcept = default;
optional(optional&& src) PHMAP_OPTIONAL_NOEXCEPT = default;

// Constructs a non-empty `optional` direct-initialized value of type `T` from
// the arguments `std::forward<Args>(args)...` within the `optional`.
Expand Down Expand Up @@ -2187,7 +2222,7 @@ class optional : private optional_internal::optional_data<T>,
optional& operator=(const optional& src) = default;

// Move assignment operator, standard semantics
optional& operator=(optional&& src) noexcept = default;
optional& operator=(optional&& src) PHMAP_OPTIONAL_NOEXCEPT = default;

// Value assignment operators
template <
Expand Down
11 changes: 8 additions & 3 deletions include/bela/__phmap/phmap_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
#define PHMAP_HAVE_BUILTIN(x) 0
#endif

#if (defined(_MSVC_LANG) && _MSVC_LANG >= 201703) || __cplusplus >= 201703
#if (!defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 5) && \
((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
#define PHMAP_HAVE_CC17 1
#else
#define PHMAP_HAVE_CC17 0
Expand Down Expand Up @@ -313,8 +314,12 @@
#endif
#endif

#if PHMAP_HAVE_CC17 && (!defined(__has_include) || __has_include(<shared_mutex>))
#define PHMAP_HAVE_SHARED_MUTEX 1
#if PHMAP_HAVE_CC17
#ifdef __has_include
#if __has_include(<shared_mutex>)
#define PHMAP_HAVE_SHARED_MUTEX 1
#endif
#endif
#endif

#ifndef PHMAP_HAVE_STD_STRING_VIEW
Expand Down

0 comments on commit 42fba64

Please sign in to comment.