diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-05-20 17:39:07 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-05-20 17:39:07 +0200 |
| commit | 8bacac732dcb2c0118e47e1bb81be855f4a0bf58 (patch) | |
| tree | 503960622342592d141fa0a375dee9b9aa265fe7 /src | |
| parent | 4dde2625a1bcb5381b50b22e7212070266cd224f (diff) | |
| download | nissy-core-8bacac732dcb2c0118e47e1bb81be855f4a0bf58.tar.gz nissy-core-8bacac732dcb2c0118e47e1bb81be855f4a0bf58.zip | |
Tests for gendata h48
Diffstat (limited to 'src')
| -rw-r--r-- | src/cube_avx2.h | 10 | ||||
| -rw-r--r-- | src/solve_h48.h | 43 |
2 files changed, 30 insertions, 23 deletions
diff --git a/src/cube_avx2.h b/src/cube_avx2.h index d39da94..934737c 100644 --- a/src/cube_avx2.h +++ b/src/cube_avx2.h | |||
| @@ -207,7 +207,7 @@ _static_inline int64_t | |||
| 207 | coord_fast_esep(cube_fast_t c) | 207 | coord_fast_esep(cube_fast_t c) |
| 208 | { | 208 | { |
| 209 | cube_fast_t ep; | 209 | cube_fast_t ep; |
| 210 | int64_t e, mem[4], i, j, k, l, ret1, ret2, bit1, bit2, is1; | 210 | int64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; |
| 211 | 211 | ||
| 212 | ep = _mm256_and_si256(c, _ep_avx2); | 212 | ep = _mm256_and_si256(c, _ep_avx2); |
| 213 | _mm256_storeu_si256((__m256i *)mem, ep); | 213 | _mm256_storeu_si256((__m256i *)mem, ep); |
| @@ -225,7 +225,8 @@ coord_fast_esep(cube_fast_t c) | |||
| 225 | ret1 += bit2 * binomial[11-i][k]; | 225 | ret1 += bit2 * binomial[11-i][k]; |
| 226 | k -= bit2; | 226 | k -= bit2; |
| 227 | 227 | ||
| 228 | ret2 += is1 * binomial[7-j][l]; | 228 | jj = j < 8; |
| 229 | ret2 += jj * is1 * binomial[7-(j*jj)][l]; | ||
| 229 | l -= is1; | 230 | l -= is1; |
| 230 | j += (1-bit2); | 231 | j += (1-bit2); |
| 231 | } | 232 | } |
| @@ -274,7 +275,7 @@ _static_inline cube_fast_t | |||
| 274 | invcoord_fast_esep(int64_t esep) | 275 | invcoord_fast_esep(int64_t esep) |
| 275 | { | 276 | { |
| 276 | cube_fast_t eee, ret; | 277 | cube_fast_t eee, ret; |
| 277 | int64_t i, j, k, l, s, v, w, is1, set1, set2; | 278 | int64_t i, j, jj, k, l, s, v, w, is1, set1, set2; |
| 278 | uint8_t bit2, bit1, mem[32]; | 279 | uint8_t bit2, bit1, mem[32]; |
| 279 | uint8_t slice[3] = {0}; | 280 | uint8_t slice[3] = {0}; |
| 280 | 281 | ||
| @@ -283,7 +284,8 @@ invcoord_fast_esep(int64_t esep) | |||
| 283 | 284 | ||
| 284 | for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) { | 285 | for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) { |
| 285 | v = binomial[11-i][k]; | 286 | v = binomial[11-i][k]; |
| 286 | w = binomial[7-j][l]; | 287 | jj = j < 8; |
| 288 | w = jj * binomial[7-(j*jj)][l]; | ||
| 287 | bit2 = set2 >= v; | 289 | bit2 = set2 >= v; |
| 288 | bit1 = set1 >= w; | 290 | bit1 = set1 >= w; |
| 289 | is1 = (1 - bit2) * bit1; | 291 | is1 = (1 - bit2) * bit1; |
diff --git a/src/solve_h48.h b/src/solve_h48.h index b95e6ce..be2c328 100644 --- a/src/solve_h48.h +++ b/src/solve_h48.h | |||
| @@ -1,12 +1,10 @@ | |||
| 1 | #define COCSEP_CLASSES 3393U | 1 | #define COCSEP_CLASSES 3393U |
| 2 | #define COCSEP_TABLESIZE (_3p7 << 7U) | 2 | #define COCSEP_TABLESIZE (_3p7 << 7U) |
| 3 | #define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + 7U) / 8U) | 3 | #define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + 7U) / 8U) |
| 4 | #define COCSEP_INFOSIZE 12U | 4 | #define COCSEP_FULLSIZE (4*(COCSEP_TABLESIZE + 12)) |
| 5 | #define COCSEP_FULLSIZE (4 * (COCSEP_TABLESIZE + COCSEP_INFOSIZE)) | ||
| 6 | 5 | ||
| 7 | #define ESEP_MAX(h) ((COCSEP_CLASSES * _12c4 * _8c4) << (h)) | 6 | #define ESEP_MAX(h) ((COCSEP_CLASSES * _12c4 * _8c4) << (h)) |
| 8 | #define ESEP_TABLESIZE(h, k) (ESEP_MAX((h)) >> (k)) | 7 | #define ESEP_TABLESIZE(h, k) (ESEP_MAX((h)) / (8U / (k))) |
| 9 | #define ESEP_INFOSIZE 25 /* TODO unknown yet */ | ||
| 10 | 8 | ||
| 11 | #define H48_ESIZE(h) ((_12c4 * _8c4) << (h)) | 9 | #define H48_ESIZE(h) ((_12c4 * _8c4) << (h)) |
| 12 | 10 | ||
| @@ -41,7 +39,7 @@ _static_inline cube_fast_t invcoord_h48(int64_t, const cube_fast_t *, uint8_t); | |||
| 41 | 39 | ||
| 42 | _static size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); | 40 | _static size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); |
| 43 | _static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); | 41 | _static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); |
| 44 | _static size_t gendata_h48(void *, uint8_t); | 42 | _static size_t gendata_h48(void *, uint8_t, uint8_t); |
| 45 | _static uint64_t gendata_esep_bfs(bfsarg_esep_t *); | 43 | _static uint64_t gendata_esep_bfs(bfsarg_esep_t *); |
| 46 | 44 | ||
| 47 | _static_inline bool get_visited(const uint8_t *, int64_t); | 45 | _static_inline bool get_visited(const uint8_t *, int64_t); |
| @@ -120,7 +118,6 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_fast_t *rep) | |||
| 120 | buf32 = (uint32_t *)buf; | 118 | buf32 = (uint32_t *)buf; |
| 121 | info = buf32 + COCSEP_TABLESIZE; | 119 | info = buf32 + COCSEP_TABLESIZE; |
| 122 | memset(buf32, 0xFFU, sizeof(uint32_t) * COCSEP_TABLESIZE); | 120 | memset(buf32, 0xFFU, sizeof(uint32_t) * COCSEP_TABLESIZE); |
| 123 | memset(info, 0, sizeof(uint32_t) * COCSEP_INFOSIZE); | ||
| 124 | memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES); | 121 | memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES); |
| 125 | 122 | ||
| 126 | arg = (dfsarg_cocsep_t) { | 123 | arg = (dfsarg_cocsep_t) { |
| @@ -163,7 +160,6 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg) | |||
| 163 | uint8_t m, t, tinv, olddepth; | 160 | uint8_t m, t, tinv, olddepth; |
| 164 | uint32_t cc; | 161 | uint32_t cc; |
| 165 | int64_t i, ii; | 162 | int64_t i, ii; |
| 166 | uint64_t sim; | ||
| 167 | cube_fast_t d; | 163 | cube_fast_t d; |
| 168 | dfsarg_cocsep_t nextarg; | 164 | dfsarg_cocsep_t nextarg; |
| 169 | 165 | ||
| @@ -208,10 +204,10 @@ TODO description | |||
| 208 | generating fixed table with h=0, k=4 | 204 | generating fixed table with h=0, k=4 |
| 209 | */ | 205 | */ |
| 210 | _static size_t | 206 | _static size_t |
| 211 | gendata_h48(void *buf, uint8_t h) | 207 | gendata_h48(void *buf, uint8_t h, uint8_t maxdepth) |
| 212 | { | 208 | { |
| 213 | const int k = 1; /* TODO: other cases? */ | 209 | const int k = 4; /* TODO: other cases? */ |
| 214 | uint32_t *buf32, *info, *cocsepdata; | 210 | uint32_t j, *buf32, *info, *cocsepdata; |
| 215 | bfsarg_esep_t arg; | 211 | bfsarg_esep_t arg; |
| 216 | int64_t sc, cc, tot; | 212 | int64_t sc, cc, tot; |
| 217 | uint64_t selfsim[COCSEP_CLASSES]; | 213 | uint64_t selfsim[COCSEP_CLASSES]; |
| @@ -219,17 +215,14 @@ gendata_h48(void *buf, uint8_t h) | |||
| 219 | size_t cocsepsize; | 215 | size_t cocsepsize; |
| 220 | 216 | ||
| 221 | cocsepsize = gendata_cocsep(buf, selfsim, crep); | 217 | cocsepsize = gendata_cocsep(buf, selfsim, crep); |
| 222 | DBG_ASSERT(cocsepsize == COCSEP_FULLSIZE, 0, | ||
| 223 | "gendata_h48: error computing cocsep data\n"); | ||
| 224 | |||
| 225 | cocsepdata = (uint32_t *)buf; | 218 | cocsepdata = (uint32_t *)buf; |
| 226 | buf32 = cocsepdata + cocsepsize; | 219 | buf32 = cocsepdata + cocsepsize/4; |
| 227 | info = buf32 + ESEP_TABLESIZE(h, k); | 220 | info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t)); |
| 228 | memset(buf32, 0xFFU, sizeof(uint32_t) * ESEP_TABLESIZE(h, k)); | 221 | memset(buf32, 0xFFU, ESEP_TABLESIZE(h, k)); |
| 229 | memset(info, 0, sizeof(uint32_t) * ESEP_INFOSIZE); | ||
| 230 | 222 | ||
| 231 | sc = coord_h48(cubetofast(solved), cocsepdata, h); | 223 | sc = coord_h48(cubetofast(solved), cocsepdata, h); |
| 232 | set_esep_pval(buf32, sc, 0); | 224 | set_esep_pval(buf32, sc, 0); |
| 225 | info[1] = 1; | ||
| 233 | arg = (bfsarg_esep_t) { | 226 | arg = (bfsarg_esep_t) { |
| 234 | .h = h, | 227 | .h = h, |
| 235 | .cocsepdata = cocsepdata, | 228 | .cocsepdata = cocsepdata, |
| @@ -237,7 +230,11 @@ gendata_h48(void *buf, uint8_t h) | |||
| 237 | .crep = crep, | 230 | .crep = crep, |
| 238 | .selfsim = selfsim | 231 | .selfsim = selfsim |
| 239 | }; | 232 | }; |
| 240 | for (tot = 1, arg.depth = 1, cc = 0; tot < ESEP_MAX(h); arg.depth++) { | 233 | for ( |
| 234 | tot = 1, arg.depth = 1, cc = 0; | ||
| 235 | tot < ESEP_MAX(h) && arg.depth <= maxdepth; | ||
| 236 | arg.depth++ | ||
| 237 | ) { | ||
| 241 | DBG_LOG("esep: generating depth %" PRIu8 "\n", arg.depth); | 238 | DBG_LOG("esep: generating depth %" PRIu8 "\n", arg.depth); |
| 242 | cc = gendata_esep_bfs(&arg); | 239 | cc = gendata_esep_bfs(&arg); |
| 243 | tot += cc; | 240 | tot += cc; |
| @@ -245,7 +242,15 @@ gendata_h48(void *buf, uint8_t h) | |||
| 245 | DBG_LOG("found %" PRIu64 "\n", cc); | 242 | DBG_LOG("found %" PRIu64 "\n", cc); |
| 246 | } | 243 | } |
| 247 | 244 | ||
| 248 | return COCSEP_FULLSIZE + cc; | 245 | info[0] = arg.depth-1; |
| 246 | |||
| 247 | DBG_LOG("h48 pruning table computed\n"); | ||
| 248 | DBG_LOG("Maximum pruning value: %" PRIu32 "\n", info[0]); | ||
| 249 | DBG_LOG("Pruning value distribution:\n"); | ||
| 250 | for (j = 0; j <= info[0]; j++) | ||
| 251 | DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+1]); | ||
| 252 | |||
| 253 | return COCSEP_FULLSIZE + ESEP_TABLESIZE(h, k) + 4*(info[0]+2); | ||
| 249 | } | 254 | } |
| 250 | 255 | ||
| 251 | _static uint64_t | 256 | _static uint64_t |
