From b80b1b78901154240bc5d2ab6f5ea4465bf7fa67 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Fri, 18 Oct 2024 19:06:45 +0200 Subject: Fixed performance regression --- src/solvers/h48/solve.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/solvers/h48/solve.h') 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 { uint8_t nissbranch; int8_t npremoves; uint8_t premoves[MAXLEN]; - _Atomic long long *nodes_visited; - _Atomic long long *table_fallbacks; + long long nodes_visited; + long long table_fallbacks; } dfsarg_solveh48_t; STATIC uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint8_t); @@ -105,7 +105,7 @@ solve_h48_stop(dfsarg_solveh48_t *arg) int8_t cbound, cbound_inv, h48bound, h48bound_inv; int64_t coord, coord_inv; - (*arg->nodes_visited)++; + arg->nodes_visited++; arg->nissbranch = MM_NORMAL; cbound = get_h48_cdata(arg->cube, arg->cocsepdata, &data); @@ -124,7 +124,7 @@ solve_h48_stop(dfsarg_solveh48_t *arg) if (arg->k == 2) { if (h48bound == 0) { - (*arg->table_fallbacks)++; + arg->table_fallbacks++; h48bound = get_h48_pval( arg->h48data_fallback, coord >> arg->h, 4); } else { @@ -141,7 +141,7 @@ solve_h48_stop(dfsarg_solveh48_t *arg) h48bound_inv = get_h48_pval(arg->h48data, coord_inv, arg->k); if (arg->k == 2) { if (h48bound_inv == 0) { - (*arg->table_fallbacks)++; + arg->table_fallbacks++; h48bound_inv = get_h48_pval( arg->h48data_fallback, coord_inv >> arg->h, 4); } else { @@ -203,6 +203,8 @@ solve_h48_dfs(dfsarg_solveh48_t *arg) } } + arg->nodes_visited = nextarg.nodes_visited; + arg->table_fallbacks = nextarg.table_fallbacks; return ret; } @@ -220,14 +222,12 @@ solve_h48( ) { _Atomic int64_t nsols; - _Atomic long long nodes, fallbacks; dfsarg_solveh48_t arg; tableinfo_t info, fbinfo; if(readtableinfo_n(data_size, data, 2, &info) != NISSY_OK) goto solve_h48_error_data; - nodes = fallbacks = 0; arg = (dfsarg_solveh48_t) { .cube = cube, .inverse = inverse(cube), @@ -240,8 +240,8 @@ solve_h48( .h48data = (uint8_t *)data + COCSEP_FULLSIZE + INFOSIZE, .solutions_size = solutions_size, .nextsol = &solutions, - .nodes_visited = &nodes, - .table_fallbacks = &fallbacks + .nodes_visited = 0, + .table_fallbacks = 0 }; if (info.bits == 2) { @@ -268,9 +268,10 @@ solve_h48( } **arg.nextsol = '\0'; - stats[0] = nodes; - stats[1] = fallbacks; - LOG("Nodes visited: %lld\nTable fallbacks: %lld\n", nodes, fallbacks); + stats[0] = arg.nodes_visited; + stats[1] = arg.table_fallbacks; + LOG("Nodes visited: %lld\nTable fallbacks: %lld\n", + arg.nodes_visited, arg.table_fallbacks); return nsols; -- cgit v1.3