aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48
diff options
context:
space:
mode:
Diffstat (limited to 'src/solvers/h48')
-rw-r--r--src/solvers/h48/gendata_h48.h21
-rw-r--r--src/solvers/h48/solve.h36
2 files changed, 37 insertions, 20 deletions
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);
18STATIC_INLINE void set_h48_pval(unsigned char *, uint64_t, uint8_t); 18STATIC_INLINE void set_h48_pval(unsigned char *, uint64_t, uint8_t);
19STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t); 19STATIC_INLINE uint8_t get_h48_pvalmin(const unsigned char *, uint64_t);
20STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t); 20STATIC_INLINE void set_h48_pvalmin(unsigned char *, uint64_t, uint8_t);
21STATIC_INLINE uint8_t get_h48_pval_and_min(
22 const unsigned char *, uint64_t, uint8_t [static 1]);
21 23
22STATIC long long 24STATIC long long
23gendata_h48_dispatch( 25gendata_h48_dispatch(
@@ -526,3 +528,22 @@ set_h48_pvalmin(unsigned char *table, uint64_t i, uint8_t val)
526 t = table[H48_INDEX(i)]; 528 t = table[H48_INDEX(i)];
527 table[H48_INDEX(i)] = (t & UINT8_C(0xF)) | (v << UINT8_C(4)); 529 table[H48_INDEX(i)] = (t & UINT8_C(0xF)) | (v << UINT8_C(4));
528} 530}
531
532STATIC_INLINE uint8_t
533get_h48_pval_and_min(
534 const unsigned char *table,
535 uint64_t coord_noext,
536 uint8_t pval_min[static 1]
537)
538{
539 uint64_t iext, imin;
540 uint8_t t, tmin;
541
542 iext = H48_LINE_EXT(coord_noext);
543 imin = H48_LINE_MIN(coord_noext);
544 t = table[H48_INDEX(iext)];
545 tmin = table[H48_INDEX(imin)];
546
547 *pval_min = tmin >> UINT8_C(4);
548 return (t & H48_MASK(iext)) >> H48_SHIFT(iext);
549}
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
108solve_h48_stop(dfsarg_solve_h48_t arg[static 1]) 108solve_h48_stop(dfsarg_solve_h48_t arg[static 1])
109{ 109{
110 uint32_t data, data_inv; 110 uint32_t data, data_inv;
111 int64_t coord, coordext, coordmin; 111 int64_t coord;
112 int8_t target, nh, n; 112 int8_t target, nh, n;
113 uint8_t pval_min, pval_eoesep; 113 uint8_t pval, pval_min, pval_eoesep;
114 114
115 arg->movemask_normal = arg->movemask_inverse = MM18_ALLMOVES; 115 arg->movemask_normal = arg->movemask_inverse = MM18_ALLMOVES;
116 arg->nodes_visited++; 116 arg->nodes_visited++;
@@ -132,25 +132,23 @@ solve_h48_stop(dfsarg_solve_h48_t arg[static 1])
132 /* Inverse probing */ 132 /* Inverse probing */
133 133
134 if (!arg->use_lb_inverse) { 134 if (!arg->use_lb_inverse) {
135 arg->table_lookups++;
136 arg->use_lb_inverse = true;
135 coord = coord_h48_edges( 137 coord = coord_h48_edges(
136 arg->inverse, COCLASS(data_inv), TTREP(data_inv), arg->h); 138 arg->inverse, COCLASS(data_inv), TTREP(data_inv), arg->h);
137 coordext = H48_LINE_EXT(coord); 139 pval = get_h48_pval_and_min(arg->h48data, coord, &pval_min);
138 arg->lb_inverse = get_h48_pval(arg->h48data, coordext);
139 arg->table_lookups++;
140 140
141 if (arg->lb_inverse == 0) { 141 if (pval == 0) {
142 arg->table_fallbacks++; 142 arg->table_fallbacks++;
143 143
144 coordmin = H48_LINE_MIN(coord);
145 pval_min = get_h48_pvalmin(arg->h48data, coordmin);
146 pval_eoesep = get_eoesep_pval_cube( 144 pval_eoesep = get_eoesep_pval_cube(
147 arg->h48data_fallback_eoesep, arg->inverse); 145 arg->h48data_fallback_eoesep, arg->inverse);
148 arg->lb_inverse = MAX(pval_min, pval_eoesep); 146 pval = MAX(pval_min, pval_eoesep);
149 } else { 147 } else {
150 arg->lb_inverse += arg->base; 148 pval += arg->base;
151 } 149 }
152 150
153 arg->use_lb_inverse = true; 151 arg->lb_inverse = pval;
154 } 152 }
155 153
156 if (arg->lb_inverse > target) 154 if (arg->lb_inverse > target)
@@ -161,25 +159,23 @@ solve_h48_stop(dfsarg_solve_h48_t arg[static 1])
161 /* Normal probing */ 159 /* Normal probing */
162 160
163 if (!arg->use_lb_normal) { 161 if (!arg->use_lb_normal) {
162 arg->table_lookups++;
163 arg->use_lb_normal = true;
164 coord = coord_h48_edges( 164 coord = coord_h48_edges(
165 arg->cube, COCLASS(data), TTREP(data), arg->h); 165 arg->cube, COCLASS(data), TTREP(data), arg->h);
166 coordext = H48_LINE_EXT(coord); 166 pval = get_h48_pval_and_min(arg->h48data, coord, &pval_min);
167 arg->lb_normal = get_h48_pval(arg->h48data, coordext);
168 arg->table_lookups++;
169 167
170 if (arg->lb_normal == 0) { 168 if (pval == 0) {
171 arg->table_fallbacks++; 169 arg->table_fallbacks++;
172 170
173 coordmin = H48_LINE_MIN(coord);
174 pval_min = get_h48_pval(arg->h48data, coordmin);
175 pval_eoesep = get_eoesep_pval_cube( 171 pval_eoesep = get_eoesep_pval_cube(
176 arg->h48data_fallback_eoesep, arg->cube); 172 arg->h48data_fallback_eoesep, arg->cube);
177 arg->lb_normal = MAX(pval_min, pval_eoesep); 173 pval = MAX(pval_min, pval_eoesep);
178 } else { 174 } else {
179 arg->lb_normal += arg->base; 175 pval += arg->base;
180 } 176 }
181 177
182 arg->use_lb_normal = true; 178 arg->lb_normal = pval;
183 } 179 }
184 180
185 if (arg->lb_normal > target) 181 if (arg->lb_normal > target)

Generated with cgit - Back to sebastiano.tronto.net