diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-19 12:28:52 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-19 12:28:52 +0200 |
| commit | 3485be851f4fff1c9c6fe621f0619d2b4103bc06 (patch) | |
| tree | 894197f164a7ef66801ae3a701fb10a3c1e3f5e3 /src/solvers | |
| parent | 691da8f06614418ed847bdeefa4e708c372a3ecf (diff) | |
| download | nissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.tar.gz nissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.zip | |
Improved logging, especially for solve
Diffstat (limited to 'src/solvers')
| -rw-r--r-- | src/solvers/coord/gendata.h | 9 | ||||
| -rw-r--r-- | src/solvers/coord/solve.h | 30 | ||||
| -rw-r--r-- | src/solvers/coord/utils.h | 2 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_cocsep.h | 2 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 50 | ||||
| -rw-r--r-- | src/solvers/h48/solve.h | 21 | ||||
| -rw-r--r-- | src/solvers/solutions.h | 18 |
7 files changed, 73 insertions, 59 deletions
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h index 6abb5eb..ae7b39e 100644 --- a/src/solvers/coord/gendata.h +++ b/src/solvers/coord/gendata.h | |||
| @@ -22,7 +22,7 @@ gendata_coord_dispatch(const char *coordstr, void *buf) | |||
| 22 | parse_coord_and_axis(strlen(coordstr), coordstr, &coord, NULL); | 22 | parse_coord_and_axis(strlen(coordstr), coordstr, &coord, NULL); |
| 23 | 23 | ||
| 24 | if (coord == NULL) { | 24 | if (coord == NULL) { |
| 25 | LOG("Could not parse coordinate '%s'\n", coordstr); | 25 | LOG("Error: could not parse coordinate '%s'\n", coordstr); |
| 26 | return NISSY_ERROR_INVALID_SOLVER; | 26 | return NISSY_ERROR_INVALID_SOLVER; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| @@ -82,7 +82,7 @@ gendata_coord_return_size: | |||
| 82 | return ninfo * INFOSIZE + coord_dsize + tablesize; | 82 | return ninfo * INFOSIZE + coord_dsize + tablesize; |
| 83 | 83 | ||
| 84 | gendata_coord_error: | 84 | gendata_coord_error: |
| 85 | LOG("An unexpected error occurred when generating the data.\n"); | 85 | LOG("Unexpected error generating coordinate data\n"); |
| 86 | return 0; | 86 | return 0; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| @@ -136,8 +136,9 @@ genptable_coord( | |||
| 136 | } | 136 | } |
| 137 | tot += t; | 137 | tot += t; |
| 138 | info.distribution[d] = t; | 138 | info.distribution[d] = t; |
| 139 | LOG("Depth %" PRIu64 ": found %" PRIu64 " (%" PRIu64 " of %" | 139 | LOG("[%s gendata] Depth %" PRIu64 ": found %" PRIu64 " (%" |
| 140 | PRIu64 ")\n", d, t, tot, coord->max); | 140 | PRIu64 " of %" PRIu64 ")\n", |
| 141 | coord->name, d, t, tot, coord->max); | ||
| 141 | } | 142 | } |
| 142 | info.maxvalue = d-1; | 143 | info.maxvalue = d-1; |
| 143 | 144 | ||
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index b289e3f..072aa27 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h | |||
| @@ -121,7 +121,8 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) | |||
| 121 | if (!coord_solution_admissible(arg)) | 121 | if (!coord_solution_admissible(arg)) |
| 122 | return 0; | 122 | return 0; |
| 123 | return appendsolution(arg->solution_moves, | 123 | return appendsolution(arg->solution_moves, |
| 124 | arg->solution_settings, arg->solution_list, true); | 124 | arg->solution_settings, arg->solution_list, true, |
| 125 | arg->coord->name); | ||
| 125 | } | 126 | } |
| 126 | 127 | ||
| 127 | if (solve_coord_dfs_stop(arg)) | 128 | if (solve_coord_dfs_stop(arg)) |
| @@ -220,12 +221,13 @@ solve_coord_dispatch( | |||
| 220 | strlen(coord_and_axis), coord_and_axis, &coord, &axis); | 221 | strlen(coord_and_axis), coord_and_axis, &coord, &axis); |
| 221 | 222 | ||
| 222 | if (coord == NULL) { | 223 | if (coord == NULL) { |
| 223 | LOG("Could not parse coordinate from '%s'\n", coord_and_axis); | 224 | LOG("Error: could not parse coordinate from '%s'\n", |
| 225 | coord_and_axis); | ||
| 224 | return NISSY_ERROR_INVALID_SOLVER; | 226 | return NISSY_ERROR_INVALID_SOLVER; |
| 225 | } | 227 | } |
| 226 | 228 | ||
| 227 | if (axis == UINT8_ERROR) { | 229 | if (axis == UINT8_ERROR) { |
| 228 | LOG("Could not parse axis from '%s'\n", coord_and_axis); | 230 | LOG("Error: could not parse axis from '%s'\n", coord_and_axis); |
| 229 | return NISSY_ERROR_INVALID_SOLVER; | 231 | return NISSY_ERROR_INVALID_SOLVER; |
| 230 | } | 232 | } |
| 231 | 233 | ||
| @@ -316,8 +318,8 @@ solve_coord( | |||
| 316 | }; | 318 | }; |
| 317 | 319 | ||
| 318 | if (coord->coord(c, coord_data) == 0) { | 320 | if (coord->coord(c, coord_data) == 0) { |
| 319 | if (minmoves == 0 && !appendsolution( | 321 | if (minmoves == 0 && !appendsolution(&solution_moves, |
| 320 | &solution_moves, &solution_settings, &solution_list, true)) | 322 | &solution_settings, &solution_list, true, coord->name)) |
| 321 | goto solve_coord_error_buffer; | 323 | goto solve_coord_error_buffer; |
| 322 | goto solve_coord_done; | 324 | goto solve_coord_done; |
| 323 | } | 325 | } |
| @@ -327,18 +329,17 @@ solve_coord( | |||
| 327 | !solutions_done(&solution_list, &solution_settings, d); | 329 | !solutions_done(&solution_list, &solution_settings, d); |
| 328 | d++ | 330 | d++ |
| 329 | ) { | 331 | ) { |
| 330 | if (d >= 10) | 332 | if (d >= 12) |
| 331 | LOG("Found %" PRIu64 " solutions, searching at depth %" | 333 | LOG("[%s solve] Found %" PRIu64 " solutions, " |
| 332 | PRId8 "\n", solution_list.nsols, d); | 334 | "searching at depth %" PRId8 "\n", |
| 335 | coord->name, solution_list.nsols, d); | ||
| 333 | 336 | ||
| 334 | arg.target_depth = d; | 337 | arg.target_depth = d; |
| 335 | solution_moves_reset(arg.solution_moves); | 338 | solution_moves_reset(arg.solution_moves); |
| 336 | ndepth = solve_coord_dfs(&arg); | 339 | ndepth = solve_coord_dfs(&arg); |
| 337 | 340 | ||
| 338 | if (ndepth < 0) { | 341 | if (ndepth < 0) |
| 339 | LOG("Error %" PRId64 "\n", ndepth); | ||
| 340 | return ndepth; | 342 | return ndepth; |
| 341 | } | ||
| 342 | 343 | ||
| 343 | solution_list.nsols += (uint64_t)ndepth; | 344 | solution_list.nsols += (uint64_t)ndepth; |
| 344 | } | 345 | } |
| @@ -347,14 +348,15 @@ solve_coord_done: | |||
| 347 | return (int64_t)solution_list.nsols; | 348 | return (int64_t)solution_list.nsols; |
| 348 | 349 | ||
| 349 | solve_coord_error_data: | 350 | solve_coord_error_data: |
| 350 | LOG("solve_coord: error reading table\n"); | 351 | LOG("[%s solve] Error reading table\n", coord->name); |
| 351 | return NISSY_ERROR_DATA; | 352 | return NISSY_ERROR_DATA; |
| 352 | 353 | ||
| 353 | solve_coord_error_buffer: | 354 | solve_coord_error_buffer: |
| 354 | LOG("Could not append solution to buffer: size too small\n"); | 355 | LOG("[%s solve] Error appending solution to buffer: size too small\n", |
| 356 | coord->name); | ||
| 355 | return NISSY_ERROR_BUFFER_SIZE; | 357 | return NISSY_ERROR_BUFFER_SIZE; |
| 356 | 358 | ||
| 357 | solve_coord_error_unsolvable: | 359 | solve_coord_error_unsolvable: |
| 358 | LOG("Cube not ready for solving %s\n", coord->name); | 360 | LOG("[%s solve] Error: cube not ready\n", coord->name); |
| 359 | return NISSY_ERROR_UNSOLVABLE_CUBE; | 361 | return NISSY_ERROR_UNSOLVABLE_CUBE; |
| 360 | } | 362 | } |
diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h index 5407de3..ef3f817 100644 --- a/src/solvers/coord/utils.h +++ b/src/solvers/coord/utils.h | |||
| @@ -59,7 +59,7 @@ dataid_coord(const char *ca, char dataid[static NISSY_SIZE_DATAID]) | |||
| 59 | parse_coord_and_axis(strlen(ca), ca, &c, NULL); | 59 | parse_coord_and_axis(strlen(ca), ca, &c, NULL); |
| 60 | 60 | ||
| 61 | if (c == NULL) { | 61 | if (c == NULL) { |
| 62 | LOG("dataid_coord: cannot parse coordinate from '%s'\n", ca); | 62 | LOG("Error: cannot parse coordinate from '%s'\n", ca); |
| 63 | return NISSY_ERROR_INVALID_SOLVER; | 63 | return NISSY_ERROR_INVALID_SOLVER; |
| 64 | } | 64 | } |
| 65 | 65 | ||
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index cda1608..f07b71a 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h | |||
| @@ -67,7 +67,7 @@ gendata_cocsep( | |||
| 67 | "cocsep: computed %" PRIu16 " symmetry classes, " | 67 | "cocsep: computed %" PRIu16 " symmetry classes, " |
| 68 | "expected %zu\n", n, COCSEP_CLASSES); | 68 | "expected %zu\n", n, COCSEP_CLASSES); |
| 69 | 69 | ||
| 70 | LOG("cocsep data computed\n"); | 70 | LOG("[H48 gendata] cocsep data computed\n"); |
| 71 | 71 | ||
| 72 | /* The following output is just noise | 72 | /* The following output is just noise |
| 73 | 73 | ||
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 4478e9e..18157dc 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -87,7 +87,7 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) | |||
| 87 | return size; /* Dry-run */ | 87 | return size; /* Dry-run */ |
| 88 | 88 | ||
| 89 | if (arg->buf_size < size) { | 89 | if (arg->buf_size < size) { |
| 90 | LOG("Error computing H48 data: buffer is too small " | 90 | LOG("[H48 gendata] Error data: buffer is too small " |
| 91 | "(needed %" PRId64 " bytes but received %" PRId64 ")\n", | 91 | "(needed %" PRId64 " bytes but received %" PRId64 ")\n", |
| 92 | size, arg->buf_size); | 92 | size, arg->buf_size); |
| 93 | return NISSY_ERROR_BUFFER_SIZE; | 93 | return NISSY_ERROR_BUFFER_SIZE; |
| @@ -106,22 +106,24 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) | |||
| 106 | } else if (arg->k == 2) { | 106 | } else if (arg->k == 2) { |
| 107 | gendata_h48k2(arg); | 107 | gendata_h48k2(arg); |
| 108 | } else { | 108 | } else { |
| 109 | LOG("Cannot generate data for h = %" PRIu8 " and k = %" PRIu8 | 109 | LOG("[H48 gendata] Error: cannot generate data for h = %" PRIu8 |
| 110 | " (not implemented yet)\n", arg->h, arg->k); | 110 | " and k = %" PRIu8 " (not implemented yet)\n", |
| 111 | arg->h, arg->k); | ||
| 111 | return NISSY_ERROR_INVALID_SOLVER; | 112 | return NISSY_ERROR_INVALID_SOLVER; |
| 112 | } | 113 | } |
| 113 | 114 | ||
| 114 | r = readtableinfo(arg->buf_size, arg->buf, &cocsepinfo); | 115 | r = readtableinfo(arg->buf_size, arg->buf, &cocsepinfo); |
| 115 | if (r != NISSY_OK) { | 116 | if (r != NISSY_OK) { |
| 116 | LOG("gendata_h48: could not read info for cocsep table\n"); | 117 | LOG("[H48 gendata] Error: could not read info " |
| 118 | "for cocsep table\n"); | ||
| 117 | return NISSY_ERROR_UNKNOWN; | 119 | return NISSY_ERROR_UNKNOWN; |
| 118 | } | 120 | } |
| 119 | 121 | ||
| 120 | cocsepinfo.next = cocsepsize; | 122 | cocsepinfo.next = cocsepsize; |
| 121 | r = writetableinfo(&cocsepinfo, arg->buf_size, arg->buf); | 123 | r = writetableinfo(&cocsepinfo, arg->buf_size, arg->buf); |
| 122 | if (r != NISSY_OK) { | 124 | if (r != NISSY_OK) { |
| 123 | LOG("gendata_h48: could not write info for cocsep table" | 125 | LOG("[H48 gendata] Error: could not write info for " |
| 124 | " with updated 'next' value\n"); | 126 | "cocsep table with updated 'next' value\n"); |
| 125 | return NISSY_ERROR_UNKNOWN; | 127 | return NISSY_ERROR_UNKNOWN; |
| 126 | } | 128 | } |
| 127 | 129 | ||
| @@ -149,21 +151,23 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) | |||
| 149 | 151 | ||
| 150 | r = readtableinfo_n(arg->buf_size, arg->buf, 2, &h48info); | 152 | r = readtableinfo_n(arg->buf_size, arg->buf, 2, &h48info); |
| 151 | if (r != NISSY_OK) { | 153 | if (r != NISSY_OK) { |
| 152 | LOG("gendata_h48: could not read info for h48 table\n"); | 154 | LOG("[H48 gendata] Error: could not read info " |
| 155 | "for h48 table\n"); | ||
| 153 | return NISSY_ERROR_UNKNOWN; | 156 | return NISSY_ERROR_UNKNOWN; |
| 154 | } | 157 | } |
| 155 | h48info.next = h48size; | 158 | h48info.next = h48size; |
| 156 | r = writetableinfo(&h48info, | 159 | r = writetableinfo(&h48info, |
| 157 | arg->buf_size - cocsepsize, (char *)arg->buf + cocsepsize); | 160 | arg->buf_size - cocsepsize, (char *)arg->buf + cocsepsize); |
| 158 | if (r != NISSY_OK) { | 161 | if (r != NISSY_OK) { |
| 159 | LOG("gendata_h48: could not write info for h48 table\n"); | 162 | LOG("[H48 gendata] Error: could not write info " |
| 163 | "for h48 table\n"); | ||
| 160 | return NISSY_ERROR_UNKNOWN; | 164 | return NISSY_ERROR_UNKNOWN; |
| 161 | } | 165 | } |
| 162 | 166 | ||
| 163 | if (arg->k == 2) { | 167 | if (arg->k == 2) { |
| 164 | r = readtableinfo_n(arg->buf_size, arg->buf, 3, &fallbackinfo); | 168 | r = readtableinfo_n(arg->buf_size, arg->buf, 3, &fallbackinfo); |
| 165 | if (r != NISSY_OK) { | 169 | if (r != NISSY_OK) { |
| 166 | LOG("gendata_h48: could not read info for h48 " | 170 | LOG("[H48 gendata] Error: could not read info for h48 " |
| 167 | "fallback table\n"); | 171 | "fallback table\n"); |
| 168 | return NISSY_ERROR_UNKNOWN; | 172 | return NISSY_ERROR_UNKNOWN; |
| 169 | } | 173 | } |
| @@ -173,8 +177,8 @@ gendata_h48(gendata_h48_arg_t arg[static 1]) | |||
| 173 | r = writetableinfo(&fallbackinfo, | 177 | r = writetableinfo(&fallbackinfo, |
| 174 | arg->buf_size - of, (char *)arg->buf + of); | 178 | arg->buf_size - of, (char *)arg->buf + of); |
| 175 | if (r != NISSY_OK) { | 179 | if (r != NISSY_OK) { |
| 176 | LOG("gendata_h48: could not write info for h48 " | 180 | LOG("[H48 gendata] Error: could not write info for " |
| 177 | "fallback table\n"); | 181 | "h48 fallback table\n"); |
| 178 | return NISSY_ERROR_UNKNOWN; | 182 | return NISSY_ERROR_UNKNOWN; |
| 179 | } | 183 | } |
| 180 | } | 184 | } |
| @@ -233,7 +237,7 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1]) | |||
| 233 | bfsarg[t].table_mutex[tt] = &table_mutex[tt]; | 237 | bfsarg[t].table_mutex[tt] = &table_mutex[tt]; |
| 234 | } | 238 | } |
| 235 | for (done = 1, d = 1; done < h48max && d <= arg->maxdepth; d++) { | 239 | for (done = 1, d = 1; done < h48max && d <= arg->maxdepth; d++) { |
| 236 | LOG("h48: generating depth %" PRId64 "\n", d); | 240 | LOG("[H48 gendata] Generating depth %" PRId64 "\n", d); |
| 237 | 241 | ||
| 238 | for (t = 0; t < THREADS; t++) { | 242 | for (t = 0; t < THREADS; t++) { |
| 239 | bfsarg[t].depth = d; | 243 | bfsarg[t].depth = d; |
| @@ -252,7 +256,7 @@ gendata_h48h0k4(gendata_h48_arg_t arg[static 1]) | |||
| 252 | done += cc; | 256 | done += cc; |
| 253 | arg->info.distribution[d] = cc; | 257 | arg->info.distribution[d] = cc; |
| 254 | 258 | ||
| 255 | LOG("found %" PRId64 "\n", cc); | 259 | LOG("[H48 gendata] Found %" PRId64 "\n", cc); |
| 256 | } | 260 | } |
| 257 | 261 | ||
| 258 | arg->info.maxvalue = d - 1; | 262 | arg->info.maxvalue = d - 1; |
| @@ -382,7 +386,7 @@ gendata_h48k2(gendata_h48_arg_t arg[static 1]) | |||
| 382 | table = (uint8_t *)arg->h48buf + INFOSIZE; | 386 | table = (uint8_t *)arg->h48buf + INFOSIZE; |
| 383 | memset(table, 0xFF, H48_TABLESIZE(arg->h, arg->k)); | 387 | memset(table, 0xFF, H48_TABLESIZE(arg->h, arg->k)); |
| 384 | 388 | ||
| 385 | LOG("Computing depth <=%" PRIu8 "\n", shortdepth) | 389 | LOG("[H48 gendata] Computing depth <=%" PRIu8 "\n", shortdepth) |
| 386 | h48map_create(&shortcubes, capacity, randomizer); | 390 | h48map_create(&shortcubes, capacity, randomizer); |
| 387 | shortarg = (gendata_h48short_arg_t) { | 391 | shortarg = (gendata_h48short_arg_t) { |
| 388 | .maxdepth = shortdepth, | 392 | .maxdepth = shortdepth, |
| @@ -392,7 +396,7 @@ gendata_h48k2(gendata_h48_arg_t arg[static 1]) | |||
| 392 | .map = &shortcubes | 396 | .map = &shortcubes |
| 393 | }; | 397 | }; |
| 394 | gendata_h48short(&shortarg); | 398 | gendata_h48short(&shortarg); |
| 395 | LOG("Computed %" PRIu64 " positions\n", shortarg.map->n); | 399 | LOG("[H48 gendata] Computed %" PRIu64 " positions\n", shortarg.map->n); |
| 396 | 400 | ||
| 397 | if (arg->base >= 20) | 401 | if (arg->base >= 20) |
| 398 | arg->base = base[arg->h]; | 402 | arg->base = base[arg->h]; |
| @@ -459,7 +463,8 @@ gendata_h48k2_runthread(void *arg) | |||
| 459 | pthread_mutex_unlock(dfsarg->shortcubes_mutex); | 463 | pthread_mutex_unlock(dfsarg->shortcubes_mutex); |
| 460 | 464 | ||
| 461 | if (count % UINT64_C(1000000) == 0) | 465 | if (count % UINT64_C(1000000) == 0) |
| 462 | LOG("Processing %" PRIu64 "th short cube\n", count); | 466 | LOG("[H48 gendata] Processing %" PRIu64 |
| 467 | "th short cube\n", count); | ||
| 463 | 468 | ||
| 464 | if (kv.val < dfsarg->shortdepth) { | 469 | if (kv.val < dfsarg->shortdepth) { |
| 465 | coord = kv.key >> (int64_t)(11 - dfsarg->h); | 470 | coord = kv.key >> (int64_t)(11 - dfsarg->h); |
| @@ -780,15 +785,16 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf) | |||
| 780 | 785 | ||
| 781 | bufsize = COCSEP_FULLSIZE + INFOSIZE; | 786 | bufsize = COCSEP_FULLSIZE + INFOSIZE; |
| 782 | if (readtableinfo(bufsize, buf, &cocsepinfo) != NISSY_OK) { | 787 | if (readtableinfo(bufsize, buf, &cocsepinfo) != NISSY_OK) { |
| 783 | LOG("gendata_h48: could not read info for cocsep table\n"); | 788 | LOG("[H48 derive gendata] Error: could not read info for " |
| 789 | "cocsep table\n"); | ||
| 784 | goto gendata_h48_derive_error; | 790 | goto gendata_h48_derive_error; |
| 785 | } | 791 | } |
| 786 | 792 | ||
| 787 | cocsepinfo.next = cocsepsize; | 793 | cocsepinfo.next = cocsepsize; |
| 788 | bufsize = COCSEP_FULLSIZE + INFOSIZE; | 794 | bufsize = COCSEP_FULLSIZE + INFOSIZE; |
| 789 | if (writetableinfo(&cocsepinfo, bufsize, buf) != NISSY_OK) { | 795 | if (writetableinfo(&cocsepinfo, bufsize, buf) != NISSY_OK) { |
| 790 | LOG("gendata_h48_derive: could not write info for cocsep table" | 796 | LOG("[H48 derive gendata] Error: could not write info for " |
| 791 | " with updated 'next' value\n"); | 797 | "cocsep table with updated 'next' value\n"); |
| 792 | goto gendata_h48_derive_error; | 798 | goto gendata_h48_derive_error; |
| 793 | } | 799 | } |
| 794 | 800 | ||
| @@ -801,7 +807,8 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf) | |||
| 801 | h48max = H48_COORDMAX(fulltableinfo.h48h); | 807 | h48max = H48_COORDMAX(fulltableinfo.h48h); |
| 802 | for (i = 0; i < h48max; i++) { | 808 | for (i = 0; i < h48max; i++) { |
| 803 | if (i % INT64_C(1000000000) == 0 && i > 0) | 809 | if (i % INT64_C(1000000000) == 0 && i > 0) |
| 804 | LOG("Processing %" PRId64 "th coordinate\n", i); | 810 | LOG("[H48 derive gendata] Processing %" PRId64 |
| 811 | "th coordinate\n", i); | ||
| 805 | j = i >> (int64_t)(fulltableinfo.h48h - h); | 812 | j = i >> (int64_t)(fulltableinfo.h48h - h); |
| 806 | val_full = get_h48_pval(h48full, i, arg.k); | 813 | val_full = get_h48_pval(h48full, i, arg.k); |
| 807 | val_derive = get_h48_pval(h48derive, j, arg.k); | 814 | val_derive = get_h48_pval(h48derive, j, arg.k); |
| @@ -813,7 +820,8 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf) | |||
| 813 | 820 | ||
| 814 | bufsize = arg.buf_size - COCSEP_FULLSIZE - INFOSIZE; | 821 | bufsize = arg.buf_size - COCSEP_FULLSIZE - INFOSIZE; |
| 815 | if (writetableinfo(&arg.info, bufsize, arg.h48buf) != NISSY_OK) { | 822 | if (writetableinfo(&arg.info, bufsize, arg.h48buf) != NISSY_OK) { |
| 816 | LOG("gendata_h48_derive: could not write info for table\n"); | 823 | LOG("H48 derive gendata] Error: could not write info " |
| 824 | "for table\n"); | ||
| 817 | goto gendata_h48_derive_error; | 825 | goto gendata_h48_derive_error; |
| 818 | } | 826 | } |
| 819 | 827 | ||
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 78b4c97..0fd419d 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -162,7 +162,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) | |||
| 162 | return 0; | 162 | return 0; |
| 163 | pthread_mutex_lock(arg->solutions_mutex); | 163 | pthread_mutex_lock(arg->solutions_mutex); |
| 164 | ret = appendsolution(arg->solution_moves, | 164 | ret = appendsolution(arg->solution_moves, |
| 165 | arg->solution_settings, arg->solution_list, true); | 165 | arg->solution_settings, arg->solution_list, true, "H48"); |
| 166 | pthread_mutex_unlock(arg->solutions_mutex); | 166 | pthread_mutex_unlock(arg->solutions_mutex); |
| 167 | return ret; | 167 | return ret; |
| 168 | } | 168 | } |
| @@ -295,7 +295,7 @@ solve_h48_maketasks( | |||
| 295 | maketasks_arg->moves, maketasks_arg->nmoves); | 295 | maketasks_arg->moves, maketasks_arg->nmoves); |
| 296 | 296 | ||
| 297 | appret = appendsolution(&moves, solve_arg->solution_settings, | 297 | appret = appendsolution(&moves, solve_arg->solution_settings, |
| 298 | solve_arg->solution_list, true); | 298 | solve_arg->solution_list, true, "H48"); |
| 299 | return appret < 0 ? appret : NISSY_OK; | 299 | return appret < 0 ? appret : NISSY_OK; |
| 300 | } | 300 | } |
| 301 | 301 | ||
| @@ -458,16 +458,17 @@ solve_h48( | |||
| 458 | arg[i].tasks = tasks; | 458 | arg[i].tasks = tasks; |
| 459 | } | 459 | } |
| 460 | 460 | ||
| 461 | LOG("Prepared %d tasks\n", ntasks); | 461 | LOG("[H48 solve] Prepared %d tasks\n", ntasks); |
| 462 | 462 | ||
| 463 | for ( | 463 | for ( |
| 464 | d = MAX(minmoves, STARTING_MOVES + 1); | 464 | d = MAX(minmoves, STARTING_MOVES + 1); |
| 465 | !solutions_done(&sollist, &settings, d); | 465 | !solutions_done(&sollist, &settings, d); |
| 466 | d++ | 466 | d++ |
| 467 | ) { | 467 | ) { |
| 468 | if (d >= 10) | 468 | if (d >= 15) |
| 469 | LOG("Found %" PRId64 " solutions, searching at depth %" | 469 | LOG("[H48 solve] Found %" PRId64 " solutions, " |
| 470 | PRId8 "\n", sollist.nsols, d); | 470 | "searching at depth %" PRId8 "\n", |
| 471 | sollist.nsols, d); | ||
| 471 | for (i = 0; i < threads; i++) { | 472 | for (i = 0; i < threads; i++) { |
| 472 | arg[i].target_depth = d; | 473 | arg[i].target_depth = d; |
| 473 | pthread_create( | 474 | pthread_create( |
| @@ -491,16 +492,16 @@ solve_h48_done: | |||
| 491 | lookups_per_node = table_lookups / (long double)nodes_visited; | 492 | lookups_per_node = table_lookups / (long double)nodes_visited; |
| 492 | fallback_rate = nodes_visited == 0 ? 0.0 : | 493 | fallback_rate = nodes_visited == 0 ? 0.0 : |
| 493 | (table_fallbacks * 100) / (long double)table_lookups; | 494 | (table_fallbacks * 100) / (long double)table_lookups; |
| 494 | LOG("Nodes visited: %" PRId64 "\n", nodes_visited); | 495 | LOG("[H48 solve] Nodes visited: %" PRId64 "\n", nodes_visited); |
| 495 | LOG("Lookups: %" PRId64 " (%.3Lf per node)\n", | 496 | LOG("[H48 solve] Lookups: %" PRId64 " (%.3Lf per node)\n", |
| 496 | table_lookups, lookups_per_node); | 497 | table_lookups, lookups_per_node); |
| 497 | LOG("Table fallbacks: %" PRId64 " (%.3Lf%%)\n", | 498 | LOG("[H48 solve] Table fallbacks: %" PRId64 " (%.3Lf%%)\n", |
| 498 | table_fallbacks, fallback_rate); | 499 | table_fallbacks, fallback_rate); |
| 499 | 500 | ||
| 500 | return sollist.nsols; | 501 | return sollist.nsols; |
| 501 | 502 | ||
| 502 | solve_h48_error_data: | 503 | solve_h48_error_data: |
| 503 | LOG("solve_h48: error reading table\n"); | 504 | LOG("[H48 solve] Error reading data table\n"); |
| 504 | return NISSY_ERROR_DATA; | 505 | return NISSY_ERROR_DATA; |
| 505 | 506 | ||
| 506 | solve_h48_error_solutions_buffer: | 507 | solve_h48_error_solutions_buffer: |
diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index 95c1d1a..c9a1313 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h | |||
| @@ -7,7 +7,8 @@ STATIC bool solution_moves_equal( | |||
| 7 | STATIC bool solution_moves_is_duplicate(size_t n, const solution_moves_t[n+1]); | 7 | STATIC bool solution_moves_is_duplicate(size_t n, const solution_moves_t[n+1]); |
| 8 | STATIC bool appendchar(solution_list_t [static 1], char); | 8 | STATIC bool appendchar(solution_list_t [static 1], char); |
| 9 | STATIC int64_t appendsolution(const solution_moves_t [static 1], | 9 | STATIC int64_t appendsolution(const solution_moves_t [static 1], |
| 10 | const solution_settings_t [static 1], solution_list_t [static 1], bool); | 10 | const solution_settings_t [static 1], solution_list_t [static 1], bool, |
| 11 | const char *); | ||
| 11 | STATIC bool solutions_done(const solution_list_t [static 1], | 12 | STATIC bool solutions_done(const solution_list_t [static 1], |
| 12 | const solution_settings_t [static 1], int8_t depth); | 13 | const solution_settings_t [static 1], int8_t depth); |
| 13 | 14 | ||
| @@ -34,7 +35,7 @@ STATIC bool | |||
| 34 | solution_list_init(solution_list_t sols[static 1], size_t n, char buf[n]) | 35 | solution_list_init(solution_list_t sols[static 1], size_t n, char buf[n]) |
| 35 | { | 36 | { |
| 36 | if (n == 0) { | 37 | if (n == 0) { |
| 37 | LOG("Cannot use solution buffer with size 0\n"); | 38 | LOG("Error: cannot use solution buffer with size 0\n"); |
| 38 | return false; | 39 | return false; |
| 39 | } | 40 | } |
| 40 | 41 | ||
| @@ -98,7 +99,8 @@ appendsolution( | |||
| 98 | const solution_moves_t moves[static 1], | 99 | const solution_moves_t moves[static 1], |
| 99 | const solution_settings_t settings[static 1], | 100 | const solution_settings_t settings[static 1], |
| 100 | solution_list_t list[static 1], | 101 | solution_list_t list[static 1], |
| 101 | bool log | 102 | bool log, |
| 103 | const char *solver_name | ||
| 102 | ) | 104 | ) |
| 103 | { | 105 | { |
| 104 | int64_t r, strl; | 106 | int64_t r, strl; |
| @@ -184,8 +186,8 @@ appendsolution( | |||
| 184 | 186 | ||
| 185 | if (log) { | 187 | if (log) { |
| 186 | list->buf[list->used-1] = '\0'; | 188 | list->buf[list->used-1] = '\0'; |
| 187 | LOG("Found solution #%" PRIu64 ": %s\n", | 189 | LOG("[%s solve] Found solution #%" PRIu64 ": %s\n", |
| 188 | list->nsols, last_start); | 190 | solver_name, list->nsols, last_start); |
| 189 | list->buf[list->used-1] = '\n'; | 191 | list->buf[list->used-1] = '\n'; |
| 190 | } | 192 | } |
| 191 | } | 193 | } |
| @@ -194,14 +196,14 @@ appendsolution( | |||
| 194 | return r; | 196 | return r; |
| 195 | 197 | ||
| 196 | appendsolution_error_buffer: | 198 | appendsolution_error_buffer: |
| 197 | LOG("Could not append solution to buffer: size too small\n"); | 199 | LOG("[%s solve] Error: buffer too small\n", solver_name); |
| 198 | list->buf[0] = '\0'; | 200 | list->buf[0] = '\0'; |
| 199 | return NISSY_ERROR_BUFFER_SIZE; | 201 | return NISSY_ERROR_BUFFER_SIZE; |
| 200 | 202 | ||
| 201 | appendsolution_error_solution_length: | 203 | appendsolution_error_solution_length: |
| 202 | LOG("Error: solution is too long (%" PRIu8 ").\n" | 204 | LOG("[%s solve] Error: solution is too long (%" PRIu8 ").\n" |
| 203 | "This is a bug, please report it.\n", | 205 | "This is a bug, please report it.\n", |
| 204 | moves->nmoves + moves->npremoves); | 206 | solver_name, moves->nmoves + moves->npremoves); |
| 205 | list->buf[0] = '\0'; | 207 | list->buf[0] = '\0'; |
| 206 | return NISSY_ERROR_UNKNOWN; | 208 | return NISSY_ERROR_UNKNOWN; |
| 207 | } | 209 | } |
