diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-14 19:10:39 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-10-14 20:21:07 +0200 |
| commit | 3c12def93ed667548bcd9c534c31ec31bfefb8e0 (patch) | |
| tree | e47695e828792aec00d73d9e9e34cb6cd3a666f4 /src/solvers/h48/gendata_h48.h | |
| parent | 87de946c47b3b5ef0fb0c5f2289bb033bc8d9038 (diff) | |
| download | nissy-core-3c12def93ed667548bcd9c534c31ec31bfefb8e0.tar.gz nissy-core-3c12def93ed667548bcd9c534c31ec31bfefb8e0.zip | |
Fallback tables
Diffstat (limited to 'src/solvers/h48/gendata_h48.h')
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 2a4469f..4400011 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -67,17 +67,20 @@ gendata_h48short(gendata_h48short_arg_t *arg) | |||
| 67 | STATIC int64_t | 67 | STATIC int64_t |
| 68 | gendata_h48(gendata_h48_arg_t *arg) | 68 | gendata_h48(gendata_h48_arg_t *arg) |
| 69 | { | 69 | { |
| 70 | uint64_t size; | 70 | uint64_t size, cocsepsize, h48size, fallbacksize; |
| 71 | void *cocsepdata_offset; | 71 | void *cocsepdata_offset; |
| 72 | size_t cocsepsize; | 72 | tableinfo_t cocsepinfo, h48info; |
| 73 | tableinfo_t cocsepinfo; | 73 | gendata_h48_arg_t arg_h0k4; |
| 74 | 74 | ||
| 75 | if (arg == NULL) { | 75 | if (arg == NULL) { |
| 76 | LOG("Error computing H48 data: arg is NULL.\n"); | 76 | LOG("Error computing H48 data: arg is NULL.\n"); |
| 77 | return NISSY_ERROR_UNKNOWN; | 77 | return NISSY_ERROR_UNKNOWN; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | size = 2*INFOSIZE + COCSEP_FULLSIZE + H48_TABLESIZE(arg->h, arg->k); | 80 | cocsepsize = COCSEP_FULLSIZE; |
| 81 | h48size = INFOSIZE + H48_TABLESIZE(arg->h, arg->k); | ||
| 82 | fallbacksize = arg->k == 2 ? INFOSIZE + H48_TABLESIZE(0, 4) : 0; | ||
| 83 | size = cocsepsize + h48size + fallbacksize; | ||
| 81 | 84 | ||
| 82 | if (arg->buf == NULL) | 85 | if (arg->buf == NULL) |
| 83 | return size; /* Dry-run */ | 86 | return size; /* Dry-run */ |
| @@ -89,7 +92,7 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 89 | return NISSY_ERROR_BUFFER_SIZE; | 92 | return NISSY_ERROR_BUFFER_SIZE; |
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | cocsepsize = gendata_cocsep(arg->buf, arg->selfsim, arg->crep); | 95 | gendata_cocsep(arg->buf, arg->selfsim, arg->crep); |
| 93 | 96 | ||
| 94 | cocsepdata_offset = (char *)arg->buf + INFOSIZE; | 97 | cocsepdata_offset = (char *)arg->buf + INFOSIZE; |
| 95 | arg->cocsepdata = (uint32_t *)cocsepdata_offset; | 98 | arg->cocsepdata = (uint32_t *)cocsepdata_offset; |
| @@ -121,6 +124,32 @@ gendata_h48(gendata_h48_arg_t *arg) | |||
| 121 | return NISSY_ERROR_UNKNOWN; | 124 | return NISSY_ERROR_UNKNOWN; |
| 122 | } | 125 | } |
| 123 | 126 | ||
| 127 | if (arg->k == 2) { | ||
| 128 | arg_h0k4 = *arg; | ||
| 129 | arg_h0k4.h = 0; | ||
| 130 | arg_h0k4.k = 4; | ||
| 131 | arg_h0k4.base = 0; | ||
| 132 | arg_h0k4.maxdepth = 20; | ||
| 133 | arg_h0k4.buf_size = arg->buf_size - h48size; | ||
| 134 | arg_h0k4.buf = (char *)arg->buf + cocsepsize + h48size; | ||
| 135 | arg_h0k4.h48buf = (char *)arg->h48buf + h48size; | ||
| 136 | |||
| 137 | gendata_h48h0k4(&arg_h0k4); | ||
| 138 | |||
| 139 | if (readtableinfo_n(arg->buf_size, arg->buf, 2, &h48info) | ||
| 140 | != NISSY_OK) { | ||
| 141 | LOG("gendata_h48: could not read info for h48 table\n"); | ||
| 142 | return NISSY_ERROR_UNKNOWN; | ||
| 143 | } | ||
| 144 | |||
| 145 | h48info.next = h48size; | ||
| 146 | if (writetableinfo(&h48info, arg->buf_size - cocsepsize, | ||
| 147 | (char *)arg->buf + cocsepsize) != NISSY_OK) { | ||
| 148 | LOG("gendata_h48: could not write info for h48 table\n"); | ||
| 149 | return NISSY_ERROR_UNKNOWN; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 124 | return size; | 153 | return size; |
| 125 | } | 154 | } |
| 126 | 155 | ||
| @@ -198,7 +227,7 @@ gendata_h48h0k4(gendata_h48_arg_t *arg) | |||
| 198 | } | 227 | } |
| 199 | 228 | ||
| 200 | arg->info.maxvalue = d - 1; | 229 | arg->info.maxvalue = d - 1; |
| 201 | bufsize = arg->buf_size - COCSEP_FULLSIZE - INFOSIZE; | 230 | bufsize = arg->buf_size - COCSEP_FULLSIZE; |
| 202 | writetableinfo(&arg->info, bufsize, arg->h48buf); | 231 | writetableinfo(&arg->info, bufsize, arg->h48buf); |
| 203 | } | 232 | } |
| 204 | 233 | ||
| @@ -377,7 +406,7 @@ gendata_h48k2(gendata_h48_arg_t *arg) | |||
| 377 | arg->info.distribution[t]++; | 406 | arg->info.distribution[t]++; |
| 378 | } | 407 | } |
| 379 | 408 | ||
| 380 | bufsize = arg->buf_size - COCSEP_FULLSIZE - INFOSIZE; | 409 | bufsize = arg->buf_size - COCSEP_FULLSIZE; |
| 381 | writetableinfo(&arg->info, bufsize, arg->h48buf); | 410 | writetableinfo(&arg->info, bufsize, arg->h48buf); |
| 382 | } | 411 | } |
| 383 | 412 | ||
| @@ -619,7 +648,6 @@ getdistribution_h48( | |||
| 619 | distr[val]++; | 648 | distr[val]++; |
| 620 | } | 649 | } |
| 621 | } | 650 | } |
| 622 | |||
| 623 | STATIC const uint32_t * | 651 | STATIC const uint32_t * |
| 624 | get_cocsepdata_constptr(const void *data) | 652 | get_cocsepdata_constptr(const void *data) |
| 625 | { | 653 | { |
