aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure.sh2
-rw-r--r--src/cube_avx2.h10
-rw-r--r--src/solve_h48.h43
-rw-r--r--test/102_gendata_h48/00_all.in0
-rw-r--r--test/102_gendata_h48/00_all.out1
-rw-r--r--test/102_gendata_h48/00_h_0.in1
-rw-r--r--test/102_gendata_h48/00_h_0.out23
-rw-r--r--test/102_gendata_h48/gendata_h48_tests.c31
8 files changed, 80 insertions, 31 deletions
diff --git a/configure.sh b/configure.sh
index c297623..60e375a 100755
--- a/configure.sh
+++ b/configure.sh
@@ -18,7 +18,7 @@ WFLAGS="-pedantic -Wall -Wextra -Wno-unused-parameter -Wno-unused-function"
18SAN="$ADDR $UNDEF" 18SAN="$ADDR $UNDEF"
19 19
20CFLAGS="$STD $WFLAGS $AVX -O3" 20CFLAGS="$STD $WFLAGS $AVX -O3"
21DBGFLAGS="$STD $WFLAGS $AVX -g3 -DDEBUG" 21DBGFLAGS="$STD $WFLAGS $SAN $AVX -g3 -DDEBUG"
22 22
23echo "Cube type: CUBE_$TYPE" 23echo "Cube type: CUBE_$TYPE"
24echo "Compiler: ${CC:-cc}" 24echo "Compiler: ${CC:-cc}"
diff --git a/src/cube_avx2.h b/src/cube_avx2.h
index d39da94..934737c 100644
--- a/src/cube_avx2.h
+++ b/src/cube_avx2.h
@@ -207,7 +207,7 @@ _static_inline int64_t
207coord_fast_esep(cube_fast_t c) 207coord_fast_esep(cube_fast_t c)
208{ 208{
209 cube_fast_t ep; 209 cube_fast_t ep;
210 int64_t e, mem[4], i, j, k, l, ret1, ret2, bit1, bit2, is1; 210 int64_t e, mem[4], i, j, jj, k, l, ret1, ret2, bit1, bit2, is1;
211 211
212 ep = _mm256_and_si256(c, _ep_avx2); 212 ep = _mm256_and_si256(c, _ep_avx2);
213 _mm256_storeu_si256((__m256i *)mem, ep); 213 _mm256_storeu_si256((__m256i *)mem, ep);
@@ -225,7 +225,8 @@ coord_fast_esep(cube_fast_t c)
225 ret1 += bit2 * binomial[11-i][k]; 225 ret1 += bit2 * binomial[11-i][k];
226 k -= bit2; 226 k -= bit2;
227 227
228 ret2 += is1 * binomial[7-j][l]; 228 jj = j < 8;
229 ret2 += jj * is1 * binomial[7-(j*jj)][l];
229 l -= is1; 230 l -= is1;
230 j += (1-bit2); 231 j += (1-bit2);
231 } 232 }
@@ -274,7 +275,7 @@ _static_inline cube_fast_t
274invcoord_fast_esep(int64_t esep) 275invcoord_fast_esep(int64_t esep)
275{ 276{
276 cube_fast_t eee, ret; 277 cube_fast_t eee, ret;
277 int64_t i, j, k, l, s, v, w, is1, set1, set2; 278 int64_t i, j, jj, k, l, s, v, w, is1, set1, set2;
278 uint8_t bit2, bit1, mem[32]; 279 uint8_t bit2, bit1, mem[32];
279 uint8_t slice[3] = {0}; 280 uint8_t slice[3] = {0};
280 281
@@ -283,7 +284,8 @@ invcoord_fast_esep(int64_t esep)
283 284
284 for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) { 285 for (i = 0, j = 0, k = 4, l = 4; i < 12; i++) {
285 v = binomial[11-i][k]; 286 v = binomial[11-i][k];
286 w = binomial[7-j][l]; 287 jj = j < 8;
288 w = jj * binomial[7-(j*jj)][l];
287 bit2 = set2 >= v; 289 bit2 = set2 >= v;
288 bit1 = set1 >= w; 290 bit1 = set1 >= w;
289 is1 = (1 - bit2) * bit1; 291 is1 = (1 - bit2) * bit1;
diff --git a/src/solve_h48.h b/src/solve_h48.h
index b95e6ce..be2c328 100644
--- a/src/solve_h48.h
+++ b/src/solve_h48.h
@@ -1,12 +1,10 @@
1#define COCSEP_CLASSES 3393U 1#define COCSEP_CLASSES 3393U
2#define COCSEP_TABLESIZE (_3p7 << 7U) 2#define COCSEP_TABLESIZE (_3p7 << 7U)
3#define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + 7U) / 8U) 3#define COCSEP_VISITEDSIZE ((COCSEP_TABLESIZE + 7U) / 8U)
4#define COCSEP_INFOSIZE 12U 4#define COCSEP_FULLSIZE (4*(COCSEP_TABLESIZE + 12))
5#define COCSEP_FULLSIZE (4 * (COCSEP_TABLESIZE + COCSEP_INFOSIZE))
6 5
7#define ESEP_MAX(h) ((COCSEP_CLASSES * _12c4 * _8c4) << (h)) 6#define ESEP_MAX(h) ((COCSEP_CLASSES * _12c4 * _8c4) << (h))
8#define ESEP_TABLESIZE(h, k) (ESEP_MAX((h)) >> (k)) 7#define ESEP_TABLESIZE(h, k) (ESEP_MAX((h)) / (8U / (k)))
9#define ESEP_INFOSIZE 25 /* TODO unknown yet */
10 8
11#define H48_ESIZE(h) ((_12c4 * _8c4) << (h)) 9#define H48_ESIZE(h) ((_12c4 * _8c4) << (h))
12 10
@@ -41,7 +39,7 @@ _static_inline cube_fast_t invcoord_h48(int64_t, const cube_fast_t *, uint8_t);
41 39
42_static size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); 40_static size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *);
43_static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); 41_static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *);
44_static size_t gendata_h48(void *, uint8_t); 42_static size_t gendata_h48(void *, uint8_t, uint8_t);
45_static uint64_t gendata_esep_bfs(bfsarg_esep_t *); 43_static uint64_t gendata_esep_bfs(bfsarg_esep_t *);
46 44
47_static_inline bool get_visited(const uint8_t *, int64_t); 45_static_inline bool get_visited(const uint8_t *, int64_t);
@@ -120,7 +118,6 @@ gendata_cocsep(void *buf, uint64_t *selfsim, cube_fast_t *rep)
120 buf32 = (uint32_t *)buf; 118 buf32 = (uint32_t *)buf;
121 info = buf32 + COCSEP_TABLESIZE; 119 info = buf32 + COCSEP_TABLESIZE;
122 memset(buf32, 0xFFU, sizeof(uint32_t) * COCSEP_TABLESIZE); 120 memset(buf32, 0xFFU, sizeof(uint32_t) * COCSEP_TABLESIZE);
123 memset(info, 0, sizeof(uint32_t) * COCSEP_INFOSIZE);
124 memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES); 121 memset(selfsim, 0, sizeof(uint64_t) * COCSEP_CLASSES);
125 122
126 arg = (dfsarg_cocsep_t) { 123 arg = (dfsarg_cocsep_t) {
@@ -163,7 +160,6 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg)
163 uint8_t m, t, tinv, olddepth; 160 uint8_t m, t, tinv, olddepth;
164 uint32_t cc; 161 uint32_t cc;
165 int64_t i, ii; 162 int64_t i, ii;
166 uint64_t sim;
167 cube_fast_t d; 163 cube_fast_t d;
168 dfsarg_cocsep_t nextarg; 164 dfsarg_cocsep_t nextarg;
169 165
@@ -208,10 +204,10 @@ TODO description
208generating fixed table with h=0, k=4 204generating fixed table with h=0, k=4
209*/ 205*/
210_static size_t 206_static size_t
211gendata_h48(void *buf, uint8_t h) 207gendata_h48(void *buf, uint8_t h, uint8_t maxdepth)
212{ 208{
213 const int k = 1; /* TODO: other cases? */ 209 const int k = 4; /* TODO: other cases? */
214 uint32_t *buf32, *info, *cocsepdata; 210 uint32_t j, *buf32, *info, *cocsepdata;
215 bfsarg_esep_t arg; 211 bfsarg_esep_t arg;
216 int64_t sc, cc, tot; 212 int64_t sc, cc, tot;
217 uint64_t selfsim[COCSEP_CLASSES]; 213 uint64_t selfsim[COCSEP_CLASSES];
@@ -219,17 +215,14 @@ gendata_h48(void *buf, uint8_t h)
219 size_t cocsepsize; 215 size_t cocsepsize;
220 216
221 cocsepsize = gendata_cocsep(buf, selfsim, crep); 217 cocsepsize = gendata_cocsep(buf, selfsim, crep);
222 DBG_ASSERT(cocsepsize == COCSEP_FULLSIZE, 0,
223 "gendata_h48: error computing cocsep data\n");
224
225 cocsepdata = (uint32_t *)buf; 218 cocsepdata = (uint32_t *)buf;
226 buf32 = cocsepdata + cocsepsize; 219 buf32 = cocsepdata + cocsepsize/4;
227 info = buf32 + ESEP_TABLESIZE(h, k); 220 info = buf32 + (ESEP_TABLESIZE(h, k) / sizeof(uint32_t));
228 memset(buf32, 0xFFU, sizeof(uint32_t) * ESEP_TABLESIZE(h, k)); 221 memset(buf32, 0xFFU, ESEP_TABLESIZE(h, k));
229 memset(info, 0, sizeof(uint32_t) * ESEP_INFOSIZE);
230 222
231 sc = coord_h48(cubetofast(solved), cocsepdata, h); 223 sc = coord_h48(cubetofast(solved), cocsepdata, h);
232 set_esep_pval(buf32, sc, 0); 224 set_esep_pval(buf32, sc, 0);
225 info[1] = 1;
233 arg = (bfsarg_esep_t) { 226 arg = (bfsarg_esep_t) {
234 .h = h, 227 .h = h,
235 .cocsepdata = cocsepdata, 228 .cocsepdata = cocsepdata,
@@ -237,7 +230,11 @@ gendata_h48(void *buf, uint8_t h)
237 .crep = crep, 230 .crep = crep,
238 .selfsim = selfsim 231 .selfsim = selfsim
239 }; 232 };
240 for (tot = 1, arg.depth = 1, cc = 0; tot < ESEP_MAX(h); arg.depth++) { 233 for (
234 tot = 1, arg.depth = 1, cc = 0;
235 tot < ESEP_MAX(h) && arg.depth <= maxdepth;
236 arg.depth++
237 ) {
241 DBG_LOG("esep: generating depth %" PRIu8 "\n", arg.depth); 238 DBG_LOG("esep: generating depth %" PRIu8 "\n", arg.depth);
242 cc = gendata_esep_bfs(&arg); 239 cc = gendata_esep_bfs(&arg);
243 tot += cc; 240 tot += cc;
@@ -245,7 +242,15 @@ gendata_h48(void *buf, uint8_t h)
245 DBG_LOG("found %" PRIu64 "\n", cc); 242 DBG_LOG("found %" PRIu64 "\n", cc);
246 } 243 }
247 244
248 return COCSEP_FULLSIZE + cc; 245 info[0] = arg.depth-1;
246
247 DBG_LOG("h48 pruning table computed\n");
248 DBG_LOG("Maximum pruning value: %" PRIu32 "\n", info[0]);
249 DBG_LOG("Pruning value distribution:\n");
250 for (j = 0; j <= info[0]; j++)
251 DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, info[j+1]);
252
253 return COCSEP_FULLSIZE + ESEP_TABLESIZE(h, k) + 4*(info[0]+2);
249} 254}
250 255
251_static uint64_t 256_static uint64_t
diff --git a/test/102_gendata_h48/00_all.in b/test/102_gendata_h48/00_all.in
deleted file mode 100644
index e69de29..0000000
--- a/test/102_gendata_h48/00_all.in
+++ /dev/null
diff --git a/test/102_gendata_h48/00_all.out b/test/102_gendata_h48/00_all.out
deleted file mode 100644
index deba01f..0000000
--- a/test/102_gendata_h48/00_all.out
+++ /dev/null
@@ -1 +0,0 @@
1something
diff --git a/test/102_gendata_h48/00_h_0.in b/test/102_gendata_h48/00_h_0.in
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/test/102_gendata_h48/00_h_0.in
@@ -0,0 +1 @@
0
diff --git a/test/102_gendata_h48/00_h_0.out b/test/102_gendata_h48/00_h_0.out
new file mode 100644
index 0000000..8c629f8
--- /dev/null
+++ b/test/102_gendata_h48/00_h_0.out
@@ -0,0 +1,23 @@
159903545
2
3cocsepdata:
4Classes: 3393
5Max value: 9
60: 1
71: 6
82: 63
93: 468
104: 3068
115: 15438
126: 53814
137: 71352
148: 8784
159: 96
16
17h48:
180: 1
191: 1
202: 4
213: 34
224: 331
235: 3608
diff --git a/test/102_gendata_h48/gendata_h48_tests.c b/test/102_gendata_h48/gendata_h48_tests.c
index f918e4d..35e6f42 100644
--- a/test/102_gendata_h48/gendata_h48_tests.c
+++ b/test/102_gendata_h48/gendata_h48_tests.c
@@ -1,18 +1,37 @@
1#include "../test.h" 1#include "../test.h"
2 2
3#define H 0 3#define MAXH 1
4#define SIZE (120000000 << (H)) 4#define MAXDEPTH 5
5#define COCSEPSIZE 1119792
6#define ETABLESIZE(h) (((3393 * 495 * 70) >> 1) << (h))
7#define SIZE (60000000 << MAXH)
5 8
6uint32_t buf[SIZE]; 9uint32_t buf[SIZE/4];
7 10
8size_t gendata_h48(void *, uint8_t); 11size_t gendata_h48(void *, uint8_t, uint8_t);
9 12
10int main(void) { 13int main(void) {
14 char str[STRLENMAX];
15 uint8_t h, i;
16 uint32_t *h48info;
11 size_t result; 17 size_t result;
12 18
13 result = gendata_h48(buf, H); 19 fgets(str, STRLENMAX, stdin);
20 h = atoi(str);
21 result = gendata_h48(buf, h, MAXDEPTH);
22 h48info = buf + (ETABLESIZE(h) + COCSEPSIZE) / 4;
14 23
15 printf("nothing\n"); 24 printf("%zu\n\n", result);
25
26 printf("cocsepdata:\n");
27 printf("Classes: %" PRIu32 "\n", buf[COCSEPSIZE/4-12]);
28 printf("Max value: %" PRIu32 "\n", buf[COCSEPSIZE/4-11]);
29 for (i = 0; i < 10; i++)
30 printf("%" PRIu32 ": %" PRIu32 "\n", i, buf[COCSEPSIZE/4-10+i]);
31
32 printf("\nh48:\n");
33 for (i = 0; i < MAXDEPTH+1; i++)
34 printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]);
16 35
17 return 0; 36 return 0;
18} 37}

Generated with cgit - Back to sebastiano.tronto.net