aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-04 08:58:47 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-04 08:58:47 +0200
commit32009294d2de3e197c8d4dc950559ff948ea2fc9 (patch)
treeac297be7b6e218ee8ae21367c94c8b65297fe2ca /tools
parent757a732336ee5f0f4b0ba44ac138210c2c1ef805 (diff)
downloadnissy-core-32009294d2de3e197c8d4dc950559ff948ea2fc9.tar.gz
nissy-core-32009294d2de3e197c8d4dc950559ff948ea2fc9.zip
Clean up tool output
Diffstat (limited to 'tools')
-rw-r--r--tools/000_gendata/gendata.c5
-rw-r--r--tools/001_derive_h48/derive_h48.c5
-rw-r--r--tools/100_checkdata/checkdata.c6
-rw-r--r--tools/200_stats_tables_h48/stats_tables_h48.c2
-rw-r--r--tools/300_solve_small/solve_small.c3
-rw-r--r--tools/tool.h13
-rwxr-xr-xtools/tool.sh29
7 files changed, 34 insertions, 29 deletions
diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c
index 90166dd..9533432 100644
--- a/tools/000_gendata/gendata.c
+++ b/tools/000_gendata/gendata.c
@@ -32,7 +32,6 @@ gendata_run_finish:
32 32
33int main(int argc, char **argv) { 33int main(int argc, char **argv) {
34 uint8_t h, k; 34 uint8_t h, k;
35 char description[256];
36 35
37 if (argc < 3) { 36 if (argc < 3) {
38 fprintf(stderr, "Error: not enough arguments. " 37 fprintf(stderr, "Error: not enough arguments. "
@@ -44,12 +43,10 @@ int main(int argc, char **argv) {
44 options = argv[2]; 43 options = argv[2];
45 parse_h48_options(options, &h, &k, NULL); 44 parse_h48_options(options, &h, &k, NULL);
46 expected = expected_h48[h][k]; 45 expected = expected_h48[h][k];
47 sprintf(description, "benchmark gendata_h48 h = %" PRIu8
48 ", k = %" PRIu8 "", h, k);
49 46
50 nissy_setlogger(log_stderr); 47 nissy_setlogger(log_stderr);
51 48
52 timerun(run, description); 49 timerun(run);
53 50
54 return 0; 51 return 0;
55} 52}
diff --git a/tools/001_derive_h48/derive_h48.c b/tools/001_derive_h48/derive_h48.c
index 3c7f8cc..c3062bf 100644
--- a/tools/001_derive_h48/derive_h48.c
+++ b/tools/001_derive_h48/derive_h48.c
@@ -7,8 +7,6 @@ void run(void) {
7} 7}
8 8
9int main(int argc, char **argv) { 9int main(int argc, char **argv) {
10 char description[256];
11
12 if (argc < 5) { 10 if (argc < 5) {
13 fprintf(stderr, 11 fprintf(stderr,
14 "Error: not enough arguments. Required:\n" 12 "Error: not enough arguments. Required:\n"
@@ -23,11 +21,10 @@ int main(int argc, char **argv) {
23 opts_small = argv[2]; 21 opts_small = argv[2];
24 filename_large = argv[3]; 22 filename_large = argv[3];
25 filename_small = argv[4]; 23 filename_small = argv[4];
26 sprintf(description, "deriving %s from %s\n", opts_small, opts_large);
27 24
28 nissy_setlogger(log_stderr); 25 nissy_setlogger(log_stderr);
29 26
30 timerun(run, description); 27 timerun(run);
31 28
32 return 0; 29 return 0;
33} 30}
diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c
index 05961c1..502925f 100644
--- a/tools/100_checkdata/checkdata.c
+++ b/tools/100_checkdata/checkdata.c
@@ -31,8 +31,6 @@ run(void) {
31} 31}
32 32
33int main(int argc, char **argv) { 33int main(int argc, char **argv) {
34 char description[256];
35
36 if (argc < 4) { 34 if (argc < 4) {
37 fprintf(stderr, "Error: not enough arguments. " 35 fprintf(stderr, "Error: not enough arguments. "
38 "A solver, its options and a file name must be given.\n"); 36 "A solver, its options and a file name must be given.\n");
@@ -42,11 +40,9 @@ int main(int argc, char **argv) {
42 solver = argv[1]; 40 solver = argv[1];
43 options = argv[2]; 41 options = argv[2];
44 filename = argv[3]; 42 filename = argv[3];
45 sprintf(description, "checking data for solver %s"
46 "with options %s from file %s", solver, options, filename);
47 nissy_setlogger(log_stderr); 43 nissy_setlogger(log_stderr);
48 44
49 timerun(run, description); 45 timerun(run);
50 46
51 return 0; 47 return 0;
52} 48}
diff --git a/tools/200_stats_tables_h48/stats_tables_h48.c b/tools/200_stats_tables_h48/stats_tables_h48.c
index adac8fa..ea5fa5a 100644
--- a/tools/200_stats_tables_h48/stats_tables_h48.c
+++ b/tools/200_stats_tables_h48/stats_tables_h48.c
@@ -92,7 +92,7 @@ int main(void) {
92 if (getdata(solver, options, &buf, filename) != 0) 92 if (getdata(solver, options, &buf, filename) != 0)
93 return 1; 93 return 1;
94 94
95 timerun(run, "h48 table stats"); 95 timerun(run);
96 96
97 free(buf); 97 free(buf);
98 return 0; 98 return 0;
diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c
index d476bce..c9dbca8 100644
--- a/tools/300_solve_small/solve_small.c
+++ b/tools/300_solve_small/solve_small.c
@@ -39,14 +39,13 @@ void run(void) {
39} 39}
40 40
41int main(void) { 41int main(void) {
42
43 srand(time(NULL)); 42 srand(time(NULL));
44 nissy_setlogger(log_stderr); 43 nissy_setlogger(log_stderr);
45 44
46 if (getdata(solver, options, &buf, filename) != 0) 45 if (getdata(solver, options, &buf, filename) != 0)
47 return 1; 46 return 1;
48 47
49 timerun(run, "small solver benchmark"); 48 timerun(run);
50 49
51 free(buf); 50 free(buf);
52 return 0; 51 return 0;
diff --git a/tools/tool.h b/tools/tool.h
index c44828d..9fee050 100644
--- a/tools/tool.h
+++ b/tools/tool.h
@@ -10,7 +10,7 @@
10 10
11static void log_stderr(const char *, ...); 11static void log_stderr(const char *, ...);
12static void log_stdout(const char *, ...); 12static void log_stdout(const char *, ...);
13static double timerun(void (*)(void), const char *); 13static double timerun(void (*)(void));
14static void getfilename(const char *, const char *, char *); 14static void getfilename(const char *, const char *, char *);
15static void writetable(const char *, int64_t, const char *); 15static void writetable(const char *, int64_t, const char *);
16static int64_t generatetable(const char *, const char *, char **); 16static int64_t generatetable(const char *, const char *, char **);
@@ -41,24 +41,19 @@ write_stdout(const char *str, ...)
41} 41}
42 42
43static double 43static double
44timerun(void (*run)(void), const char *name) 44timerun(void (*run)(void))
45{ 45{
46 struct timespec start, end; 46 struct timespec start, end;
47 double tdiff, tdsec, tdnano; 47 double tdiff, tdsec, tdnano;
48 48
49 printf("\n");
50 fflush(stdout); 49 fflush(stdout);
51 50
52 if (run == NULL) { 51 if (run == NULL) {
53 printf("> %s: nothing to run!\n", name); 52 printf("nothing to run!\n");
54 fflush(stdout); 53 fflush(stdout);
55 return -1.0; 54 return -1.0;
56 } 55 }
57 56
58 printf("Running tool: %s\n", name);
59 printf("==========\n");
60 fflush(stdout);
61
62 clock_gettime(CLOCK_MONOTONIC, &start); 57 clock_gettime(CLOCK_MONOTONIC, &start);
63 run(); 58 run();
64 clock_gettime(CLOCK_MONOTONIC, &end); 59 clock_gettime(CLOCK_MONOTONIC, &end);
@@ -67,7 +62,7 @@ timerun(void (*run)(void), const char *name)
67 tdnano = end.tv_nsec - start.tv_nsec; 62 tdnano = end.tv_nsec - start.tv_nsec;
68 tdiff = tdsec + 1e-9 * tdnano; 63 tdiff = tdsec + 1e-9 * tdnano;
69 64
70 printf("==========\n"); 65 printf("---------\n");
71 printf("\nTotal time: %.4fs\n", tdiff); 66 printf("\nTotal time: %.4fs\n", tdiff);
72 fflush(stdout); 67 fflush(stdout);
73 68
diff --git a/tools/tool.sh b/tools/tool.sh
index 64bfd89..23d781d 100755
--- a/tools/tool.sh
+++ b/tools/tool.sh
@@ -8,15 +8,36 @@ fi
8CC="$CC -D_POSIX_C_SOURCE=199309L" # For timer 8CC="$CC -D_POSIX_C_SOURCE=199309L" # For timer
9 9
10BIN="tools/run" 10BIN="tools/run"
11d="$(date +'%Y-%m-%d-%H-%M-%S')" 11RESULTS="tools/results"
12LAST="$RESULTS/last.out"
13date="$(date +'%Y-%m-%d-%H-%M-%S')"
12 14
13for t in tools/*; do 15for t in tools/*; do
14 if [ ! -d "$t" ] || ! (echo "$t" | grep -q "$TOOL"); then 16 if [ ! -d "$t" ] || ! (echo "$t" | grep -q "$TOOL"); then
15 continue 17 continue
16 fi 18 fi
17 toolname="$(basename "$t" .c)" 19 toolname="$(basename "$t" .c)"
18 $CC -o $BIN "$t"/*.c "$OBJ" || exit 1;
19 $BIN $TOOLARGS \
20 | tee "tools/results/$toolname-$d.txt" "tools/results/last.out"
21 break 20 break
22done 21done
22
23file="$RESULTS/$toolname-$date.txt"
24
25$CC -o $BIN "$t"/*.c "$OBJ" || exit 1;
26
27(
28date +'%Y-%m-%d %H:%M'
29echo ""
30echo "======== config.mk ========"
31cat config.mk
32echo "==========================="
33echo ""
34echo "=== tool configuration ===="
35echo "TOOL=$toolname"
36echo "TOOLARGS=$TOOLARGS"
37echo "CC=$CC"
38echo "==========================="
39echo ""
40echo "======= tool output ======="
41$BIN $TOOLARGS
42echo "==========================="
43) | tee "$file" "$LAST"

Generated with cgit - Back to sebastiano.tronto.net