aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-09-10 19:43:05 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-09-10 19:43:05 +0200
commit70d3a3de3a2fdef7e47b2bd510261d69390a3a9c (patch)
tree2c545953d0b61b37c4f281cd47981e9350b5c09b
parent1f4900a3cc6ca74f94b73e224d14a09d52c4549c (diff)
downloadnissy-core-70d3a3de3a2fdef7e47b2bd510261d69390a3a9c.tar.gz
nissy-core-70d3a3de3a2fdef7e47b2bd510261d69390a3a9c.zip
New tableinfo for gendata_h48, still work to do
-rw-r--r--src/solvers/h48/gendata_cocsep.h36
-rw-r--r--src/solvers/h48/gendata_h48.h131
-rw-r--r--src/solvers/tables.h16
-rw-r--r--test/090_tables_readwrite/00_table.in1
-rw-r--r--test/090_tables_readwrite/00_table.out1
-rw-r--r--test/090_tables_readwrite/tables_readwrite_tests.c5
-rw-r--r--test/100_gendata_cocsep/00_all.out2
-rw-r--r--test/100_gendata_cocsep/gendata_cocsep_tests.c35
-rw-r--r--test/101_cocsep_transform_invariant/cocsep_transform_invariant.c9
-rw-r--r--test/102_cocsep_selfsim/cocsep_selfsim_tests.c7
-rw-r--r--test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c2
-rw-r--r--test/104_cocsep_ttrep/cocsep_ttrep_tests.c10
-rw-r--r--test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c7
-rw-r--r--test/112_gen_h48short/gen_h48short_tests.c (renamed from test/112_gen_h48short/gen_h48short.c)9
-rw-r--r--test/120_gendata_h48h0k4/00_h_0.out2
-rw-r--r--test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c60
16 files changed, 242 insertions, 91 deletions
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h
index 4a9b67e..2189145 100644
--- a/src/solvers/h48/gendata_cocsep.h
+++ b/src/solvers/h48/gendata_cocsep.h
@@ -1,7 +1,7 @@
1#define COCSEP_CLASSES ((size_t)3393) 1#define COCSEP_CLASSES ((size_t)3393)
2#define COCSEP_TABLESIZE ((size_t)POW_3_7 << (size_t)7) 2#define COCSEP_TABLESIZE ((size_t)POW_3_7 << (size_t)7)
3#define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + (size_t)7) / (size_t)8) 3#define COCSEP_VISITEDSIZE DIV_ROUND_UP(COCSEP_TABLESIZE, (size_t)8)
4#define COCSEP_FULLSIZE ((size_t)4 * (COCSEP_TABLESIZE + (size_t)12)) 4#define COCSEP_FULLSIZE (INFOSIZE + (size_t)4 * COCSEP_TABLESIZE)
5 5
6#define VISITED_IND(i) ((uint32_t)(i) / UINT32_C(8)) 6#define VISITED_IND(i) ((uint32_t)(i) / UINT32_C(8))
7#define VISITED_MASK(i) (UINT32_C(1) << ((uint32_t)(i) % UINT32_C(8))) 7#define VISITED_MASK(i) (UINT32_C(1) << ((uint32_t)(i) % UINT32_C(8)))
@@ -42,20 +42,33 @@ After the data as described above, more auxiliary information is appended:
42STATIC size_t 42STATIC size_t
43gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep) 43gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep)
44{ 44{
45 uint32_t *buf32, *info, cc; 45 uint32_t *buf32, cc;
46 uint16_t n; 46 uint16_t n;
47 uint8_t i, j, visited[COCSEP_VISITEDSIZE]; 47 uint8_t i, j, visited[COCSEP_VISITEDSIZE];
48 tableinfo_t info;
48 cocsep_dfs_arg_t arg; 49 cocsep_dfs_arg_t arg;
49 50
50 if (buf == NULL) 51 if (buf == NULL)
51 goto gendata_cocsep_return_size; 52 goto gendata_cocsep_return_size;
52 53
53 buf32 = (uint32_t *)buf; 54 memset(buf, 0xFF, COCSEP_FULLSIZE);
54 info = buf32 + COCSEP_TABLESIZE; 55 buf32 = (uint32_t *)((char *)buf + INFOSIZE);
55 memset(buf32, 0xFF, sizeof(uint32_t) * COCSEP_TABLESIZE);
56 if (selfsim != NULL) 56 if (selfsim != NULL)
57 memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES); 57 memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES);
58 58
59 info = (tableinfo_t) {
60 .solver = "cocsep data for h48",
61 .type = TABLETYPE_SPECIAL,
62 .infosize = INFOSIZE,
63 .fullsize = COCSEP_FULLSIZE,
64 .hash = 0, /* TODO */
65 .entries = COCSEP_TABLESIZE,
66 .classes = COCSEP_CLASSES,
67 .bits = 32,
68 .base = 0,
69 .maxvalue = 9,
70 .next = 0
71 };
59 arg = (cocsep_dfs_arg_t) { 72 arg = (cocsep_dfs_arg_t) {
60 .cube = SOLVED_CUBE, 73 .cube = SOLVED_CUBE,
61 .n = &n, 74 .n = &n,
@@ -70,22 +83,21 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep)
70 arg.depth = 0; 83 arg.depth = 0;
71 arg.maxdepth = i; 84 arg.maxdepth = i;
72 cc = gendata_cocsep_dfs(&arg); 85 cc = gendata_cocsep_dfs(&arg);
73 info[i+2] = cc; 86 info.distribution[i] = cc;
74 LOG("found %" PRIu32 "\n", cc); 87 LOG("found %" PRIu32 "\n", cc);
75 } 88 }
76 89
77 info[0] = (uint32_t)n; 90 writetableinfo(&info, buf);
78 info[1] = 9; /* Known max pruning value */ 91
79 DBG_ASSERT(n == COCSEP_CLASSES, 0, 92 DBG_ASSERT(n == COCSEP_CLASSES, 0,
80 "cocsep: computed %" PRIu16 " symmetry classes, " 93 "cocsep: computed %" PRIu16 " symmetry classes, "
81 "expected %zu\n", n, COCSEP_CLASSES); 94 "expected %zu\n", n, COCSEP_CLASSES);
82 95
83 LOG("cocsep data computed\n"); 96 LOG("cocsep data computed\n");
84 LOG("Symmetry classes: %" PRIu32 "\n", info[0]); 97 LOG("Symmetry classes: %" PRIu32 "\n", COCSEP_CLASSES);
85 LOG("Maximum pruning value: %" PRIu32 "\n", info[1]);
86 LOG("Pruning value distribution:\n"); 98 LOG("Pruning value distribution:\n");
87 for (j = 0; j < 10; j++) 99 for (j = 0; j < 10; j++)
88 LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+2]); 100 LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info.distribution[j]);
89 101
90gendata_cocsep_return_size: 102gendata_cocsep_return_size:
91 return COCSEP_FULLSIZE; 103 return COCSEP_FULLSIZE;
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 4b20c13..c8673fa 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -1,5 +1,5 @@
1#define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * COMB_12_4 * COMB_8_4)) 1#define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * COMB_12_4 * COMB_8_4))
2#define H48_COORDMAX(h) ((int64_t)(H48_COORDMAX_NOEO << (int64_t)(h))) 2#define H48_COORDMAX(h) (H48_COORDMAX_NOEO << (int64_t)(h))
3#define H48_DIV(k) ((size_t)8 / (size_t)(k)) 3#define H48_DIV(k) ((size_t)8 / (size_t)(k))
4#define H48_TABLESIZE(h, k) DIV_ROUND_UP((size_t)H48_COORDMAX((h)), H48_DIV(k)) 4#define H48_TABLESIZE(h, k) DIV_ROUND_UP((size_t)H48_COORDMAX((h)), H48_DIV(k))
5 5
@@ -33,10 +33,10 @@ typedef struct {
33 uint8_t h; 33 uint8_t h;
34 uint8_t k; 34 uint8_t k;
35 uint8_t maxdepth; 35 uint8_t maxdepth;
36 tableinfo_t info;
36 void *buf; 37 void *buf;
37 uint32_t *info; 38 void *h48buf;
38 uint32_t *cocsepdata; 39 uint32_t *cocsepdata;
39 uint32_t *h48data;
40 uint64_t selfsim[COCSEP_CLASSES]; 40 uint64_t selfsim[COCSEP_CLASSES];
41 cube_t crep[COCSEP_CLASSES]; 41 cube_t crep[COCSEP_CLASSES];
42} gendata_h48_arg_t; 42} gendata_h48_arg_t;
@@ -65,7 +65,7 @@ typedef struct {
65 uint8_t base; 65 uint8_t base;
66 uint8_t shortdepth; 66 uint8_t shortdepth;
67 uint32_t *cocsepdata; 67 uint32_t *cocsepdata;
68 uint32_t *h48data; 68 uint32_t *buf32;
69 uint64_t *selfsim; 69 uint64_t *selfsim;
70 cube_t *crep; 70 cube_t *crep;
71 h48map_t *shortcubes; 71 h48map_t *shortcubes;
@@ -130,32 +130,45 @@ gen_h48short(gendata_h48short_arg_t *arg)
130STATIC size_t 130STATIC size_t
131gendata_h48(gendata_h48_arg_t *arg) 131gendata_h48(gendata_h48_arg_t *arg)
132{ 132{
133 static const size_t infosize = 88; /* TODO: change to e.g. 1024 */ 133 void *cocsepdata_offset;
134
135 size_t cocsepsize, h48size; 134 size_t cocsepsize, h48size;
135 tableinfo_t cocsepinfo;
136 136
137 /* TODO: move info at the start */ 137 cocsepsize = gendata_cocsep(arg->buf, arg->selfsim, arg->crep);
138 arg->cocsepdata = (uint32_t *)arg->buf;
139 cocsepsize = gendata_cocsep(
140 (void *)arg->cocsepdata, arg->selfsim, arg->crep);
141 arg->h48data = arg->cocsepdata + (cocsepsize / sizeof(uint32_t));
142 arg->info = arg->h48data + 1 +
143 (H48_TABLESIZE(arg->h, arg->k) / sizeof(uint32_t));
144 138
145 if (arg->buf != NULL) 139 cocsepdata_offset = (char *)arg->buf + INFOSIZE;
146 memset(arg->h48data, 0xFF, H48_TABLESIZE(arg->h, arg->k)); 140 arg->cocsepdata = (uint32_t *)cocsepdata_offset;
141 arg->h48buf = (char *)arg->buf + cocsepsize;
147 142
148 if (arg->h == 0 && arg->k == 4) { 143 if (arg->h == 0 && arg->k == 4) {
149 h48size = gendata_h48h0k4(arg); 144 h48size = gendata_h48h0k4(arg);
150 } else if (arg->k == 2) { 145 } else if (arg->k == 2) {
151 h48size = gendata_h48k2(arg); 146 h48size = gendata_h48k2(arg);
152 } else { 147 } else {
153 h48size = 0;
154 LOG("Cannot generate data for h = %" PRIu8 " and k = %" PRIu8 148 LOG("Cannot generate data for h = %" PRIu8 " and k = %" PRIu8
155 " (not implemented yet)\n", arg->h, arg->k); 149 " (not implemented yet)\n", arg->h, arg->k);
150 goto gendata_h48_error;
156 } 151 }
157 152
158 return infosize + cocsepsize + h48size; 153 if (arg->buf == 0)
154 goto gendata_h48_return_size;
155
156 if (!readtableinfo(arg->buf, &cocsepinfo)) {
157 LOG("gendata_h48: could not read info for cocsep table\n");
158 goto gendata_h48_error;
159 }
160 cocsepinfo.next = cocsepsize;
161 if (!writetableinfo(&cocsepinfo, arg->buf)) {
162 LOG("gendata_h48: could not write info for cocsep table"
163 " with updated 'next' value\n");
164 goto gendata_h48_error;
165 }
166
167gendata_h48_return_size:
168 return cocsepsize + h48size;
169
170gendata_h48_error:
171 return 0;
159} 172}
160 173
161/* 174/*
@@ -165,20 +178,36 @@ generating fixed table with h=0, k=4
165STATIC size_t 178STATIC size_t
166gendata_h48h0k4(gendata_h48_arg_t *arg) 179gendata_h48h0k4(gendata_h48_arg_t *arg)
167{ 180{
168 uint32_t j; 181 uint32_t j, *buf32;
169 h48h0k4_bfs_arg_t bfsarg; 182 h48h0k4_bfs_arg_t bfsarg;
170 int64_t sc, cc, esep_max; 183 int64_t sc, cc, esep_max;
171 184
172 if (arg->buf == NULL) 185 if (arg->buf == NULL)
173 goto gendata_h48h0k4_return_size; 186 goto gendata_h48h0k4_return_size;
174 187
188 arg->info = (tableinfo_t) {
189 .solver = "h48 solver h = 0, k = 4",
190 .type = TABLETYPE_PRUNING,
191 .infosize = INFOSIZE,
192 .fullsize = H48_TABLESIZE(0, 4) + INFOSIZE,
193 .hash = 0, /* TODO */
194 .entries = H48_COORDMAX(0),
195 .classes = 0,
196 .bits = 4,
197 .base = 0,
198 .next = 0,
199 };
200
201 buf32 = (uint32_t *)((char *)arg->h48buf + INFOSIZE);
202 memset(buf32, 0xFF, H48_TABLESIZE(0, 4));
203
175 esep_max = (int64_t)H48_COORDMAX(0); 204 esep_max = (int64_t)H48_COORDMAX(0);
176 sc = coord_h48(SOLVED_CUBE, arg->cocsepdata, 0); 205 sc = coord_h48(SOLVED_CUBE, arg->cocsepdata, 0);
177 set_esep_pval(arg->h48data, sc, 4, 0); 206 set_esep_pval(buf32, sc, 4, 0);
178 arg->info[1] = 1; 207 arg->info.distribution[0] = 1;
179 bfsarg = (h48h0k4_bfs_arg_t) { 208 bfsarg = (h48h0k4_bfs_arg_t) {
180 .cocsepdata = arg->cocsepdata, 209 .cocsepdata = arg->cocsepdata,
181 .buf32 = arg->h48data, 210 .buf32 = buf32,
182 .selfsim = arg->selfsim, 211 .selfsim = arg->selfsim,
183 .crep = arg->crep 212 .crep = arg->crep
184 }; 213 };
@@ -190,20 +219,22 @@ gendata_h48h0k4(gendata_h48_arg_t *arg)
190 LOG("esep: generating depth %" PRIu8 "\n", bfsarg.depth); 219 LOG("esep: generating depth %" PRIu8 "\n", bfsarg.depth);
191 cc = gendata_h48h0k4_bfs(&bfsarg); 220 cc = gendata_h48h0k4_bfs(&bfsarg);
192 bfsarg.done += cc; 221 bfsarg.done += cc;
193 arg->info[bfsarg.depth+1] = cc; 222 arg->info.distribution[bfsarg.depth] = cc;
194 LOG("found %" PRId64 "\n", cc); 223 LOG("found %" PRId64 "\n", cc);
195 } 224 }
196 225
197 arg->info[0] = bfsarg.depth-1; 226 arg->info.maxvalue = bfsarg.depth-1;
198 227
199 LOG("h48 pruning table computed\n"); 228 LOG("h48 pruning table computed\n");
200 LOG("Maximum pruning value: %" PRIu32 "\n", arg->info[0]); 229 LOG("Maximum pruning value: %" PRIu32 "\n", arg->info.maxvalue);
201 LOG("Pruning value distribution:\n"); 230 LOG("Pruning value distribution:\n");
202 for (j = 0; j <= arg->info[0]; j++) 231 for (j = 0; j <= arg->info.maxvalue; j++)
203 LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, arg->info[j+1]); 232 LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, arg->info.distribution[j]);
233
234 writetableinfo(&arg->info, arg->h48buf);
204 235
205gendata_h48h0k4_return_size: 236gendata_h48h0k4_return_size:
206 return H48_TABLESIZE(0, 4); 237 return H48_TABLESIZE(0, 4) + INFOSIZE;
207} 238}
208 239
209STATIC int64_t 240STATIC int64_t
@@ -226,6 +257,7 @@ gendata_h48h0k4_bfs_fromdone(h48h0k4_bfs_arg_t *arg)
226 cube_t cube, moved; 257 cube_t cube, moved;
227 258
228 for (i = 0, cc = 0; i < (int64_t)H48_COORDMAX(0); i++) { 259 for (i = 0, cc = 0; i < (int64_t)H48_COORDMAX(0); i++) {
260//LOG("getting esep val for %" PRId64 "\n", i);
229 c = get_esep_pval(arg->buf32, i, 4); 261 c = get_esep_pval(arg->buf32, i, 4);
230 if (c != arg->depth - 1) 262 if (c != arg->depth - 1)
231 continue; 263 continue;
@@ -300,7 +332,8 @@ gendata_h48k2(gendata_h48_arg_t *arg)
300 [11] = 10 332 [11] = 10
301 }; 333 };
302 334
303 uint8_t t; 335 uint8_t t, selectedbase;
336 uint32_t *buf32;
304 int64_t j; 337 int64_t j;
305 uint64_t nshort, i, ii; 338 uint64_t nshort, i, ii;
306 h48map_t shortcubes; 339 h48map_t shortcubes;
@@ -311,6 +344,10 @@ gendata_h48k2(gendata_h48_arg_t *arg)
311 if (arg->buf == NULL) 344 if (arg->buf == NULL)
312 goto gendata_h48k2_return_size; 345 goto gendata_h48k2_return_size;
313 346
347 buf32 = (uint32_t *)((char *)arg->h48buf + INFOSIZE);
348 if (arg->buf != NULL)
349 memset(buf32, 0xFF, H48_TABLESIZE(arg->h, arg->k));
350
314 LOG("Computing depth <=%" PRIu8 "\n", shortdepth) 351 LOG("Computing depth <=%" PRIu8 "\n", shortdepth)
315 h48map_create(&shortcubes, capacity, randomizer); 352 h48map_create(&shortcubes, capacity, randomizer);
316 shortarg = (gendata_h48short_arg_t) { 353 shortarg = (gendata_h48short_arg_t) {
@@ -323,13 +360,29 @@ gendata_h48k2(gendata_h48_arg_t *arg)
323 nshort = gen_h48short(&shortarg); 360 nshort = gen_h48short(&shortarg);
324 LOG("Cubes in <= %" PRIu8 " moves: %" PRIu64 "\n", shortdepth, nshort); 361 LOG("Cubes in <= %" PRIu8 " moves: %" PRIu64 "\n", shortdepth, nshort);
325 362
363 selectedbase = base[arg->h];
364 arg->info = (tableinfo_t) {
365 .solver = "h48 solver h = , k = 4",
366 .type = TABLETYPE_PRUNING,
367 .infosize = INFOSIZE,
368 .fullsize = H48_TABLESIZE(arg->h, 2) + INFOSIZE,
369 .hash = 0, /* TODO */
370 .entries = H48_COORDMAX(arg->h),
371 .bits = 2,
372 .base = selectedbase,
373 .next = 0,
374 };
375 arg->info.solver[15] = (arg->h % 10) + '0';
376 if (arg->h >= 10)
377 arg->info.solver[14] = (arg->h / 10) + '0';
378
326 dfsarg = (h48k2_dfs_arg_t){ 379 dfsarg = (h48k2_dfs_arg_t){
327 .h = arg->h, 380 .h = arg->h,
328 .k = arg->k, 381 .k = arg->k,
329 .base = base[arg->h], 382 .base = selectedbase,
330 .shortdepth = shortdepth, 383 .shortdepth = shortdepth,
331 .cocsepdata = arg->cocsepdata, 384 .cocsepdata = arg->cocsepdata,
332 .h48data = arg->h48data, 385 .buf32 = buf32,
333 .selfsim = arg->selfsim, 386 .selfsim = arg->selfsim,
334 .crep = arg->crep, 387 .crep = arg->crep,
335 .shortcubes = &shortcubes 388 .shortcubes = &shortcubes
@@ -348,15 +401,16 @@ gendata_h48k2(gendata_h48_arg_t *arg)
348 401
349 h48map_destroy(&shortcubes); 402 h48map_destroy(&shortcubes);
350 403
351 memset(arg->info, 0, 5 * sizeof(arg->info[0])); 404 arg->info.base = selectedbase;
352 arg->info[0] = base[arg->k];
353 for (j = 0; j < H48_COORDMAX(arg->h); j++) { 405 for (j = 0; j < H48_COORDMAX(arg->h); j++) {
354 t = get_esep_pval(arg->h48data, j, 2); 406 t = get_esep_pval(buf32, j, 2);
355 arg->info[1 + t]++; 407 arg->info.distribution[t]++;
356 } 408 }
357 409
410 writetableinfo(&arg->info, arg->h48buf);
411
358gendata_h48k2_return_size: 412gendata_h48k2_return_size:
359 return H48_TABLESIZE(arg->h, 2); 413 return H48_TABLESIZE(arg->h, 2) + INFOSIZE;
360} 414}
361 415
362STATIC void 416STATIC void
@@ -427,10 +481,9 @@ gendata_h48k2_mark(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg)
427 FOREACH_H48SIM(cube, arg->cocsepdata, arg->selfsim, 481 FOREACH_H48SIM(cube, arg->cocsepdata, arg->selfsim,
428 fullcoord = coord_h48(cube, arg->cocsepdata, 11); 482 fullcoord = coord_h48(cube, arg->cocsepdata, 11);
429 coord = fullcoord >> (int64_t)(11 - arg->h); 483 coord = fullcoord >> (int64_t)(11 - arg->h);
430 oldval = get_esep_pval(arg->h48data, coord, arg->k); 484 oldval = get_esep_pval(arg->buf32, coord, arg->k);
431 newval = (uint8_t)MAX(depth, 0); 485 newval = (uint8_t)MAX(depth, 0);
432 set_esep_pval( 486 set_esep_pval(arg->buf32, coord, arg->k, MIN(oldval, newval));
433 arg->h48data, coord, arg->k, MIN(oldval, newval));
434 ) 487 )
435} 488}
436 489
@@ -445,7 +498,7 @@ gendata_h48k2_dfs_stop(cube_t cube, uint8_t depth, h48k2_dfs_arg_t *arg)
445 /* We are in the "real coordinate" case, we can stop 498 /* We are in the "real coordinate" case, we can stop
446 if this coordinate has already been visited */ 499 if this coordinate has already been visited */
447 coord = coord_h48(cube, arg->cocsepdata, arg->h); 500 coord = coord_h48(cube, arg->cocsepdata, arg->h);
448 oldval = get_esep_pval(arg->h48data, coord, arg->k); 501 oldval = get_esep_pval(arg->buf32, coord, arg->k);
449 return oldval <= depth; 502 return oldval <= depth;
450 } else { 503 } else {
451 /* With 0 < k < 11 we do not have a "real coordinate". 504 /* With 0 < k < 11 we do not have a "real coordinate".
diff --git a/src/solvers/tables.h b/src/solvers/tables.h
index 29d0641..44363fe 100644
--- a/src/solvers/tables.h
+++ b/src/solvers/tables.h
@@ -1,18 +1,21 @@
1#define OFFSET(B, K) (((uint8_t *)B) + K) 1#define OFFSET(B, K) (((uint8_t *)B) + K)
2
2#define INFOSIZE 512 3#define INFOSIZE 512
4#define INFO_SOLVER_STRLEN 100
5#define INFO_DISTRIBUTION_LEN 21
6
3#define INFO_OFFSET_SOLVER 0 7#define INFO_OFFSET_SOLVER 0
4#define INFO_SOLVER_STRLEN 20
5#define INFO_OFFSET_TYPE INFO_SOLVER_STRLEN 8#define INFO_OFFSET_TYPE INFO_SOLVER_STRLEN
6#define INFO_OFFSET_INFOSIZE (INFO_OFFSET_TYPE + sizeof(uint64_t)) 9#define INFO_OFFSET_INFOSIZE (INFO_OFFSET_TYPE + sizeof(uint64_t))
7#define INFO_OFFSET_FULLSIZE (INFO_OFFSET_INFOSIZE + sizeof(uint64_t)) 10#define INFO_OFFSET_FULLSIZE (INFO_OFFSET_INFOSIZE + sizeof(uint64_t))
8#define INFO_OFFSET_HASH (INFO_OFFSET_FULLSIZE + sizeof(uint64_t)) 11#define INFO_OFFSET_HASH (INFO_OFFSET_FULLSIZE + sizeof(uint64_t))
9#define INFO_OFFSET_ENTRIES (INFO_OFFSET_HASH + sizeof(uint64_t)) 12#define INFO_OFFSET_ENTRIES (INFO_OFFSET_HASH + sizeof(uint64_t))
10#define INFO_OFFSET_BITS (INFO_OFFSET_ENTRIES + sizeof(uint64_t)) 13#define INFO_OFFSET_CLASSES (INFO_OFFSET_ENTRIES + sizeof(uint64_t))
14#define INFO_OFFSET_BITS (INFO_OFFSET_CLASSES + sizeof(uint64_t))
11#define INFO_OFFSET_BASE (INFO_OFFSET_BITS + sizeof(uint8_t)) 15#define INFO_OFFSET_BASE (INFO_OFFSET_BITS + sizeof(uint8_t))
12#define INFO_OFFSET_MAXVALUE (INFO_OFFSET_BASE + sizeof(uint8_t)) 16#define INFO_OFFSET_MAXVALUE (INFO_OFFSET_BASE + sizeof(uint8_t))
13#define INFO_OFFSET_NEXT (INFO_OFFSET_MAXVALUE + sizeof(uint8_t)) 17#define INFO_OFFSET_NEXT (INFO_OFFSET_MAXVALUE + sizeof(uint8_t))
14#define INFO_OFFSET_DISTRIBUTION (INFO_OFFSET_NEXT + sizeof(uint64_t)) 18#define INFO_OFFSET_DISTRIBUTION (INFO_OFFSET_NEXT + sizeof(uint64_t))
15#define INFO_DISTRIBUTION_LEN 21
16 19
17const uint64_t TABLETYPE_PRUNING = 0; 20const uint64_t TABLETYPE_PRUNING = 0;
18const uint64_t TABLETYPE_SPECIAL = 1; 21const uint64_t TABLETYPE_SPECIAL = 1;
@@ -24,6 +27,7 @@ typedef struct {
24 uint64_t fullsize; 27 uint64_t fullsize;
25 uint64_t hash; 28 uint64_t hash;
26 uint64_t entries; 29 uint64_t entries;
30 uint64_t classes; /* Used only by cocsepdata, for now */
27 uint8_t bits; 31 uint8_t bits;
28 uint8_t base; 32 uint8_t base;
29 uint8_t maxvalue; 33 uint8_t maxvalue;
@@ -38,7 +42,7 @@ STATIC bool
38readtableinfo(const void *buf, tableinfo_t *info) 42readtableinfo(const void *buf, tableinfo_t *info)
39{ 43{
40 if (buf == NULL) { 44 if (buf == NULL) {
41 LOG("Error reading table: buffer in NULL\n"); 45 LOG("Error reading table: buffer is NULL\n");
42 return false; 46 return false;
43 } 47 }
44 48
@@ -54,6 +58,7 @@ readtableinfo(const void *buf, tableinfo_t *info)
54 info->fullsize = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_FULLSIZE); 58 info->fullsize = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_FULLSIZE);
55 info->hash = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_HASH); 59 info->hash = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_HASH);
56 info->entries = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_ENTRIES); 60 info->entries = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_ENTRIES);
61 info->classes = *(const uint64_t *)OFFSET(buf, INFO_OFFSET_CLASSES);
57 info->bits = *OFFSET(buf, INFO_OFFSET_BITS); 62 info->bits = *OFFSET(buf, INFO_OFFSET_BITS);
58 info->base = *OFFSET(buf, INFO_OFFSET_BASE); 63 info->base = *OFFSET(buf, INFO_OFFSET_BASE);
59 info->maxvalue = *OFFSET(buf, INFO_OFFSET_MAXVALUE); 64 info->maxvalue = *OFFSET(buf, INFO_OFFSET_MAXVALUE);
@@ -70,7 +75,7 @@ writetableinfo(const tableinfo_t *info, void *buf)
70 int i; 75 int i;
71 76
72 if (buf == NULL) { 77 if (buf == NULL) {
73 LOG("Error reading table: buffer in NULL\n"); 78 LOG("Error writing table: buffer is NULL\n");
74 return false; 79 return false;
75 } 80 }
76 81
@@ -92,6 +97,7 @@ writetableinfo(const tableinfo_t *info, void *buf)
92 *(uint64_t *)OFFSET(buf, INFO_OFFSET_FULLSIZE) = info->fullsize; 97 *(uint64_t *)OFFSET(buf, INFO_OFFSET_FULLSIZE) = info->fullsize;
93 *(uint64_t *)OFFSET(buf, INFO_OFFSET_HASH) = info->hash; 98 *(uint64_t *)OFFSET(buf, INFO_OFFSET_HASH) = info->hash;
94 *(uint64_t *)OFFSET(buf, INFO_OFFSET_ENTRIES) = info->entries; 99 *(uint64_t *)OFFSET(buf, INFO_OFFSET_ENTRIES) = info->entries;
100 *(uint64_t *)OFFSET(buf, INFO_OFFSET_CLASSES) = info->classes;
95 *OFFSET(buf, INFO_OFFSET_BITS) = info->bits; 101 *OFFSET(buf, INFO_OFFSET_BITS) = info->bits;
96 *OFFSET(buf, INFO_OFFSET_BASE) = info->base; 102 *OFFSET(buf, INFO_OFFSET_BASE) = info->base;
97 *OFFSET(buf, INFO_OFFSET_MAXVALUE) = info->maxvalue; 103 *OFFSET(buf, INFO_OFFSET_MAXVALUE) = info->maxvalue;
diff --git a/test/090_tables_readwrite/00_table.in b/test/090_tables_readwrite/00_table.in
index f286968..579736a 100644
--- a/test/090_tables_readwrite/00_table.in
+++ b/test/090_tables_readwrite/00_table.in
@@ -5,6 +5,7 @@ Test solver
5100000000000 5100000000000
612345678912345 612345678912345
7399999999998 7399999999998
83393
82 92
90 100
1020 1120
diff --git a/test/090_tables_readwrite/00_table.out b/test/090_tables_readwrite/00_table.out
index f286968..579736a 100644
--- a/test/090_tables_readwrite/00_table.out
+++ b/test/090_tables_readwrite/00_table.out
@@ -5,6 +5,7 @@ Test solver
5100000000000 5100000000000
612345678912345 612345678912345
7399999999998 7399999999998
83393
82 92
90 100
1020 1120
diff --git a/test/090_tables_readwrite/tables_readwrite_tests.c b/test/090_tables_readwrite/tables_readwrite_tests.c
index f3162ea..32d171a 100644
--- a/test/090_tables_readwrite/tables_readwrite_tests.c
+++ b/test/090_tables_readwrite/tables_readwrite_tests.c
@@ -1,7 +1,7 @@
1#include "../test.h" 1#include "../test.h"
2 2
3#define INFOSIZE 512 3#define INFOSIZE 512
4#define INFO_SOLVER_STRLEN 20 4#define INFO_SOLVER_STRLEN 100
5#define INFO_DISTRIBUTION_LEN 21 5#define INFO_DISTRIBUTION_LEN 21
6 6
7typedef struct { 7typedef struct {
@@ -11,6 +11,7 @@ typedef struct {
11 uint64_t fullsize; 11 uint64_t fullsize;
12 uint64_t hash; 12 uint64_t hash;
13 uint64_t entries; 13 uint64_t entries;
14 uint64_t classes;
14 uint8_t bits; 15 uint8_t bits;
15 uint8_t base; 16 uint8_t base;
16 uint8_t maxvalue; 17 uint8_t maxvalue;
@@ -45,6 +46,7 @@ tableinfo_t test_readinfo(void) {
45 ret.fullsize = readn(); 46 ret.fullsize = readn();
46 ret.hash = readn(); 47 ret.hash = readn();
47 ret.entries = readn(); 48 ret.entries = readn();
49 ret.classes = readn();
48 ret.bits = (uint8_t)readn(); 50 ret.bits = (uint8_t)readn();
49 ret.base = (uint8_t)readn(); 51 ret.base = (uint8_t)readn();
50 ret.maxvalue = (uint8_t)readn(); 52 ret.maxvalue = (uint8_t)readn();
@@ -69,6 +71,7 @@ void test_writeinfo(tableinfo_t info) {
69 printf("%" PRIu64 "\n", info.fullsize); 71 printf("%" PRIu64 "\n", info.fullsize);
70 printf("%" PRIu64 "\n", info.hash); 72 printf("%" PRIu64 "\n", info.hash);
71 printf("%" PRIu64 "\n", info.entries); 73 printf("%" PRIu64 "\n", info.entries);
74 printf("%" PRIu64 "\n", info.classes);
72 printf("%" PRIu8 "\n", info.bits); 75 printf("%" PRIu8 "\n", info.bits);
73 printf("%" PRIu8 "\n", info.base); 76 printf("%" PRIu8 "\n", info.base);
74 printf("%" PRIu8 "\n", info.maxvalue); 77 printf("%" PRIu8 "\n", info.maxvalue);
diff --git a/test/100_gendata_cocsep/00_all.out b/test/100_gendata_cocsep/00_all.out
index e14b938..82eb6c2 100644
--- a/test/100_gendata_cocsep/00_all.out
+++ b/test/100_gendata_cocsep/00_all.out
@@ -1,4 +1,4 @@
11119792 11120256
2Classes: 3393 2Classes: 3393
3Max value: 9 3Max value: 9
40: 1 40: 1
diff --git a/test/100_gendata_cocsep/gendata_cocsep_tests.c b/test/100_gendata_cocsep/gendata_cocsep_tests.c
index 4a29ebb..ee26de9 100644
--- a/test/100_gendata_cocsep/gendata_cocsep_tests.c
+++ b/test/100_gendata_cocsep/gendata_cocsep_tests.c
@@ -1,20 +1,45 @@
1#include "../test.h" 1#include "../test.h"
2 2
3#define COCSEP_CLASSES 3393 3#define INFOSIZE 512
4#define INFO_SOLVER_STRLEN 100
5#define INFO_DISTRIBUTION_LEN 21
6#define COCSEP_CLASSES 3393
7
8typedef struct {
9 char solver[INFO_SOLVER_STRLEN];
10 uint64_t type;
11 uint64_t infosize;
12 uint64_t fullsize;
13 uint64_t hash;
14 uint64_t entries;
15 uint64_t classes; /* Used only by cocsepdata, for now */
16 uint8_t bits;
17 uint8_t base;
18 uint8_t maxvalue;
19 uint64_t next;
20 uint64_t distribution[INFO_DISTRIBUTION_LEN];
21} tableinfo_t;
4 22
5size_t gendata_cocsep(void *, uint64_t *, cube_t *); 23size_t gendata_cocsep(void *, uint64_t *, cube_t *);
24bool readtableinfo(const void *, tableinfo_t *);
6 25
7void run(void) { 26void run(void) {
8 uint32_t buf[300000], i; 27 char buf[2000000];
28 uint32_t i;
9 uint64_t selfsim[COCSEP_CLASSES]; 29 uint64_t selfsim[COCSEP_CLASSES];
10 cube_t rep[COCSEP_CLASSES]; 30 cube_t rep[COCSEP_CLASSES];
11 size_t result; 31 size_t result;
32 tableinfo_t info;
12 33
13 result = gendata_cocsep(buf, selfsim, rep); 34 result = gendata_cocsep(buf, selfsim, rep);
35 if (!readtableinfo(buf, &info)) {
36 printf("Error reading info from table\n");
37 return;
38 }
14 39
15 printf("%zu\n", result); 40 printf("%zu\n", result);
16 printf("Classes: %" PRIu32 "\n", buf[result/4-12]); 41 printf("Classes: %" PRIu64 "\n", info.classes);
17 printf("Max value: %" PRIu32 "\n", buf[result/4-11]); 42 printf("Max value: %" PRIu8 "\n", info.maxvalue);
18 for (i = 0; i < 10; i++) 43 for (i = 0; i < 10; i++)
19 printf("%" PRIu32 ": %" PRIu32 "\n", i, buf[result/4-10+i]); 44 printf("%" PRIu32 ": %" PRIu64 "\n", i, info.distribution[i]);
20} 45}
diff --git a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c
index b0286e5..67f70a5 100644
--- a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c
+++ b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c
@@ -3,6 +3,7 @@
3#define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) 3#define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16))
4#define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16)) 4#define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16))
5 5
6#define INFOSIZE 512
6#define COCSEP_CLASSES 3393 7#define COCSEP_CLASSES 3393
7 8
8size_t gendata_cocsep(void *, uint64_t *, cube_t *); 9size_t gendata_cocsep(void *, uint64_t *, cube_t *);
@@ -11,7 +12,8 @@ int64_t coord_cocsep(cube_t);
11 12
12void run(void) { 13void run(void) {
13 uint8_t t; 14 uint8_t t;
14 uint32_t buf[300000]; 15 char buf[2000000];
16 uint32_t *cocsepdata;
15 uint64_t selfsim[COCSEP_CLASSES]; 17 uint64_t selfsim[COCSEP_CLASSES];
16 int64_t coord, tcoord; 18 int64_t coord, tcoord;
17 char str[STRLENMAX]; 19 char str[STRLENMAX];
@@ -21,11 +23,12 @@ void run(void) {
21 cube = readcube("H48", str); 23 cube = readcube("H48", str);
22 24
23 gendata_cocsep(buf, selfsim, rep); 25 gendata_cocsep(buf, selfsim, rep);
26 cocsepdata = (uint32_t *)((char *)buf + INFOSIZE);
24 27
25 coord = (int64_t)COCLASS(buf[coord_cocsep(cube)]); 28 coord = (int64_t)COCLASS(cocsepdata[coord_cocsep(cube)]);
26 for (t = 0; t < 48; t++) { 29 for (t = 0; t < 48; t++) {
27 transd = transform(cube, t); 30 transd = transform(cube, t);
28 tcoord = (int64_t)COCLASS(buf[coord_cocsep(transd)]); 31 tcoord = (int64_t)COCLASS(cocsepdata[coord_cocsep(transd)]);
29 if (coord != tcoord) 32 if (coord != tcoord)
30 printf("Error: expected %" PRId64 33 printf("Error: expected %" PRId64
31 " but got %" PRId64 "\n", coord, tcoord); 34 " but got %" PRId64 "\n", coord, tcoord);
diff --git a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c
index 7211e2e..490952a 100644
--- a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c
+++ b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c
@@ -8,25 +8,28 @@
8#include "../test.h" 8#include "../test.h"
9 9
10#define COCSEP_CLASSES 3393 10#define COCSEP_CLASSES 3393
11#define INFOSIZE 512
11 12
12size_t gendata_cocsep(void *, uint64_t *, cube_t *); 13size_t gendata_cocsep(void *, uint64_t *, cube_t *);
13int64_t coord_cocsep(cube_t); 14int64_t coord_cocsep(cube_t);
14 15
15void run(void) { 16void run(void) {
16 char str[STRLENMAX]; 17 char str[STRLENMAX];
17 uint32_t buf[300000], data; 18 char buf[2000000];
19 uint32_t *cocsepdata, data;
18 int64_t coord, coclass; 20 int64_t coord, coclass;
19 uint64_t selfsim[COCSEP_CLASSES], sim, t; 21 uint64_t selfsim[COCSEP_CLASSES], sim, t;
20 cube_t cube, rep[COCSEP_CLASSES]; 22 cube_t cube, rep[COCSEP_CLASSES];
21 23
22 gendata_cocsep(buf, selfsim, rep); 24 gendata_cocsep(buf, selfsim, rep);
25 cocsepdata = (uint32_t *)((char *)buf + INFOSIZE);
23 26
24 /* All cases in the same test so we do not generate data many times */ 27 /* All cases in the same test so we do not generate data many times */
25 28
26 while (fgets(str, STRLENMAX, stdin) != NULL) { 29 while (fgets(str, STRLENMAX, stdin) != NULL) {
27 cube = readcube("H48", str); 30 cube = readcube("H48", str);
28 coord = coord_cocsep(cube); 31 coord = coord_cocsep(cube);
29 data = buf[coord]; 32 data = cocsepdata[coord];
30 coclass = (data & (0xFFFU << 16)) >> 16; 33 coclass = (data & (0xFFFU << 16)) >> 16;
31 sim = selfsim[coclass]; 34 sim = selfsim[coclass];
32 for (t = 0; t < 48 && sim; t++, sim >>= 1) { 35 for (t = 0; t < 48 && sim; t++, sim >>= 1) {
diff --git a/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c b/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c
index fb1338e..84e3fd8 100644
--- a/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c
+++ b/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c
@@ -17,7 +17,7 @@ int bcount(uint64_t x) {
17} 17}
18 18
19void run(void) { 19void run(void) {
20 uint32_t buf[300000]; 20 char buf[2000000];
21 int size[65], tot, j; 21 int size[65], tot, j;
22 int64_t i; 22 int64_t i;
23 uint64_t selfsim[COCSEP_CLASSES], sim; 23 uint64_t selfsim[COCSEP_CLASSES], sim;
diff --git a/test/104_cocsep_ttrep/cocsep_ttrep_tests.c b/test/104_cocsep_ttrep/cocsep_ttrep_tests.c
index f692ca8..efe5a26 100644
--- a/test/104_cocsep_ttrep/cocsep_ttrep_tests.c
+++ b/test/104_cocsep_ttrep/cocsep_ttrep_tests.c
@@ -1,9 +1,11 @@
1#include "../test.h" 1#include "../test.h"
2 2
3#define COCSEP_CLASSES 3393
4#define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8)) 3#define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8))
5#define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8)) 4#define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8))
6 5
6#define COCSEP_CLASSES 3393
7#define INFOSIZE 512
8
7uint8_t inverse_trans(uint8_t); 9uint8_t inverse_trans(uint8_t);
8cube_t transform_corners(cube_t, uint8_t); 10cube_t transform_corners(cube_t, uint8_t);
9int64_t coord_cocsep(cube_t); 11int64_t coord_cocsep(cube_t);
@@ -11,19 +13,21 @@ size_t gendata_cocsep(void *, uint64_t *, cube_t *);
11 13
12void run(void) { 14void run(void) {
13 uint8_t t; 15 uint8_t t;
14 uint32_t buf[300000], tt; 16 char buf[2000000];
17 uint32_t *cocsepdata, tt;
15 uint64_t selfsim[COCSEP_CLASSES]; 18 uint64_t selfsim[COCSEP_CLASSES];
16 int64_t i, j, k, l; 19 int64_t i, j, k, l;
17 cube_t rep[COCSEP_CLASSES], c, d; 20 cube_t rep[COCSEP_CLASSES], c, d;
18 21
19 gendata_cocsep(buf, selfsim, rep); 22 gendata_cocsep(buf, selfsim, rep);
23 cocsepdata = (uint32_t *)((char *)buf + INFOSIZE);
20 24
21 for (i = 0; i < COCSEP_CLASSES; i++) { 25 for (i = 0; i < COCSEP_CLASSES; i++) {
22 c = rep[i]; 26 c = rep[i];
23 for (t = 0; t < 48; t++) { 27 for (t = 0; t < 48; t++) {
24 d = transform_corners(c, t); 28 d = transform_corners(c, t);
25 j = coord_cocsep(d); 29 j = coord_cocsep(d);
26 tt = TTREP(buf[j]); 30 tt = TTREP(cocsepdata[j]);
27 d = transform_corners(d, tt); 31 d = transform_corners(d, tt);
28 k = coord_cocsep(d); 32 k = coord_cocsep(d);
29 l = coord_cocsep(c); 33 l = coord_cocsep(c);
diff --git a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c
index 77dea81..1fcbabd 100644
--- a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c
+++ b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c
@@ -1,6 +1,7 @@
1#include "../test.h" 1#include "../test.h"
2 2
3#define COCSEP_CLASSES 3393 3#define COCSEP_CLASSES 3393
4#define INFOSIZE 512
4 5
5size_t gendata_cocsep(void *, uint64_t *, cube_t *); 6size_t gendata_cocsep(void *, uint64_t *, cube_t *);
6int64_t coord_h48(cube_t, const uint32_t *, uint8_t); 7int64_t coord_h48(cube_t, const uint32_t *, uint8_t);
@@ -12,12 +13,14 @@ void run(void) {
12 int i; 13 int i;
13 bool found; 14 bool found;
14 uint8_t h, t; 15 uint8_t h, t;
15 uint32_t cocsepdata[300000]; 16 char buf[2000000];
17 uint32_t *cocsepdata;
16 uint64_t selfsim[COCSEP_CLASSES]; 18 uint64_t selfsim[COCSEP_CLASSES];
17 int64_t c, cc; 19 int64_t c, cc;
18 cube_t cube, invc, rep[COCSEP_CLASSES]; 20 cube_t cube, invc, rep[COCSEP_CLASSES];
19 21
20 gendata_cocsep(cocsepdata, selfsim, rep); 22 gendata_cocsep(buf, selfsim, rep);
23 cocsepdata = (uint32_t *)((char *)buf + INFOSIZE);
21 24
22 i = 1; 25 i = 1;
23 h = 11; 26 h = 11;
diff --git a/test/112_gen_h48short/gen_h48short.c b/test/112_gen_h48short/gen_h48short_tests.c
index 335821a..a706dff 100644
--- a/test/112_gen_h48short/gen_h48short.c
+++ b/test/112_gen_h48short/gen_h48short_tests.c
@@ -1,7 +1,8 @@
1#include "../test.h" 1#include "../test.h"
2 2
3#define COCSEP_CLASSES 3393 3#define COCSEP_CLASSES 3393
4#define MAXPOS 200 4#define INFOSIZE 512
5#define MAXPOS 200
5 6
6typedef struct { 7typedef struct {
7 uint64_t n; 8 uint64_t n;
@@ -51,7 +52,7 @@ uint64_t readl(void) {
51} 52}
52 53
53void run(void) { 54void run(void) {
54 uint32_t cocsepdata[300000]; 55 char buf[2000000];
55 h48map_t map; 56 h48map_t map;
56 uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES]; 57 uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES];
57 kvpair_t kv, b[MAXPOS]; 58 kvpair_t kv, b[MAXPOS];
@@ -61,13 +62,13 @@ void run(void) {
61 capacity = readl(); 62 capacity = readl();
62 randomizer = readl(); 63 randomizer = readl();
63 arg.maxdepth = readl(); 64 arg.maxdepth = readl();
64 arg.cocsepdata = cocsepdata;
65 arg.crep = crep; 65 arg.crep = crep;
66 arg.selfsim = selfsim; 66 arg.selfsim = selfsim;
67 arg.map = &map; 67 arg.map = &map;
68 68
69 h48map_create(&map, capacity, randomizer); 69 h48map_create(&map, capacity, randomizer);
70 gendata_cocsep(cocsepdata, selfsim, crep); 70 gendata_cocsep(buf, selfsim, crep);
71 arg.cocsepdata = (uint32_t *)((char *)buf + INFOSIZE);
71 gen_h48short(&arg); 72 gen_h48short(&arg);
72 73
73 i = 0; 74 i = 0;
diff --git a/test/120_gendata_h48h0k4/00_h_0.out b/test/120_gendata_h48h0k4/00_h_0.out
index 04e8bf6..7d70463 100644
--- a/test/120_gendata_h48h0k4/00_h_0.out
+++ b/test/120_gendata_h48h0k4/00_h_0.out
@@ -1,4 +1,4 @@
159903605 159904493
2 2
3cocsepdata: 3cocsepdata:
4Classes: 3393 4Classes: 3393
diff --git a/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c b/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c
index d6c6cb2..bc3488c 100644
--- a/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c
+++ b/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c
@@ -1,27 +1,47 @@
1#include "../test.h" 1#include "../test.h"
2 2
3#define COCSEP_CLASSES 3393 3#define COCSEP_CLASSES 3393
4#define COCSEPSIZE 1119792 4#define INFOSIZE 512
5#define INFO_SOLVER_STRLEN 100
6#define INFO_DISTRIBUTION_LEN 21
7
8typedef struct {
9 char solver[INFO_SOLVER_STRLEN];
10 uint64_t type;
11 uint64_t infosize;
12 uint64_t fullsize;
13 uint64_t hash;
14 uint64_t entries;
15 uint64_t classes; /* Used only by cocsepdata, for now */
16 uint8_t bits;
17 uint8_t base;
18 uint8_t maxvalue;
19 uint64_t next;
20 uint64_t distribution[INFO_DISTRIBUTION_LEN];
21} tableinfo_t;
5 22
6typedef struct { 23typedef struct {
7 uint8_t h; 24 uint8_t h;
8 uint8_t k; 25 uint8_t k;
9 uint8_t maxdepth; 26 uint8_t maxdepth;
27 tableinfo_t info;
10 void *buf; 28 void *buf;
11 uint32_t *info; 29 void *h48buf;
12 uint32_t *cocsepdata; 30 uint32_t *cocsepdata;
13 uint32_t *h48data;
14 uint64_t selfsim[COCSEP_CLASSES]; 31 uint64_t selfsim[COCSEP_CLASSES];
15 cube_t crep[COCSEP_CLASSES]; 32 cube_t crep[COCSEP_CLASSES];
16} gendata_h48_arg_t; 33} gendata_h48_arg_t;
17 34
18int64_t gendata_h48(gendata_h48_arg_t *); 35int64_t gendata_h48(gendata_h48_arg_t *);
36bool readtableinfo(const void *, tableinfo_t *);
19 37
20void run(void) { 38void run(void) {
21 char str[STRLENMAX]; 39 char str[STRLENMAX];
22 uint8_t i; 40 uint8_t i;
23 gendata_h48_arg_t arg; 41 gendata_h48_arg_t arg;
24 size_t result, sz; 42 size_t result, sz;
43 tableinfo_t cinfo, hinfo;
44 void *h48buf;
25 45
26 fgets(str, STRLENMAX, stdin); 46 fgets(str, STRLENMAX, stdin);
27 arg.maxdepth = atoi(str); 47 arg.maxdepth = atoi(str);
@@ -30,21 +50,37 @@ void run(void) {
30 arg.k = 4; 50 arg.k = 4;
31 51
32 sz = gendata_h48(&arg); /* With buf = NULL returns data size */ 52 sz = gendata_h48(&arg); /* With buf = NULL returns data size */
33 arg.buf = malloc(sz); 53 arg.buf = malloc(sz+23);
54/*
55TODO: the +23 is a workaround for a bug that I don't understand and seems
56to happen only with gcc. Hopefully this gets fixed when switching to 8-bit.
57*/
58
34 result = gendata_h48(&arg); 59 result = gendata_h48(&arg);
35 60
61 if (!readtableinfo(arg.buf, &cinfo)) {
62 printf("Error reading cocsep info\n");
63 goto end;
64 }
65
66 h48buf = (char *)arg.buf + cinfo.next;
67 if (!readtableinfo(h48buf, &hinfo)) {
68 printf("Error reading h48 info\n");
69 goto end;
70 }
71
36 printf("%zu\n\n", result); 72 printf("%zu\n\n", result);
37 73
38 printf("cocsepdata:\n"); 74 printf("cocsepdata:\n");
39 printf("Classes: %" PRIu32 "\n", arg.cocsepdata[COCSEPSIZE/4-12]); 75 printf("Classes: %" PRIu64 "\n", cinfo.classes);
40 printf("Max value: %" PRIu32 "\n", arg.cocsepdata[COCSEPSIZE/4-11]); 76 printf("Max value: %" PRIu8 "\n", cinfo.maxvalue);
41 for (i = 0; i < 10; i++) 77 for (i = 0; i <= cinfo.maxvalue; i++)
42 printf("%" PRIu32 ": %" PRIu32 "\n", 78 printf("%" PRIu32 ": %" PRIu64 "\n", i, cinfo.distribution[i]);
43 i, arg.cocsepdata[COCSEPSIZE/4-10+i]);
44 79
45 printf("\nh48:\n"); 80 printf("\nh48:\n");
46 for (i = 0; i < arg.maxdepth+1; i++) 81 for (i = 0; i <= hinfo.maxvalue; i++)
47 printf("%" PRIu32 ": %" PRIu32 "\n", i, arg.info[i+1]); 82 printf("%" PRIu32 ": %" PRIu64 "\n", i, hinfo.distribution[i]);
48 83
84end:
49 free(arg.buf); 85 free(arg.buf);
50} 86}

Generated with cgit - Back to sebastiano.tronto.net