diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-10 19:43:05 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-10 19:43:05 +0200 |
| commit | 70d3a3de3a2fdef7e47b2bd510261d69390a3a9c (patch) | |
| tree | 2c545953d0b61b37c4f281cd47981e9350b5c09b /src | |
| parent | 1f4900a3cc6ca74f94b73e224d14a09d52c4549c (diff) | |
| download | nissy-core-70d3a3de3a2fdef7e47b2bd510261d69390a3a9c.tar.gz nissy-core-70d3a3de3a2fdef7e47b2bd510261d69390a3a9c.zip | |
New tableinfo for gendata_h48, still work to do
Diffstat (limited to 'src')
| -rw-r--r-- | src/solvers/h48/gendata_cocsep.h | 36 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 131 | ||||
| -rw-r--r-- | src/solvers/tables.h | 16 |
3 files changed, 127 insertions, 56 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: | |||
| 42 | STATIC size_t | 42 | STATIC size_t |
| 43 | gendata_cocsep(void *buf, uint64_t *selfsim, cube_t *rep) | 43 | gendata_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 | ||
| 90 | gendata_cocsep_return_size: | 102 | gendata_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) | |||
| 130 | STATIC size_t | 130 | STATIC size_t |
| 131 | gendata_h48(gendata_h48_arg_t *arg) | 131 | gendata_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 | |||
| 167 | gendata_h48_return_size: | ||
| 168 | return cocsepsize + h48size; | ||
| 169 | |||
| 170 | gendata_h48_error: | ||
| 171 | return 0; | ||
| 159 | } | 172 | } |
| 160 | 173 | ||
| 161 | /* | 174 | /* |
| @@ -165,20 +178,36 @@ generating fixed table with h=0, k=4 | |||
| 165 | STATIC size_t | 178 | STATIC size_t |
| 166 | gendata_h48h0k4(gendata_h48_arg_t *arg) | 179 | gendata_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 | ||
| 205 | gendata_h48h0k4_return_size: | 236 | gendata_h48h0k4_return_size: |
| 206 | return H48_TABLESIZE(0, 4); | 237 | return H48_TABLESIZE(0, 4) + INFOSIZE; |
| 207 | } | 238 | } |
| 208 | 239 | ||
| 209 | STATIC int64_t | 240 | STATIC 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 | |||
| 358 | gendata_h48k2_return_size: | 412 | gendata_h48k2_return_size: |
| 359 | return H48_TABLESIZE(arg->h, 2); | 413 | return H48_TABLESIZE(arg->h, 2) + INFOSIZE; |
| 360 | } | 414 | } |
| 361 | 415 | ||
| 362 | STATIC void | 416 | STATIC 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 | ||
| 17 | const uint64_t TABLETYPE_PRUNING = 0; | 20 | const uint64_t TABLETYPE_PRUNING = 0; |
| 18 | const uint64_t TABLETYPE_SPECIAL = 1; | 21 | const 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 | |||
| 38 | readtableinfo(const void *buf, tableinfo_t *info) | 42 | readtableinfo(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; |
