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 | |
| 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')
| -rw-r--r-- | test/090_tables_readwrite/00_table.in | 1 | ||||
| -rw-r--r-- | test/090_tables_readwrite/00_table.out | 1 | ||||
| -rw-r--r-- | test/090_tables_readwrite/tables_readwrite_tests.c | 5 | ||||
| -rw-r--r-- | test/100_gendata_cocsep/00_all.out | 2 | ||||
| -rw-r--r-- | test/100_gendata_cocsep/gendata_cocsep_tests.c | 35 | ||||
| -rw-r--r-- | test/101_cocsep_transform_invariant/cocsep_transform_invariant.c | 9 | ||||
| -rw-r--r-- | test/102_cocsep_selfsim/cocsep_selfsim_tests.c | 7 | ||||
| -rw-r--r-- | test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c | 2 | ||||
| -rw-r--r-- | test/104_cocsep_ttrep/cocsep_ttrep_tests.c | 10 | ||||
| -rw-r--r-- | test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c | 7 | ||||
| -rw-r--r-- | test/112_gen_h48short/gen_h48short_tests.c (renamed from test/112_gen_h48short/gen_h48short.c) | 9 | ||||
| -rw-r--r-- | test/120_gendata_h48h0k4/00_h_0.out | 2 | ||||
| -rw-r--r-- | test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c | 60 |
13 files changed, 115 insertions, 35 deletions
diff --git a/test/090_tables_readwrite/00_table.in b/test/090_tables_readwrite/00_table.in index f286968..579736a 100644 --- a/test/090_tables_readwrite/00_table.in +++ b/test/090_tables_readwrite/00_table.in | |||
| @@ -5,6 +5,7 @@ Test solver | |||
| 5 | 100000000000 | 5 | 100000000000 |
| 6 | 12345678912345 | 6 | 12345678912345 |
| 7 | 399999999998 | 7 | 399999999998 |
| 8 | 3393 | ||
| 8 | 2 | 9 | 2 |
| 9 | 0 | 10 | 0 |
| 10 | 20 | 11 | 20 |
diff --git a/test/090_tables_readwrite/00_table.out b/test/090_tables_readwrite/00_table.out index f286968..579736a 100644 --- a/test/090_tables_readwrite/00_table.out +++ b/test/090_tables_readwrite/00_table.out | |||
| @@ -5,6 +5,7 @@ Test solver | |||
| 5 | 100000000000 | 5 | 100000000000 |
| 6 | 12345678912345 | 6 | 12345678912345 |
| 7 | 399999999998 | 7 | 399999999998 |
| 8 | 3393 | ||
| 8 | 2 | 9 | 2 |
| 9 | 0 | 10 | 0 |
| 10 | 20 | 11 | 20 |
diff --git a/test/090_tables_readwrite/tables_readwrite_tests.c b/test/090_tables_readwrite/tables_readwrite_tests.c index f3162ea..32d171a 100644 --- a/test/090_tables_readwrite/tables_readwrite_tests.c +++ b/test/090_tables_readwrite/tables_readwrite_tests.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | #define INFOSIZE 512 | 3 | #define INFOSIZE 512 |
| 4 | #define INFO_SOLVER_STRLEN 20 | 4 | #define INFO_SOLVER_STRLEN 100 |
| 5 | #define INFO_DISTRIBUTION_LEN 21 | 5 | #define INFO_DISTRIBUTION_LEN 21 |
| 6 | 6 | ||
| 7 | typedef struct { | 7 | typedef struct { |
| @@ -11,6 +11,7 @@ typedef struct { | |||
| 11 | uint64_t fullsize; | 11 | uint64_t fullsize; |
| 12 | uint64_t hash; | 12 | uint64_t hash; |
| 13 | uint64_t entries; | 13 | uint64_t entries; |
| 14 | uint64_t classes; | ||
| 14 | uint8_t bits; | 15 | uint8_t bits; |
| 15 | uint8_t base; | 16 | uint8_t base; |
| 16 | uint8_t maxvalue; | 17 | uint8_t maxvalue; |
| @@ -45,6 +46,7 @@ tableinfo_t test_readinfo(void) { | |||
| 45 | ret.fullsize = readn(); | 46 | ret.fullsize = readn(); |
| 46 | ret.hash = readn(); | 47 | ret.hash = readn(); |
| 47 | ret.entries = readn(); | 48 | ret.entries = readn(); |
| 49 | ret.classes = readn(); | ||
| 48 | ret.bits = (uint8_t)readn(); | 50 | ret.bits = (uint8_t)readn(); |
| 49 | ret.base = (uint8_t)readn(); | 51 | ret.base = (uint8_t)readn(); |
| 50 | ret.maxvalue = (uint8_t)readn(); | 52 | ret.maxvalue = (uint8_t)readn(); |
| @@ -69,6 +71,7 @@ void test_writeinfo(tableinfo_t info) { | |||
| 69 | printf("%" PRIu64 "\n", info.fullsize); | 71 | printf("%" PRIu64 "\n", info.fullsize); |
| 70 | printf("%" PRIu64 "\n", info.hash); | 72 | printf("%" PRIu64 "\n", info.hash); |
| 71 | printf("%" PRIu64 "\n", info.entries); | 73 | printf("%" PRIu64 "\n", info.entries); |
| 74 | printf("%" PRIu64 "\n", info.classes); | ||
| 72 | printf("%" PRIu8 "\n", info.bits); | 75 | printf("%" PRIu8 "\n", info.bits); |
| 73 | printf("%" PRIu8 "\n", info.base); | 76 | printf("%" PRIu8 "\n", info.base); |
| 74 | printf("%" PRIu8 "\n", info.maxvalue); | 77 | printf("%" PRIu8 "\n", info.maxvalue); |
diff --git a/test/100_gendata_cocsep/00_all.out b/test/100_gendata_cocsep/00_all.out index e14b938..82eb6c2 100644 --- a/test/100_gendata_cocsep/00_all.out +++ b/test/100_gendata_cocsep/00_all.out | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | 1119792 | 1 | 1120256 |
| 2 | Classes: 3393 | 2 | Classes: 3393 |
| 3 | Max value: 9 | 3 | Max value: 9 |
| 4 | 0: 1 | 4 | 0: 1 |
diff --git a/test/100_gendata_cocsep/gendata_cocsep_tests.c b/test/100_gendata_cocsep/gendata_cocsep_tests.c index 4a29ebb..ee26de9 100644 --- a/test/100_gendata_cocsep/gendata_cocsep_tests.c +++ b/test/100_gendata_cocsep/gendata_cocsep_tests.c | |||
| @@ -1,20 +1,45 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | #define COCSEP_CLASSES 3393 | 3 | #define INFOSIZE 512 |
| 4 | #define INFO_SOLVER_STRLEN 100 | ||
| 5 | #define INFO_DISTRIBUTION_LEN 21 | ||
| 6 | #define COCSEP_CLASSES 3393 | ||
| 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; | ||
| 4 | 22 | ||
| 5 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 23 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 24 | bool readtableinfo(const void *, tableinfo_t *); | ||
| 6 | 25 | ||
| 7 | void run(void) { | 26 | void run(void) { |
| 8 | uint32_t buf[300000], i; | 27 | char buf[2000000]; |
| 28 | uint32_t i; | ||
| 9 | uint64_t selfsim[COCSEP_CLASSES]; | 29 | uint64_t selfsim[COCSEP_CLASSES]; |
| 10 | cube_t rep[COCSEP_CLASSES]; | 30 | cube_t rep[COCSEP_CLASSES]; |
| 11 | size_t result; | 31 | size_t result; |
| 32 | tableinfo_t info; | ||
| 12 | 33 | ||
| 13 | result = gendata_cocsep(buf, selfsim, rep); | 34 | result = gendata_cocsep(buf, selfsim, rep); |
| 35 | if (!readtableinfo(buf, &info)) { | ||
| 36 | printf("Error reading info from table\n"); | ||
| 37 | return; | ||
| 38 | } | ||
| 14 | 39 | ||
| 15 | printf("%zu\n", result); | 40 | printf("%zu\n", result); |
| 16 | printf("Classes: %" PRIu32 "\n", buf[result/4-12]); | 41 | printf("Classes: %" PRIu64 "\n", info.classes); |
| 17 | printf("Max value: %" PRIu32 "\n", buf[result/4-11]); | 42 | printf("Max value: %" PRIu8 "\n", info.maxvalue); |
| 18 | for (i = 0; i < 10; i++) | 43 | for (i = 0; i < 10; i++) |
| 19 | printf("%" PRIu32 ": %" PRIu32 "\n", i, buf[result/4-10+i]); | 44 | printf("%" PRIu32 ": %" PRIu64 "\n", i, info.distribution[i]); |
| 20 | } | 45 | } |
diff --git a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c index b0286e5..67f70a5 100644 --- a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c +++ b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) | 3 | #define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16)) |
| 4 | #define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16)) | 4 | #define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16)) |
| 5 | 5 | ||
| 6 | #define INFOSIZE 512 | ||
| 6 | #define COCSEP_CLASSES 3393 | 7 | #define COCSEP_CLASSES 3393 |
| 7 | 8 | ||
| 8 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 9 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| @@ -11,7 +12,8 @@ int64_t coord_cocsep(cube_t); | |||
| 11 | 12 | ||
| 12 | void run(void) { | 13 | void run(void) { |
| 13 | uint8_t t; | 14 | uint8_t t; |
| 14 | uint32_t buf[300000]; | 15 | char buf[2000000]; |
| 16 | uint32_t *cocsepdata; | ||
| 15 | uint64_t selfsim[COCSEP_CLASSES]; | 17 | uint64_t selfsim[COCSEP_CLASSES]; |
| 16 | int64_t coord, tcoord; | 18 | int64_t coord, tcoord; |
| 17 | char str[STRLENMAX]; | 19 | char str[STRLENMAX]; |
| @@ -21,11 +23,12 @@ void run(void) { | |||
| 21 | cube = readcube("H48", str); | 23 | cube = readcube("H48", str); |
| 22 | 24 | ||
| 23 | gendata_cocsep(buf, selfsim, rep); | 25 | gendata_cocsep(buf, selfsim, rep); |
| 26 | cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); | ||
| 24 | 27 | ||
| 25 | coord = (int64_t)COCLASS(buf[coord_cocsep(cube)]); | 28 | coord = (int64_t)COCLASS(cocsepdata[coord_cocsep(cube)]); |
| 26 | for (t = 0; t < 48; t++) { | 29 | for (t = 0; t < 48; t++) { |
| 27 | transd = transform(cube, t); | 30 | transd = transform(cube, t); |
| 28 | tcoord = (int64_t)COCLASS(buf[coord_cocsep(transd)]); | 31 | tcoord = (int64_t)COCLASS(cocsepdata[coord_cocsep(transd)]); |
| 29 | if (coord != tcoord) | 32 | if (coord != tcoord) |
| 30 | printf("Error: expected %" PRId64 | 33 | printf("Error: expected %" PRId64 |
| 31 | " but got %" PRId64 "\n", coord, tcoord); | 34 | " but got %" PRId64 "\n", coord, tcoord); |
diff --git a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c index 7211e2e..490952a 100644 --- a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c +++ b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c | |||
| @@ -8,25 +8,28 @@ | |||
| 8 | #include "../test.h" | 8 | #include "../test.h" |
| 9 | 9 | ||
| 10 | #define COCSEP_CLASSES 3393 | 10 | #define COCSEP_CLASSES 3393 |
| 11 | #define INFOSIZE 512 | ||
| 11 | 12 | ||
| 12 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 13 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 13 | int64_t coord_cocsep(cube_t); | 14 | int64_t coord_cocsep(cube_t); |
| 14 | 15 | ||
| 15 | void run(void) { | 16 | void run(void) { |
| 16 | char str[STRLENMAX]; | 17 | char str[STRLENMAX]; |
| 17 | uint32_t buf[300000], data; | 18 | char buf[2000000]; |
| 19 | uint32_t *cocsepdata, data; | ||
| 18 | int64_t coord, coclass; | 20 | int64_t coord, coclass; |
| 19 | uint64_t selfsim[COCSEP_CLASSES], sim, t; | 21 | uint64_t selfsim[COCSEP_CLASSES], sim, t; |
| 20 | cube_t cube, rep[COCSEP_CLASSES]; | 22 | cube_t cube, rep[COCSEP_CLASSES]; |
| 21 | 23 | ||
| 22 | gendata_cocsep(buf, selfsim, rep); | 24 | gendata_cocsep(buf, selfsim, rep); |
| 25 | cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); | ||
| 23 | 26 | ||
| 24 | /* All cases in the same test so we do not generate data many times */ | 27 | /* All cases in the same test so we do not generate data many times */ |
| 25 | 28 | ||
| 26 | while (fgets(str, STRLENMAX, stdin) != NULL) { | 29 | while (fgets(str, STRLENMAX, stdin) != NULL) { |
| 27 | cube = readcube("H48", str); | 30 | cube = readcube("H48", str); |
| 28 | coord = coord_cocsep(cube); | 31 | coord = coord_cocsep(cube); |
| 29 | data = buf[coord]; | 32 | data = cocsepdata[coord]; |
| 30 | coclass = (data & (0xFFFU << 16)) >> 16; | 33 | coclass = (data & (0xFFFU << 16)) >> 16; |
| 31 | sim = selfsim[coclass]; | 34 | sim = selfsim[coclass]; |
| 32 | for (t = 0; t < 48 && sim; t++, sim >>= 1) { | 35 | for (t = 0; t < 48 && sim; t++, sim >>= 1) { |
diff --git a/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c b/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c index fb1338e..84e3fd8 100644 --- a/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c +++ b/test/103_cocsep_selfsim_distribution/cocsep_selfsim_distribution_tests.c | |||
| @@ -17,7 +17,7 @@ int bcount(uint64_t x) { | |||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | void run(void) { | 19 | void run(void) { |
| 20 | uint32_t buf[300000]; | 20 | char buf[2000000]; |
| 21 | int size[65], tot, j; | 21 | int size[65], tot, j; |
| 22 | int64_t i; | 22 | int64_t i; |
| 23 | uint64_t selfsim[COCSEP_CLASSES], sim; | 23 | uint64_t selfsim[COCSEP_CLASSES], sim; |
diff --git a/test/104_cocsep_ttrep/cocsep_ttrep_tests.c b/test/104_cocsep_ttrep/cocsep_ttrep_tests.c index f692ca8..efe5a26 100644 --- a/test/104_cocsep_ttrep/cocsep_ttrep_tests.c +++ b/test/104_cocsep_ttrep/cocsep_ttrep_tests.c | |||
| @@ -1,9 +1,11 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | #define COCSEP_CLASSES 3393 | ||
| 4 | #define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8)) | 3 | #define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8)) |
| 5 | #define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8)) | 4 | #define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8)) |
| 6 | 5 | ||
| 6 | #define COCSEP_CLASSES 3393 | ||
| 7 | #define INFOSIZE 512 | ||
| 8 | |||
| 7 | uint8_t inverse_trans(uint8_t); | 9 | uint8_t inverse_trans(uint8_t); |
| 8 | cube_t transform_corners(cube_t, uint8_t); | 10 | cube_t transform_corners(cube_t, uint8_t); |
| 9 | int64_t coord_cocsep(cube_t); | 11 | int64_t coord_cocsep(cube_t); |
| @@ -11,19 +13,21 @@ size_t gendata_cocsep(void *, uint64_t *, cube_t *); | |||
| 11 | 13 | ||
| 12 | void run(void) { | 14 | void run(void) { |
| 13 | uint8_t t; | 15 | uint8_t t; |
| 14 | uint32_t buf[300000], tt; | 16 | char buf[2000000]; |
| 17 | uint32_t *cocsepdata, tt; | ||
| 15 | uint64_t selfsim[COCSEP_CLASSES]; | 18 | uint64_t selfsim[COCSEP_CLASSES]; |
| 16 | int64_t i, j, k, l; | 19 | int64_t i, j, k, l; |
| 17 | cube_t rep[COCSEP_CLASSES], c, d; | 20 | cube_t rep[COCSEP_CLASSES], c, d; |
| 18 | 21 | ||
| 19 | gendata_cocsep(buf, selfsim, rep); | 22 | gendata_cocsep(buf, selfsim, rep); |
| 23 | cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); | ||
| 20 | 24 | ||
| 21 | for (i = 0; i < COCSEP_CLASSES; i++) { | 25 | for (i = 0; i < COCSEP_CLASSES; i++) { |
| 22 | c = rep[i]; | 26 | c = rep[i]; |
| 23 | for (t = 0; t < 48; t++) { | 27 | for (t = 0; t < 48; t++) { |
| 24 | d = transform_corners(c, t); | 28 | d = transform_corners(c, t); |
| 25 | j = coord_cocsep(d); | 29 | j = coord_cocsep(d); |
| 26 | tt = TTREP(buf[j]); | 30 | tt = TTREP(cocsepdata[j]); |
| 27 | d = transform_corners(d, tt); | 31 | d = transform_corners(d, tt); |
| 28 | k = coord_cocsep(d); | 32 | k = coord_cocsep(d); |
| 29 | l = coord_cocsep(c); | 33 | l = coord_cocsep(c); |
diff --git a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c index 77dea81..1fcbabd 100644 --- a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c +++ b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | #define COCSEP_CLASSES 3393 | 3 | #define COCSEP_CLASSES 3393 |
| 4 | #define INFOSIZE 512 | ||
| 4 | 5 | ||
| 5 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 6 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 6 | int64_t coord_h48(cube_t, const uint32_t *, uint8_t); | 7 | int64_t coord_h48(cube_t, const uint32_t *, uint8_t); |
| @@ -12,12 +13,14 @@ void run(void) { | |||
| 12 | int i; | 13 | int i; |
| 13 | bool found; | 14 | bool found; |
| 14 | uint8_t h, t; | 15 | uint8_t h, t; |
| 15 | uint32_t cocsepdata[300000]; | 16 | char buf[2000000]; |
| 17 | uint32_t *cocsepdata; | ||
| 16 | uint64_t selfsim[COCSEP_CLASSES]; | 18 | uint64_t selfsim[COCSEP_CLASSES]; |
| 17 | int64_t c, cc; | 19 | int64_t c, cc; |
| 18 | cube_t cube, invc, rep[COCSEP_CLASSES]; | 20 | cube_t cube, invc, rep[COCSEP_CLASSES]; |
| 19 | 21 | ||
| 20 | gendata_cocsep(cocsepdata, selfsim, rep); | 22 | gendata_cocsep(buf, selfsim, rep); |
| 23 | cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); | ||
| 21 | 24 | ||
| 22 | i = 1; | 25 | i = 1; |
| 23 | h = 11; | 26 | h = 11; |
diff --git a/test/112_gen_h48short/gen_h48short.c b/test/112_gen_h48short/gen_h48short_tests.c index 335821a..a706dff 100644 --- a/test/112_gen_h48short/gen_h48short.c +++ b/test/112_gen_h48short/gen_h48short_tests.c | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | #define COCSEP_CLASSES 3393 | 3 | #define COCSEP_CLASSES 3393 |
| 4 | #define MAXPOS 200 | 4 | #define INFOSIZE 512 |
| 5 | #define MAXPOS 200 | ||
| 5 | 6 | ||
| 6 | typedef struct { | 7 | typedef struct { |
| 7 | uint64_t n; | 8 | uint64_t n; |
| @@ -51,7 +52,7 @@ uint64_t readl(void) { | |||
| 51 | } | 52 | } |
| 52 | 53 | ||
| 53 | void run(void) { | 54 | void run(void) { |
| 54 | uint32_t cocsepdata[300000]; | 55 | char buf[2000000]; |
| 55 | h48map_t map; | 56 | h48map_t map; |
| 56 | uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES]; | 57 | uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES]; |
| 57 | kvpair_t kv, b[MAXPOS]; | 58 | kvpair_t kv, b[MAXPOS]; |
| @@ -61,13 +62,13 @@ void run(void) { | |||
| 61 | capacity = readl(); | 62 | capacity = readl(); |
| 62 | randomizer = readl(); | 63 | randomizer = readl(); |
| 63 | arg.maxdepth = readl(); | 64 | arg.maxdepth = readl(); |
| 64 | arg.cocsepdata = cocsepdata; | ||
| 65 | arg.crep = crep; | 65 | arg.crep = crep; |
| 66 | arg.selfsim = selfsim; | 66 | arg.selfsim = selfsim; |
| 67 | arg.map = ↦ | 67 | arg.map = ↦ |
| 68 | 68 | ||
| 69 | h48map_create(&map, capacity, randomizer); | 69 | h48map_create(&map, capacity, randomizer); |
| 70 | gendata_cocsep(cocsepdata, selfsim, crep); | 70 | gendata_cocsep(buf, selfsim, crep); |
| 71 | arg.cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); | ||
| 71 | gen_h48short(&arg); | 72 | gen_h48short(&arg); |
| 72 | 73 | ||
| 73 | i = 0; | 74 | i = 0; |
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 | } |
