diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-08-27 21:44:19 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-08-27 21:44:19 +0200 |
| commit | 1983bacfbb84e2a410ebe663ac1fa7c1b22eb096 (patch) | |
| tree | 106ddc90aa7aa92558415f89a8b39076ab508364 /tools/001_gendata_h48h0k4 | |
| parent | 30526a688c8c8e9ffed34a07e959322f75bc639b (diff) | |
| parent | b5efa2c7bfa259f1b9f5afa68349e2742427de80 (diff) | |
| download | nissy-core-1983bacfbb84e2a410ebe663ac1fa7c1b22eb096.tar.gz nissy-core-1983bacfbb84e2a410ebe663ac1fa7c1b22eb096.zip | |
Merge branch 'master' of tronto.net:h48
Diffstat (limited to 'tools/001_gendata_h48h0k4')
| -rw-r--r-- | tools/001_gendata_h48h0k4/gendata_h48h0k4.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tools/001_gendata_h48h0k4/gendata_h48h0k4.c b/tools/001_gendata_h48h0k4/gendata_h48h0k4.c new file mode 100644 index 0000000..a73f818 --- /dev/null +++ b/tools/001_gendata_h48h0k4/gendata_h48h0k4.c | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | #include "../timerun.h" | ||
| 2 | #include "../../src/nissy.h" | ||
| 3 | |||
| 4 | #define MAXDEPTH 20 | ||
| 5 | #define HVALUE 0 | ||
| 6 | #define OPTIONS "0;4;20" | ||
| 7 | #define LONGOPTIONS "h = 0, k = 4, max depth = 20" | ||
| 8 | |||
| 9 | #define COCSEPSIZE 1119792 | ||
| 10 | #define ETABLESIZE(h) (((3393 * 495 * 70) >> 1) << (size_t)(h)) | ||
| 11 | |||
| 12 | uint32_t expected[21] = { | ||
| 13 | [0] = 1, | ||
| 14 | [1] = 1, | ||
| 15 | [2] = 4, | ||
| 16 | [3] = 34, | ||
| 17 | [4] = 331, | ||
| 18 | [5] = 3612, | ||
| 19 | [6] = 41605, | ||
| 20 | [7] = 474128, | ||
| 21 | [8] = 4953846, | ||
| 22 | [9] = 34776317, | ||
| 23 | [10] = 68566704, | ||
| 24 | [11] = 8749194, | ||
| 25 | [12] = 1673, | ||
| 26 | }; | ||
| 27 | |||
| 28 | char *buf; | ||
| 29 | |||
| 30 | void run(void) { | ||
| 31 | uint32_t *h48info, x; | ||
| 32 | int i; | ||
| 33 | int64_t s; | ||
| 34 | |||
| 35 | s = nissy_gendata("h48", OPTIONS, buf); | ||
| 36 | |||
| 37 | if (s == -1) { | ||
| 38 | printf("Error generating table\n"); | ||
| 39 | } else { | ||
| 40 | printf("Succesfully generated %" PRId64 " bytes. Table:\n", s); | ||
| 41 | h48info = (uint32_t *)buf + (ETABLESIZE(HVALUE) + COCSEPSIZE) / 4; | ||
| 42 | for (i = 0; i < MAXDEPTH+1 && h48info[i+1]; i++) { | ||
| 43 | x = h48info[i+1]; | ||
| 44 | printf("%d:\t%" PRIu32, i, x); | ||
| 45 | if (x != expected[i]) | ||
| 46 | printf(" <--- Error! Expected: %" PRIu32 "\n", | ||
| 47 | expected[i]); | ||
| 48 | printf("\n"); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | int main(void) { | ||
| 54 | int64_t size; | ||
| 55 | |||
| 56 | nissy_setlogger(log_stderr); | ||
| 57 | |||
| 58 | size = nissy_datasize("h48", OPTIONS); | ||
| 59 | if (size == -1) { | ||
| 60 | printf("gendata_h48 benchmark: error in datasize\n"); | ||
| 61 | return 1; | ||
| 62 | } | ||
| 63 | |||
| 64 | buf = malloc(size); | ||
| 65 | |||
| 66 | timerun(run, "benchmark gendata_h48 " LONGOPTIONS); | ||
| 67 | |||
| 68 | free(buf); | ||
| 69 | |||
| 70 | return 0; | ||
| 71 | } | ||
