aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/solve_multithread.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/solvers/h48/solve_multithread.h')
-rw-r--r--src/solvers/h48/solve_multithread.h30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/solvers/h48/solve_multithread.h b/src/solvers/h48/solve_multithread.h
index 2e3a1e9..2755372 100644
--- a/src/solvers/h48/solve_multithread.h
+++ b/src/solvers/h48/solve_multithread.h
@@ -261,13 +261,11 @@ solve_h48_multithread(
261 _Atomic int64_t nsols = 0; 261 _Atomic int64_t nsols = 0;
262 int p_depth = 0; 262 int p_depth = 0;
263 dfsarg_solveh48_t arg; 263 dfsarg_solveh48_t arg;
264 tableinfo_t info; 264 tableinfo_t info, fbinfo;
265 pthread_t threads[THREADS]; 265 pthread_t threads[THREADS];
266 266
267 if (readtableinfo_n(data_size, data, 2, &info) != NISSY_OK) { 267 if (readtableinfo_n(data_size, data, 2, &info) != NISSY_OK)
268 LOG("solve_h48: error reading table\n"); 268 goto solve_h48_multithread_error_data;
269 return NISSY_ERROR_DATA;
270 }
271 269
272 arg = (dfsarg_solveh48_t){ 270 arg = (dfsarg_solveh48_t){
273 .cube = cube, 271 .cube = cube,
@@ -278,12 +276,23 @@ solve_h48_multithread(
278 .h = info.h48h, 276 .h = info.h48h,
279 .k = info.bits, 277 .k = info.bits,
280 .base = info.base, 278 .base = info.base,
281 .cocsepdata = get_cocsepdata_constptr(data), 279 .cocsepdata = (uint32_t *)((char *)data + INFOSIZE),
282 .h48data = get_h48data_constptr(data), 280 .h48data = (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE,
283 .solutions_size = solutions_size, 281 .solutions_size = solutions_size,
284 .nextsol = &solutions 282 .nextsol = &solutions
285 }; 283 };
286 284
285 if (info.bits == 2) {
286 if (readtableinfo_n(data_size, data, 3, &fbinfo) != NISSY_OK)
287 goto solve_h48_multithread_error_data;
288 /* We only support h0k4 as fallback table */
289 if (fbinfo.h48h != 0 || fbinfo.bits != 4)
290 goto solve_h48_multithread_error_data;
291 arg.h48data_fallback = arg.h48data + info.next;
292 } else {
293 arg.h48data_fallback = NULL;
294 }
295
287 task_queue_t q; 296 task_queue_t q;
288 init_queue(&q); 297 init_queue(&q);
289 if (solve_h48_bfs(&arg, &q, maxmoves)) 298 if (solve_h48_bfs(&arg, &q, maxmoves))
@@ -301,7 +310,8 @@ solve_h48_multithread(
301 p_depth <= maxmoves && nsols < maxsolutions; 310 p_depth <= maxmoves && nsols < maxsolutions;
302 p_depth++) 311 p_depth++)
303 { 312 {
304 LOG("Found %" PRId64 " solutions, searching at depth %" PRId8 "\n", nsols, p_depth); 313 LOG("Found %" PRId64 " solutions, "
314 "searching at depth %" PRId8 "\n", nsols, p_depth);
305 copy_queue(&q, &nq, p_depth, &nsols); 315 copy_queue(&q, &nq, p_depth, &nsols);
306 316
307 pthread_mutex_lock(&nq.mutex); 317 pthread_mutex_lock(&nq.mutex);
@@ -319,4 +329,8 @@ solve_h48_multithread(
319 **arg.nextsol = '\0'; 329 **arg.nextsol = '\0';
320 (*arg.nextsol)++; 330 (*arg.nextsol)++;
321 return nsols; 331 return nsols;
332
333solve_h48_multithread_error_data:
334 LOG("solve_h48: error reading table\n");
335 return NISSY_ERROR_DATA;
322} 336}

Generated with cgit - Back to sebastiano.tronto.net