aboutsummaryrefslogtreecommitdiff
path: root/tools/100_stats_tables_h48
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-09-18 13:58:31 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-09-18 13:58:31 +0200
commit7f78e56994a824fc8364c91032c1be4ee767ec41 (patch)
treefeb20ee002a415b80a827f24188ef4ed239a8bf5 /tools/100_stats_tables_h48
parent4adeab7cdfb957db832bd6730060fa5eca952d82 (diff)
downloadnissy-core-7f78e56994a824fc8364c91032c1be4ee767ec41.tar.gz
nissy-core-7f78e56994a824fc8364c91032c1be4ee767ec41.zip
Renamed tools; fixed solve tool; added gendata_h48h1k2 tool
Diffstat (limited to 'tools/100_stats_tables_h48')
-rw-r--r--tools/100_stats_tables_h48/stats_tables_h48.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/tools/100_stats_tables_h48/stats_tables_h48.c b/tools/100_stats_tables_h48/stats_tables_h48.c
new file mode 100644
index 0000000..adac8fa
--- /dev/null
+++ b/tools/100_stats_tables_h48/stats_tables_h48.c
@@ -0,0 +1,99 @@
1#include <pthread.h>
2
3#include "../tool.h"
4
5#define MAXMOVES 20
6#define NCUBES_PER_THREAD 10000
7#define LOG_EVERY (NCUBES_PER_THREAD / 10)
8
9const char *solver = "h48stats";
10const char *options = "";
11const char *filename = "tables/h48h0k4";
12char *buf;
13
14typedef struct {
15 int n;
16 int thread_id;
17 int64_t v[12][100];
18} thread_arg_t;
19
20uint64_t rand64(void) {
21 uint64_t i, ret;
22
23 for (i = 0, ret = 0; i < 64; i++)
24 ret |= (uint64_t)(rand() % 2) << i;
25
26 return ret;
27}
28
29static void *
30run_thread(void *arg)
31{
32 char sols[12], cube[22];
33 int64_t ep, eo, cp, co;
34 int i, j;
35
36 thread_arg_t *a = (thread_arg_t *)arg;
37
38 for (i = 0; i < a->n; i++) {
39 ep = rand64();
40 eo = rand64();
41 cp = rand64();
42 co = rand64();
43 nissy_getcube(ep, eo, cp, co, "fix", cube);
44 nissy_solve(cube, "h48stats", "", "",
45 0, MAXMOVES, 1, -1, buf, sols);
46 for (j = 0; j < 12; j++)
47 a->v[j][(int)sols[j]]++;
48 if ((i+1) % LOG_EVERY == 0)
49 fprintf(stderr, "[thread %d] %d cubes solved...\n",
50 a->thread_id, i+1);
51 }
52
53 return NULL;
54}
55
56void run(void) {
57 int64_t i, j, k, tot;
58 double avg;
59 pthread_t thread[THREADS];
60 thread_arg_t arg[THREADS];
61
62 for (i = 0; i < THREADS; i++) {
63 arg[i] = (thread_arg_t) {
64 .thread_id = i,
65 .n = NCUBES_PER_THREAD,
66 .v = {{0}}
67 };
68 pthread_create(&thread[i], NULL, run_thread, &arg[i]);
69 }
70
71 for (i = 0; i < THREADS; i++)
72 pthread_join(thread[i], NULL);
73
74 for (j = 0; j < 12; j++) {
75 printf("Data for h=%" PRId64 "\n", j);
76 for (k = 0, avg = 0.0; k < 16; k++) {
77 for (i = 0, tot = 0; i < THREADS; i++)
78 tot += arg[i].v[j][k];
79 printf("%" PRId64 "\t%" PRId64 "\n", k, tot);
80 avg += tot * k;
81 }
82 avg /= (double)(NCUBES_PER_THREAD * THREADS);
83 printf("Average: %.4lf\n", avg);
84 printf("\n");
85 }
86}
87
88int main(void) {
89 srand(time(NULL));
90 nissy_setlogger(log_stderr);
91
92 if (getdata(solver, options, &buf, filename) != 0)
93 return 1;
94
95 timerun(run, "h48 table stats");
96
97 free(buf);
98 return 0;
99}

Generated with cgit - Back to sebastiano.tronto.net