diff options
Diffstat (limited to 'src/solvers/h48/solve.h')
| -rw-r--r-- | src/solvers/h48/solve.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 67c596b..d506596 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -17,8 +17,8 @@ typedef struct { | |||
| 17 | uint8_t nissbranch; | 17 | uint8_t nissbranch; |
| 18 | int8_t npremoves; | 18 | int8_t npremoves; |
| 19 | uint8_t premoves[MAXLEN]; | 19 | uint8_t premoves[MAXLEN]; |
| 20 | _Atomic long long *nodes_visited; | 20 | long long nodes_visited; |
| 21 | _Atomic long long *table_fallbacks; | 21 | long long table_fallbacks; |
| 22 | } dfsarg_solveh48_t; | 22 | } dfsarg_solveh48_t; |
| 23 | 23 | ||
| 24 | STATIC uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint8_t); | 24 | STATIC uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint8_t); |
| @@ -105,7 +105,7 @@ solve_h48_stop(dfsarg_solveh48_t *arg) | |||
| 105 | int8_t cbound, cbound_inv, h48bound, h48bound_inv; | 105 | int8_t cbound, cbound_inv, h48bound, h48bound_inv; |
| 106 | int64_t coord, coord_inv; | 106 | int64_t coord, coord_inv; |
| 107 | 107 | ||
| 108 | (*arg->nodes_visited)++; | 108 | arg->nodes_visited++; |
| 109 | 109 | ||
| 110 | arg->nissbranch = MM_NORMAL; | 110 | arg->nissbranch = MM_NORMAL; |
| 111 | cbound = get_h48_cdata(arg->cube, arg->cocsepdata, &data); | 111 | cbound = get_h48_cdata(arg->cube, arg->cocsepdata, &data); |
| @@ -124,7 +124,7 @@ solve_h48_stop(dfsarg_solveh48_t *arg) | |||
| 124 | 124 | ||
| 125 | if (arg->k == 2) { | 125 | if (arg->k == 2) { |
| 126 | if (h48bound == 0) { | 126 | if (h48bound == 0) { |
| 127 | (*arg->table_fallbacks)++; | 127 | arg->table_fallbacks++; |
| 128 | h48bound = get_h48_pval( | 128 | h48bound = get_h48_pval( |
| 129 | arg->h48data_fallback, coord >> arg->h, 4); | 129 | arg->h48data_fallback, coord >> arg->h, 4); |
| 130 | } else { | 130 | } else { |
| @@ -141,7 +141,7 @@ solve_h48_stop(dfsarg_solveh48_t *arg) | |||
| 141 | h48bound_inv = get_h48_pval(arg->h48data, coord_inv, arg->k); | 141 | h48bound_inv = get_h48_pval(arg->h48data, coord_inv, arg->k); |
| 142 | if (arg->k == 2) { | 142 | if (arg->k == 2) { |
| 143 | if (h48bound_inv == 0) { | 143 | if (h48bound_inv == 0) { |
| 144 | (*arg->table_fallbacks)++; | 144 | arg->table_fallbacks++; |
| 145 | h48bound_inv = get_h48_pval( | 145 | h48bound_inv = get_h48_pval( |
| 146 | arg->h48data_fallback, coord_inv >> arg->h, 4); | 146 | arg->h48data_fallback, coord_inv >> arg->h, 4); |
| 147 | } else { | 147 | } else { |
| @@ -203,6 +203,8 @@ solve_h48_dfs(dfsarg_solveh48_t *arg) | |||
| 203 | } | 203 | } |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | arg->nodes_visited = nextarg.nodes_visited; | ||
| 207 | arg->table_fallbacks = nextarg.table_fallbacks; | ||
| 206 | return ret; | 208 | return ret; |
| 207 | } | 209 | } |
| 208 | 210 | ||
| @@ -220,14 +222,12 @@ solve_h48( | |||
| 220 | ) | 222 | ) |
| 221 | { | 223 | { |
| 222 | _Atomic int64_t nsols; | 224 | _Atomic int64_t nsols; |
| 223 | _Atomic long long nodes, fallbacks; | ||
| 224 | dfsarg_solveh48_t arg; | 225 | dfsarg_solveh48_t arg; |
| 225 | tableinfo_t info, fbinfo; | 226 | tableinfo_t info, fbinfo; |
| 226 | 227 | ||
| 227 | if(readtableinfo_n(data_size, data, 2, &info) != NISSY_OK) | 228 | if(readtableinfo_n(data_size, data, 2, &info) != NISSY_OK) |
| 228 | goto solve_h48_error_data; | 229 | goto solve_h48_error_data; |
| 229 | 230 | ||
| 230 | nodes = fallbacks = 0; | ||
| 231 | arg = (dfsarg_solveh48_t) { | 231 | arg = (dfsarg_solveh48_t) { |
| 232 | .cube = cube, | 232 | .cube = cube, |
| 233 | .inverse = inverse(cube), | 233 | .inverse = inverse(cube), |
| @@ -240,8 +240,8 @@ solve_h48( | |||
| 240 | .h48data = (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE, | 240 | .h48data = (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE, |
| 241 | .solutions_size = solutions_size, | 241 | .solutions_size = solutions_size, |
| 242 | .nextsol = &solutions, | 242 | .nextsol = &solutions, |
| 243 | .nodes_visited = &nodes, | 243 | .nodes_visited = 0, |
| 244 | .table_fallbacks = &fallbacks | 244 | .table_fallbacks = 0 |
| 245 | }; | 245 | }; |
| 246 | 246 | ||
| 247 | if (info.bits == 2) { | 247 | if (info.bits == 2) { |
| @@ -268,9 +268,10 @@ solve_h48( | |||
| 268 | } | 268 | } |
| 269 | **arg.nextsol = '\0'; | 269 | **arg.nextsol = '\0'; |
| 270 | 270 | ||
| 271 | stats[0] = nodes; | 271 | stats[0] = arg.nodes_visited; |
| 272 | stats[1] = fallbacks; | 272 | stats[1] = arg.table_fallbacks; |
| 273 | LOG("Nodes visited: %lld\nTable fallbacks: %lld\n", nodes, fallbacks); | 273 | LOG("Nodes visited: %lld\nTable fallbacks: %lld\n", |
| 274 | arg.nodes_visited, arg.table_fallbacks); | ||
| 274 | 275 | ||
| 275 | return nsols; | 276 | return nsols; |
| 276 | 277 | ||
