aboutsummaryrefslogtreecommitdiff
path: root/tools/200_stats_tables_h48
diff options
context:
space:
mode:
Diffstat (limited to 'tools/200_stats_tables_h48')
-rw-r--r--tools/200_stats_tables_h48/stats_tables_h48.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/tools/200_stats_tables_h48/stats_tables_h48.c b/tools/200_stats_tables_h48/stats_tables_h48.c
index ea5fa5a..a9a2a1e 100644
--- a/tools/200_stats_tables_h48/stats_tables_h48.c
+++ b/tools/200_stats_tables_h48/stats_tables_h48.c
@@ -3,11 +3,10 @@
3#include "../tool.h" 3#include "../tool.h"
4 4
5#define MAXMOVES 20 5#define MAXMOVES 20
6#define NCUBES_PER_THREAD 10000
7#define LOG_EVERY (NCUBES_PER_THREAD / 10) 6#define LOG_EVERY (NCUBES_PER_THREAD / 10)
8 7
8int NCUBES_PER_THREAD;
9const char *solver = "h48stats"; 9const char *solver = "h48stats";
10const char *options = "";
11const char *filename = "tables/h48h0k4"; 10const char *filename = "tables/h48h0k4";
12char *buf; 11char *buf;
13 12
@@ -29,7 +28,7 @@ uint64_t rand64(void) {
29static void * 28static void *
30run_thread(void *arg) 29run_thread(void *arg)
31{ 30{
32 char sols[12], cube[22]; 31 char s[12], cube[22];
33 int64_t ep, eo, cp, co; 32 int64_t ep, eo, cp, co;
34 int i, j; 33 int i, j;
35 34
@@ -41,10 +40,9 @@ run_thread(void *arg)
41 cp = rand64(); 40 cp = rand64();
42 co = rand64(); 41 co = rand64();
43 nissy_getcube(ep, eo, cp, co, "fix", cube); 42 nissy_getcube(ep, eo, cp, co, "fix", cube);
44 nissy_solve(cube, "h48stats", "", "", 43 nissy_solve(cube, "h48stats", "", 0, MAXMOVES, 1, -1, buf, s);
45 0, MAXMOVES, 1, -1, buf, sols);
46 for (j = 0; j < 12; j++) 44 for (j = 0; j < 12; j++)
47 a->v[j][(int)sols[j]]++; 45 a->v[j][(int)s[j]]++;
48 if ((i+1) % LOG_EVERY == 0) 46 if ((i+1) % LOG_EVERY == 0)
49 fprintf(stderr, "[thread %d] %d cubes solved...\n", 47 fprintf(stderr, "[thread %d] %d cubes solved...\n",
50 a->thread_id, i+1); 48 a->thread_id, i+1);
@@ -85,11 +83,27 @@ void run(void) {
85 } 83 }
86} 84}
87 85
88int main(void) { 86int main(int argc, char **argv) {
89 srand(time(NULL)); 87 srand(time(NULL));
90 nissy_setlogger(log_stderr); 88 nissy_setlogger(log_stderr);
91 89
92 if (getdata(solver, options, &buf, filename) != 0) 90 if (argc < 2) {
91 fprintf(stderr, "Error: not enough arguments. "
92 "Number of cubes per thread must be provided.\n");
93 return 1;
94 }
95
96 NCUBES_PER_THREAD = atoi(argv[1]);
97
98 if (NCUBES_PER_THREAD < 1 || NCUBES_PER_THREAD > 1000000) {
99 fprintf(stderr, "Invalid number of cubes: must be > 0 and "
100 "< 1000000, but %d was given.\n", NCUBES_PER_THREAD);
101 return 1;
102 }
103
104 printf("Using %d cubes per thread (%d total)\n",
105 NCUBES_PER_THREAD, NCUBES_PER_THREAD * THREADS);
106 if (getdata(solver, &buf, filename) != 0)
93 return 1; 107 return 1;
94 108
95 timerun(run); 109 timerun(run);

Generated with cgit - Back to sebastiano.tronto.net