aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/solve.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/solvers/h48/solve.h')
-rw-r--r--src/solvers/h48/solve.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h
index 50e4f99..bf10723 100644
--- a/src/solvers/h48/solve.h
+++ b/src/solvers/h48/solve.h
@@ -43,9 +43,9 @@ typedef struct {
43 int ntasks; 43 int ntasks;
44 solve_h48_task_t *tasks; 44 solve_h48_task_t *tasks;
45 int thread_id; 45 int thread_id;
46 pthread_mutex_t *solutions_mutex; 46 wrapthread_define_struct_mutex_t(*solutions_mutex);
47 _Atomic int *status; 47 wrapthread_atomic int *status;
48 _Atomic bool thread_done; 48 wrapthread_atomic bool thread_done;
49} dfsarg_solve_h48_t; 49} dfsarg_solve_h48_t;
50 50
51typedef struct { 51typedef struct {
@@ -207,10 +207,10 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1])
207 + arg->solution_moves->npremoves; 207 + arg->solution_moves->npremoves;
208 if (arg->target_depth != nm) 208 if (arg->target_depth != nm)
209 return 0; 209 return 0;
210 pthread_mutex_lock(arg->solutions_mutex); 210 wrapthread_mutex_lock(arg->solutions_mutex);
211 ret = appendsolution(arg->solution_moves, 211 ret = appendsolution(arg->solution_moves,
212 arg->solution_settings, arg->solution_list); 212 arg->solution_settings, arg->solution_list);
213 pthread_mutex_unlock(arg->solutions_mutex); 213 wrapthread_mutex_unlock(arg->solutions_mutex);
214 return ret; 214 return ret;
215 } 215 }
216 216
@@ -455,7 +455,7 @@ solve_h48(
455{ 455{
456 int i, ntasks, eoesep_table_index; 456 int i, ntasks, eoesep_table_index;
457 bool td; 457 bool td;
458 _Atomic int status, prev_status; 458 wrapthread_atomic int status, prev_status;
459 size_t lastused; 459 size_t lastused;
460 int8_t d; 460 int8_t d;
461 dfsarg_solve_h48_t arg[THREADS]; 461 dfsarg_solve_h48_t arg[THREADS];
@@ -471,8 +471,8 @@ solve_h48(
471 solution_moves_t solution_moves[THREADS]; 471 solution_moves_t solution_moves[THREADS];
472 solution_settings_t settings; 472 solution_settings_t settings;
473 solution_list_t sollist; 473 solution_list_t sollist;
474 pthread_t thread[THREADS]; 474 wrapthread_define_var_thread_t(thread[THREADS]);
475 pthread_mutex_t solutions_mutex; 475 wrapthread_define_var_mutex_t(solutions_mutex);
476 476
477 if (!solution_list_init(&sollist, solutions_size, solutions)) 477 if (!solution_list_init(&sollist, solutions_size, solutions))
478 goto solve_h48_error_solutions_buffer; 478 goto solve_h48_error_solutions_buffer;
@@ -541,7 +541,7 @@ solve_h48(
541 541
542 } 542 }
543 543
544 pthread_mutex_init(&solutions_mutex, NULL); 544 wrapthread_mutex_init(&solutions_mutex, NULL);
545 545
546 maketasks_arg = (dfsarg_solve_h48_maketasks_t) { 546 maketasks_arg = (dfsarg_solve_h48_maketasks_t) {
547 .cube = oc.cube, 547 .cube = oc.cube,
@@ -591,7 +591,7 @@ solve_h48(
591 for (i = 0; i < threads; i++) { 591 for (i = 0; i < threads; i++) {
592 arg[i].target_depth = d; 592 arg[i].target_depth = d;
593 arg[i].thread_done = false; 593 arg[i].thread_done = false;
594 pthread_create( 594 wrapthread_create(
595 &thread[i], NULL, solve_h48_runthread, &arg[i]); 595 &thread[i], NULL, solve_h48_runthread, &arg[i]);
596 } 596 }
597 597
@@ -601,10 +601,10 @@ solve_h48(
601 while (!td && status != NISSY_STATUS_STOP) { 601 while (!td && status != NISSY_STATUS_STOP) {
602 msleep(BASE_SLEEP_TIME); 602 msleep(BASE_SLEEP_TIME);
603 603
604 pthread_mutex_lock(&solutions_mutex); 604 wrapthread_mutex_lock(&solutions_mutex);
605 solve_h48_log_solutions(&sollist, lastused); 605 solve_h48_log_solutions(&sollist, lastused);
606 lastused = sollist.used; 606 lastused = sollist.used;
607 pthread_mutex_unlock(&solutions_mutex); 607 wrapthread_mutex_unlock(&solutions_mutex);
608 608
609 prev_status = status; 609 prev_status = status;
610 status = poll_status(poll_status_data); 610 status = poll_status(poll_status_data);
@@ -621,7 +621,7 @@ solve_h48(
621 } 621 }
622 622
623 for (i = 0; i < threads; i++) 623 for (i = 0; i < threads; i++)
624 pthread_join(thread[i], NULL); 624 wrapthread_join(thread[i], NULL);
625 625
626 solve_h48_log_solutions(&sollist, lastused); 626 solve_h48_log_solutions(&sollist, lastused);
627 lastused = sollist.used; 627 lastused = sollist.used;

Generated with cgit - Back to sebastiano.tronto.net