From ac3a91f4f173e7a38c70d5cd0caf5a025642312b Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 17 Dec 2025 10:51:34 +0100 Subject: Improve pruning value fetching and re-do benchmarks --- src/solvers/h48/gendata_h48.h | 21 +++++++++++++++++++++ src/solvers/h48/solve.h | 36 ++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 15b7589..ef8a854 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h @@ -18,6 +18,8 @@ STATIC_INLINE uint8_t get_h48_pval(const unsigned char *, uint64_t); STATIC_INLINE void set_h48_pval(unsigned char *, uint64_t, uint8_t); STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t); STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t); +STATIC_INLINE uint8_t get_h48_pval_and_min( + const unsigned char *, uint64_t, uint8_t [static 1]); STATIC long long gendata_h48_dispatch( @@ -526,3 +528,22 @@ set_h48_pvalmin(unsigned char *table, uint64_t i, uint8_t val) t = table[H48_INDEX(i)]; table[H48_INDEX(i)] = (t & UINT8_C(0xF)) | (v << UINT8_C(4)); } + +STATIC_INLINE uint8_t +get_h48_pval_and_min( + const unsigned char *table, + uint64_t coord_noext, + uint8_t pval_min[static 1] +) +{ + uint64_t iext, imin; + uint8_t t, tmin; + + iext = H48_LINE_EXT(coord_noext); + imin = H48_LINE_MIN(coord_noext); + t = table[H48_INDEX(iext)]; + tmin = table[H48_INDEX(imin)]; + + *pval_min = tmin >> UINT8_C(4); + return (t & H48_MASK(iext)) >> H48_SHIFT(iext); +} diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 5fd3dd9..2920fa7 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h @@ -108,9 +108,9 @@ STATIC_INLINE bool solve_h48_stop(dfsarg_solve_h48_t arg[static 1]) { uint32_t data, data_inv; - int64_t coord, coordext, coordmin; + int64_t coord; int8_t target, nh, n; - uint8_t pval_min, pval_eoesep; + uint8_t pval, pval_min, pval_eoesep; arg->movemask_normal = arg->movemask_inverse = MM18_ALLMOVES; arg->nodes_visited++; @@ -132,25 +132,23 @@ solve_h48_stop(dfsarg_solve_h48_t arg[static 1]) /* Inverse probing */ if (!arg->use_lb_inverse) { + arg->table_lookups++; + arg->use_lb_inverse = true; coord = coord_h48_edges( arg->inverse, COCLASS(data_inv), TTREP(data_inv), arg->h); - coordext = H48_LINE_EXT(coord); - arg->lb_inverse = get_h48_pval(arg->h48data, coordext); - arg->table_lookups++; + pval = get_h48_pval_and_min(arg->h48data, coord, &pval_min); - if (arg->lb_inverse == 0) { + if (pval == 0) { arg->table_fallbacks++; - coordmin = H48_LINE_MIN(coord); - pval_min = get_h48_pvalmin(arg->h48data, coordmin); pval_eoesep = get_eoesep_pval_cube( arg->h48data_fallback_eoesep, arg->inverse); - arg->lb_inverse = MAX(pval_min, pval_eoesep); + pval = MAX(pval_min, pval_eoesep); } else { - arg->lb_inverse += arg->base; + pval += arg->base; } - arg->use_lb_inverse = true; + arg->lb_inverse = pval; } if (arg->lb_inverse > target) @@ -161,25 +159,23 @@ solve_h48_stop(dfsarg_solve_h48_t arg[static 1]) /* Normal probing */ if (!arg->use_lb_normal) { + arg->table_lookups++; + arg->use_lb_normal = true; coord = coord_h48_edges( arg->cube, COCLASS(data), TTREP(data), arg->h); - coordext = H48_LINE_EXT(coord); - arg->lb_normal = get_h48_pval(arg->h48data, coordext); - arg->table_lookups++; + pval = get_h48_pval_and_min(arg->h48data, coord, &pval_min); - if (arg->lb_normal == 0) { + if (pval == 0) { arg->table_fallbacks++; - coordmin = H48_LINE_MIN(coord); - pval_min = get_h48_pval(arg->h48data, coordmin); pval_eoesep = get_eoesep_pval_cube( arg->h48data_fallback_eoesep, arg->cube); - arg->lb_normal = MAX(pval_min, pval_eoesep); + pval = MAX(pval_min, pval_eoesep); } else { - arg->lb_normal += arg->base; + pval += arg->base; } - arg->use_lb_normal = true; + arg->lb_normal = pval; } if (arg->lb_normal > target) -- cgit v1.3