aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-07-03 15:05:10 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-07-03 15:05:10 +0200
commit4a16da26dacdb37b9ef8d3d11e10ecb94b0cf396 (patch)
tree64723639df2a44c94deb26276c5793101d3b6c41
parent3c9efb490ccbe1b0d7768d77fcdcac012c00e8c6 (diff)
downloadnissy-core-4a16da26dacdb37b9ef8d3d11e10ecb94b0cf396.tar.gz
nissy-core-4a16da26dacdb37b9ef8d3d11e10ecb94b0cf396.zip
renamed benchmarks to tools
Diffstat (limited to '')
-rw-r--r--Makefile6
-rw-r--r--tools/benchmark_gendata_h48/benchmark_gendata_h48.c (renamed from benchmark/00_gendata_h48/gendata_h48_benchmark.c)17
-rwxr-xr-xtools/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
diff --git a/Makefile b/Makefile
index 43bc3e4..f5ea6d9 100644
--- a/Makefile
+++ b/Makefile
@@ -17,8 +17,8 @@ clean:
17test: debugcube.o 17test: debugcube.o
18 CUBETYPE=${CUBETYPE} TEST=${TEST} ./test/test.sh 18 CUBETYPE=${CUBETYPE} TEST=${TEST} ./test/test.sh
19 19
20benchmark: cube.o 20tool: cube.o
21 CUBETYPE=${CUBETYPE} ./benchmark/benchmark.sh 21 CUBETYPE=${CUBETYPE} ./tools/run_tool.sh
22 22
23shell: cube.o 23shell: 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
9char *buf; 12char *buf;
10 13
11void run(void) { 14void 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
3re="${RUN:-$@}" 3if [ -z "$TOOL" ]; then
4 echo "No tool selected (TOOL variable must be set)"
5 exit 1
6fi
4 7
5CC="cc -std=c99 -pedantic -Wall -Wextra \ 8CC="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
11BIN="benchmark/run" 14BIN="tools/run"
12RES="benchmark/results"
13CUBEOBJ="cube.o" 15CUBEOBJ="cube.o"
14d="$(date +'%Y-%m-%d-%H-%M-%S')" 16d="$(date +'%Y-%m-%d-%H-%M-%S')"
15 17
16mkdir -p "$RES" 18for t in tools/*; do
17 19 if [ ! -d "$t" ] || [ -z "$(echo "$t" | grep "$TOOL")" ]; then
18for 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
25done 25done
26 26
27rm -rf $BIN $CUBEOBJ 27rm -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
7double 7double
8time_benchmark(void (*run)(void), char *name) 8timerun(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

Generated with cgit - Back to sebastiano.tronto.net