From c558c7989eaa0921f7b29ee274b325f4f6d97f8c Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 26 Aug 2024 21:42:50 +0200 Subject: Gendata added for h48k2, need to verify with new tool --- test/112_gen_h48short/00_depth_1.in | 28 ++++++++ test/112_gen_h48short/00_depth_1.out | 3 + test/112_gen_h48short/01_depth_3.in | 3 + test/112_gen_h48short/01_depth_3.out | 40 +++++++++++ test/112_gen_h48short/gen_h48short.c | 87 ++++++++++++++++++++++++ test/112_gendata_h48/00_h_0.in | 2 - test/112_gendata_h48/00_h_0.out | 23 ------- test/112_gendata_h48/gendata_h48_tests.c | 50 -------------- test/113_gen_h48short/00_depth_1.in | 28 -------- test/113_gen_h48short/00_depth_1.out | 3 - test/113_gen_h48short/01_depth_3.in | 3 - test/113_gen_h48short/01_depth_3.out | 40 ----------- test/113_gen_h48short/gen_h48short.c | 87 ------------------------ test/120_gendata_h48h0k4/00_h_0.in | 2 + test/120_gendata_h48h0k4/00_h_0.out | 23 +++++++ test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c | 50 ++++++++++++++ 16 files changed, 236 insertions(+), 236 deletions(-) create mode 100644 test/112_gen_h48short/00_depth_1.in create mode 100644 test/112_gen_h48short/00_depth_1.out create mode 100644 test/112_gen_h48short/01_depth_3.in create mode 100644 test/112_gen_h48short/01_depth_3.out create mode 100644 test/112_gen_h48short/gen_h48short.c delete mode 100644 test/112_gendata_h48/00_h_0.in delete mode 100644 test/112_gendata_h48/00_h_0.out delete mode 100644 test/112_gendata_h48/gendata_h48_tests.c delete mode 100644 test/113_gen_h48short/00_depth_1.in delete mode 100644 test/113_gen_h48short/00_depth_1.out delete mode 100644 test/113_gen_h48short/01_depth_3.in delete mode 100644 test/113_gen_h48short/01_depth_3.out delete mode 100644 test/113_gen_h48short/gen_h48short.c create mode 100644 test/120_gendata_h48h0k4/00_h_0.in create mode 100644 test/120_gendata_h48h0k4/00_h_0.out create mode 100644 test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c (limited to 'test') diff --git a/test/112_gen_h48short/00_depth_1.in b/test/112_gen_h48short/00_depth_1.in new file mode 100644 index 0000000..c86f15b --- /dev/null +++ b/test/112_gen_h48short/00_depth_1.in @@ -0,0 +1,28 @@ +73 +157 +1 + +For longer test: + +20000003 +20000023 +8 + +Short h48: generating depth 0 +found 1 +Short h48: generating depth 1 +found 1 +Short h48: generating depth 2 +found 4 +Short h48: generating depth 3 +found 34 +Short h48: generating depth 4 +found 333 +Short h48: generating depth 5 +found 3815 +Short h48: generating depth 6 +found 45382 +Short h48: generating depth 7 +found 548562 +Short h48: generating depth 8 +found 6839723 diff --git a/test/112_gen_h48short/00_depth_1.out b/test/112_gen_h48short/00_depth_1.out new file mode 100644 index 0000000..b0dba31 --- /dev/null +++ b/test/112_gen_h48short/00_depth_1.out @@ -0,0 +1,3 @@ +2 +0 0 +71075840 1 diff --git a/test/112_gen_h48short/01_depth_3.in b/test/112_gen_h48short/01_depth_3.in new file mode 100644 index 0000000..920e70a --- /dev/null +++ b/test/112_gen_h48short/01_depth_3.in @@ -0,0 +1,3 @@ +73 +157 +3 diff --git a/test/112_gen_h48short/01_depth_3.out b/test/112_gen_h48short/01_depth_3.out new file mode 100644 index 0000000..dbce376 --- /dev/null +++ b/test/112_gen_h48short/01_depth_3.out @@ -0,0 +1,40 @@ +40 +0 0 +70981632 3 +71075840 1 +71086080 3 +142067712 2 +218789888 3 +218884096 2 +283879424 2 +283899904 3 +283953152 3 +283973632 2 +360548808 3 +360835072 3 +473668032 3 +473956352 3 +499869696 3 +500011008 3 +598679552 3 +599109185 3 +662171648 3 +662601226 3 +724818316 3 +725106688 3 +790513664 3 +790607872 3 +904991108 3 +926726144 3 +928729088 3 +1009662340 3 +1088755203 3 +1171758595 3 +1206452224 3 +1206480896 3 +1277360128 3 +1277454336 3 +1403695492 3 +1403697540 3 +1403736452 3 +1403738500 3 diff --git a/test/112_gen_h48short/gen_h48short.c b/test/112_gen_h48short/gen_h48short.c new file mode 100644 index 0000000..335821a --- /dev/null +++ b/test/112_gen_h48short/gen_h48short.c @@ -0,0 +1,87 @@ +#include "../test.h" + +#define COCSEP_CLASSES 3393 +#define MAXPOS 200 + +typedef struct { + uint64_t n; + uint64_t capacity; + uint64_t randomizer; + uint64_t *table; + uint32_t *info; + uint32_t *cocsepdata; + uint32_t *h48data; + uint64_t selfsim[COCSEP_CLASSES]; + cube_t crep[COCSEP_CLASSES]; +} h48map_t; + +typedef struct { + uint64_t key; + uint64_t val; +} kvpair_t; + +typedef struct { + uint8_t maxdepth; + const uint32_t *cocsepdata; + const cube_t *crep; + const uint64_t *selfsim; + h48map_t *map; +} gendata_h48short_arg_t; + +void h48map_create(h48map_t *, uint64_t, uint64_t); +void h48map_destroy(h48map_t *); +kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); +size_t gendata_cocsep(void *, uint64_t *, cube_t *); +uint64_t gen_h48short(gendata_h48short_arg_t *); + +char str[STRLENMAX]; + +int compare(const void *x, const void *y) { + uint64_t a = ((kvpair_t *)x)->key; + uint64_t b = ((kvpair_t *)y)->key; + + if (a > b) return 1; + if (a == b) return 0; + return -1; +} + +uint64_t readl(void) { + fgets(str, STRLENMAX, stdin); + return atoll(str); +} + +void run(void) { + uint32_t cocsepdata[300000]; + h48map_t map; + uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES]; + kvpair_t kv, b[MAXPOS]; + gendata_h48short_arg_t arg; + cube_t crep[COCSEP_CLASSES]; + + capacity = readl(); + randomizer = readl(); + arg.maxdepth = readl(); + arg.cocsepdata = cocsepdata; + arg.crep = crep; + arg.selfsim = selfsim; + arg.map = ↦ + + h48map_create(&map, capacity, randomizer); + gendata_cocsep(cocsepdata, selfsim, crep); + gen_h48short(&arg); + + i = 0; + for (kv = h48map_nextkvpair(&map, &i), j = 0; + i != map.capacity && j < MAXPOS; + kv = h48map_nextkvpair(&map, &i) + ) { + b[j++] = kv; + } + qsort(b, j, sizeof(kvpair_t), compare); + + printf("%" PRIu64 "\n", map.n); + for (i = 0; i < j; i++) + printf("%" PRIu64 " %" PRIu64 "\n", b[i].key, b[i].val); + + h48map_destroy(&map); +} diff --git a/test/112_gendata_h48/00_h_0.in b/test/112_gendata_h48/00_h_0.in deleted file mode 100644 index cb6e5ed..0000000 --- a/test/112_gendata_h48/00_h_0.in +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/test/112_gendata_h48/00_h_0.out b/test/112_gendata_h48/00_h_0.out deleted file mode 100644 index 04e8bf6..0000000 --- a/test/112_gendata_h48/00_h_0.out +++ /dev/null @@ -1,23 +0,0 @@ -59903605 - -cocsepdata: -Classes: 3393 -Max value: 9 -0: 1 -1: 6 -2: 63 -3: 468 -4: 3068 -5: 15438 -6: 53814 -7: 71352 -8: 8784 -9: 96 - -h48: -0: 1 -1: 1 -2: 4 -3: 34 -4: 331 -5: 3612 diff --git a/test/112_gendata_h48/gendata_h48_tests.c b/test/112_gendata_h48/gendata_h48_tests.c deleted file mode 100644 index d6c6cb2..0000000 --- a/test/112_gendata_h48/gendata_h48_tests.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "../test.h" - -#define COCSEP_CLASSES 3393 -#define COCSEPSIZE 1119792 - -typedef struct { - uint8_t h; - uint8_t k; - uint8_t maxdepth; - void *buf; - uint32_t *info; - 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 *); - -void run(void) { - char str[STRLENMAX]; - uint8_t i; - gendata_h48_arg_t arg; - size_t result, sz; - - fgets(str, STRLENMAX, stdin); - arg.maxdepth = atoi(str); - fgets(str, STRLENMAX, stdin); - arg.h = atoi(str); - arg.k = 4; - - sz = gendata_h48(&arg); /* With buf = NULL returns data size */ - arg.buf = malloc(sz); - result = gendata_h48(&arg); - - 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("\nh48:\n"); - for (i = 0; i < arg.maxdepth+1; i++) - printf("%" PRIu32 ": %" PRIu32 "\n", i, arg.info[i+1]); - - free(arg.buf); -} diff --git a/test/113_gen_h48short/00_depth_1.in b/test/113_gen_h48short/00_depth_1.in deleted file mode 100644 index c86f15b..0000000 --- a/test/113_gen_h48short/00_depth_1.in +++ /dev/null @@ -1,28 +0,0 @@ -73 -157 -1 - -For longer test: - -20000003 -20000023 -8 - -Short h48: generating depth 0 -found 1 -Short h48: generating depth 1 -found 1 -Short h48: generating depth 2 -found 4 -Short h48: generating depth 3 -found 34 -Short h48: generating depth 4 -found 333 -Short h48: generating depth 5 -found 3815 -Short h48: generating depth 6 -found 45382 -Short h48: generating depth 7 -found 548562 -Short h48: generating depth 8 -found 6839723 diff --git a/test/113_gen_h48short/00_depth_1.out b/test/113_gen_h48short/00_depth_1.out deleted file mode 100644 index b0dba31..0000000 --- a/test/113_gen_h48short/00_depth_1.out +++ /dev/null @@ -1,3 +0,0 @@ -2 -0 0 -71075840 1 diff --git a/test/113_gen_h48short/01_depth_3.in b/test/113_gen_h48short/01_depth_3.in deleted file mode 100644 index 920e70a..0000000 --- a/test/113_gen_h48short/01_depth_3.in +++ /dev/null @@ -1,3 +0,0 @@ -73 -157 -3 diff --git a/test/113_gen_h48short/01_depth_3.out b/test/113_gen_h48short/01_depth_3.out deleted file mode 100644 index dbce376..0000000 --- a/test/113_gen_h48short/01_depth_3.out +++ /dev/null @@ -1,40 +0,0 @@ -40 -0 0 -70981632 3 -71075840 1 -71086080 3 -142067712 2 -218789888 3 -218884096 2 -283879424 2 -283899904 3 -283953152 3 -283973632 2 -360548808 3 -360835072 3 -473668032 3 -473956352 3 -499869696 3 -500011008 3 -598679552 3 -599109185 3 -662171648 3 -662601226 3 -724818316 3 -725106688 3 -790513664 3 -790607872 3 -904991108 3 -926726144 3 -928729088 3 -1009662340 3 -1088755203 3 -1171758595 3 -1206452224 3 -1206480896 3 -1277360128 3 -1277454336 3 -1403695492 3 -1403697540 3 -1403736452 3 -1403738500 3 diff --git a/test/113_gen_h48short/gen_h48short.c b/test/113_gen_h48short/gen_h48short.c deleted file mode 100644 index 335821a..0000000 --- a/test/113_gen_h48short/gen_h48short.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "../test.h" - -#define COCSEP_CLASSES 3393 -#define MAXPOS 200 - -typedef struct { - uint64_t n; - uint64_t capacity; - uint64_t randomizer; - uint64_t *table; - uint32_t *info; - uint32_t *cocsepdata; - uint32_t *h48data; - uint64_t selfsim[COCSEP_CLASSES]; - cube_t crep[COCSEP_CLASSES]; -} h48map_t; - -typedef struct { - uint64_t key; - uint64_t val; -} kvpair_t; - -typedef struct { - uint8_t maxdepth; - const uint32_t *cocsepdata; - const cube_t *crep; - const uint64_t *selfsim; - h48map_t *map; -} gendata_h48short_arg_t; - -void h48map_create(h48map_t *, uint64_t, uint64_t); -void h48map_destroy(h48map_t *); -kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); -size_t gendata_cocsep(void *, uint64_t *, cube_t *); -uint64_t gen_h48short(gendata_h48short_arg_t *); - -char str[STRLENMAX]; - -int compare(const void *x, const void *y) { - uint64_t a = ((kvpair_t *)x)->key; - uint64_t b = ((kvpair_t *)y)->key; - - if (a > b) return 1; - if (a == b) return 0; - return -1; -} - -uint64_t readl(void) { - fgets(str, STRLENMAX, stdin); - return atoll(str); -} - -void run(void) { - uint32_t cocsepdata[300000]; - h48map_t map; - uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES]; - kvpair_t kv, b[MAXPOS]; - gendata_h48short_arg_t arg; - cube_t crep[COCSEP_CLASSES]; - - capacity = readl(); - randomizer = readl(); - arg.maxdepth = readl(); - arg.cocsepdata = cocsepdata; - arg.crep = crep; - arg.selfsim = selfsim; - arg.map = ↦ - - h48map_create(&map, capacity, randomizer); - gendata_cocsep(cocsepdata, selfsim, crep); - gen_h48short(&arg); - - i = 0; - for (kv = h48map_nextkvpair(&map, &i), j = 0; - i != map.capacity && j < MAXPOS; - kv = h48map_nextkvpair(&map, &i) - ) { - b[j++] = kv; - } - qsort(b, j, sizeof(kvpair_t), compare); - - printf("%" PRIu64 "\n", map.n); - for (i = 0; i < j; i++) - printf("%" PRIu64 " %" PRIu64 "\n", b[i].key, b[i].val); - - h48map_destroy(&map); -} diff --git a/test/120_gendata_h48h0k4/00_h_0.in b/test/120_gendata_h48h0k4/00_h_0.in new file mode 100644 index 0000000..cb6e5ed --- /dev/null +++ b/test/120_gendata_h48h0k4/00_h_0.in @@ -0,0 +1,2 @@ +5 +0 diff --git a/test/120_gendata_h48h0k4/00_h_0.out b/test/120_gendata_h48h0k4/00_h_0.out new file mode 100644 index 0000000..04e8bf6 --- /dev/null +++ b/test/120_gendata_h48h0k4/00_h_0.out @@ -0,0 +1,23 @@ +59903605 + +cocsepdata: +Classes: 3393 +Max value: 9 +0: 1 +1: 6 +2: 63 +3: 468 +4: 3068 +5: 15438 +6: 53814 +7: 71352 +8: 8784 +9: 96 + +h48: +0: 1 +1: 1 +2: 4 +3: 34 +4: 331 +5: 3612 diff --git a/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c b/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c new file mode 100644 index 0000000..d6c6cb2 --- /dev/null +++ b/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c @@ -0,0 +1,50 @@ +#include "../test.h" + +#define COCSEP_CLASSES 3393 +#define COCSEPSIZE 1119792 + +typedef struct { + uint8_t h; + uint8_t k; + uint8_t maxdepth; + void *buf; + uint32_t *info; + 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 *); + +void run(void) { + char str[STRLENMAX]; + uint8_t i; + gendata_h48_arg_t arg; + size_t result, sz; + + fgets(str, STRLENMAX, stdin); + arg.maxdepth = atoi(str); + fgets(str, STRLENMAX, stdin); + arg.h = atoi(str); + arg.k = 4; + + sz = gendata_h48(&arg); /* With buf = NULL returns data size */ + arg.buf = malloc(sz); + result = gendata_h48(&arg); + + 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("\nh48:\n"); + for (i = 0; i < arg.maxdepth+1; i++) + printf("%" PRIu32 ": %" PRIu32 "\n", i, arg.info[i+1]); + + free(arg.buf); +} -- cgit v1.3