From 70d3a3de3a2fdef7e47b2bd510261d69390a3a9c Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 10 Sep 2024 19:43:05 +0200 Subject: New tableinfo for gendata_h48, still work to do --- test/120_gendata_h48h0k4/00_h_0.out | 2 +- test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c | 60 +++++++++++++++++++----- 2 files changed, 49 insertions(+), 13 deletions(-) (limited to 'test/120_gendata_h48h0k4') 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 @@ -59903605 +59904493 cocsepdata: 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 @@ #include "../test.h" -#define COCSEP_CLASSES 3393 -#define COCSEPSIZE 1119792 +#define COCSEP_CLASSES 3393 +#define INFOSIZE 512 +#define INFO_SOLVER_STRLEN 100 +#define INFO_DISTRIBUTION_LEN 21 + +typedef struct { + char solver[INFO_SOLVER_STRLEN]; + uint64_t type; + uint64_t infosize; + uint64_t fullsize; + uint64_t hash; + uint64_t entries; + uint64_t classes; /* Used only by cocsepdata, for now */ + uint8_t bits; + uint8_t base; + uint8_t maxvalue; + uint64_t next; + uint64_t distribution[INFO_DISTRIBUTION_LEN]; +} tableinfo_t; typedef struct { uint8_t h; uint8_t k; uint8_t maxdepth; + tableinfo_t info; void *buf; - uint32_t *info; + void *h48buf; uint32_t *cocsepdata; - uint32_t *h48data; uint64_t selfsim[COCSEP_CLASSES]; cube_t crep[COCSEP_CLASSES]; } gendata_h48_arg_t; int64_t gendata_h48(gendata_h48_arg_t *); +bool readtableinfo(const void *, tableinfo_t *); void run(void) { char str[STRLENMAX]; uint8_t i; gendata_h48_arg_t arg; size_t result, sz; + tableinfo_t cinfo, hinfo; + void *h48buf; fgets(str, STRLENMAX, stdin); arg.maxdepth = atoi(str); @@ -30,21 +50,37 @@ void run(void) { arg.k = 4; sz = gendata_h48(&arg); /* With buf = NULL returns data size */ - arg.buf = malloc(sz); + arg.buf = malloc(sz+23); +/* +TODO: the +23 is a workaround for a bug that I don't understand and seems +to happen only with gcc. Hopefully this gets fixed when switching to 8-bit. +*/ + result = gendata_h48(&arg); + if (!readtableinfo(arg.buf, &cinfo)) { + printf("Error reading cocsep info\n"); + goto end; + } + + h48buf = (char *)arg.buf + cinfo.next; + if (!readtableinfo(h48buf, &hinfo)) { + printf("Error reading h48 info\n"); + goto end; + } + printf("%zu\n\n", result); printf("cocsepdata:\n"); - printf("Classes: %" PRIu32 "\n", arg.cocsepdata[COCSEPSIZE/4-12]); - printf("Max value: %" PRIu32 "\n", arg.cocsepdata[COCSEPSIZE/4-11]); - for (i = 0; i < 10; i++) - printf("%" PRIu32 ": %" PRIu32 "\n", - i, arg.cocsepdata[COCSEPSIZE/4-10+i]); + printf("Classes: %" PRIu64 "\n", cinfo.classes); + printf("Max value: %" PRIu8 "\n", cinfo.maxvalue); + for (i = 0; i <= cinfo.maxvalue; i++) + printf("%" PRIu32 ": %" PRIu64 "\n", i, cinfo.distribution[i]); printf("\nh48:\n"); - for (i = 0; i < arg.maxdepth+1; i++) - printf("%" PRIu32 ": %" PRIu32 "\n", i, arg.info[i+1]); + for (i = 0; i <= hinfo.maxvalue; i++) + printf("%" PRIu32 ": %" PRIu64 "\n", i, hinfo.distribution[i]); +end: free(arg.buf); } -- cgit v1.3