aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md1
-rwxr-xr-xnissybin327920 -> 332048 bytes
-rw-r--r--src/cubetypes.h1
-rw-r--r--src/pruning.c89
-rw-r--r--src/symcoord.c3
5 files changed, 72 insertions, 22 deletions
diff --git a/TODO.md b/TODO.md
index 180866f..4fe3a5d 100644
--- a/TODO.md
+++ b/TODO.md
@@ -5,7 +5,6 @@ It's more of a personal reminder than anything else.
5 5
6## For version 2.1 6## For version 2.1
7### Moving coordinates 7### Moving coordinates
8* parallelize genptable_fixnasty
9* general cleanup 8* general cleanup
10### Changes to Step and Solve 9### Changes to Step and Solve
11* add a list of "helper" coordinates to every step 10* add a list of "helper" coordinates to every step
diff --git a/nissy b/nissy
index ac231a0..3f0c768 100755
--- a/nissy
+++ b/nissy
Binary files differ
diff --git a/src/cubetypes.h b/src/cubetypes.h
index 109c6c4..ad9c627 100644
--- a/src/cubetypes.h
+++ b/src/cubetypes.h
@@ -173,6 +173,7 @@ coordinate
173 CoordTransformer transform; 173 CoordTransformer transform;
174 SymData * sd; 174 SymData * sd;
175 TransFinder tfind; /* TODO: should be easy to remove */ 175 TransFinder tfind; /* TODO: should be easy to remove */
176 Coordinate * base; /* TODO: part of refactor */
176}; 177};
177 178
178struct 179struct
diff --git a/src/pruning.c b/src/pruning.c
index 6cab7e7..3ca9fac 100644
--- a/src/pruning.c
+++ b/src/pruning.c
@@ -6,9 +6,10 @@
6static int findchunk(PruneData *pd, int nchunks, uint64_t i); 6static int findchunk(PruneData *pd, int nchunks, uint64_t i);
7static void genptable_bfs(PruneData *pd, int d, int nt, int nc); 7static void genptable_bfs(PruneData *pd, int d, int nt, int nc);
8static void genptable_compress(PruneData *pd); 8static void genptable_compress(PruneData *pd);
9static void genptable_fixnasty(PruneData *pd, int d); 9static void genptable_fixnasty(PruneData *pd, int d, int nthreads);
10static void genptable_setbase(PruneData *pd); 10static void genptable_setbase(PruneData *pd);
11static void * instance_bfs(void *arg); 11static void * instance_bfs(void *arg);
12static void * instance_fixnasty(void *arg);
12static void ptable_update(PruneData *pd, Cube cube, int m); 13static void ptable_update(PruneData *pd, Cube cube, int m);
13static void ptable_update_index(PruneData *pd, uint64_t ind, int m); 14static void ptable_update_index(PruneData *pd, uint64_t ind, int m);
14static int ptableval_index(PruneData *pd, uint64_t ind); 15static int ptableval_index(PruneData *pd, uint64_t ind);
@@ -171,7 +172,7 @@ genptable(PruneData *pd, int nthreads)
171 ptable_update(pd, (Cube){0}, 0); 172 ptable_update(pd, (Cube){0}, 0);
172 pd->n = 1; 173 pd->n = 1;
173 oldn = 0; 174 oldn = 0;
174 genptable_fixnasty(pd, 0); 175 genptable_fixnasty(pd, 0, nthreads);
175 fprintf(stderr, "Depth %d done, generated %" 176 fprintf(stderr, "Depth %d done, generated %"
176 PRIu64 "\t(%" PRIu64 "/%" PRIu64 ")\n", 177 PRIu64 "\t(%" PRIu64 "/%" PRIu64 ")\n",
177 0, pd->n - oldn, pd->n, pd->coord->max); 178 0, pd->n - oldn, pd->n, pd->coord->max);
@@ -179,7 +180,7 @@ genptable(PruneData *pd, int nthreads)
179 pd->count[0] = pd->n; 180 pd->count[0] = pd->n;
180 for (d = 0; d < 15 && pd->n < pd->coord->max; d++) { 181 for (d = 0; d < 15 && pd->n < pd->coord->max; d++) {
181 genptable_bfs(pd, d, nthreads, nchunks); 182 genptable_bfs(pd, d, nthreads, nchunks);
182 genptable_fixnasty(pd, d+1); 183 genptable_fixnasty(pd, d+1, nthreads);
183 fprintf(stderr, "Depth %d done, generated %" 184 fprintf(stderr, "Depth %d done, generated %"
184 PRIu64 "\t(%" PRIu64 "/%" PRIu64 ")\n", 185 PRIu64 "\t(%" PRIu64 "/%" PRIu64 ")\n",
185 d+1, pd->n - oldn, pd->n, pd->coord->max); 186 d+1, pd->n - oldn, pd->n, pd->coord->max);
@@ -256,30 +257,31 @@ genptable_compress(PruneData *pd)
256} 257}
257 258
258static void 259static void
259genptable_fixnasty(PruneData *pd, int d) 260genptable_fixnasty(PruneData *pd, int d, int nthreads)
260{ 261{
261 uint64_t i, ii; 262 int i;
262 int j, n; 263 pthread_t t[nthreads];
263 Trans t, aux[NTRANS]; 264 ThreadDataGenpt td[nthreads];
265 pthread_mutex_t *upmtx;
264 266
265 if (pd->coord->tfind == NULL) 267 if (pd->coord->tfind == NULL)
266 return; 268 return;
267 269
268 for (i = 0; i < pd->coord->max; i++) { 270 upmtx = malloc(sizeof(pthread_mutex_t));
269 if (ptableval_index(pd, i) == d) { 271 pthread_mutex_init(upmtx, NULL);
270 if ((n = pd->coord->tfind(i, aux)) == 1) 272 for (i = 0; i < nthreads; i++) {
271 continue; 273 td[i].thid = i;
272 274 td[i].nthreads = nthreads;
273 for (j = 0; j < n; j++) { 275 td[i].pd = pd;
274 t = aux[j]; 276 td[i].d = d;
275 ii = pd->coord->transform(t, i); 277 td[i].upmutex = upmtx;
276 if (ptableval_index(pd, ii) > d) { 278 pthread_create(&t[i], NULL, instance_fixnasty, &td[i]);
277 ptable_update_index(pd, ii, d);
278 pd->n++;
279 }
280 }
281 }
282 } 279 }
280
281 for (i = 0; i < nthreads; i++)
282 pthread_join(t[i], NULL);
283
284 free(upmtx);
283} 285}
284 286
285static void 287static void
@@ -335,6 +337,51 @@ instance_bfs(void *arg)
335 } 337 }
336 } 338 }
337 } 339 }
340
341 pthread_mutex_lock(td->upmutex);
342 td->pd->n += updated;
343 pthread_mutex_unlock(td->upmutex);
344
345 return NULL;
346}
347
348static void *
349instance_fixnasty(void *arg)
350{
351 ThreadDataGenpt *td;
352 uint64_t i, ii, nb, blocksize, rmin, rmax, updated;
353 int j, n;
354 Trans t, aux[NTRANS];
355
356 td = (ThreadDataGenpt *)arg;
357 nb = td->pd->coord->max / td->pd->coord->base->max;
358 blocksize = (uint64_t)((nb / td->nthreads) * td->pd->coord->base->max);
359 rmin = ((uint64_t)td->thid) * blocksize;
360 rmax = td->thid == td->nthreads - 1 ?
361 td->pd->coord->max :
362 ((uint64_t)td->thid + 1) * blocksize;
363
364 updated = 0;
365 for (i = rmin; i < rmax; i++) {
366 if (ptableval_index(td->pd, i) == td->d) {
367 if ((n = td->pd->coord->tfind(i, aux)) == 1)
368 continue;
369
370 for (j = 0; j < n; j++) {
371 if ((t = aux[j]) == uf)
372 continue;
373 ii = td->pd->coord->transform(t, i);
374 if (ii < rmin || ii >= rmax)
375 fprintf(stderr,
376 "Error: transformed out of bound!\n");
377 if (ptableval_index(td->pd, ii) > td->d) {
378 ptable_update_index(td->pd, ii, td->d);
379 updated++;
380 }
381 }
382 }
383 }
384
338 pthread_mutex_lock(td->upmutex); 385 pthread_mutex_lock(td->upmutex);
339 td->pd->n += updated; 386 td->pd->n += updated;
340 pthread_mutex_unlock(td->upmutex); 387 pthread_mutex_unlock(td->upmutex);
diff --git a/src/symcoord.c b/src/symcoord.c
index c852ef2..20d7c28 100644
--- a/src/symcoord.c
+++ b/src/symcoord.c
@@ -106,6 +106,7 @@ coord_drud_sym16 = {
106 .index = index_drud_sym16, 106 .index = index_drud_sym16,
107 .move = move_drud_sym16, 107 .move = move_drud_sym16,
108 .max = POW3TO7 * CLASSES_EOFBEPOS_16, 108 .max = POW3TO7 * CLASSES_EOFBEPOS_16,
109 .base = &coord_eofbepos_sym16,
109 .transform = transform_drud_sym16, 110 .transform = transform_drud_sym16,
110 .tfind = tfind_drud_sym16, 111 .tfind = tfind_drud_sym16,
111}; 112};
@@ -115,6 +116,7 @@ coord_drudfin_noE_sym16 = {
115 .index = index_drudfin_noE_sym16, 116 .index = index_drudfin_noE_sym16,
116 .move = move_drudfin_noE_sym16, 117 .move = move_drudfin_noE_sym16,
117 .max = FACTORIAL8 * CLASSES_CP_16, 118 .max = FACTORIAL8 * CLASSES_CP_16,
119 .base = &coord_cp_sym16,
118 .transform = transform_drudfin_noE_sym16, 120 .transform = transform_drudfin_noE_sym16,
119 .tfind = tfind_drudfin_noE_sym16, 121 .tfind = tfind_drudfin_noE_sym16,
120}; 122};
@@ -124,6 +126,7 @@ coord_nxopt31 = {
124 .index = index_nxopt31, 126 .index = index_nxopt31,
125 .move = move_nxopt31, 127 .move = move_nxopt31,
126 .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16, 128 .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16,
129 .base = &coord_eofbepos_sym16,
127 .transform = transform_nxopt31, 130 .transform = transform_nxopt31,
128 .tfind = tfind_nxopt31, 131 .tfind = tfind_nxopt31,
129}; 132};

Generated with cgit - Back to sebastiano.tronto.net