diff options
Diffstat (limited to 'tools/expected_distributions.h')
| -rw-r--r-- | tools/expected_distributions.h | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h index 0780cf8..60e7500 100644 --- a/tools/expected_distributions.h +++ b/tools/expected_distributions.h | |||
| @@ -58,7 +58,6 @@ uint64_t expected_h48[12][9][21] = { | |||
| 58 | [2] = 392789689, | 58 | [2] = 392789689, |
| 59 | [3] = 477195231, | 59 | [3] = 477195231, |
| 60 | }, | 60 | }, |
| 61 | |||
| 62 | }, | 61 | }, |
| 63 | [4] = { | 62 | [4] = { |
| 64 | [2] = { | 63 | [2] = { |
| @@ -126,6 +125,17 @@ uint64_t expected_h48[12][9][21] = { | |||
| 126 | }, | 125 | }, |
| 127 | }; | 126 | }; |
| 128 | 127 | ||
| 128 | uint64_t expected_eo[21] = { | ||
| 129 | [0] = 1, | ||
| 130 | [1] = 2, | ||
| 131 | [2] = 25, | ||
| 132 | [3] = 202, | ||
| 133 | [4] = 620, | ||
| 134 | [5] = 900, | ||
| 135 | [6] = 285, | ||
| 136 | [7] = 13, | ||
| 137 | }; | ||
| 138 | |||
| 129 | static bool | 139 | static bool |
| 130 | distribution_equal(const uint64_t *expected, const uint64_t *actual, int n) | 140 | distribution_equal(const uint64_t *expected, const uint64_t *actual, int n) |
| 131 | { | 141 | { |
| @@ -144,6 +154,18 @@ distribution_equal(const uint64_t *expected, const uint64_t *actual, int n) | |||
| 144 | return equal; | 154 | return equal; |
| 145 | } | 155 | } |
| 146 | 156 | ||
| 157 | STATIC bool | ||
| 158 | check_table(uint64_t *exp, tableinfo_t *info) | ||
| 159 | { | ||
| 160 | if (!distribution_equal(exp, info->distribution, info->maxvalue)) { | ||
| 161 | printf("ERROR! Distribution is incorrect\n"); | ||
| 162 | return false; | ||
| 163 | } | ||
| 164 | |||
| 165 | printf("Distribution is correct\n"); | ||
| 166 | return true; | ||
| 167 | } | ||
| 168 | |||
| 147 | static bool | 169 | static bool |
| 148 | check_cocsep(uint64_t data_size, const void *data) | 170 | check_cocsep(uint64_t data_size, const void *data) |
| 149 | { | 171 | { |
| @@ -169,6 +191,7 @@ unknown_h48(uint8_t h, uint8_t k) | |||
| 169 | STATIC bool | 191 | STATIC bool |
| 170 | check_distribution(const char *solver, uint64_t data_size, const void *data) | 192 | check_distribution(const char *solver, uint64_t data_size, const void *data) |
| 171 | { | 193 | { |
| 194 | const char *str; | ||
| 172 | tableinfo_t info = {0}; | 195 | tableinfo_t info = {0}; |
| 173 | 196 | ||
| 174 | if (!strncmp(solver, "h48", 3)) { | 197 | if (!strncmp(solver, "h48", 3)) { |
| @@ -184,14 +207,20 @@ check_distribution(const char *solver, uint64_t data_size, const void *data) | |||
| 184 | if (unknown_h48(info.h48h, info.bits)) | 207 | if (unknown_h48(info.h48h, info.bits)) |
| 185 | goto check_distribution_unknown; | 208 | goto check_distribution_unknown; |
| 186 | 209 | ||
| 187 | if (!distribution_equal(expected_h48[info.h48h][info.bits], | 210 | return check_table(expected_h48[info.h48h][info.bits], &info); |
| 188 | info.distribution, info.maxvalue)) { | 211 | } |
| 189 | printf("ERROR! h48 distribution is incorrect\n"); | ||
| 190 | return false; | ||
| 191 | } | ||
| 192 | 212 | ||
| 193 | printf("h48 distribution is correct\n"); | 213 | if (!strncmp(solver, "coord_", 6)) { |
| 194 | return true; | 214 | readtableinfo(data_size, data, &info); |
| 215 | if (!strncmp(info.solver, "coord helper table for ", 23)) | ||
| 216 | readtableinfo_n(data_size, data, 2, &info); | ||
| 217 | |||
| 218 | str = info.solver + 22; /* "coordinate solver for COORD" */ | ||
| 219 | if (!strcmp(str, "EO")) { | ||
| 220 | return check_table(expected_eo, &info); | ||
| 221 | } else { | ||
| 222 | goto check_distribution_unknown; | ||
| 223 | } | ||
| 195 | } | 224 | } |
| 196 | 225 | ||
| 197 | check_distribution_unknown: | 226 | check_distribution_unknown: |
