diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-07-03 15:05:10 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-07-03 15:05:10 +0200 |
| commit | 4a16da26dacdb37b9ef8d3d11e10ecb94b0cf396 (patch) | |
| tree | 64723639df2a44c94deb26276c5793101d3b6c41 | |
| parent | 3c9efb490ccbe1b0d7768d77fcdcac012c00e8c6 (diff) | |
| download | nissy-core-4a16da26dacdb37b9ef8d3d11e10ecb94b0cf396.tar.gz nissy-core-4a16da26dacdb37b9ef8d3d11e10ecb94b0cf396.zip | |
renamed benchmarks to tools
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | tools/benchmark_gendata_h48/benchmark_gendata_h48.c (renamed from benchmark/00_gendata_h48/gendata_h48_benchmark.c) | 17 | ||||
| -rwxr-xr-x | tools/run_tool.sh (renamed from benchmark/benchmark.sh) | 18 | ||||
| -rw-r--r-- | tools/timerun.h (renamed from benchmark/benchmark.h) | 4 |
4 files changed, 25 insertions, 20 deletions
| @@ -17,8 +17,8 @@ clean: | |||
| 17 | test: debugcube.o | 17 | test: debugcube.o |
| 18 | CUBETYPE=${CUBETYPE} TEST=${TEST} ./test/test.sh | 18 | CUBETYPE=${CUBETYPE} TEST=${TEST} ./test/test.sh |
| 19 | 19 | ||
| 20 | benchmark: cube.o | 20 | tool: cube.o |
| 21 | CUBETYPE=${CUBETYPE} ./benchmark/benchmark.sh | 21 | CUBETYPE=${CUBETYPE} ./tools/run_tool.sh |
| 22 | 22 | ||
| 23 | shell: cube.o | 23 | shell: cube.o |
| 24 | mkdir -p tables | 24 | mkdir -p tables |
| @@ -28,4 +28,4 @@ debugshell: debugcube.o | |||
| 28 | mkdir -p tables | 28 | mkdir -p tables |
| 29 | ${CC} ${DBGFLAGS} -o run debugcube.o shell.c | 29 | ${CC} ${DBGFLAGS} -o run debugcube.o shell.c |
| 30 | 30 | ||
| 31 | .PHONY: all clean test benchmark shell debugshell | 31 | .PHONY: all clean test tool shell debugshell |
diff --git a/benchmark/00_gendata_h48/gendata_h48_benchmark.c b/tools/benchmark_gendata_h48/benchmark_gendata_h48.c index 1dc7c57..efb6f6f 100644 --- a/benchmark/00_gendata_h48/gendata_h48_benchmark.c +++ b/tools/benchmark_gendata_h48/benchmark_gendata_h48.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #include "../benchmark.h" | 1 | #include "../timerun.h" |
| 2 | #include "../../src/cube.h" | 2 | #include "../../src/cube.h" |
| 3 | 3 | ||
| 4 | #define MAXDEPTH 10 | 4 | #define MAXDEPTH 10 |
| @@ -6,10 +6,13 @@ | |||
| 6 | #define OPTIONS "2;10" | 6 | #define OPTIONS "2;10" |
| 7 | #define LONGOPTIONS "h = 2, max depth = 10" | 7 | #define LONGOPTIONS "h = 2, max depth = 10" |
| 8 | 8 | ||
| 9 | #define COCSEPSIZE 1119792 | ||
| 10 | #define ETABLESIZE(h) (((3393 * 495 * 70) >> 1) << (size_t)(h)) | ||
| 11 | |||
| 9 | char *buf; | 12 | char *buf; |
| 10 | 13 | ||
| 11 | void run(void) { | 14 | void run(void) { |
| 12 | uint32_t *buf32; | 15 | uint32_t *h48info; |
| 13 | int i; | 16 | int i; |
| 14 | int64_t s; | 17 | int64_t s; |
| 15 | 18 | ||
| @@ -19,9 +22,9 @@ void run(void) { | |||
| 19 | printf("Error generating table\n"); | 22 | printf("Error generating table\n"); |
| 20 | } else { | 23 | } else { |
| 21 | printf("Succesfully generated %" PRId64 " bytes. Table:\n", s); | 24 | printf("Succesfully generated %" PRId64 " bytes. Table:\n", s); |
| 22 | buf32 = (uint32_t *)&buf[s-sizeof(uint32_t)*(MAXDEPTH+1)]; | 25 | h48info = (uint32_t *)buf + (ETABLESIZE(HVALUE) + COCSEPSIZE) / 4; |
| 23 | for (i = 0; i <= MAXDEPTH; i++) | 26 | for (i = 0; i < MAXDEPTH+1; i++) |
| 24 | printf("%d:\t%" PRId32 "\n", i, buf32[i]); | 27 | printf("%d:\t%" PRIu32 "\n", i, h48info[i+1]); |
| 25 | } | 28 | } |
| 26 | } | 29 | } |
| 27 | 30 | ||
| @@ -36,7 +39,9 @@ int main() { | |||
| 36 | 39 | ||
| 37 | buf = malloc(size); | 40 | buf = malloc(size); |
| 38 | 41 | ||
| 39 | time_benchmark(run, "gendata_h48 " LONGOPTIONS); | 42 | timerun(run, "benchmark gendata_h48 " LONGOPTIONS); |
| 43 | |||
| 44 | free(buf); | ||
| 40 | 45 | ||
| 41 | return 0; | 46 | return 0; |
| 42 | } | 47 | } |
diff --git a/benchmark/benchmark.sh b/tools/run_tool.sh index 6de280c..21b6ce9 100755 --- a/benchmark/benchmark.sh +++ b/tools/run_tool.sh | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | re="${RUN:-$@}" | 3 | if [ -z "$TOOL" ]; then |
| 4 | echo "No tool selected (TOOL variable must be set)" | ||
| 5 | exit 1 | ||
| 6 | fi | ||
| 4 | 7 | ||
| 5 | CC="cc -std=c99 -pedantic -Wall -Wextra \ | 8 | CC="cc -std=c99 -pedantic -Wall -Wextra \ |
| 6 | -Wno-unused-parameter -Wno-unused-function -O3 -D$CUBETYPE \ | 9 | -Wno-unused-parameter -Wno-unused-function -O3 -D$CUBETYPE \ |
| @@ -8,20 +11,17 @@ CC="cc -std=c99 -pedantic -Wall -Wextra \ | |||
| 8 | 11 | ||
| 9 | [ "$CUBETYPE" = "CUBE_AVX2" ] && CC="$CC -mavx2" | 12 | [ "$CUBETYPE" = "CUBE_AVX2" ] && CC="$CC -mavx2" |
| 10 | 13 | ||
| 11 | BIN="benchmark/run" | 14 | BIN="tools/run" |
| 12 | RES="benchmark/results" | ||
| 13 | CUBEOBJ="cube.o" | 15 | CUBEOBJ="cube.o" |
| 14 | d="$(date +'%Y-%m-%d-%H-%M-%S')" | 16 | d="$(date +'%Y-%m-%d-%H-%M-%S')" |
| 15 | 17 | ||
| 16 | mkdir -p "$RES" | 18 | for t in tools/*; do |
| 17 | 19 | if [ ! -d "$t" ] || [ -z "$(echo "$t" | grep "$TOOL")" ]; then | |
| 18 | for t in benchmark/*; do | ||
| 19 | if [ -n "$re" ] && [ -z "$(echo "$t" | grep "$re")" ]; then | ||
| 20 | continue | 20 | continue |
| 21 | fi | 21 | fi |
| 22 | if [ ! -d "$t" ] || [ "$t" = "benchmark/results" ]; then continue; fi | ||
| 23 | $CC -o $BIN $t/*.c $CUBEOBJ || exit 1; | 22 | $CC -o $BIN $t/*.c $CUBEOBJ || exit 1; |
| 24 | $BIN | tee "$RES/results-$d.txt" "$RES/results-last.txt" | 23 | $BIN |
| 24 | break | ||
| 25 | done | 25 | done |
| 26 | 26 | ||
| 27 | rm -rf $BIN $CUBEOBJ | 27 | rm -rf $BIN $CUBEOBJ |
diff --git a/benchmark/benchmark.h b/tools/timerun.h index e9361a8..dabfde0 100644 --- a/benchmark/benchmark.h +++ b/tools/timerun.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #include <time.h> | 5 | #include <time.h> |
| 6 | 6 | ||
| 7 | double | 7 | double |
| 8 | time_benchmark(void (*run)(void), char *name) | 8 | timerun(void (*run)(void), char *name) |
| 9 | { | 9 | { |
| 10 | struct timespec start, end; | 10 | struct timespec start, end; |
| 11 | double tdiff, tdsec, tdnano; | 11 | double tdiff, tdsec, tdnano; |
| @@ -19,7 +19,7 @@ time_benchmark(void (*run)(void), char *name) | |||
| 19 | return -1.0; | 19 | return -1.0; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | printf("Benchmark: %s\n\n", name); | 22 | printf("Running tool: %s\n", name); |
| 23 | printf("==========\n"); | 23 | printf("==========\n"); |
| 24 | fflush(stdout); | 24 | fflush(stdout); |
| 25 | 25 | ||
