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.h23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/solvers/h48/solve_multithread.h b/src/solvers/h48/solve_multithread.h
index 2755372..394350e 100644
--- a/src/solvers/h48/solve_multithread.h
+++ b/src/solvers/h48/solve_multithread.h
@@ -20,8 +20,8 @@ STATIC void copy_queue(task_queue_t *, task_queue_t *, int, _Atomic int64_t *);
20STATIC void *start_thread(void *); 20STATIC void *start_thread(void *);
21STATIC int64_t solve_h48_bfs(dfsarg_solveh48_t *, task_queue_t *, int8_t); 21STATIC int64_t solve_h48_bfs(dfsarg_solveh48_t *, task_queue_t *, int8_t);
22STATIC int64_t solve_h48_single(dfsarg_solveh48_t *, task_queue_t *); 22STATIC int64_t solve_h48_single(dfsarg_solveh48_t *, task_queue_t *);
23STATIC int64_t solve_h48_multithread(cube_t, int8_t, int8_t, int8_t, 23STATIC int64_t solve_h48_multithread(cube_t, int8_t, int8_t, int8_t, uint64_t,
24 uint64_t, const void *, uint64_t, char *); 24 const void *, uint64_t, char *, long long [static NISSY_SIZE_SOLVE_STATS]);
25 25
26STATIC void 26STATIC void
27solve_h48_appendsolution_thread(dfsarg_solveh48_t *arg, task_queue_t *tq) 27solve_h48_appendsolution_thread(dfsarg_solveh48_t *arg, task_queue_t *tq)
@@ -255,10 +255,12 @@ solve_h48_multithread(
255 uint64_t data_size, 255 uint64_t data_size,
256 const void *data, 256 const void *data,
257 uint64_t solutions_size, 257 uint64_t solutions_size,
258 char *solutions 258 char *solutions,
259 long long stats[static NISSY_SIZE_SOLVE_STATS]
259) 260)
260{ 261{
261 _Atomic int64_t nsols = 0; 262 _Atomic int64_t nsols = 0;
263 _Atomic long long nodes, fallbacks;
262 int p_depth = 0; 264 int p_depth = 0;
263 dfsarg_solveh48_t arg; 265 dfsarg_solveh48_t arg;
264 tableinfo_t info, fbinfo; 266 tableinfo_t info, fbinfo;
@@ -267,6 +269,7 @@ solve_h48_multithread(
267 if (readtableinfo_n(data_size, data, 2, &info) != NISSY_OK) 269 if (readtableinfo_n(data_size, data, 2, &info) != NISSY_OK)
268 goto solve_h48_multithread_error_data; 270 goto solve_h48_multithread_error_data;
269 271
272 nodes = fallbacks = 0;
270 arg = (dfsarg_solveh48_t){ 273 arg = (dfsarg_solveh48_t){
271 .cube = cube, 274 .cube = cube,
272 .inverse = inverse(cube), 275 .inverse = inverse(cube),
@@ -279,7 +282,9 @@ solve_h48_multithread(
279 .cocsepdata = (uint32_t *)((char *)data + INFOSIZE), 282 .cocsepdata = (uint32_t *)((char *)data + INFOSIZE),
280 .h48data = (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE, 283 .h48data = (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE,
281 .solutions_size = solutions_size, 284 .solutions_size = solutions_size,
282 .nextsol = &solutions 285 .nextsol = &solutions,
286 .nodes_visited = &nodes,
287 .table_fallbacks = &fallbacks
283 }; 288 };
284 289
285 if (info.bits == 2) { 290 if (info.bits == 2) {
@@ -301,7 +306,7 @@ solve_h48_multithread(
301 task_queue_t nq; 306 task_queue_t nq;
302 init_queue(&nq); 307 init_queue(&nq);
303 308
304 for (int i = 0; i < THREADS; i++){ 309 for (int i = 0; i < THREADS; i++) {
305 pthread_create(&threads[i], NULL, &start_thread, &nq); 310 pthread_create(&threads[i], NULL, &start_thread, &nq);
306 } 311 }
307 312
@@ -323,11 +328,15 @@ solve_h48_multithread(
323 atomic_store(&nq.terminate, true); 328 atomic_store(&nq.terminate, true);
324 pthread_cond_broadcast(&nq.cond); 329 pthread_cond_broadcast(&nq.cond);
325 330
326 for (int i = 0; i < THREADS; i++){ 331 for (int i = 0; i < THREADS; i++) {
327 pthread_join(threads[i], NULL); 332 pthread_join(threads[i], NULL);
328 } 333 }
329 **arg.nextsol = '\0'; 334 **arg.nextsol = '\0';
330 (*arg.nextsol)++; 335
336 stats[0] = nodes;
337 stats[1] = fallbacks;
338 LOG("Nodes visited: %lld\nTable fallbacks: %lld\n", nodes, fallbacks);
339
331 return nsols; 340 return nsols;
332 341
333solve_h48_multithread_error_data: 342solve_h48_multithread_error_data:

Generated with cgit - Back to sebastiano.tronto.net