aboutsummaryrefslogtreecommitdiff
path: root/tools/002_stats_tables_h48
diff options
context:
space:
mode:
Diffstat (limited to 'tools/002_stats_tables_h48')
-rw-r--r--tools/002_stats_tables_h48/stats_tables_h48.c59
1 files changed, 8 insertions, 51 deletions
diff --git a/tools/002_stats_tables_h48/stats_tables_h48.c b/tools/002_stats_tables_h48/stats_tables_h48.c
index 2e48497..8b65862 100644
--- a/tools/002_stats_tables_h48/stats_tables_h48.c
+++ b/tools/002_stats_tables_h48/stats_tables_h48.c
@@ -1,22 +1,23 @@
1#include <pthread.h> 1#include <pthread.h>
2#include <time.h> 2
3#include "../timerun.h" 3#include "../tool.h"
4#include "../../src/nissy.h"
5 4
6#define MAXMOVES 20 5#define MAXMOVES 20
7#define NTHREADS 32 6#define NTHREADS 32
8#define NCUBES_PER_THREAD 10000 7#define NCUBES_PER_THREAD 10000
9#define LOG_EVERY (NCUBES_PER_THREAD / 10) 8#define LOG_EVERY (NCUBES_PER_THREAD / 10)
10 9
10const char *solver = "h48stats";
11const char *options = "";
12const char *filename = "tables/h48h0k4";
13char *buf;
14
11typedef struct { 15typedef struct {
12 int n; 16 int n;
13 int thread_id; 17 int thread_id;
14 int64_t v[12][100]; 18 int64_t v[12][100];
15} thread_arg_t; 19} thread_arg_t;
16 20
17const char *filename = "tables/h48h0k4";
18char *buf;
19
20uint64_t rand64(void) { 21uint64_t rand64(void) {
21 uint64_t i, ret; 22 uint64_t i, ret;
22 23
@@ -85,56 +86,12 @@ void run(void) {
85 } 86 }
86} 87}
87 88
88int getdata(int64_t size) {
89 int64_t s;
90 FILE *f;
91
92 buf = malloc(size);
93
94 if ((f = fopen(filename, "rb")) == NULL) {
95 fprintf(stderr, "Table file not found, generating them."
96 " This can take a while.\n");
97 s = nissy_gendata("h48stats", "", buf);
98 if (s != size) {
99 fprintf(stderr, "Error generating table");
100 if (s != -1)
101 fprintf(stderr, " (got %" PRId64 " bytes)", s);
102 fprintf(stderr, "\n");
103 return 1;
104 }
105 if ((f = fopen(filename, "wb")) == NULL) {
106 fprintf(stderr, "Could not write tables to file %s"
107 ", will be regenerated next time.\n", filename);
108 } else {
109 fwrite(buf, size, 1, f);
110 fclose(f);
111 }
112 } else {
113 fprintf(stderr, "Reading tables from file %s\n", filename);
114 fread(buf, size, 1, f);
115 fclose(f);
116 }
117
118 return 0;
119}
120
121int main(void) { 89int main(void) {
122 int64_t size;
123
124 srand(time(NULL)); 90 srand(time(NULL));
125
126 nissy_setlogger(log_stderr); 91 nissy_setlogger(log_stderr);
127 size = nissy_datasize("h48stats", "");
128 if (size == -1) {
129 printf("h48 stats: error in datasize\n");
130 return 1;
131 }
132 92
133 if (getdata(size) != 0) { 93 if (getdata(solver, options, &buf, filename) != 0)
134 printf("Error getting table, stopping\n");
135 free(buf);
136 return 1; 94 return 1;
137 }
138 95
139 timerun(run, "h48 table stats"); 96 timerun(run, "h48 table stats");
140 97

Generated with cgit - Back to sebastiano.tronto.net