diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-10 19:43:05 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-10 19:43:05 +0200 |
| commit | 70d3a3de3a2fdef7e47b2bd510261d69390a3a9c (patch) | |
| tree | 2c545953d0b61b37c4f281cd47981e9350b5c09b /test/120_gendata_h48h0k4 | |
| parent | 1f4900a3cc6ca74f94b73e224d14a09d52c4549c (diff) | |
| download | nissy-core-70d3a3de3a2fdef7e47b2bd510261d69390a3a9c.tar.gz nissy-core-70d3a3de3a2fdef7e47b2bd510261d69390a3a9c.zip | |
New tableinfo for gendata_h48, still work to do
Diffstat (limited to 'test/120_gendata_h48h0k4')
| -rw-r--r-- | test/120_gendata_h48h0k4/00_h_0.out | 2 | ||||
| -rw-r--r-- | test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c | 60 |
2 files changed, 49 insertions, 13 deletions
diff --git a/test/120_gendata_h48h0k4/00_h_0.out b/test/120_gendata_h48h0k4/00_h_0.out index 04e8bf6..7d70463 100644 --- a/test/120_gendata_h48h0k4/00_h_0.out +++ b/test/120_gendata_h48h0k4/00_h_0.out | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | 59903605 | 1 | 59904493 |
| 2 | 2 | ||
| 3 | cocsepdata: | 3 | cocsepdata: |
| 4 | Classes: 3393 | 4 | Classes: 3393 |
diff --git a/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c b/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c index d6c6cb2..bc3488c 100644 --- a/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c +++ b/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c | |||
| @@ -1,27 +1,47 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | #define COCSEP_CLASSES 3393 | 3 | #define COCSEP_CLASSES 3393 |
| 4 | #define COCSEPSIZE 1119792 | 4 | #define INFOSIZE 512 |
| 5 | #define INFO_SOLVER_STRLEN 100 | ||
| 6 | #define INFO_DISTRIBUTION_LEN 21 | ||
| 7 | |||
| 8 | typedef struct { | ||
| 9 | char solver[INFO_SOLVER_STRLEN]; | ||
| 10 | uint64_t type; | ||
| 11 | uint64_t infosize; | ||
| 12 | uint64_t fullsize; | ||
| 13 | uint64_t hash; | ||
| 14 | uint64_t entries; | ||
| 15 | uint64_t classes; /* Used only by cocsepdata, for now */ | ||
| 16 | uint8_t bits; | ||
| 17 | uint8_t base; | ||
| 18 | uint8_t maxvalue; | ||
| 19 | uint64_t next; | ||
| 20 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; | ||
| 21 | } tableinfo_t; | ||
| 5 | 22 | ||
| 6 | typedef struct { | 23 | typedef struct { |
| 7 | uint8_t h; | 24 | uint8_t h; |
| 8 | uint8_t k; | 25 | uint8_t k; |
| 9 | uint8_t maxdepth; | 26 | uint8_t maxdepth; |
| 27 | tableinfo_t info; | ||
| 10 | void *buf; | 28 | void *buf; |
| 11 | uint32_t *info; | 29 | void *h48buf; |
| 12 | uint32_t *cocsepdata; | 30 | uint32_t *cocsepdata; |
| 13 | uint32_t *h48data; | ||
| 14 | uint64_t selfsim[COCSEP_CLASSES]; | 31 | uint64_t selfsim[COCSEP_CLASSES]; |
| 15 | cube_t crep[COCSEP_CLASSES]; | 32 | cube_t crep[COCSEP_CLASSES]; |
| 16 | } gendata_h48_arg_t; | 33 | } gendata_h48_arg_t; |
| 17 | 34 | ||
| 18 | int64_t gendata_h48(gendata_h48_arg_t *); | 35 | int64_t gendata_h48(gendata_h48_arg_t *); |
| 36 | bool readtableinfo(const void *, tableinfo_t *); | ||
| 19 | 37 | ||
| 20 | void run(void) { | 38 | void run(void) { |
| 21 | char str[STRLENMAX]; | 39 | char str[STRLENMAX]; |
| 22 | uint8_t i; | 40 | uint8_t i; |
| 23 | gendata_h48_arg_t arg; | 41 | gendata_h48_arg_t arg; |
| 24 | size_t result, sz; | 42 | size_t result, sz; |
| 43 | tableinfo_t cinfo, hinfo; | ||
| 44 | void *h48buf; | ||
| 25 | 45 | ||
| 26 | fgets(str, STRLENMAX, stdin); | 46 | fgets(str, STRLENMAX, stdin); |
| 27 | arg.maxdepth = atoi(str); | 47 | arg.maxdepth = atoi(str); |
| @@ -30,21 +50,37 @@ void run(void) { | |||
| 30 | arg.k = 4; | 50 | arg.k = 4; |
| 31 | 51 | ||
| 32 | sz = gendata_h48(&arg); /* With buf = NULL returns data size */ | 52 | sz = gendata_h48(&arg); /* With buf = NULL returns data size */ |
| 33 | arg.buf = malloc(sz); | 53 | arg.buf = malloc(sz+23); |
| 54 | /* | ||
| 55 | TODO: the +23 is a workaround for a bug that I don't understand and seems | ||
| 56 | to happen only with gcc. Hopefully this gets fixed when switching to 8-bit. | ||
| 57 | */ | ||
| 58 | |||
| 34 | result = gendata_h48(&arg); | 59 | result = gendata_h48(&arg); |
| 35 | 60 | ||
| 61 | if (!readtableinfo(arg.buf, &cinfo)) { | ||
| 62 | printf("Error reading cocsep info\n"); | ||
| 63 | goto end; | ||
| 64 | } | ||
| 65 | |||
| 66 | h48buf = (char *)arg.buf + cinfo.next; | ||
| 67 | if (!readtableinfo(h48buf, &hinfo)) { | ||
| 68 | printf("Error reading h48 info\n"); | ||
| 69 | goto end; | ||
| 70 | } | ||
| 71 | |||
| 36 | printf("%zu\n\n", result); | 72 | printf("%zu\n\n", result); |
| 37 | 73 | ||
| 38 | printf("cocsepdata:\n"); | 74 | printf("cocsepdata:\n"); |
| 39 | printf("Classes: %" PRIu32 "\n", arg.cocsepdata[COCSEPSIZE/4-12]); | 75 | printf("Classes: %" PRIu64 "\n", cinfo.classes); |
| 40 | printf("Max value: %" PRIu32 "\n", arg.cocsepdata[COCSEPSIZE/4-11]); | 76 | printf("Max value: %" PRIu8 "\n", cinfo.maxvalue); |
| 41 | for (i = 0; i < 10; i++) | 77 | for (i = 0; i <= cinfo.maxvalue; i++) |
| 42 | printf("%" PRIu32 ": %" PRIu32 "\n", | 78 | printf("%" PRIu32 ": %" PRIu64 "\n", i, cinfo.distribution[i]); |
| 43 | i, arg.cocsepdata[COCSEPSIZE/4-10+i]); | ||
| 44 | 79 | ||
| 45 | printf("\nh48:\n"); | 80 | printf("\nh48:\n"); |
| 46 | for (i = 0; i < arg.maxdepth+1; i++) | 81 | for (i = 0; i <= hinfo.maxvalue; i++) |
| 47 | printf("%" PRIu32 ": %" PRIu32 "\n", i, arg.info[i+1]); | 82 | printf("%" PRIu32 ": %" PRIu64 "\n", i, hinfo.distribution[i]); |
| 48 | 83 | ||
| 84 | end: | ||
| 49 | free(arg.buf); | 85 | free(arg.buf); |
| 50 | } | 86 | } |
