aboutsummaryrefslogtreecommitdiff
path: root/src/solvers
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-09-27 16:37:55 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-09-27 16:37:55 +0200
commit41be2d294e5b6f55d485d635065096f274bc89c1 (patch)
treed1906840307eedc503e66f6aebf746717f57d1ed /src/solvers
parent15fe089b3e625cb6d3a19dee661f4fc9c6224699 (diff)
downloadnissy-core-41be2d294e5b6f55d485d635065096f274bc89c1.tar.gz
nissy-core-41be2d294e5b6f55d485d635065096f274bc89c1.zip
Made table derivation tool more flexible
So apparently my RAM is broken. That took me a while to figure out. While I get a replacement, I have to restrict myself to a weaker test for the intermediate tables: instead of deriving them from the huge table and checking that they are the same, I have to derive a small h0k2 table from the intermediate ones and check that it is correct. This is not a 100% proof of correctness, but it is good enough (and much faster).
Diffstat (limited to 'src/solvers')
-rw-r--r--src/solvers/h48/gendata_h48.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index b1ae38c..d7f4c92 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -389,7 +389,7 @@ gendata_h48k2(gendata_h48_arg_t *arg)
389 [8] = 10, 389 [8] = 10,
390 [9] = 10, 390 [9] = 10,
391 [10] = 10, 391 [10] = 10,
392 [11] = 10 392 [11] = 8
393 }; 393 };
394 394
395 uint8_t t, *table; 395 uint8_t t, *table;
@@ -609,14 +609,17 @@ STATIC_INLINE bool
609gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg) 609gendata_h48k2_dfs_stop(cube_t cube, int8_t depth, h48k2_dfs_arg_t *arg)
610{ 610{
611 uint64_t val; 611 uint64_t val;
612 int64_t coord; 612 int64_t coord, mutex;
613 int8_t oldval; 613 int8_t oldval;
614 614
615 if (arg->h == 0 || arg->h == 11) { 615 if (arg->h == 0 || arg->h == 11) {
616 /* We are in the "real coordinate" case, we can stop 616 /* We are in the "real coordinate" case, we can stop
617 if this coordinate has already been visited */ 617 if this coordinate has already been visited */
618 coord = coord_h48(cube, arg->cocsepdata, arg->h); 618 coord = coord_h48(cube, arg->cocsepdata, arg->h);
619 mutex = H48_INDEX(coord, arg->k) % CHUNKS;
620 pthread_mutex_lock(arg->table_mutex[mutex]);
619 oldval = get_h48_pval(arg->table, coord, arg->k); 621 oldval = get_h48_pval(arg->table, coord, arg->k);
622 pthread_mutex_unlock(arg->table_mutex[mutex]);
620 return oldval <= depth; 623 return oldval <= depth;
621 } else { 624 } else {
622 /* With 0 < k < 11 we do not have a "real coordinate". 625 /* With 0 < k < 11 we do not have a "real coordinate".
@@ -747,7 +750,7 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
747 /* Technically this step is redundant, except that we 750 /* Technically this step is redundant, except that we
748 need selfsim and crep */ 751 need selfsim and crep */
749 cocsepsize = gendata_cocsep(buf, arg.selfsim, arg.crep); 752 cocsepsize = gendata_cocsep(buf, arg.selfsim, arg.crep);
750 arg.h48buf = (char *)buf + cocsepsize; 753 arg.h48buf = (uint8_t *)buf + cocsepsize;
751 h48size = H48_TABLESIZE(h, arg.k) + INFOSIZE; 754 h48size = H48_TABLESIZE(h, arg.k) + INFOSIZE;
752 755
753 if (buf == NULL) 756 if (buf == NULL)
@@ -765,17 +768,17 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
765 goto gendata_h48_derive_error; 768 goto gendata_h48_derive_error;
766 } 769 }
767 770
768 h48full = (uint8_t *)fulltable + INFOSIZE; 771 h48full = (uint8_t *)fulltable + cocsepsize + INFOSIZE;
769 h48derive = (uint8_t *)arg.h48buf + INFOSIZE; 772 h48derive = (uint8_t *)arg.h48buf + INFOSIZE;
770 memset(h48derive, 0xFF, H48_TABLESIZE(h, arg.k)); 773 memset(h48derive, 0xFF, H48_TABLESIZE(h, arg.k));
771 memset(arg.info.distribution, 0, 774 memset(arg.info.distribution, 0,
772 INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); 775 INFO_DISTRIBUTION_LEN * sizeof(uint64_t));
773 776
774 h48max = H48_COORDMAX(11); 777 h48max = H48_COORDMAX(fulltableinfo.h48h);
775 for (i = 0; i < h48max; i++) { 778 for (i = 0; i < h48max; i++) {
776 if (i % INT64_C(1000000000) == 0) 779 if (i % INT64_C(1000000000) == 0 && i > 0)
777 LOG("Processing %" PRId64 "th coordinate\n", i); 780 LOG("Processing %" PRId64 "th coordinate\n", i);
778 j = i >> (int64_t)(11-h); 781 j = i >> (int64_t)(fulltableinfo.h48h - h);
779 val_full = get_h48_pval(h48full, i, arg.k); 782 val_full = get_h48_pval(h48full, i, arg.k);
780 val_derive = get_h48_pval(h48derive, j, arg.k); 783 val_derive = get_h48_pval(h48derive, j, arg.k);
781 set_h48_pval(h48derive, j, arg.k, MIN(val_full, val_derive)); 784 set_h48_pval(h48derive, j, arg.k, MIN(val_full, val_derive));
@@ -783,7 +786,7 @@ gendata_h48_derive(uint8_t h, const void *fulltable, void *buf)
783 786
784 getdistribution_h48(h48derive, arg.info.distribution, h, arg.k); 787 getdistribution_h48(h48derive, arg.info.distribution, h, arg.k);
785 788
786 if (!writetableinfo(&arg.info, buf)) { 789 if (!writetableinfo(&arg.info, arg.h48buf)) {
787 LOG("gendata_h48_derive: could not write info for table\n"); 790 LOG("gendata_h48_derive: could not write info for table\n");
788 goto gendata_h48_derive_error; 791 goto gendata_h48_derive_error;
789 } 792 }

Generated with cgit - Back to sebastiano.tronto.net