diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-05-19 17:45:14 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-05-19 17:45:14 +0200 |
| commit | 62d87e063318cc4c842b1b2d8c184f48aeaf6659 (patch) | |
| tree | 832bf338232c477975bea69f7370ca13f350fb07 /src/solvers/h48/gendata_h48.h | |
| parent | 8b94d135429a9f3253cc7f25a1453b412065c4a0 (diff) | |
| download | nissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.tar.gz nissy-core-62d87e063318cc4c842b1b2d8c184f48aeaf6659.zip | |
Refactored checkdata
Relevant changes include:
- Changed the signature of nissy_checkdata().
- Removed expected_distribution.h from tools; this data is now included
in each solver's src/ code.
- Removed distribution check for cocsep; may add back later.
Diffstat (limited to 'src/solvers/h48/gendata_h48.h')
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 644ddc2..d1ab3bd 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -25,8 +25,6 @@ STATIC_INLINE uint8_t get_h48_pval_atomic( | |||
| 25 | STATIC_INLINE void set_h48_pval_atomic( | 25 | STATIC_INLINE void set_h48_pval_atomic( |
| 26 | _Atomic unsigned char *, int64_t, uint8_t, uint8_t); | 26 | _Atomic unsigned char *, int64_t, uint8_t, uint8_t); |
| 27 | 27 | ||
| 28 | size_t gendata_h48_derive(uint8_t, const unsigned char *, unsigned char *); | ||
| 29 | |||
| 30 | STATIC long long | 28 | STATIC long long |
| 31 | gendata_h48_dispatch( | 29 | gendata_h48_dispatch( |
| 32 | const char *solver, | 30 | const char *solver, |
| @@ -711,91 +709,3 @@ set_h48_pval_atomic( | |||
| 711 | table[H48_INDEX(i, k)] = (table[H48_INDEX(i, k)] & (~H48_MASK(i, k))) | 709 | table[H48_INDEX(i, k)] = (table[H48_INDEX(i, k)] & (~H48_MASK(i, k))) |
| 712 | | (val << H48_SHIFT(i, k)); | 710 | | (val << H48_SHIFT(i, k)); |
| 713 | } | 711 | } |
| 714 | |||
| 715 | size_t | ||
| 716 | gendata_h48_derive(uint8_t h, const unsigned char *fulltable, unsigned char *buf) | ||
| 717 | { | ||
| 718 | size_t cocsepsize, h48size; | ||
| 719 | uint8_t val_full, val_derive; | ||
| 720 | const unsigned char *h48full; | ||
| 721 | unsigned char *h48derive; | ||
| 722 | int64_t i, j, h48max; | ||
| 723 | uint64_t bufsize; | ||
| 724 | gendata_h48_arg_t arg; | ||
| 725 | tableinfo_t cocsepinfo, fulltableinfo; | ||
| 726 | |||
| 727 | /* Initializing values in case of error */ | ||
| 728 | /* TODO cleanup this */ | ||
| 729 | fulltableinfo.h48h = 11; | ||
| 730 | fulltableinfo.bits = 2; | ||
| 731 | fulltableinfo.base = 8; | ||
| 732 | |||
| 733 | int64_t TODOlarge = 999999999999; /* TODO: cleanup here */ | ||
| 734 | |||
| 735 | readtableinfo_n(TODOlarge, fulltable, 2, &fulltableinfo); | ||
| 736 | arg.h = h; | ||
| 737 | arg.k = fulltableinfo.bits; | ||
| 738 | arg.maxdepth = 20; | ||
| 739 | arg.buf = buf; | ||
| 740 | arg.cocsepdata = (uint32_t *)(buf + INFOSIZE); | ||
| 741 | arg.base = fulltableinfo.base; | ||
| 742 | arg.info = makeinfo_h48k2(&arg); | ||
| 743 | |||
| 744 | /* Technically this step is redundant, except that we | ||
| 745 | need selfsim and crep */ | ||
| 746 | cocsepsize = gendata_cocsep(buf, arg.selfsim, arg.crep); | ||
| 747 | arg.h48buf = (_Atomic unsigned char *)buf + cocsepsize; | ||
| 748 | h48size = H48_TABLESIZE(h, arg.k) + INFOSIZE; | ||
| 749 | |||
| 750 | if (buf == NULL) | ||
| 751 | goto gendata_h48_derive_return_size; | ||
| 752 | |||
| 753 | bufsize = COCSEP_FULLSIZE + INFOSIZE; | ||
| 754 | if (readtableinfo(bufsize, buf, &cocsepinfo) != NISSY_OK) { | ||
| 755 | LOG("[H48 derive gendata] Error: could not read info for " | ||
| 756 | "cocsep table\n"); | ||
| 757 | goto gendata_h48_derive_error; | ||
| 758 | } | ||
| 759 | |||
| 760 | cocsepinfo.next = cocsepsize; | ||
| 761 | bufsize = COCSEP_FULLSIZE + INFOSIZE; | ||
| 762 | if (writetableinfo(&cocsepinfo, bufsize, buf) != NISSY_OK) { | ||
| 763 | LOG("[H48 derive gendata] Error: could not write info for " | ||
| 764 | "cocsep table with updated 'next' value\n"); | ||
| 765 | goto gendata_h48_derive_error; | ||
| 766 | } | ||
| 767 | |||
| 768 | h48full = fulltable + cocsepsize + INFOSIZE; | ||
| 769 | h48derive = (unsigned char *)arg.h48buf + INFOSIZE; | ||
| 770 | memset(h48derive, 0xFF, H48_TABLESIZE(h, arg.k)); | ||
| 771 | memset(arg.info.distribution, 0, | ||
| 772 | INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); | ||
| 773 | |||
| 774 | h48max = H48_COORDMAX(fulltableinfo.h48h); | ||
| 775 | for (i = 0; i < h48max; i++) { | ||
| 776 | if (i % INT64_C(1000000000) == 0 && i > 0) | ||
| 777 | LOG("[H48 derive gendata] Processing %" PRId64 | ||
| 778 | "th coordinate\n", i); | ||
| 779 | j = i >> (int64_t)(fulltableinfo.h48h - h); | ||
| 780 | val_full = get_h48_pval(h48full, i, arg.k); | ||
| 781 | val_derive = get_h48_pval(h48derive, j, arg.k); | ||
| 782 | set_h48_pval( | ||
| 783 | h48derive, j, arg.k, MIN(val_full, val_derive)); | ||
| 784 | } | ||
| 785 | |||
| 786 | getdistribution(h48derive, arg.info.distribution, &arg.info); | ||
| 787 | |||
| 788 | bufsize = arg.buf_size - COCSEP_FULLSIZE - INFOSIZE; | ||
| 789 | if (writetableinfo(&arg.info, bufsize, (unsigned char *)arg.h48buf) | ||
| 790 | != NISSY_OK) { | ||
| 791 | LOG("H48 derive gendata] Error: could not write info " | ||
| 792 | "for table\n"); | ||
| 793 | goto gendata_h48_derive_error; | ||
| 794 | } | ||
| 795 | |||
| 796 | gendata_h48_derive_return_size: | ||
| 797 | return cocsepsize + h48size; | ||
| 798 | |||
| 799 | gendata_h48_derive_error: | ||
| 800 | return 0; | ||
| 801 | } | ||
