summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-05-29 20:42:43 +0200
committerTyge Løvset <[email protected]>2023-05-29 20:42:43 +0200
commit80df921622c97634aeea31821a61f46885324d9c (patch)
treed755e6e3b1294f80ff068695a7b8c5096b3b8359
parent8497b5497ecba2c2f1d368c9161ec52d4f03ae30 (diff)
downloadSTC-modified-80df921622c97634aeea31821a61f46885324d9c.tar.gz
STC-modified-80df921622c97634aeea31821a61f46885324d9c.zip
Update extern benchmark maps.
Removed i_expandby in cmap. Always expand by 2 i.e 2^n buckets..
-rw-r--r--include/stc/cmap.h22
-rw-r--r--misc/benchmarks/external/ankerl/unordered_dense.h6
-rw-r--r--misc/benchmarks/external/emhash/hash_table7.hpp2
-rw-r--r--misc/examples/scheduler.c6
4 files changed, 11 insertions, 25 deletions
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 4ba6156b..837631f8 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -265,18 +265,7 @@ _cx_memb(_eq)(const _cx_self* self, const _cx_self* other) {
#ifndef i_max_load_factor
#define i_max_load_factor 0.80f
#endif
-#ifndef i_expandby
- #define i_expandby 2
-#endif
-
-#ifndef CMAP_H_INCLUDED
-STC_INLINE intptr_t fastrange_1(uint64_t x, uint64_t n)
- { return (intptr_t)((uint32_t)x*n >> 32); } // n < 2^32
-
-STC_INLINE intptr_t fastrange_2(uint64_t x, uint64_t n)
- { return (intptr_t)(x & (n - 1)); } // n power of 2.
-
-#endif // CMAP_H_INCLUDED
+#define fastrange_2(x, n) (intptr_t)((x) & (size_t)((n) - 1)) // n power of 2.
STC_DEF _cx_iter _cx_memb(_begin)(const _cx_self* self) {
_cx_iter it = {self->data, self->data+self->bucket_count, self->slot};
@@ -356,7 +345,7 @@ STC_DEF chash_bucket
_cx_memb(_bucket_)(const _cx_self* self, const _cx_keyraw* rkeyptr) {
const uint64_t _hash = i_hash(rkeyptr);
intptr_t _cap = self->bucket_count;
- chash_bucket b = {c_PASTE(fastrange_,i_expandby)(_hash, (uint64_t)_cap), (uint8_t)(_hash | 0x80)};
+ chash_bucket b = {fastrange_2(_hash, _cap), (uint8_t)(_hash | 0x80)};
const chash_slot* s = self->slot;
while (s[b.idx].hashx) {
if (s[b.idx].hashx == b.hashx) {
@@ -413,10 +402,8 @@ _cx_memb(_reserve)(_cx_self* self, const intptr_t _newcap) {
const intptr_t _oldbucks = self->bucket_count;
if (_newcap != self->size && _newcap <= _oldbucks)
return true;
- intptr_t _newbucks = (intptr_t)((float)_newcap / (i_max_load_factor)) | 1;
- #if i_expandby == 2
+ intptr_t _newbucks = (intptr_t)((float)_newcap / (i_max_load_factor)) + 4;
_newbucks = cnextpow2(_newbucks);
- #endif
_cx_self m = {
(_cx_value *)i_malloc(_newbucks*c_sizeof(_cx_value)),
(chash_slot *)i_calloc(_newbucks + 1, sizeof(chash_slot)),
@@ -452,7 +439,7 @@ _cx_memb(_erase_entry)(_cx_self* self, _cx_value* _val) {
if (! s[j].hashx)
break;
const _cx_keyraw _raw = i_keyto(_i_keyref(d + j));
- k = (intptr_t)c_PASTE(fastrange_,i_expandby)(i_hash((&_raw)), (uint64_t)_cap);
+ k = fastrange_2(i_hash((&_raw)), _cap);
if ((j < i) ^ (k <= i) ^ (k > j)) { // is k outside (i, j]?
d[i] = d[j];
s[i] = s[j];
@@ -464,7 +451,6 @@ _cx_memb(_erase_entry)(_cx_self* self, _cx_value* _val) {
}
#endif // i_implement
#undef i_max_load_factor
-#undef i_expandby
#undef _i_isset
#undef _i_ismap
#undef _i_keyref
diff --git a/misc/benchmarks/external/ankerl/unordered_dense.h b/misc/benchmarks/external/ankerl/unordered_dense.h
index dc4de8ab..b8cacea7 100644
--- a/misc/benchmarks/external/ankerl/unordered_dense.h
+++ b/misc/benchmarks/external/ankerl/unordered_dense.h
@@ -1,7 +1,7 @@
///////////////////////// ankerl::unordered_dense::{map, set} /////////////////////////
// A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion.
-// Version 4.0.0
+// Version 4.0.1
// https://github.com/martinus/unordered_dense
//
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
@@ -32,7 +32,7 @@
// see https://semver.org/spec/v2.0.0.html
#define ANKERL_UNORDERED_DENSE_VERSION_MAJOR 4 // NOLINT(cppcoreguidelines-macro-usage) incompatible API changes
#define ANKERL_UNORDERED_DENSE_VERSION_MINOR 0 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible functionality
-#define ANKERL_UNORDERED_DENSE_VERSION_PATCH 0 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible bug fixes
+#define ANKERL_UNORDERED_DENSE_VERSION_PATCH 1 // NOLINT(cppcoreguidelines-macro-usage) backwards compatible bug fixes
// API versioning with inline namespace, see https://www.foonathan.net/2018/11/inline-namespaces/
@@ -1907,7 +1907,7 @@ auto erase_if(ankerl::unordered_dense::detail::table<Key, T, Hash, KeyEqual, All
}
}
- return map.size() - old_size;
+ return old_size - map.size();
}
} // namespace std
diff --git a/misc/benchmarks/external/emhash/hash_table7.hpp b/misc/benchmarks/external/emhash/hash_table7.hpp
index c21e145b..41970d8c 100644
--- a/misc/benchmarks/external/emhash/hash_table7.hpp
+++ b/misc/benchmarks/external/emhash/hash_table7.hpp
@@ -1777,7 +1777,7 @@ private:
next_bucket = find_last_bucket(next_bucket);
//find a new empty and link it to tail
- return EMH_BUCKET(_pairs, next_bucket) = find_unique_empty(next_bucket);
+ return EMH_BUCKET(_pairs, next_bucket) = find_empty_bucket(next_bucket, bucket);
}
#if EMH_INT_HASH
diff --git a/misc/examples/scheduler.c b/misc/examples/scheduler.c
index ea1414c7..aecb1a26 100644
--- a/misc/examples/scheduler.c
+++ b/misc/examples/scheduler.c
@@ -12,12 +12,12 @@ struct Task {
#define i_type Scheduler
#define i_val struct Task
#define i_no_cmp
-#include <stc/clist.h>
+#include <stc/cqueue.h>
static bool schedule(Scheduler* sched)
{
struct Task task = *Scheduler_front(sched);
- Scheduler_pop_front(sched);
+ Scheduler_pop(sched);
if (!cco_done(&task))
task.resume(&task);
@@ -27,7 +27,7 @@ static bool schedule(Scheduler* sched)
static bool push_task(const struct Task* task)
{
- Scheduler_push_back(task->sched, *task);
+ Scheduler_push(task->sched, *task);
return false;
}