diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 21 | ||||
| -rw-r--r-- | src/solvers/h48/map.h | 5 | ||||
| -rw-r--r-- | src/utils/math.h | 1 |
3 files changed, 19 insertions, 8 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index c421c27..fbb8b35 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * _12c4 * _8c4)) | 1 | #define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * _12c4 * _8c4)) |
| 2 | #define H48_COORDMAX(h) ((int64_t)(H48_COORDMAX_NOEO << (int64_t)(h))) | 2 | #define H48_COORDMAX(h) ((int64_t)(H48_COORDMAX_NOEO << (int64_t)(h))) |
| 3 | #define H48_TABLESIZE(h, k) ((size_t)H48_COORDMAX((h)) / ((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 | 5 | ||
| 5 | #define H48_COEFF(k) (UINT32_C(32) / (uint32_t)(k)) | 6 | #define H48_COEFF(k) (UINT32_C(32) / (uint32_t)(k)) |
| 6 | #define H48_INDEX(i, k) ((uint32_t)(i) / H48_COEFF(k)) | 7 | #define H48_INDEX(i, k) ((uint32_t)(i) / H48_COEFF(k)) |
| @@ -140,7 +141,7 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 140 | cocsepsize = gendata_cocsep( | 141 | cocsepsize = gendata_cocsep( |
| 141 | (void *)arg->cocsepdata, arg->selfsim, arg->crep); | 142 | (void *)arg->cocsepdata, arg->selfsim, arg->crep); |
| 142 | arg->h48data = arg->cocsepdata + (cocsepsize / sizeof(uint32_t)); | 143 | arg->h48data = arg->cocsepdata + (cocsepsize / sizeof(uint32_t)); |
| 143 | arg->info = arg->h48data + | 144 | arg->info = arg->h48data + 1 + |
| 144 | (H48_TABLESIZE(arg->h, arg->k) / sizeof(uint32_t)); | 145 | (H48_TABLESIZE(arg->h, arg->k) / sizeof(uint32_t)); |
| 145 | 146 | ||
| 146 | if (arg->buf != NULL) | 147 | if (arg->buf != NULL) |
| @@ -341,18 +342,27 @@ gendata_h48k2(gendata_h48_arg_t *arg) | |||
| 341 | }; | 342 | }; |
| 342 | 343 | ||
| 343 | i = 0; | 344 | i = 0; |
| 345 | int jj = 0; | ||
| 344 | for (kv = h48map_nextkvpair(&shortcubes, &i); | 346 | for (kv = h48map_nextkvpair(&shortcubes, &i); |
| 345 | i != shortcubes.capacity; | 347 | i != shortcubes.capacity; |
| 346 | kv = h48map_nextkvpair(&shortcubes, &i) | 348 | kv = h48map_nextkvpair(&shortcubes, &i) |
| 347 | ) { | 349 | ) { |
| 348 | /* TODO maybe over all sim? */ | ||
| 349 | dfsarg.cube = invcoord_h48(kv.key, arg->crep, 11); | 350 | dfsarg.cube = invcoord_h48(kv.key, arg->crep, 11); |
| 351 | |||
| 352 | #if 1 | ||
| 350 | gendata_h48k2_dfs(&dfsarg); | 353 | gendata_h48k2_dfs(&dfsarg); |
| 354 | #else | ||
| 355 | /* It looks like this is not necessary, we get the same result */ | ||
| 356 | _foreach_h48sim( | ||
| 357 | dfsarg.cube, arg->cocsepdata, arg->selfsim, arg->h, | ||
| 358 | gendata_h48k2_dfs(&dfsarg); | ||
| 359 | ) | ||
| 360 | #endif | ||
| 361 | if ((++jj) % 1000 == 0) LOG("Done %d distance 8 cubes\n", jj); | ||
| 351 | } | 362 | } |
| 352 | 363 | ||
| 353 | h48map_destroy(&shortcubes); | 364 | h48map_destroy(&shortcubes); |
| 354 | 365 | ||
| 355 | /* TODO: move info update to dfs? */ | ||
| 356 | memset(arg->info, 0, 5 * sizeof(arg->info[0])); | 366 | memset(arg->info, 0, 5 * sizeof(arg->info[0])); |
| 357 | arg->info[0] = base[arg->k]; | 367 | arg->info[0] = base[arg->k]; |
| 358 | for (j = 0; j < H48_COORDMAX(arg->h); j++) { | 368 | for (j = 0; j < H48_COORDMAX(arg->h); j++) { |
| @@ -384,8 +394,7 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) | |||
| 384 | set_esep_pval(arg->h48data, coord, arg->k, newval); | 394 | set_esep_pval(arg->h48data, coord, arg->k, newval); |
| 385 | } | 395 | } |
| 386 | 396 | ||
| 387 | if ((val < arg->shortdepth) || | 397 | if ((arg->depth > arg->shortdepth && val != MAP_UNSET_VAL) || |
| 388 | (arg->depth > arg->shortdepth && val != MAP_UNSET) || | ||
| 389 | (arg->depth >= arg->maxdepth || arg->depth >= arg->base + 2)) | 398 | (arg->depth >= arg->maxdepth || arg->depth >= arg->base + 2)) |
| 390 | return; | 399 | return; |
| 391 | 400 | ||
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h index 82e5a2c..0e9f926 100644 --- a/src/solvers/h48/map.h +++ b/src/solvers/h48/map.h | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #define MAP_UNSET UINT64_C(0xFFFFFFFFFFFFFFFF) | 1 | #define MAP_UNSET UINT64_C(0xFFFFFFFFFFFFFFFF) |
| 2 | #define MAP_KEYMASK UINT64_C(0xFFFFFFFFFF) | 2 | #define MAP_KEYMASK UINT64_C(0xFFFFFFFFFF) |
| 3 | #define MAP_KEYSHIFT UINT64_C(40) | 3 | #define MAP_KEYSHIFT UINT64_C(40) |
| 4 | #define MAP_UNSET_VAL (MAP_UNSET >> MAP_KEYSHIFT) | ||
| 4 | 5 | ||
| 5 | typedef struct { | 6 | typedef struct { |
| 6 | uint64_t n; | 7 | uint64_t n; |
| @@ -84,8 +85,8 @@ h48map_nextkvpair(h48map_t *map, uint64_t *p) | |||
| 84 | kvpair_t kv; | 85 | kvpair_t kv; |
| 85 | uint64_t pair; | 86 | uint64_t pair; |
| 86 | 87 | ||
| 87 | kv.key = MAP_UNSET; | 88 | kv.key = MAP_KEYMASK; |
| 88 | kv.val = MAP_UNSET; | 89 | kv.val = MAP_UNSET_VAL; |
| 89 | 90 | ||
| 90 | DBG_ASSERT(*p < map->capacity, kv, | 91 | DBG_ASSERT(*p < map->capacity, kv, |
| 91 | "Error looping over map: given index %" PRIu64 " is out of " | 92 | "Error looping over map: given index %" PRIu64 " is out of " |
diff --git a/src/utils/math.h b/src/utils/math.h index 87402e6..a361808 100644 --- a/src/utils/math.h +++ b/src/utils/math.h | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #define _swap(x, y) do { x ^= y; y ^= x; x ^= y; } while (0) | 1 | #define _swap(x, y) do { x ^= y; y ^= x; x ^= y; } while (0) |
| 2 | #define _min(x, y) ((x) < (y) ? (x) : (y)) | 2 | #define _min(x, y) ((x) < (y) ? (x) : (y)) |
| 3 | #define _max(x, y) ((x) > (y) ? (x) : (y)) | 3 | #define _max(x, y) ((x) > (y) ? (x) : (y)) |
| 4 | #define _div_round_up(n, d) (((n) + (d) - 1) / (d)) | ||
| 4 | 5 | ||
| 5 | _static int64_t factorial(int64_t); | 6 | _static int64_t factorial(int64_t); |
| 6 | _static bool isperm(uint8_t *, int64_t); | 7 | _static bool isperm(uint8_t *, int64_t); |
