diff options
| author | Tyge Løvset <[email protected]> | 2021-11-06 23:14:20 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-11-06 23:14:20 +0100 |
| commit | 52e35a16e81181aea361a8257d5d447b599a00ab (patch) | |
| tree | ba12e93eb92b7cba79ef0d6b6a556a39535d695b | |
| parent | 38935b1d85da5be067b5cf0c00dc02d8cb231f9e (diff) | |
| download | STC-modified-52e35a16e81181aea361a8257d5d447b599a00ab.tar.gz STC-modified-52e35a16e81181aea361a8257d5d447b599a00ab.zip | |
Updated shootout_hashmaps.cpp. Cleanup/renamed benchmark folders.
| -rw-r--r-- | .gitattributes | 2 | ||||
| -rw-r--r-- | benchmarks/build_all.sh | 8 | ||||
| -rw-r--r-- | benchmarks/external/khash.h (renamed from benchmarks/others/khash.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/btree.h (renamed from benchmarks/others/parallel_hashmap/btree.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/conanfile.py (renamed from benchmarks/others/parallel_hashmap/conanfile.py) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/meminfo.h (renamed from benchmarks/others/parallel_hashmap/meminfo.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/phmap.h (renamed from benchmarks/others/parallel_hashmap/phmap.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/phmap_base.h (renamed from benchmarks/others/parallel_hashmap/phmap_base.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/phmap_bits.h (renamed from benchmarks/others/parallel_hashmap/phmap_bits.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/phmap_config.h (renamed from benchmarks/others/parallel_hashmap/phmap_config.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/phmap_dump.h (renamed from benchmarks/others/parallel_hashmap/phmap_dump.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/phmap_fwd_decl.h (renamed from benchmarks/others/parallel_hashmap/phmap_fwd_decl.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/parallel_hashmap/phmap_utils.h (renamed from benchmarks/others/parallel_hashmap/phmap_utils.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/robin_hood.h (renamed from benchmarks/others/robin_hood.hpp) | 0 | ||||
| -rw-r--r-- | benchmarks/external/skarupke/bytell_hash_map.hpp (renamed from benchmarks/others/skarupke/bytell_hash_map.hpp) | 0 | ||||
| -rw-r--r-- | benchmarks/external/skarupke/flat_hash_map.hpp (renamed from benchmarks/others/skarupke/flat_hash_map.hpp) | 0 | ||||
| -rw-r--r-- | benchmarks/external/tsl/hopscotch_growth_policy.h (renamed from benchmarks/others/tsl/hopscotch_growth_policy.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/tsl/hopscotch_hash.h (renamed from benchmarks/others/tsl/hopscotch_hash.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/tsl/hopscotch_map.h (renamed from benchmarks/others/tsl/hopscotch_map.h) | 0 | ||||
| -rw-r--r-- | benchmarks/external/update.sh (renamed from benchmarks/others/update.sh) | 0 | ||||
| -rw-r--r-- | benchmarks/misc/names.txt (renamed from benchmarks/names.txt) | 0 | ||||
| -rw-r--r-- | benchmarks/misc/prng_bench.cpp (renamed from benchmarks/shootout4_crand.cpp) | 0 | ||||
| -rw-r--r-- | benchmarks/misc/rust_cmap.c (renamed from benchmarks/rust_cmap.c) | 0 | ||||
| -rw-r--r-- | benchmarks/misc/rust_hashmap.rs (renamed from benchmarks/rust_hashmap.rs) | 0 | ||||
| -rw-r--r-- | benchmarks/misc/string_bench.c (renamed from benchmarks/string_bench.c) | 0 | ||||
| -rw-r--r-- | benchmarks/misc/string_bench.cpp (renamed from benchmarks/string_bench.cpp) | 0 | ||||
| -rw-r--r-- | benchmarks/others/old/carray_v1.h | 215 | ||||
| -rw-r--r-- | benchmarks/picobench/picobench.hpp (renamed from benchmarks/picobench.hpp) | 0 | ||||
| -rw-r--r-- | benchmarks/picobench/picobench_cmap.cpp (renamed from benchmarks/shootout1_cmap.cpp) | 8 | ||||
| -rw-r--r-- | benchmarks/picobench/picobench_csmap.cpp (renamed from benchmarks/shootout3_csmap.cpp) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/cdeq_benchmark.cpp (renamed from benchmarks/cdeq_benchmark.cpp) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/clist_benchmark.cpp (renamed from benchmarks/clist_benchmark.cpp) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/cmap_benchmark.cpp (renamed from benchmarks/cmap_benchmark.cpp) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/cpque_benchmark.cpp (renamed from benchmarks/cpque_benchmark.cpp) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/csmap_benchmark.cpp (renamed from benchmarks/csmap_benchmark.cpp) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/cvec_benchmark.cpp (renamed from benchmarks/cvec_benchmark.cpp) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/plot.py (renamed from benchmarks/plot.py) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/run_all.bat (renamed from benchmarks/run_all.bat) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/run_all.sh (renamed from benchmarks/run_all.sh) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/run_clang.sh (renamed from benchmarks/run_clang.sh) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/run_gcc.sh (renamed from benchmarks/run_gcc.sh) | 0 | ||||
| -rw-r--r-- | benchmarks/plotbench/run_vc.bat (renamed from benchmarks/run_vc.bat) | 0 | ||||
| -rw-r--r-- | benchmarks/shootout_hashmaps.cpp (renamed from benchmarks/shootout2_cmap.cpp) | 130 | ||||
| -rw-r--r-- | include/stc/alt/clist.h (renamed from benchmarks/others/old/clist.h) | 0 | ||||
| -rw-r--r-- | include/stc/alt/csmap.h (renamed from benchmarks/others/old/csmap.h) | 0 | ||||
| -rw-r--r-- | include/stc/alt/sstr.h (renamed from benchmarks/others/old/sstr.h) | 0 | ||||
| -rw-r--r-- | include/stc/cmap.h | 2 |
47 files changed, 74 insertions, 291 deletions
diff --git a/.gitattributes b/.gitattributes index 474746c1..66fdcd56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,3 @@ -benchmarks/others/* linguist-vendored
+benchmarks/external/* linguist-vendored
*.h linguist-language=C
*.c linguist-language=C
diff --git a/benchmarks/build_all.sh b/benchmarks/build_all.sh index 36dc8f33..348a79dd 100644 --- a/benchmarks/build_all.sh +++ b/benchmarks/build_all.sh @@ -18,14 +18,14 @@ if [ ! -z "$1" ] ; then cc=$@ fi if [ $run = 0 ] ; then - for i in *.cpp ; do + for i in misc/*.c* picobench/*.cpp plotbench/*.cpp ; do echo $cc -I../include $i $cc -I../include $i done else - for i in *.c ; do - echo $cc -I../include $i - $cc -I../include $i + for i in misc/*.c* picobench/*.cpp ; do + echo $cc -O3 -I../include $i + $cc -O3 -I../include $i if [ -f $(basename -s .c $i).exe ]; then ./$(basename -s .c $i).exe; fi if [ -f ./a.exe ]; then ./a.exe; fi if [ -f ./a.out ]; then ./a.out; fi diff --git a/benchmarks/others/khash.h b/benchmarks/external/khash.h index 61dabc4d..61dabc4d 100644 --- a/benchmarks/others/khash.h +++ b/benchmarks/external/khash.h diff --git a/benchmarks/others/parallel_hashmap/btree.h b/benchmarks/external/parallel_hashmap/btree.h index b8c95433..b8c95433 100644 --- a/benchmarks/others/parallel_hashmap/btree.h +++ b/benchmarks/external/parallel_hashmap/btree.h diff --git a/benchmarks/others/parallel_hashmap/conanfile.py b/benchmarks/external/parallel_hashmap/conanfile.py index c046377d..c046377d 100644 --- a/benchmarks/others/parallel_hashmap/conanfile.py +++ b/benchmarks/external/parallel_hashmap/conanfile.py diff --git a/benchmarks/others/parallel_hashmap/meminfo.h b/benchmarks/external/parallel_hashmap/meminfo.h index 872f3c69..872f3c69 100644 --- a/benchmarks/others/parallel_hashmap/meminfo.h +++ b/benchmarks/external/parallel_hashmap/meminfo.h diff --git a/benchmarks/others/parallel_hashmap/phmap.h b/benchmarks/external/parallel_hashmap/phmap.h index 653ae5ea..653ae5ea 100644 --- a/benchmarks/others/parallel_hashmap/phmap.h +++ b/benchmarks/external/parallel_hashmap/phmap.h diff --git a/benchmarks/others/parallel_hashmap/phmap_base.h b/benchmarks/external/parallel_hashmap/phmap_base.h index d0c6f3ce..d0c6f3ce 100644 --- a/benchmarks/others/parallel_hashmap/phmap_base.h +++ b/benchmarks/external/parallel_hashmap/phmap_base.h diff --git a/benchmarks/others/parallel_hashmap/phmap_bits.h b/benchmarks/external/parallel_hashmap/phmap_bits.h index 6b765fff..6b765fff 100644 --- a/benchmarks/others/parallel_hashmap/phmap_bits.h +++ b/benchmarks/external/parallel_hashmap/phmap_bits.h diff --git a/benchmarks/others/parallel_hashmap/phmap_config.h b/benchmarks/external/parallel_hashmap/phmap_config.h index fa515025..fa515025 100644 --- a/benchmarks/others/parallel_hashmap/phmap_config.h +++ b/benchmarks/external/parallel_hashmap/phmap_config.h diff --git a/benchmarks/others/parallel_hashmap/phmap_dump.h b/benchmarks/external/parallel_hashmap/phmap_dump.h index 0f2018ef..0f2018ef 100644 --- a/benchmarks/others/parallel_hashmap/phmap_dump.h +++ b/benchmarks/external/parallel_hashmap/phmap_dump.h diff --git a/benchmarks/others/parallel_hashmap/phmap_fwd_decl.h b/benchmarks/external/parallel_hashmap/phmap_fwd_decl.h index a7719c49..a7719c49 100644 --- a/benchmarks/others/parallel_hashmap/phmap_fwd_decl.h +++ b/benchmarks/external/parallel_hashmap/phmap_fwd_decl.h diff --git a/benchmarks/others/parallel_hashmap/phmap_utils.h b/benchmarks/external/parallel_hashmap/phmap_utils.h index 1d0c4728..1d0c4728 100644 --- a/benchmarks/others/parallel_hashmap/phmap_utils.h +++ b/benchmarks/external/parallel_hashmap/phmap_utils.h diff --git a/benchmarks/others/robin_hood.hpp b/benchmarks/external/robin_hood.h index ec2af8c6..ec2af8c6 100644 --- a/benchmarks/others/robin_hood.hpp +++ b/benchmarks/external/robin_hood.h diff --git a/benchmarks/others/skarupke/bytell_hash_map.hpp b/benchmarks/external/skarupke/bytell_hash_map.hpp index 9c9a2467..9c9a2467 100644 --- a/benchmarks/others/skarupke/bytell_hash_map.hpp +++ b/benchmarks/external/skarupke/bytell_hash_map.hpp diff --git a/benchmarks/others/skarupke/flat_hash_map.hpp b/benchmarks/external/skarupke/flat_hash_map.hpp index a8723ee8..a8723ee8 100644 --- a/benchmarks/others/skarupke/flat_hash_map.hpp +++ b/benchmarks/external/skarupke/flat_hash_map.hpp diff --git a/benchmarks/others/tsl/hopscotch_growth_policy.h b/benchmarks/external/tsl/hopscotch_growth_policy.h index 0e463868..0e463868 100644 --- a/benchmarks/others/tsl/hopscotch_growth_policy.h +++ b/benchmarks/external/tsl/hopscotch_growth_policy.h diff --git a/benchmarks/others/tsl/hopscotch_hash.h b/benchmarks/external/tsl/hopscotch_hash.h index ad4f58e0..ad4f58e0 100644 --- a/benchmarks/others/tsl/hopscotch_hash.h +++ b/benchmarks/external/tsl/hopscotch_hash.h diff --git a/benchmarks/others/tsl/hopscotch_map.h b/benchmarks/external/tsl/hopscotch_map.h index 15c9e398..15c9e398 100644 --- a/benchmarks/others/tsl/hopscotch_map.h +++ b/benchmarks/external/tsl/hopscotch_map.h diff --git a/benchmarks/others/update.sh b/benchmarks/external/update.sh index 1ac8ad91..1ac8ad91 100644 --- a/benchmarks/others/update.sh +++ b/benchmarks/external/update.sh diff --git a/benchmarks/names.txt b/benchmarks/misc/names.txt index 561acbbf..561acbbf 100644 --- a/benchmarks/names.txt +++ b/benchmarks/misc/names.txt diff --git a/benchmarks/shootout4_crand.cpp b/benchmarks/misc/prng_bench.cpp index e3524766..e3524766 100644 --- a/benchmarks/shootout4_crand.cpp +++ b/benchmarks/misc/prng_bench.cpp diff --git a/benchmarks/rust_cmap.c b/benchmarks/misc/rust_cmap.c index 88dfbec1..88dfbec1 100644 --- a/benchmarks/rust_cmap.c +++ b/benchmarks/misc/rust_cmap.c diff --git a/benchmarks/rust_hashmap.rs b/benchmarks/misc/rust_hashmap.rs index cd1f114e..cd1f114e 100644 --- a/benchmarks/rust_hashmap.rs +++ b/benchmarks/misc/rust_hashmap.rs diff --git a/benchmarks/string_bench.c b/benchmarks/misc/string_bench.c index 8e639aa2..8e639aa2 100644 --- a/benchmarks/string_bench.c +++ b/benchmarks/misc/string_bench.c diff --git a/benchmarks/string_bench.cpp b/benchmarks/misc/string_bench.cpp index 37db0201..37db0201 100644 --- a/benchmarks/string_bench.cpp +++ b/benchmarks/misc/string_bench.cpp diff --git a/benchmarks/others/old/carray_v1.h b/benchmarks/others/old/carray_v1.h deleted file mode 100644 index c4f294cf..00000000 --- a/benchmarks/others/old/carray_v1.h +++ /dev/null @@ -1,215 +0,0 @@ -/* MIT License
- *
- * Copyright (c) 2021 Tyge Løvset, NORCE, www.norceresearch.no
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef CARRAY_H_INCLUDED
-#define CARRAY_H_INCLUDED
-
-#include <stdlib.h>
-#include "ccommon.h"
-
-/*
- Multi-dimensional generic array allocated as one block of heap-memory.
- // demo:
-#include <stdio.h>
-#include "stc/carray.h"
-using_carray3(f, float);
-
-int main()
-{
- carray3f a3 = carray3f_init(30, 20, 10, 0.0f);
- *carray3f_at(&a3, 5, 4, 3) = 10.2f; // a3[5][4][3]
- carray2f a2 = carray3f_at1(&a3, 5); // sub-array reference: a2 = a3[5]
- printf("%g\n", *carray2f_at(&a2, 4, 3)); // lookup a2[4][3] (=10.2f)
- printf("%g\n", *carray3f_at(&a3, 5, 4, 3)); // same data location, via a3 array.
-
- carray2f_del(&a2); // does nothing, since it is a sub-array.
- carray3f_del(&a3); // destroy a3, invalidates a2.
-}
-*/
-
-#define using_carray2(...) c_MACRO_OVERLOAD(using_carray2, __VA_ARGS__)
-
-#define using_carray2_2(X, Value) \
- using_carray2_4(X, Value, c_default_del, c_default_fromraw)
-
-#define using_carray2_4(X, Value, valueDel, valueClone) \
-\
- typedef Value carray1##X##_value, carray2##X##_value; \
-\
- typedef struct { \
- carray1##X##_value *data; \
- size_t _xdim; \
- } carray1##X; \
-\
- typedef struct { \
- carray2##X##_value *data; \
- size_t _xdim, _ydim; \
- } carray2##X; \
-\
- STC_INLINE size_t \
- carray1##X##_size(carray1##X a) {return _carray_xdim(a);} \
- STC_INLINE size_t \
- carray2##X##_size(carray2##X a) {return _carray_xdim(a)*_carray_ydim(a);} \
- STC_INLINE size_t \
- carray2##X##_ydim(carray2##X a) {return _carray_ydim(a);} \
-\
- _using_carray_common(1, X, Value, valueDel, valueClone) \
- _using_carray_common(2, X, Value, valueDel, valueClone) \
-\
- STC_INLINE carray1##X \
- carray1##X##_init(size_t xdim, Value val) { \
- carray1##X##_value* m = c_new_n(carray1##X##_value, xdim); \
- for (size_t i=0; i<xdim; ++i) m[i] = val; \
- carray1##X a = {m, xdim | _carray_OWN}; \
- return a; \
- } \
- STC_INLINE carray2##X \
- carray2##X##_init(size_t ydim, size_t xdim, Value val) { \
- const size_t n = ydim * xdim; \
- carray2##X##_value* m = c_new_n(carray2##X##_value, n); \
- for (size_t i=0; i<n; ++i) m[i] = val; \
- carray2##X a = {m, xdim | _carray_OWN, ydim}; \
- return a; \
- } \
-\
- STC_INLINE carray1##X \
- carray1##X##_from(carray1##X##_value* array, size_t xdim) { \
- carray1##X a = {array, xdim}; \
- return a; \
- } \
- STC_INLINE carray2##X \
- carray2##X##_from(carray2##X##_value* array, size_t ydim, size_t xdim) { \
- carray2##X a = {array, xdim, ydim}; \
- return a; \
- } \
-\
- STC_INLINE carray1##X##_value* \
- carray1##X##_at(const carray1##X *a, size_t x) { return a->data + x; } \
- \
- STC_INLINE carray1##X \
- carray2##X##_at1(const carray2##X *a, size_t y) { \
- carray1##X sub = {a->data + y*_carray_xdim(*a), _carray_xdim(*a)}; \
- return sub; \
- } \
- STC_INLINE carray2##X##_value* \
- carray2##X##_at(const carray2##X *a, size_t y, size_t x) { \
- return a->data + y*_carray_xdim(*a) + x; \
- } \
- typedef carray2##X carray2##X##_t
-
-
-#define using_carray3(...) c_MACRO_OVERLOAD(using_carray3, __VA_ARGS__)
-
-#define using_carray3_2(X, Value) \
- using_carray3_4(X, Value, c_default_del, c_default_fromraw)
-
-#define using_carray3_4(X, Value, valueDel, valueClone) \
-\
- using_carray2_4(X, Value, valueDel, valueClone); \
- typedef Value carray3##X##_value; \
-\
- typedef struct { \
- carray3##X##_value *data; \
- size_t _xdim, _ydim, _zdim; \
- } carray3##X; \
-\
- STC_INLINE size_t \
- carray3##X##_size(carray3##X a) {return _carray_xdim(a)*_carray_ydim(a)*_carray_zdim(a);} \
- STC_INLINE size_t \
- carray3##X##_ydim(carray3##X a) {return _carray_ydim(a);} \
- STC_INLINE size_t \
- carray3##X##_zdim(carray3##X a) {return _carray_zdim(a);} \
-\
- _using_carray_common(3, X, Value, valueDel, valueClone) \
-\
- STC_INLINE carray3##X \
- carray3##X##_init(size_t zdim, size_t ydim, size_t xdim, Value val) { \
- const size_t n = zdim * ydim * xdim; \
- carray3##X##_value* m = c_new_n(carray3##X##_value, n); \
- for (size_t i=0; i<n; ++i) m[i] = val; \
- carray3##X a = {m, xdim | _carray_OWN, ydim, zdim}; \
- return a; \
- } \
-\
- STC_INLINE carray3##X \
- carray3##X##_from(carray3##X##_value* array, size_t zdim, size_t ydim, size_t xdim) { \
- carray3##X a = {array, xdim, ydim, zdim}; \
- return a; \
- } \
-\
- STC_INLINE carray2##X \
- carray3##X##_at1(const carray3##X *a, size_t z) { \
- carray2##X sub = {a->data + z*_carray_ydim(*a)*_carray_xdim(*a), _carray_xdim(*a), _carray_ydim(*a)}; \
- return sub; \
- } \
- STC_INLINE carray1##X \
- carray3##X##_at2(const carray3##X *a, size_t z, size_t y) { \
- carray1##X sub = {a->data + (z*_carray_ydim(*a) + y)*_carray_xdim(*a), _carray_xdim(*a)}; \
- return sub; \
- } \
- STC_INLINE carray3##X##_value* \
- carray3##X##_at(const carray3##X *a, size_t z, size_t y, size_t x) { \
- return a->data + (z*_carray_ydim(*a) + y)*_carray_xdim(*a) + x; \
- } \
- typedef carray3##X carray3##X##_t
-
-
-#define _carray_SUB (SIZE_MAX >> 1)
-#define _carray_OWN (_carray_SUB + 1)
-#define _carray_xdim(a) ((a)._xdim & _carray_SUB)
-#define _carray_ydim(a) (a)._ydim
-#define _carray_zdim(a) (a)._zdim
-
-#define _using_carray_common(D, X, Value, valueDel, valueClone) \
- typedef struct { carray1##X##_value *ref; } carray##D##X##_iter; \
-\
- STC_INLINE carray##D##X##_iter \
- carray##D##X##_begin(const carray##D##X* a) { \
- carray##D##X##_iter it = {a->data}; return it; \
- } \
- STC_INLINE carray##D##X##_iter \
- carray##D##X##_end(const carray##D##X* a) { \
- carray##D##X##_iter it = {a->data + carray##D##X##_size(*a)}; return it; \
- } \
- STC_INLINE void \
- carray##D##X##_next(carray##D##X##_iter* it) {++it->ref;} \
-\
- STC_INLINE void \
- carray##D##X##_del(carray##D##X* self) { \
- if (self->_xdim & _carray_OWN) { \
- c_foreach_3 (i, carray##D##X, *self) \
- valueDel(i.ref); \
- c_free(self->data); \
- } \
- } \
- STC_INLINE carray##D##X \
- carray##D##X##_clone(carray##D##X arr) { \
- carray##D##X cp = arr; size_t k = 0; \
- cp.data = c_new_n(carray1##X##_value, carray##D##X##_size(arr)); \
- c_foreach_3 (i, carray##D##X, arr) \
- cp.data[k++] = valueClone(*i.ref); \
- return cp; \
- } \
- STC_INLINE size_t \
- carray##D##X##_xdim(carray##D##X a) {return _carray_xdim(a);} \
-
-#endif
diff --git a/benchmarks/picobench.hpp b/benchmarks/picobench/picobench.hpp index 2e4541e0..2e4541e0 100644 --- a/benchmarks/picobench.hpp +++ b/benchmarks/picobench/picobench.hpp diff --git a/benchmarks/shootout1_cmap.cpp b/benchmarks/picobench/picobench_cmap.cpp index 87790844..68d91f86 100644 --- a/benchmarks/shootout1_cmap.cpp +++ b/benchmarks/picobench/picobench_cmap.cpp @@ -4,10 +4,10 @@ #include <string>
#include <unordered_map>
#include <stdexcept>
-#include "others/robin_hood.hpp"
-#include "others/skarupke/bytell_hash_map.hpp"
-#include "others/tsl/hopscotch_map.h"
-#include "others/parallel_hashmap/phmap.h"
+#include "../external/robin_hood.h"
+#include "../external/skarupke/bytell_hash_map.hpp"
+#include "../external/tsl/hopscotch_map.h"
+#include "../external/parallel_hashmap/phmap.h"
#define PICOBENCH_IMPLEMENT_WITH_MAIN
#include "picobench.hpp"
diff --git a/benchmarks/shootout3_csmap.cpp b/benchmarks/picobench/picobench_csmap.cpp index 7a0addad..7a0addad 100644 --- a/benchmarks/shootout3_csmap.cpp +++ b/benchmarks/picobench/picobench_csmap.cpp diff --git a/benchmarks/cdeq_benchmark.cpp b/benchmarks/plotbench/cdeq_benchmark.cpp index 6db167b0..6db167b0 100644 --- a/benchmarks/cdeq_benchmark.cpp +++ b/benchmarks/plotbench/cdeq_benchmark.cpp diff --git a/benchmarks/clist_benchmark.cpp b/benchmarks/plotbench/clist_benchmark.cpp index 676d31e7..676d31e7 100644 --- a/benchmarks/clist_benchmark.cpp +++ b/benchmarks/plotbench/clist_benchmark.cpp diff --git a/benchmarks/cmap_benchmark.cpp b/benchmarks/plotbench/cmap_benchmark.cpp index 0dbe5a31..0dbe5a31 100644 --- a/benchmarks/cmap_benchmark.cpp +++ b/benchmarks/plotbench/cmap_benchmark.cpp diff --git a/benchmarks/cpque_benchmark.cpp b/benchmarks/plotbench/cpque_benchmark.cpp index 19a9c701..19a9c701 100644 --- a/benchmarks/cpque_benchmark.cpp +++ b/benchmarks/plotbench/cpque_benchmark.cpp diff --git a/benchmarks/csmap_benchmark.cpp b/benchmarks/plotbench/csmap_benchmark.cpp index 47762791..47762791 100644 --- a/benchmarks/csmap_benchmark.cpp +++ b/benchmarks/plotbench/csmap_benchmark.cpp diff --git a/benchmarks/cvec_benchmark.cpp b/benchmarks/plotbench/cvec_benchmark.cpp index c4648e34..c4648e34 100644 --- a/benchmarks/cvec_benchmark.cpp +++ b/benchmarks/plotbench/cvec_benchmark.cpp diff --git a/benchmarks/plot.py b/benchmarks/plotbench/plot.py index ea3871f4..ea3871f4 100644 --- a/benchmarks/plot.py +++ b/benchmarks/plotbench/plot.py diff --git a/benchmarks/run_all.bat b/benchmarks/plotbench/run_all.bat index 2edd0a1e..2edd0a1e 100644 --- a/benchmarks/run_all.bat +++ b/benchmarks/plotbench/run_all.bat diff --git a/benchmarks/run_all.sh b/benchmarks/plotbench/run_all.sh index f15a5881..f15a5881 100644 --- a/benchmarks/run_all.sh +++ b/benchmarks/plotbench/run_all.sh diff --git a/benchmarks/run_clang.sh b/benchmarks/plotbench/run_clang.sh index ae19486e..ae19486e 100644 --- a/benchmarks/run_clang.sh +++ b/benchmarks/plotbench/run_clang.sh diff --git a/benchmarks/run_gcc.sh b/benchmarks/plotbench/run_gcc.sh index 6a6472c0..6a6472c0 100644 --- a/benchmarks/run_gcc.sh +++ b/benchmarks/plotbench/run_gcc.sh diff --git a/benchmarks/run_vc.bat b/benchmarks/plotbench/run_vc.bat index 3dca925b..3dca925b 100644 --- a/benchmarks/run_vc.bat +++ b/benchmarks/plotbench/run_vc.bat diff --git a/benchmarks/shootout2_cmap.cpp b/benchmarks/shootout_hashmaps.cpp index a2b65cdd..bd98a2a5 100644 --- a/benchmarks/shootout2_cmap.cpp +++ b/benchmarks/shootout_hashmaps.cpp @@ -2,16 +2,16 @@ #include <time.h> #include <stc/crandom.h> #include <stc/cstr.h> -#include "others/khash.h" +#include "external/khash.h" enum {max_load_factor = 77}; #ifdef __cplusplus #include <limits> #include <unordered_map> -#include "others/robin_hood.hpp" -#include "others/skarupke/bytell_hash_map.hpp" -#include "others/parallel_hashmap/phmap.h" +#include "external/robin_hood.h" +#include "external/skarupke/bytell_hash_map.hpp" +#include "external/parallel_hashmap/phmap.h" template<typename C> inline void std_destroy(C& c) { C().swap(c); } template <class K, class V> using robin_hood_flat_map = robin_hood::unordered_flat_map< @@ -119,38 +119,38 @@ size_t seed; #define MAP_TEST0(M, X, n) \ -{ \ +{ /* Insert, update */ \ M##_SETUP(X, int64_t, int64_t); \ - uint64_t checksum = 0; \ + uint64_t sum = 0; \ SEED(seed); \ clock_t difference, before = clock(); \ for (size_t i = 0; i < n; ++i) { \ - checksum += ++ M##_EMPLACE(X, RAND(rr), i); \ + sum += ++ M##_EMPLACE(X, RAND(keybits), i); \ } \ difference = clock() - before; \ - printf(#M ": time: %5.02f, sum: %zu, size: %zu, buckets: %8zu\n", \ - (float) difference / CLOCKS_PER_SEC, checksum, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X)); \ + printf(#M ": time: %5.02f, size: %zu, buckets: %8zu, sum: %zu\n", \ + (float) difference / CLOCKS_PER_SEC, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X), sum); \ M##_DTOR(X); \ } #define MAP_TEST1(M, X, n) \ -{ \ +{ /* Insert, update and erase another */ \ M##_SETUP(X, int64_t, int64_t); \ - uint64_t checksum = 0, erased = 0; \ + uint64_t sum = 0, erased = 0; \ SEED(seed); \ clock_t difference, before = clock(); \ for (size_t i = 0; i < n; ++i) { \ - checksum += ++ M##_EMPLACE(X, RAND(rr), i); \ - erased += M##_ERASE(X, RAND(rr)); \ + sum += ++ M##_EMPLACE(X, RAND(keybits), i); \ + erased += M##_ERASE(X, RAND(keybits)); \ } \ difference = clock() - before; \ - printf(#M ": time: %5.02f, sum: %zu, erased %zu, size: %zu, buckets: %8zu\n", \ - (float) difference / CLOCKS_PER_SEC, checksum, erased, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X)); \ + printf(#M ": time: %5.02f, size: %zu, buckets: %8zu, erased %zu, sum: %zu\n", \ + (float) difference / CLOCKS_PER_SEC, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X), erased, sum); \ M##_DTOR(X); \ } #define MAP_TEST2(M, X, n) \ -{ \ +{ /* Insert sequential keys, then erase them */ \ M##_SETUP(X, int64_t, int64_t); \ size_t erased = 0; \ clock_t difference, before = clock(); \ @@ -159,121 +159,119 @@ size_t seed; for (size_t i = 0; i < n; ++i) \ erased += M##_ERASE(X, i); \ difference = clock() - before; \ - printf(#M ": time: %5.02f, erased %zu, size: %zu, buckets: %8zu\n", \ - (float) difference / CLOCKS_PER_SEC, erased, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X)); \ + printf(#M ": time: %5.02f, size: %zu, buckets: %8zu, erased %zu\n", \ + (float) difference / CLOCKS_PER_SEC, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X), erased); \ M##_DTOR(X); \ } #define MAP_TEST3(M, X, n) \ -{ \ +{ /* Erase elements */ \ M##_SETUP(X, int64_t, int64_t); \ size_t erased = 0; \ clock_t difference, before; \ SEED(seed); \ for (size_t i = 0; i < n; ++i) \ - M##_PUT(X, RAND(rr), i); \ + M##_PUT(X, RAND(keybits), i); \ SEED(seed); \ before = clock(); \ for (size_t i = 0; i < n; ++i) \ - erased += M##_ERASE(X, RAND(rr)); \ + erased += M##_ERASE(X, RAND(keybits)); \ difference = clock() - before; \ - printf(#M ": time: %5.02f, erased %zu, size: %zu, buckets: %8zu\n", \ - (float) difference / CLOCKS_PER_SEC, erased, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X)); \ + printf(#M ": time: %5.02f, size: %zu, buckets: %8zu, erased %zu\n", \ + (float) difference / CLOCKS_PER_SEC, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X), erased); \ M##_DTOR(X); \ } #define MAP_TEST4(M, X, n) \ -{ \ +{ /* Iterate */ \ M##_SETUP(X, int64_t, int64_t); \ - size_t sum = 0; \ + size_t sum = 0, m = 1ull << (keybits + 1), nn = n; \ + if (nn < m) m = nn; \ SEED(seed); \ - for (size_t i = 0; i < n; ++i) \ - M##_PUT(X, RAND(rr), i); \ + for (size_t i = 0; i < m; ++i) \ + M##_PUT(X, RAND(keybits), i); \ + size_t x = 500000000/M##_SIZE(X); \ clock_t difference, before = clock(); \ - for (int k=0; k<5; k++) M##_FOR (X, i) \ - sum += M##_ITEM(X, i); \ + for (int k=0; k < x; k++) M##_FOR (X, it) \ + sum += M##_ITEM(X, it); \ difference = clock() - before; \ - printf(#M ": time: %5.02f, sum %zu, size: %zu, buckets: %8zu\n", \ - (float) difference / CLOCKS_PER_SEC, sum, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X)); \ + printf(#M ": time: %5.02f, size: %zu, buckets: %8zu, repeats: %zu, sum: %zu\n", \ + (float) difference / CLOCKS_PER_SEC, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X), x, sum); \ M##_DTOR(X); \ } #define MAP_TEST5(M, X, n) \ -{ \ +{ /* Lookup */ \ M##_SETUP(X, int64_t, int64_t); \ - size_t found = 0; \ + size_t found = 0, m = 1ull << (keybits + 1), nn = n; \ clock_t difference, before; \ + if (nn < m) m = nn; \ SEED(seed); \ - for (size_t i = 0; i < n; ++i) \ - M##_PUT(X, RAND(rr), i); \ + for (size_t i = 0; i < m; ++i) \ + M##_PUT(X, RAND(keybits), i); \ before = clock(); \ - for (size_t i = 0; i < n/2; ++i) \ - found += M##_FIND(X, RAND(rr)); \ + size_t x = m * 20000000/M##_SIZE(X); \ + for (size_t i = 0; i < x; ++i) \ + found += M##_FIND(X, RAND(keybits)); \ SEED(seed); \ - for (size_t i = 0; i < n/2; ++i) \ - found += M##_FIND(X, RAND(rr)); \ + for (size_t i = 0; i < x; ++i) \ + found += M##_FIND(X, RAND(keybits)); \ difference = clock() - before; \ - printf(#M ": time: %5.02f, found %zu, size: %zu, buckets: %8zu\n", \ - (float) difference / CLOCKS_PER_SEC, found, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X)); \ + printf(#M ": time: %5.02f, size: %zu, buckets: %8zu, lookups: %zu, found: %zu\n", \ + (float) difference / CLOCKS_PER_SEC, (size_t) M##_SIZE(X), (size_t) M##_BUCKETS(X), x*2, found); \ M##_DTOR(X); \ } #ifdef __cplusplus -#define RUN_TEST(n) MAP_TEST##n(KMAP, ii, N##n) MAP_TEST##n(CMAP, ii, N##n) MAP_TEST##n(PMAP, ii, N##n) \ +#define RUN_TEST(n) MAP_TEST##n(CMAP, ii, N##n) MAP_TEST##n(KMAP, ii, N##n) MAP_TEST##n(PMAP, ii, N##n) \ MAP_TEST##n(FMAP, ii, N##n) MAP_TEST##n(RMAP, ii, N##n) MAP_TEST##n(UMAP, ii, N##n) #define ITR_TEST(n) MAP_TEST##n(CMAP, ii, N##n) MAP_TEST##n(PMAP, ii, N##n) \ MAP_TEST##n(FMAP, ii, N##n) MAP_TEST##n(RMAP, ii, N##n) MAP_TEST##n(UMAP, ii, N##n) #else -#define RUN_TEST(n) MAP_TEST##n(KMAP, ii, N##n) MAP_TEST##n(CMAP, ii, N##n) +#define RUN_TEST(n) MAP_TEST##n(CMAP, ii, N##n) MAP_TEST##n(KMAP, ii, N##n) #define ITR_TEST(n) MAP_TEST##n(CMAP, ii, N##n) #endif enum { - RR = 27, - NN = 10, - NF = 1000000, - F0 = 4, - F1 = 2, - F2 = 4, - F3 = 6, - F4 = 8, - F5 = 6, + DEFAULT_N_MILL = 50, + DEFAULT_KEYBITS = 25, }; - int main(int argc, char* argv[]) { - int nn = argc >= 2 ? atoi(argv[1]) : NN; - int rr = argc >= 3 ? atoi(argv[2]) : RR; - int n = NF * nn; - int N0 = n*F0, N1 = n*F1, N2 = n*F2, N3 = n*F3, N4 = n*F4, N5 = n*F5; + int n_mill = argc >= 2 ? atoi(argv[1]) : DEFAULT_N_MILL; + int keybits = argc >= 3 ? atoi(argv[2]) : DEFAULT_KEYBITS; + int n = n_mill * 1000000; + int N0 = n, N1 = n/2, N2 = n/2, N3 = n, N4 = n, N5 = n; seed = time(NULL); - printf("\nUnordered hash map shootout\nUsage %s [n-base=%d key-bits=%d]\n\n", argv[0], NN, RR); + printf("\nUnordered hash map shootout\n"); printf("CMAP = https://github.com/tylov/STC\n" "KMAP = https://github.com/attractivechaos/klib\n" "PMAP = https://github.com/greg7mdp/parallel-hashmap\n" "FMAP = https://github.com/skarupke/flat_hash_map\n" "RMAP = https://github.com/martinus/robin-hood-hashing\n" - "UMAP = std::unordered_map\n"); + "UMAP = std::unordered_map\n\n"); - printf("\nN-base = %d. Random keys are in range [0, 2^%d). Seed = %zu:\n", nn, rr, seed); - printf("\nN=%d. Insert random keys:\n", N0); + printf("Usage %s [n-million=%d key-bits=%d]\n", argv[0], DEFAULT_N_MILL, DEFAULT_KEYBITS); + printf("N-base = %d. Random keys are in range [0, 2^%d). Seed = %zu:\n", n_mill, keybits, seed); + + printf("\nT0: Insert/update random keys:\n"); RUN_TEST(0) - printf("\nN=%d. Insert random key + try to remove another random key:\n", N1); + printf("\nT1: Insert/update random key + try to remove another random key:\n"); RUN_TEST(1) - printf("\nN=%d. Insert sequential keys, then remove them in same order:\n", N2); + printf("\nT2: Insert sequential keys, then remove them in same order:\n"); RUN_TEST(2) - printf("\nN=%d. Remove random keys:\n", N3); + printf("\nT3: Remove random keys:\n"); RUN_TEST(3) - printf("\nN=%d. Iterate random keys:\n", N4); + printf("\nT4: Iterate random keys:\n"); ITR_TEST(4) - printf("\nN=%d. Lookup random keys:\n", N5); + printf("\nT5: Lookup random keys:\n"); RUN_TEST(5) } diff --git a/benchmarks/others/old/clist.h b/include/stc/alt/clist.h index ea1bb9a5..ea1bb9a5 100644 --- a/benchmarks/others/old/clist.h +++ b/include/stc/alt/clist.h diff --git a/benchmarks/others/old/csmap.h b/include/stc/alt/csmap.h index 699e18c1..699e18c1 100644 --- a/benchmarks/others/old/csmap.h +++ b/include/stc/alt/csmap.h diff --git a/benchmarks/others/old/sstr.h b/include/stc/alt/sstr.h index 2ea1033d..2ea1033d 100644 --- a/benchmarks/others/old/sstr.h +++ b/include/stc/alt/sstr.h diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 1c9abea7..883fec03 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -302,7 +302,7 @@ _cx_memb(_bucket_)(const _cx_self* self, const _cx_rawkey* rkeyptr) { STC_DEF _cx_result
_cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey) {
if (self->size + 1 >= (_cx_size) (self->bucket_count * self->max_load_factor))
- _cx_memb(_reserve)(self, 8 + ((size_t)self->size*3 >> 1));
+ _cx_memb(_reserve)(self, ((size_t)self->size*3 >> 1) + 4);
chash_bucket_t b = _cx_memb(_bucket_)(self, &rkey);
_cx_result res = {&self->table[b.idx], !self->_hashx[b.idx]};
if (res.inserted) {
|
