From 8da81e7a625f06ec667793ff624c6876d03abbde Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sun, 19 Sep 2021 13:49:41 +0200 Subject: Fixed errors caused by gcc -std=c99 -pedantic. --- benchmarks/build_all.sh | 35 +++++++++++++++++++++++++++++++++++ benchmarks/cpque_benchmark.cpp | 4 ++-- benchmarks/run_clang.sh | 24 +++++++++++++----------- benchmarks/run_gcc.sh | 22 +++++++++++----------- benchmarks/shootout1_cmap.cpp | 7 ------- benchmarks/shootout2_cmap.cpp | 13 ------------- benchmarks/shootout5_crand.cpp | 8 ++++---- 7 files changed, 65 insertions(+), 48 deletions(-) create mode 100644 benchmarks/build_all.sh (limited to 'benchmarks') diff --git a/benchmarks/build_all.sh b/benchmarks/build_all.sh new file mode 100644 index 00000000..6217d5e1 --- /dev/null +++ b/benchmarks/build_all.sh @@ -0,0 +1,35 @@ +#!/bin/sh +cc='g++ -std=c++17' +#cc='clang' +#cc='clang -c -DSTC_HEADER' +#cc='cl -nologo' +#cc='cl -nologo -TP' +#cc='cl -nologo -std:c11' +run=0 +if [ "$1" == '-h' -o "$1" == '--help' ]; then + echo usage: runall.sh [-run] [compiler + options] + exit +fi +if [ "$1" == '-run' ]; then + run=1 + shift +fi +if [ ! -z "$1" ] ; then + cc=$@ +fi +if [ $run = 0 ] ; then + for i in *.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 + 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 + done +fi + +rm -f a.out *.o *.obj *.exe diff --git a/benchmarks/cpque_benchmark.cpp b/benchmarks/cpque_benchmark.cpp index 2b6445c5..5f7dd364 100644 --- a/benchmarks/cpque_benchmark.cpp +++ b/benchmarks/cpque_benchmark.cpp @@ -2,7 +2,7 @@ #include #include -#define i_tag x +#define i_tag f #define i_val float #define i_cmp -c_default_compare #include @@ -18,7 +18,7 @@ int main() rng = stc64_init(seed); clock_t start = clock(); c_forrange (i, int, N) - cvec_f_push_back(&pq, (float) stc64_randf(&rng)*100000); + cpque_f_push_back(&pq, (float) stc64_randf(&rng)*100000); cpque_f_make_heap(&pq); printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC); diff --git a/benchmarks/run_clang.sh b/benchmarks/run_clang.sh index e8e9910f..f7575882 100644 --- a/benchmarks/run_clang.sh +++ b/benchmarks/run_clang.sh @@ -1,12 +1,14 @@ -clang++ -I../include -O3 -o cdeq_benchmark.exe cdeq_benchmark.cpp -clang++ -I../include -O3 -o clist_benchmark.exe clist_benchmark.cpp -clang++ -I../include -O3 -o cmap_benchmark.exe cmap_benchmark.cpp -clang++ -I../include -O3 -o csmap_benchmark.exe csmap_benchmark.cpp -clang++ -I../include -O3 -o cvec_benchmark.exe cvec_benchmark.cpp +exe='' +if [ "$OS" == 'Windows_NT' ]; then exe='.exe'; fi +clang++ -I../include -O3 -o cdeq_benchmark$exe cdeq_benchmark.cpp +clang++ -I../include -O3 -o clist_benchmark$exe clist_benchmark.cpp +clang++ -I../include -O3 -o cmap_benchmark$exe cmap_benchmark.cpp +clang++ -I../include -O3 -o csmap_benchmark$exe csmap_benchmark.cpp +clang++ -I../include -O3 -o cvec_benchmark$exe cvec_benchmark.cpp -c=Win-Clang-12 -./cdeq_benchmark.exe $c -./clist_benchmark.exe $c -./cmap_benchmark.exe $c -./csmap_benchmark.exe $c -./cvec_benchmark.exe $c +c='Win-Clang-12' +./cdeq_benchmark$exe $c +./clist_benchmark$exe $c +./cmap_benchmark$exe $c +./csmap_benchmark$exe $c +./cvec_benchmark$exe $c diff --git a/benchmarks/run_gcc.sh b/benchmarks/run_gcc.sh index 460afe16..6a6472c0 100644 --- a/benchmarks/run_gcc.sh +++ b/benchmarks/run_gcc.sh @@ -1,12 +1,12 @@ -g++ -I../include -O3 -o cdeq_benchmark.exe cdeq_benchmark.cpp -g++ -I../include -O3 -o clist_benchmark.exe clist_benchmark.cpp -g++ -I../include -O3 -o cmap_benchmark.exe cmap_benchmark.cpp -g++ -I../include -O3 -o csmap_benchmark.exe csmap_benchmark.cpp -g++ -I../include -O3 -o cvec_benchmark.exe cvec_benchmark.cpp +g++ -I../include -O3 -o cdeq_benchmark cdeq_benchmark.cpp +g++ -I../include -O3 -o clist_benchmark clist_benchmark.cpp +g++ -I../include -O3 -o cmap_benchmark cmap_benchmark.cpp +g++ -I../include -O3 -o csmap_benchmark csmap_benchmark.cpp +g++ -I../include -O3 -o cvec_benchmark cvec_benchmark.cpp -c=Mingw-g++-10.30 -./cdeq_benchmark.exe $c -./clist_benchmark.exe $c -./cmap_benchmark.exe $c -./csmap_benchmark.exe $c -./cvec_benchmark.exe $c \ No newline at end of file +c='Mingw-g++-10.30' +./cdeq_benchmark $c +./clist_benchmark $c +./cmap_benchmark $c +./csmap_benchmark $c +./cvec_benchmark $c \ No newline at end of file diff --git a/benchmarks/shootout1_cmap.cpp b/benchmarks/shootout1_cmap.cpp index 5fd32586..2cdb919f 100644 --- a/benchmarks/shootout1_cmap.cpp +++ b/benchmarks/shootout1_cmap.cpp @@ -7,7 +7,6 @@ #include "others/robin_hood.hpp" #include "others/skarupke/bytell_hash_map.hpp" #include "others/tsl/hopscotch_map.h" -#include "others/tsl/robin_map.h" #include "others/sparsepp/spp.h" #define PICOBENCH_IMPLEMENT_WITH_MAIN @@ -20,7 +19,6 @@ template using umap = std::unordered_map; template using bmap = ska::bytell_hash_map; template using fmap = ska::flat_hash_map; template using hmap = tsl::hopscotch_map; -template using omap = tsl::robin_map; template using smap = spp::sparse_hash_map; template using rmap = robin_hood::unordered_flat_map, std::equal_to, MaxLoadFactor100>; @@ -29,7 +27,6 @@ template using rmap = robin_hood::unordered_flat_map).P; PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_i).P; -PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_cmap_x).P; @@ -165,7 +161,6 @@ PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_i).P; -PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_cmap_i).P; @@ -223,7 +218,6 @@ PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_s).P; -PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_cmap_s).P; @@ -297,7 +291,6 @@ PICOBENCH(iterate_x).P; PICOBENCH(iterate_x).P; PICOBENCH(iterate_x).P; PICOBENCH(iterate_x).P; -PICOBENCH(iterate_x).P; PICOBENCH(iterate_x).P; PICOBENCH(iterate_x).P; PICOBENCH(iterate_cmap_x).P; diff --git a/benchmarks/shootout2_cmap.cpp b/benchmarks/shootout2_cmap.cpp index 669c336c..6224c1f3 100644 --- a/benchmarks/shootout2_cmap.cpp +++ b/benchmarks/shootout2_cmap.cpp @@ -9,7 +9,6 @@ #include "others/robin_hood.hpp" #include "others/skarupke/bytell_hash_map.hpp" #include "others/tsl/hopscotch_map.h" -#include "others/tsl/robin_map.h" #include "others/sparsepp/spp.h" template inline void destroy_me(C& c) { C().swap(c); } #endif @@ -105,18 +104,6 @@ stc64_t rng; #define HMAP_CLEAR(X) UMAP_CLEAR(X) #define HMAP_DTOR(X) UMAP_DTOR(X) -#define OMAP_SETUP(X, Key, Value) tsl::robin_map map; map.max_load_factor(max_load_factor) -#define OMAP_PUT(X, key, val) UMAP_PUT(X, key, val) -#define OMAP_EMPLACE(X, key, val) UMAP_EMPLACE(X, key, val) -#define OMAP_FIND(X, key) UMAP_FIND(X, key) -#define OMAP_ERASE(X, key) UMAP_ERASE(X, key) -#define OMAP_FOR(X, i) UMAP_FOR(X, i) -#define OMAP_ITEM(X, i) UMAP_ITEM(X, i) -#define OMAP_SIZE(X) UMAP_SIZE(X) -#define OMAP_BUCKETS(X) UMAP_BUCKETS(X) -#define OMAP_CLEAR(X) UMAP_CLEAR(X) -#define OMAP_DTOR(X) UMAP_DTOR(X) - #define RMAP_SETUP(X, Key, Value) robin_hood::unordered_map map #define RMAP_PUT(X, key, val) UMAP_PUT(X, key, val) #define RMAP_EMPLACE(X, key, val) UMAP_EMPLACE(X, key, val) diff --git a/benchmarks/shootout5_crand.cpp b/benchmarks/shootout5_crand.cpp index eacca54a..0a034fc4 100644 --- a/benchmarks/shootout5_crand.cpp +++ b/benchmarks/shootout5_crand.cpp @@ -2,7 +2,7 @@ #include #include #include "stc/crandom.h" -#include "others/pcg_random.hpp" +//#include "pcg_random.hpp" static struct stc32_state { stc64_t rng; uint64_t spare; unsigned n; } stc32_global = {{0x7a5fed, 0x8e3f52, 0x9bc713, 0x6a09e667a7541669}, 0, 0}; @@ -59,7 +59,7 @@ void test1(void) c_forrange (8) printf("%f ", fdist(rng)); puts("\n"); } - +/* void test2() { clock_t diff, before; @@ -96,7 +96,7 @@ void test2() c_forrange (8) printf("%f ", fdist(rng)); puts("\n"); } - +*/ void test3(void) { @@ -132,6 +132,6 @@ void test3(void) int main() { test1(); - test2(); + //test2(); test3(); } \ No newline at end of file -- cgit v1.2.3