summaryrefslogtreecommitdiffhomepage
path: root/benchmarks/external
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-06-02 18:02:12 +0200
committerTyge Løvset <[email protected]>2022-06-02 18:02:12 +0200
commitdd5ff55b2ec373370c894ad7e3aec884ce640a43 (patch)
treed681e9117246b1aa6ed69d2c2f3a02abba234df2 /benchmarks/external
parent1732086e71074951ea5bf6ca000c907bd933369b (diff)
downloadSTC-modified-dd5ff55b2ec373370c894ad7e3aec884ce640a43.tar.gz
STC-modified-dd5ff55b2ec373370c894ad7e3aec884ce640a43.zip
Improved namings in utf8tabs.py and removed unicode tables
Diffstat (limited to 'benchmarks/external')
-rw-r--r--benchmarks/external/robin_hood.h45
-rw-r--r--benchmarks/external/tsl/hopscotch_hash.h11
-rw-r--r--benchmarks/external/tsl/robin_growth_policy.h6
-rw-r--r--benchmarks/external/tsl/robin_hash.h45
-rw-r--r--benchmarks/external/tsl/robin_map.h8
5 files changed, 75 insertions, 40 deletions
diff --git a/benchmarks/external/robin_hood.h b/benchmarks/external/robin_hood.h
index ec2af8c6..0af031f5 100644
--- a/benchmarks/external/robin_hood.h
+++ b/benchmarks/external/robin_hood.h
@@ -36,7 +36,7 @@
// see https://semver.org/
#define ROBIN_HOOD_VERSION_MAJOR 3 // for incompatible API changes
#define ROBIN_HOOD_VERSION_MINOR 11 // for adding functionality in a backwards-compatible manner
-#define ROBIN_HOOD_VERSION_PATCH 3 // for backwards-compatible bug fixes
+#define ROBIN_HOOD_VERSION_PATCH 5 // for backwards-compatible bug fixes
#include <algorithm>
#include <cstdlib>
@@ -1821,6 +1821,12 @@ public:
}
template <typename... Args>
+ iterator emplace_hint(const_iterator position, Args&&... args) {
+ (void)position;
+ return emplace(std::forward<Args>(args)...).first;
+ }
+
+ template <typename... Args>
std::pair<iterator, bool> try_emplace(const key_type& key, Args&&... args) {
return try_emplace_impl(key, std::forward<Args>(args)...);
}
@@ -1831,16 +1837,15 @@ public:
}
template <typename... Args>
- std::pair<iterator, bool> try_emplace(const_iterator hint, const key_type& key,
- Args&&... args) {
+ iterator try_emplace(const_iterator hint, const key_type& key, Args&&... args) {
(void)hint;
- return try_emplace_impl(key, std::forward<Args>(args)...);
+ return try_emplace_impl(key, std::forward<Args>(args)...).first;
}
template <typename... Args>
- std::pair<iterator, bool> try_emplace(const_iterator hint, key_type&& key, Args&&... args) {
+ iterator try_emplace(const_iterator hint, key_type&& key, Args&&... args) {
(void)hint;
- return try_emplace_impl(std::move(key), std::forward<Args>(args)...);
+ return try_emplace_impl(std::move(key), std::forward<Args>(args)...).first;
}
template <typename Mapped>
@@ -1854,16 +1859,15 @@ public:
}
template <typename Mapped>
- std::pair<iterator, bool> insert_or_assign(const_iterator hint, const key_type& key,
- Mapped&& obj) {
+ iterator insert_or_assign(const_iterator hint, const key_type& key, Mapped&& obj) {
(void)hint;
- return insertOrAssignImpl(key, std::forward<Mapped>(obj));
+ return insertOrAssignImpl(key, std::forward<Mapped>(obj)).first;
}
template <typename Mapped>
- std::pair<iterator, bool> insert_or_assign(const_iterator hint, key_type&& key, Mapped&& obj) {
+ iterator insert_or_assign(const_iterator hint, key_type&& key, Mapped&& obj) {
(void)hint;
- return insertOrAssignImpl(std::move(key), std::forward<Mapped>(obj));
+ return insertOrAssignImpl(std::move(key), std::forward<Mapped>(obj)).first;
}
std::pair<iterator, bool> insert(const value_type& keyval) {
@@ -1871,10 +1875,20 @@ public:
return emplace(keyval);
}
+ iterator insert(const_iterator hint, const value_type& keyval) {
+ (void)hint;
+ return emplace(keyval).first;
+ }
+
std::pair<iterator, bool> insert(value_type&& keyval) {
return emplace(std::move(keyval));
}
+ iterator insert(const_iterator hint, value_type&& keyval) {
+ (void)hint;
+ return emplace(std::move(keyval)).first;
+ }
+
// Returns 1 if key is found, 0 otherwise.
size_t count(const key_type& key) const { // NOLINT(modernize-use-nodiscard)
ROBIN_HOOD_TRACE(this)
@@ -2107,10 +2121,6 @@ public:
ROBIN_HOOD_TRACE(this)
return MaxLoadFactor100 / 100.0F;
}
- void max_load_factor(float) const noexcept { // NOLINT(modernize-use-nodiscard)
- ROBIN_HOOD_TRACE(this)
- }
-
// Average number of elements per bucket. Since we allow only 1 per bucket
float load_factor() const noexcept { // NOLINT(modernize-use-nodiscard)
@@ -2312,13 +2322,14 @@ private:
auto const numElementsWithBuffer = calcNumElementsWithBuffer(max_elements);
- // calloc also zeroes everything
+ // malloc & zero mInfo. Faster than calloc everything.
auto const numBytesTotal = calcNumBytesTotal(numElementsWithBuffer);
ROBIN_HOOD_LOG("std::calloc " << numBytesTotal << " = calcNumBytesTotal("
<< numElementsWithBuffer << ")")
mKeyVals = reinterpret_cast<Node*>(
- detail::assertNotNull<std::bad_alloc>(std::calloc(1, numBytesTotal)));
+ detail::assertNotNull<std::bad_alloc>(std::malloc(numBytesTotal)));
mInfo = reinterpret_cast<uint8_t*>(mKeyVals + numElementsWithBuffer);
+ std::memset(mInfo, 0, numBytesTotal - numElementsWithBuffer * sizeof(Node));
// set sentinel
mInfo[numElementsWithBuffer] = 1;
diff --git a/benchmarks/external/tsl/hopscotch_hash.h b/benchmarks/external/tsl/hopscotch_hash.h
index ad4f58e0..6611ff93 100644
--- a/benchmarks/external/tsl/hopscotch_hash.h
+++ b/benchmarks/external/tsl/hopscotch_hash.h
@@ -35,6 +35,7 @@
#include <iterator>
#include <limits>
#include <memory>
+#include <new>
#include <stdexcept>
#include <tuple>
#include <type_traits>
@@ -309,12 +310,22 @@ class hopscotch_bucket : public hopscotch_bucket_hash<StoreHash> {
value_type& value() noexcept {
tsl_hh_assert(!empty());
+#if defined(__cplusplus) && __cplusplus >= 201703L
+ return *std::launder(
+ reinterpret_cast<value_type*>(std::addressof(m_value)));
+#else
return *reinterpret_cast<value_type*>(std::addressof(m_value));
+#endif
}
const value_type& value() const noexcept {
tsl_hh_assert(!empty());
+#if defined(__cplusplus) && __cplusplus >= 201703L
+ return *std::launder(
+ reinterpret_cast<const value_type*>(std::addressof(m_value)));
+#else
return *reinterpret_cast<const value_type*>(std::addressof(m_value));
+#endif
}
template <typename... Args>
diff --git a/benchmarks/external/tsl/robin_growth_policy.h b/benchmarks/external/tsl/robin_growth_policy.h
index 62f9a2e0..eba8cdfa 100644
--- a/benchmarks/external/tsl/robin_growth_policy.h
+++ b/benchmarks/external/tsl/robin_growth_policy.h
@@ -51,15 +51,15 @@
#define TSL_RH_THROW_OR_TERMINATE(ex, msg) throw ex(msg)
#else
#define TSL_RH_NO_EXCEPTIONS
-#ifdef NDEBUG
-#define TSL_RH_THROW_OR_TERMINATE(ex, msg) std::terminate()
-#else
+#ifdef TSL_DEBUG
#include <iostream>
#define TSL_RH_THROW_OR_TERMINATE(ex, msg) \
do { \
std::cerr << msg << std::endl; \
std::terminate(); \
} while (0)
+#else
+#define TSL_RH_THROW_OR_TERMINATE(ex, msg) std::terminate()
#endif
#endif
diff --git a/benchmarks/external/tsl/robin_hash.h b/benchmarks/external/tsl/robin_hash.h
index e34eac32..f9fb9e76 100644
--- a/benchmarks/external/tsl/robin_hash.h
+++ b/benchmarks/external/tsl/robin_hash.h
@@ -33,6 +33,7 @@
#include <iterator>
#include <limits>
#include <memory>
+#include <new>
#include <stdexcept>
#include <tuple>
#include <type_traits>
@@ -195,6 +196,7 @@ class bucket_entry : public bucket_entry_hash<StoreHash> {
value_type(other.value());
m_dist_from_ideal_bucket = other.m_dist_from_ideal_bucket;
}
+ tsl_rh_assert(empty() == other.empty());
}
/**
@@ -212,6 +214,7 @@ class bucket_entry : public bucket_entry_hash<StoreHash> {
value_type(std::move(other.value()));
m_dist_from_ideal_bucket = other.m_dist_from_ideal_bucket;
}
+ tsl_rh_assert(empty() == other.empty());
}
bucket_entry& operator=(const bucket_entry& other) noexcept(
@@ -249,12 +252,22 @@ class bucket_entry : public bucket_entry_hash<StoreHash> {
value_type& value() noexcept {
tsl_rh_assert(!empty());
+#if defined(__cplusplus) && __cplusplus >= 201703L
+ return *std::launder(
+ reinterpret_cast<value_type*>(std::addressof(m_value)));
+#else
return *reinterpret_cast<value_type*>(std::addressof(m_value));
+#endif
}
const value_type& value() const noexcept {
tsl_rh_assert(!empty());
+#if defined(__cplusplus) && __cplusplus >= 201703L
+ return *std::launder(
+ reinterpret_cast<const value_type*>(std::addressof(m_value)));
+#else
return *reinterpret_cast<const value_type*>(std::addressof(m_value));
+#endif
}
distance_type dist_from_ideal_bucket() const noexcept {
@@ -283,6 +296,7 @@ class bucket_entry : public bucket_entry_hash<StoreHash> {
void swap_with_value_in_bucket(distance_type& dist_from_ideal_bucket,
truncated_hash_type& hash, value_type& value) {
tsl_rh_assert(!empty());
+ tsl_rh_assert(dist_from_ideal_bucket > m_dist_from_ideal_bucket);
using std::swap;
swap(value, this->value());
@@ -410,9 +424,9 @@ class robin_hash : private Hash, private KeyEqual, private GrowthPolicy {
TSL_RH_UNUSED(bucket_count);
return true;
} else if (STORE_HASH && is_power_of_two_policy<GrowthPolicy>::value) {
- tsl_rh_assert(bucket_count > 0);
- return (bucket_count - 1) <=
- std::numeric_limits<truncated_hash_type>::max();
+ return bucket_count == 0 ||
+ (bucket_count - 1) <=
+ std::numeric_limits<truncated_hash_type>::max();
} else {
TSL_RH_UNUSED(bucket_count);
return false;
@@ -536,23 +550,18 @@ class robin_hash : private Hash, private KeyEqual, private GrowthPolicy {
: Hash(hash),
KeyEqual(equal),
GrowthPolicy(bucket_count),
- m_buckets_data(
- [&]() {
- if (bucket_count > max_bucket_count()) {
- TSL_RH_THROW_OR_TERMINATE(
- std::length_error,
- "The map exceeds its maximum bucket count.");
- }
-
- return bucket_count;
- }(),
- alloc),
+ m_buckets_data(bucket_count, alloc),
m_buckets(m_buckets_data.empty() ? static_empty_bucket_ptr()
: m_buckets_data.data()),
m_bucket_count(bucket_count),
m_nb_elements(0),
m_grow_on_next_insert(false),
m_try_shrink_on_next_insert(false) {
+ if (bucket_count > max_bucket_count()) {
+ TSL_RH_THROW_OR_TERMINATE(std::length_error,
+ "The map exceeds its maximum bucket count.");
+ }
+
if (m_bucket_count > 0) {
tsl_rh_assert(!m_buckets_data.empty());
m_buckets_data.back().set_as_last_bucket();
@@ -664,7 +673,7 @@ class robin_hash : private Hash, private KeyEqual, private GrowthPolicy {
robin_hash& operator=(robin_hash&& other) {
other.swap(*this);
- other.clear();
+ other.clear_and_shrink();
return *this;
}
@@ -1073,11 +1082,12 @@ class robin_hash : private Hash, private KeyEqual, private GrowthPolicy {
m_max_load_factor = clamp(ml, float(MINIMUM_MAX_LOAD_FACTOR),
float(MAXIMUM_MAX_LOAD_FACTOR));
m_load_threshold = size_type(float(bucket_count()) * m_max_load_factor);
+ tsl_rh_assert(bucket_count() == 0 || m_load_threshold < bucket_count());
}
void rehash(size_type count_) {
count_ = std::max(count_,
- size_type(std::ceil(float(size()) / max_load_factor())));
+ size_type(std::ceil(float(size()) / max_load_factor())));
rehash_impl(count_);
}
@@ -1276,6 +1286,8 @@ class robin_hash : private Hash, private KeyEqual, private GrowthPolicy {
void insert_value_impl(std::size_t ibucket,
distance_type dist_from_ideal_bucket,
truncated_hash_type hash, value_type& value) {
+ tsl_rh_assert(dist_from_ideal_bucket >
+ m_buckets[ibucket].dist_from_ideal_bucket());
m_buckets[ibucket].swap_with_value_in_bucket(dist_from_ideal_bucket, hash,
value);
ibucket = next_bucket(ibucket);
@@ -1309,6 +1321,7 @@ class robin_hash : private Hash, private KeyEqual, private GrowthPolicy {
robin_hash new_table(count_, static_cast<Hash&>(*this),
static_cast<KeyEqual&>(*this), get_allocator(),
m_min_load_factor, m_max_load_factor);
+ tsl_rh_assert(size() <= new_table.m_load_threshold);
const bool use_stored_hash =
USE_STORED_HASH_ON_REHASH(new_table.bucket_count());
diff --git a/benchmarks/external/tsl/robin_map.h b/benchmarks/external/tsl/robin_map.h
index 3de7a59d..aeb354c3 100644
--- a/benchmarks/external/tsl/robin_map.h
+++ b/benchmarks/external/tsl/robin_map.h
@@ -97,8 +97,8 @@ class robin_map {
public:
using key_type = Key;
- const key_type& operator()(const std::pair<Key, T>& key_value) const
- noexcept {
+ const key_type& operator()(
+ const std::pair<Key, T>& key_value) const noexcept {
return key_value.first;
}
@@ -111,8 +111,8 @@ class robin_map {
public:
using value_type = T;
- const value_type& operator()(const std::pair<Key, T>& key_value) const
- noexcept {
+ const value_type& operator()(
+ const std::pair<Key, T>& key_value) const noexcept {
return key_value.second;
}