aboutsummaryrefslogtreecommitdiff
path: root/tools/002_gendata_h48h0k2
diff options
context:
space:
mode:
Diffstat (limited to 'tools/002_gendata_h48h0k2')
-rw-r--r--tools/002_gendata_h48h0k2/gendata_h48h0k2.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/002_gendata_h48h0k2/gendata_h48h0k2.c b/tools/002_gendata_h48h0k2/gendata_h48h0k2.c
new file mode 100644
index 0000000..2754f80
--- /dev/null
+++ b/tools/002_gendata_h48h0k2/gendata_h48h0k2.c
@@ -0,0 +1,62 @@
1#include "../tool.h"
2
3#define MAXDEPTH 20
4#define HVALUE 0
5#define OPTIONS "0;2;20"
6#define LONGOPTIONS "h = 0, k = 2, max depth = 20"
7
8#define COCSEPSIZE 1119792
9#define ETABLESIZE(h) (((3393 * 495 * 70) >> 2) << (size_t)(h))
10
11uint32_t expected[21] = {
12 /* Base value is 8 */
13 [0] = 5473562,
14 [1] = 34776317,
15 [2] = 68566704,
16 [3] = 8750867,
17};
18
19char *buf;
20
21void run(void) {
22 uint32_t *h48info, x;
23 int i;
24 int64_t s;
25
26 s = nissy_gendata("h48", OPTIONS, buf);
27
28 if (s == -1) {
29 printf("Error generating table\n");
30 } else {
31 printf("Succesfully generated %" PRId64 " bytes. Table:\n", s);
32 h48info = (uint32_t *)buf + 1 + (ETABLESIZE(HVALUE) + COCSEPSIZE) / 4;
33 for (i = 0; i < 4; i++) {
34 x = h48info[i+1];
35 printf("%d:\t%" PRIu32, i, x);
36 if (x != expected[i])
37 printf(" <--- Error! Expected: %" PRIu32,
38 expected[i]);
39 printf("\n");
40 }
41 }
42}
43
44int main(void) {
45 int64_t size;
46
47 nissy_setlogger(log_stderr);
48
49 size = nissy_datasize("h48", OPTIONS);
50 if (size == -1) {
51 printf("gendata_h48 benchmark: error in datasize\n");
52 return 1;
53 }
54
55 buf = malloc(size);
56
57 timerun(run, "benchmark gendata_h48 " LONGOPTIONS);
58
59 free(buf);
60
61 return 0;
62}

Generated with cgit - Back to sebastiano.tronto.net