aboutsummaryrefslogtreecommitdiff
path: root/test/120_gendata_h48h0k4/gendata_h48h0k4_tests.c
blob: 7c5b44161fe096141e4cf5897f491ac695672e53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "../test.h"

#define COCSEP_CLASSES        3393
#define INFOSIZE              512
#define INFO_SOLVER_STRLEN    100
#define INFO_DISTRIBUTION_LEN 21

typedef struct {
	uint64_t distribution[INFO_DISTRIBUTION_LEN];
	uint64_t type;
	uint64_t infosize;
	uint64_t fullsize;
	uint64_t hash;
	uint64_t entries;
	uint64_t classes; /* Used only by cocsepdata, for now */
	uint64_t next;
	char solver[INFO_SOLVER_STRLEN];
	uint8_t h48h;
	uint8_t bits;
	uint8_t base;
	uint8_t maxvalue;
} tableinfo_t;

typedef struct {
	uint8_t h;
	uint8_t k;
	uint8_t base;
	uint8_t maxdepth;
	tableinfo_t info;
	void *buf;
	void *h48buf;
	uint32_t *cocsepdata;
	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);
	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);

	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: %" 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 <= hinfo.maxvalue; i++)
		printf("%" PRIu32 ": %" PRIu64 "\n", i, hinfo.distribution[i]);

end:
	free(arg.buf);
}

Generated with cgit - Back to sebastiano.tronto.net