aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-12-23 19:01:33 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-12-23 19:01:33 +0100
commit4fb970ad4e7d0558f7bf32dbad2333dbf3cb3ab4 (patch)
treef8cf70973ed3fb78816e89bd9034c983b68b6062
parent4dddac9e257433a8e2f5f763d91470a7e05ff680 (diff)
downloadnissy-4fb970ad4e7d0558f7bf32dbad2333dbf3cb3ab4.tar.gz
nissy-4fb970ad4e7d0558f7bf32dbad2333dbf3cb3ab4.zip
Fixes for yesterday's commit
-rw-r--r--TODO.md2
-rwxr-xr-xnissybin321808 -> 321808 bytes
-rw-r--r--src/commands.c2
-rw-r--r--src/pruning.c30
-rw-r--r--src/shell.c6
-rw-r--r--src/steps.c5
6 files changed, 33 insertions, 12 deletions
diff --git a/TODO.md b/TODO.md
index 5ffef7c..ea4a94d 100644
--- a/TODO.md
+++ b/TODO.md
@@ -60,6 +60,8 @@ It's more of a personal reminder than anything else.
60### Performance 60### Performance
61* solve (allow_next): filter out based on base_move; only check once for each 61* solve (allow_next): filter out based on base_move; only check once for each
62 triple of moves; how to deal with different movesets? 62 triple of moves; how to deal with different movesets?
63
64### Other optimal solvers
63* try htr corners + edges in slice but not oriented (300Mb table); 65* try htr corners + edges in slice but not oriented (300Mb table);
64 de Bondt's trick does not work, but I can use full symmetry and 66 de Bondt's trick does not work, but I can use full symmetry and
65 take advantage of the fact that it is a subset invariant under half-turns 67 take advantage of the fact that it is a subset invariant under half-turns
diff --git a/nissy b/nissy
index 9b10f0b..efdbd4e 100755
--- a/nissy
+++ b/nissy
Binary files differ
diff --git a/src/commands.c b/src/commands.c
index 9a2ad51..01671ee 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -322,7 +322,7 @@ help_exec(CommandArgs *args)
322 "available commands.\n" 322 "available commands.\n"
323 "See the manual page for more details. The manual" 323 "See the manual page for more details. The manual"
324 " page is available with \"man nissy\" on a UNIX" 324 " page is available with \"man nissy\" on a UNIX"
325 " system (such a Linux or MacOS) or in pdf and html" 325 " system (such as Linux or MacOS) or in pdf and html"
326 " format in the docs folder.\n" 326 " format in the docs folder.\n"
327 "Nissy is available for free at " 327 "Nissy is available for free at "
328 "https://github.com/sebastianotronto/nissy\n" 328 "https://github.com/sebastianotronto/nissy\n"
diff --git a/src/pruning.c b/src/pruning.c
index 9fdc32e..5c74e1e 100644
--- a/src/pruning.c
+++ b/src/pruning.c
@@ -127,19 +127,25 @@ findchunk(PruneData *pd, int nchunks, uint64_t i)
127void 127void
128genptable(PruneData *pd, int nthreads) 128genptable(PruneData *pd, int nthreads)
129{ 129{
130 bool compact;
130 int d, nchunks; 131 int d, nchunks;
131 uint64_t oldn; 132 uint64_t oldn, sz;
132 133
133 if (pd->generated) 134 if (pd->generated)
134 return; 135 return;
135 136
136 /* TODO: check if memory is enough, otherwise maybe exit gracefully? */ 137 /* TODO: check if memory is enough, otherwise maybe exit gracefully? */
137 pd->ptable = malloc(ptablesize(pd) * sizeof(entry_group_t)); 138 sz = ptablesize(pd) * (pd->compact ? 2 : 1);
139 pd->ptable = malloc(sz * sizeof(entry_group_t));
138 140
139 if (read_ptable_file(pd)) { 141 if (read_ptable_file(pd)) {
140 pd->generated = true; 142 pd->generated = true;
141 return; 143 return;
142 } 144 }
145
146 /* For the first steps we proceed the same way for compact and not */
147 compact = pd->compact;
148 pd->compact = false;
143 pd->generated = true; 149 pd->generated = true;
144 150
145 nchunks = MIN(ptablesize(pd), 100000); 151 nchunks = MIN(ptablesize(pd), 100000);
@@ -169,7 +175,7 @@ genptable(PruneData *pd, int nthreads)
169 fprintf(stderr, "Pruning table generated!\n"); 175 fprintf(stderr, "Pruning table generated!\n");
170 176
171 genptable_setbase(pd); 177 genptable_setbase(pd);
172 if (pd->compact) 178 if (compact)
173 genptable_compress(pd); 179 genptable_compress(pd);
174 180
175 if (!write_ptable_file(pd)) 181 if (!write_ptable_file(pd))
@@ -217,18 +223,22 @@ genptable_compress(PruneData *pd)
217 uint64_t i, j; 223 uint64_t i, j;
218 entry_group_t mask, v; 224 entry_group_t mask, v;
219 225
220 pd->compact = false; 226 fprintf(stderr, "Compressing table to 2 bits per entry\n");
227
221 for (i = 0; i < pd->coord->max; i += ENTRIES_PER_GROUP_COMPACT) { 228 for (i = 0; i < pd->coord->max; i += ENTRIES_PER_GROUP_COMPACT) {
222 mask = 0; 229 mask = (entry_group_t)0;
223 for (j = 0; j < ENTRIES_PER_GROUP_COMPACT; j++) { 230 for (j = 0; j < ENTRIES_PER_GROUP_COMPACT; j++) {
231 if (i+j >= pd->coord->max)
232 break;
224 val = ptableval_index(pd, i+j) - pd->base; 233 val = ptableval_index(pd, i+j) - pd->base;
225 v = MIN(3, MAX(0, val)); 234 v = (entry_group_t)MIN(3, MAX(0, val));
226 mask |= v << (2*j); 235 mask |= v << (2*j);
227 } 236 }
228 pd->ptable[i/ENTRIES_PER_GROUP_COMPACT] = mask; 237 pd->ptable[i/ENTRIES_PER_GROUP_COMPACT] = mask;
229 } 238 }
239
230 pd->compact = true; 240 pd->compact = true;
231 realloc(pd->ptable, sizeof(entry_group_t) * ptablesize(pd)); 241 pd->ptable = realloc(pd->ptable, sizeof(entry_group_t)*ptablesize(pd));
232} 242}
233 243
234static void 244static void
@@ -390,9 +400,9 @@ ptableval_index(PruneData *pd, uint64_t ind)
390 } 400 }
391 401
392 e = pd->compact ? ENTRIES_PER_GROUP_COMPACT : ENTRIES_PER_GROUP; 402 e = pd->compact ? ENTRIES_PER_GROUP_COMPACT : ENTRIES_PER_GROUP;
393 m = pd->compact ? 3 : 15; 403 m = (entry_group_t)(pd->compact ? 3 : 15);
394 404
395 sh = 4 * (ind % e); 405 sh = (ind % e) * (pd->compact ? 2 : 4);
396 mask = m << sh; 406 mask = m << sh;
397 i = ind/e; 407 i = ind/e;
398 408
@@ -402,7 +412,7 @@ ptableval_index(PruneData *pd, uint64_t ind)
402 if (ret) 412 if (ret)
403 ret += pd->base; 413 ret += pd->base;
404 else 414 else
405 ret = ptableval_index(pd->fallback, ind % pd->fbmod); 415 ret = ptableval_index(pd->fallback, ind / pd->fbmod);
406 } 416 }
407 417
408 return ret; 418 return ret;
diff --git a/src/shell.c b/src/shell.c
index 5fb18bc..6d2de94 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -97,6 +97,12 @@ launch(bool batchmode)
97int 97int
98main(int argc, char *argv[]) 98main(int argc, char *argv[])
99{ 99{
100/*
101 init_movesets();
102 init_symcoord();
103 print_ptable(&pd_nxopt31_HTM);
104*/
105
100 if (argc > 1) { 106 if (argc > 1) {
101 if (!strcmp(argv[1], "-b")) { 107 if (!strcmp(argv[1], "-b")) {
102 launch(true); 108 launch(true);
diff --git a/src/steps.c b/src/steps.c
index 0357e69..2517d16 100644
--- a/src/steps.c
+++ b/src/steps.c
@@ -1497,6 +1497,9 @@ prepare_step(Step *step, SolveOptions *opts)
1497 fprintf(stderr, "Step is final, NISS not used (-n ignored)\n"); 1497 fprintf(stderr, "Step is final, NISS not used (-n ignored)\n");
1498 } 1498 }
1499 1499
1500 for (i = 0; i < step->ntables; i++) 1500 for (i = 0; i < step->ntables; i++) {
1501 genptable(step->tables[i], opts->nthreads); 1501 genptable(step->tables[i], opts->nthreads);
1502 if (step->tables[i]->compact)
1503 genptable(step->tables[i]->fallback, opts->nthreads);
1504 }
1502} 1505}

Generated with cgit - Back to sebastiano.tronto.net