aboutsummaryrefslogtreecommitdiff
path: root/tools/200_stats_tables_h48
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-10 14:30:39 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-10 14:30:39 +0200
commitf8d247c53c3c3bd94fed645b5b47a9096cadc123 (patch)
tree7a62cc7322ea8175a7df9b655d4a9d5e026a004a /tools/200_stats_tables_h48
parent2e93de4ad102973961cb24d5b91f0c299763299f (diff)
downloadnissy-core-f8d247c53c3c3bd94fed645b5b47a9096cadc123.tar.gz
nissy-core-f8d247c53c3c3bd94fed645b5b47a9096cadc123.zip
Removed "options" from solver selection
Now the solver name fully determines the solver (and options) to be used. For example, now one must specify "h48h0k4" as the name of the solver. This PR also fixes a couple of things in tools.
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