aboutsummaryrefslogtreecommitdiff
path: root/old
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-04-01 10:11:50 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-04-01 10:11:50 +0200
commit2cff8fe8f8d18d0d6ed51d5a25b43b20ddf20901 (patch)
tree8a6392cfc78266c1b01830ce4a94f3dc1c90d0e0 /old
parentd46f5be9da49b4f353ac1aa09cc54c223f4fe5b5 (diff)
downloadnissy-core-2cff8fe8f8d18d0d6ed51d5a25b43b20ddf20901.tar.gz
nissy-core-2cff8fe8f8d18d0d6ed51d5a25b43b20ddf20901.zip
Performance improvement for gendata_cocsep
Diffstat (limited to 'old')
-rw-r--r--old/gendata_bfs_attempt.c153
1 files changed, 153 insertions, 0 deletions
diff --git a/old/gendata_bfs_attempt.c b/old/gendata_bfs_attempt.c
new file mode 100644
index 0000000..4cd5ae9
--- /dev/null
+++ b/old/gendata_bfs_attempt.c
@@ -0,0 +1,153 @@
1_static size_t gendata_cocsep(void *);
2_static uint32_t dfs_cocsep(cube_fast_t, uint8_t, uint8_t, uint32_t *);
3
4/*
5Each element of the cocsep table is a uint32_t used as follows:
6 - Lowest 8-bit block: pruning value
7 - Second-lower 8-bit block: "ttrep" (transformation to representative)
8 - Top 16-bit block: symcoord value
9After the data as described above, more auxiliary information is appended:
10 - A uint32_t representing the number of symmetry classes
11 - A uint32_t representing the highest value of the pruning table
12 - One uint32_t for each "line" of the pruning table, representing the number
13 of positions having that pruning value.
14*/
15_static size_t
16gendata_cocsep(void *buf)
17{
18 uint32_t *buf32, cc;
19 uint64_t i64;
20 uint16_t n;
21 uint8_t i, j;
22 size_t tablesize;
23
24 tablesize = _3p7 << 7U;
25
26 buf32 = (uint32_t *)buf;
27 memset(buf32, 0xFFU, 4*tablesize);
28 memset(buf32 + tablesize, 0, 21*4);
29
30/* New impl BFS
31
32 uint32_t nold = 0, nnew = 0;
33 uint64_t coord;
34 uint8_t m, olddepth;
35 cube_fast_t c, d, oldlevel[100000], newlevel[100000];
36 newlevel[0] = cubetofast(solvedcube());
37 nnew = 1;
38 buf32[coord_fast_cocsep(newlevel[0])] = UFr << 8U;
39 n = 1;
40 DBG_LOG("gendata_cocsep: found 1 position at depth 0\n");
41 for (i = 1; i < 10; i++) {
42 DBG_LOG("gendata_cocsep: generating depth %" PRIu8 "\n", i);
43 memcpy(oldlevel, newlevel, nnew * sizeof(cube_fast_t));
44 nold = nnew;
45 nnew = 0;
46 for (j = 0; j < nold; j++) {
47 _foreach_move(m, oldlevel[j], newlevel[nnew],
48 coord = coord_fast_cocsep(newlevel[nnew]);
49 olddepth = buf32[coord] & 0xFFU;
50 buf32[coord] = i;
51 nnew += olddepth > i;
52 )
53 }
54 DBG_LOG("found %" PRIu32 "\n", nnew);
55 }
56
57End new impl BFS */
58
59 /* Pruning values */
60 buf32[tablesize+1] = 9U; /* Known max pruning value */
61 for (i = 0, cc = 0; i < 10; i++) {
62 DBG_LOG("gendata_cocsep: generating depth %" PRIu8 "\n", i);
63 cc = dfs_cocsep(cubetofast(solvedcube()), 0, i, buf32);
64 buf32[tablesize+i+2] = cc;
65 DBG_LOG("found %" PRIu32 "\n", cc);
66 }
67
68 /* Symmetries */
69 for (i64 = 0, n = 0; i64 < tablesize; i64++) {
70 }
71 buf32[tablesize] = (uint32_t)n;
72
73 DBG_LOG("cocsep data computed, %" PRIu32 " symmetry classes\n", n);
74 DBG_LOG("Maximum pruning value: %" PRIu32 "\n", buf32[tablesize+1]);
75 DBG_LOG("Pruning value distribution:\n");
76 for (j = 0; j < 10; j++)
77 DBG_LOG("%" PRIu8 ":\t%" PRIu32 "\n", j, buf32[tablesize+j+2]);
78
79 return 4*(tablesize + 11);
80}
81
82_static uint32_t
83dfs_cocsep(cube_fast_t c, uint8_t depth, uint8_t maxdepth, uint32_t *buf32)
84{
85 uint8_t m, olddepth;
86 uint32_t update, cc;
87 uint64_t i;
88 cube_fast_t d;
89
90 i = coord_fast_cocsep(c);
91 olddepth = (uint8_t)(buf32[i] & 0xFFU);
92 if (olddepth < depth)
93 return 0;
94
95 if (depth == maxdepth) {
96 update = (buf32[i] & 0xFFU) == 0xFFU;
97 buf32[i] = depth;
98 return update;
99 }
100
101 cc = 0;
102 _foreach_move(m, c, d,
103 cc += dfs_cocsep(d, depth+1, maxdepth, buf32);
104 )
105
106 return cc;
107}
108
109/*
110_static uint32_t
111dfs_cocsep(
112 cube_fast_t c,
113 uint8_t depth,
114 uint8_t maxdepth,
115 uint16_t *n,
116 uint32_t *buf32
117)
118{
119 uint8_t m, t, tinv, olddepth;
120 uint32_t cc, oldvalue;
121 uint64_t i;
122 cube_fast_t d;
123
124 oldvalue = buf32[coord_fast_cocsep(c)];
125 if (depth == maxdepth) {
126 if ((oldvalue & 0xFFU) != 0xFFU)
127 return 0;
128
129 for (t = 0, cc = 0; t < 48; t++) {
130 d = transform(c, t);
131 i = coord_fast_cocsep(d);
132 tinv = inverse_trans(t);
133 if ((buf32[i] & 0xFFU) == 0xFFU)
134 cc++;
135 buf32[i] = (*n << 16U) | (tinv << 8U) | depth;
136 }
137 (*n)++;
138
139 return cc;
140 }
141
142 olddepth = (uint8_t)(oldvalue & 0xFFU);
143 if (olddepth != depth)
144 return 0;
145
146 cc = 0;
147 _foreach_move(m, c, d,
148 cc += dfs_cocsep(d, depth+1, maxdepth, n, buf32);
149 )
150
151 return cc;
152}
153*/

Generated with cgit - Back to sebastiano.tronto.net