From 121f024be02046af2a5a3b274d7d5ce36d6f43dc Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 6 Apr 2018 17:29:19 -0400 Subject: [PATCH] Cleaning. --- scalarvssimd/Makefile | 6 +++--- scalarvssimd/README.md | 3 +++ scalarvssimd/{ => benchmarks}/bench.cpp | 11 +++++++++-- scalarvssimd/{ => include}/avxprocessing.h | 0 scalarvssimd/{ => include}/benchmark.h | 4 ++-- scalarvssimd/{ => include}/common_defs.h | 0 scalarvssimd/{ => include}/jsonstruct.h | 0 scalarvssimd/{ => include}/scalarprocessing.h | 0 scalarvssimd/{ => include}/util.h | 0 scalarvssimd/run.sh | 11 +++++++++++ 10 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 scalarvssimd/README.md rename scalarvssimd/{ => benchmarks}/bench.cpp (85%) rename scalarvssimd/{ => include}/avxprocessing.h (100%) rename scalarvssimd/{ => include}/benchmark.h (98%) rename scalarvssimd/{ => include}/common_defs.h (100%) rename scalarvssimd/{ => include}/jsonstruct.h (100%) rename scalarvssimd/{ => include}/scalarprocessing.h (100%) rename scalarvssimd/{ => include}/util.h (100%) create mode 100755 scalarvssimd/run.sh diff --git a/scalarvssimd/Makefile b/scalarvssimd/Makefile index 07d8e79a..c3f99ea0 100644 --- a/scalarvssimd/Makefile +++ b/scalarvssimd/Makefile @@ -1,6 +1,6 @@ -HEADERS:=avxprocessing.h benchmark.h common_defs.h jsonstruct.h scalarprocessing.h util.h -bench: bench.cpp $(HEADERS) - $(CXX) -O3 -o $@ bench.cpp -march=native -lm -Wall -Wextra +HEADERS:=include/avxprocessing.h include/benchmark.h include/common_defs.h include/jsonstruct.h include/scalarprocessing.h include/util.h +bench: benchmarks/bench.cpp $(HEADERS) + $(CXX) -std=c++11 -O3 -o $@ benchmarks/bench.cpp -Iinclude -march=native -lm -Wall -Wextra clean: rm -f bench diff --git a/scalarvssimd/README.md b/scalarvssimd/README.md new file mode 100644 index 00000000..6068a149 --- /dev/null +++ b/scalarvssimd/README.md @@ -0,0 +1,3 @@ +``` +./run.sh +``` diff --git a/scalarvssimd/bench.cpp b/scalarvssimd/benchmarks/bench.cpp similarity index 85% rename from scalarvssimd/bench.cpp rename to scalarvssimd/benchmarks/bench.cpp index 3cfa9530..5624b4b7 100644 --- a/scalarvssimd/bench.cpp +++ b/scalarvssimd/benchmarks/bench.cpp @@ -21,7 +21,14 @@ int main(int argc, char * argv[]) { } pair p = get_corpus(argv[argc - 1]); ParsedJson pj; - std::cout << "Input has "<< p.second << " bytes."< 1024 * 1024) + std::cout << p.second / (1024*1024) << " MB "; + else if (p.second > 1024) + std::cout << p.second / 1024 << " KB "; + else + std::cout << p.second << " B "; + std::cout << std::endl; if (posix_memalign( (void **)&pj.structurals, 8, ROUNDUP_N(p.second, 64)/8)) { throw "Allocation failed"; @@ -46,7 +53,7 @@ int main(int argc, char * argv[]) { colorfuldisplay(pj, p.first); debugdisplay(pj,p.first); } - int repeat = 5; + int repeat = 10; int volume = p.second; BEST_TIME_NOCHECK(avx_json_parse(p.first, p.second, pj), , repeat, volume, true); BEST_TIME_NOCHECK(scalar_json_parse(p.first, p.second, pj), , repeat, volume, true); diff --git a/scalarvssimd/avxprocessing.h b/scalarvssimd/include/avxprocessing.h similarity index 100% rename from scalarvssimd/avxprocessing.h rename to scalarvssimd/include/avxprocessing.h diff --git a/scalarvssimd/benchmark.h b/scalarvssimd/include/benchmark.h similarity index 98% rename from scalarvssimd/benchmark.h rename to scalarvssimd/include/benchmark.h index 39b84509..59209d97 100644 --- a/scalarvssimd/benchmark.h +++ b/scalarvssimd/include/benchmark.h @@ -142,9 +142,9 @@ uint64_t global_rdtsc_overhead = (uint64_t)UINT64_MAX; float cycle_per_op = (min_diff) / (double)S; \ float avg_cycle_per_op = (sum_diff) / ((double)S * repeat); \ if (verbose) \ - printf(" %.3f %s per operation (best) ", cycle_per_op, unitname); \ + printf(" %.3f %s per input byte (best) ", cycle_per_op, unitname); \ if (verbose) \ - printf(" %.3f %s per operation (avg) ", avg_cycle_per_op, unitname); \ + printf(" %.3f %s per input byte (avg) ", avg_cycle_per_op, unitname); \ if (verbose) \ printf("\n"); \ if (!verbose) \ diff --git a/scalarvssimd/common_defs.h b/scalarvssimd/include/common_defs.h similarity index 100% rename from scalarvssimd/common_defs.h rename to scalarvssimd/include/common_defs.h diff --git a/scalarvssimd/jsonstruct.h b/scalarvssimd/include/jsonstruct.h similarity index 100% rename from scalarvssimd/jsonstruct.h rename to scalarvssimd/include/jsonstruct.h diff --git a/scalarvssimd/scalarprocessing.h b/scalarvssimd/include/scalarprocessing.h similarity index 100% rename from scalarvssimd/scalarprocessing.h rename to scalarvssimd/include/scalarprocessing.h diff --git a/scalarvssimd/util.h b/scalarvssimd/include/util.h similarity index 100% rename from scalarvssimd/util.h rename to scalarvssimd/include/util.h diff --git a/scalarvssimd/run.sh b/scalarvssimd/run.sh new file mode 100755 index 00000000..3caf1580 --- /dev/null +++ b/scalarvssimd/run.sh @@ -0,0 +1,11 @@ +#!/bin/bash +SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" +cd $SCRIPTPATH +make bench +echo +for i in $SCRIPTPATH/../jsonexamples/*.json; do + [ -f "$i" ] || break + echo $i + $SCRIPTPATH/bench $i + echo +done