aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48
diff options
context:
space:
mode:
Diffstat (limited to 'src/solvers/h48')
-rw-r--r--src/solvers/h48/coordinate.h8
-rw-r--r--src/solvers/h48/coordinate_macros.h6
-rw-r--r--src/solvers/h48/gendata_cocsep.h22
-rw-r--r--src/solvers/h48/gendata_h48.h73
-rw-r--r--src/solvers/h48/gendata_types_macros.h94
-rw-r--r--src/solvers/h48/h48.h1
-rw-r--r--src/solvers/h48/map.h18
-rw-r--r--src/solvers/h48/map_types_macros.h16
8 files changed, 121 insertions, 117 deletions
diff --git a/src/solvers/h48/coordinate.h b/src/solvers/h48/coordinate.h
index 25e13f9..6caac2a 100644
--- a/src/solvers/h48/coordinate.h
+++ b/src/solvers/h48/coordinate.h
@@ -1,9 +1,5 @@
1#define H48_ESIZE(h) ((COMB_12_4 * COMB_8_4) << (int64_t)(h)) 1/* Macros defined in a separate file for easier testing */
2 2#include "coordinate_macros.h"
3#define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16))
4#define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16))
5#define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8))
6#define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8))
7 3
8STATIC_INLINE int64_t coord_h48(cube_t, const uint32_t *, uint8_t); 4STATIC_INLINE int64_t coord_h48(cube_t, const uint32_t *, uint8_t);
9STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t); 5STATIC_INLINE int64_t coord_h48_edges(cube_t, int64_t, uint8_t, uint8_t);
diff --git a/src/solvers/h48/coordinate_macros.h b/src/solvers/h48/coordinate_macros.h
new file mode 100644
index 0000000..5b67177
--- /dev/null
+++ b/src/solvers/h48/coordinate_macros.h
@@ -0,0 +1,6 @@
1#define H48_ESIZE(h) ((COMB_12_4 * COMB_8_4) << (int64_t)(h))
2
3#define COCLASS_MASK (UINT32_C(0xFFFF) << UINT32_C(16))
4#define COCLASS(x) (((x) & COCLASS_MASK) >> UINT32_C(16))
5#define TTREP_MASK (UINT32_C(0xFF) << UINT32_C(8))
6#define TTREP(x) (((x) & TTREP_MASK) >> UINT32_C(8))
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h
index 5f0fae9..3daaf2a 100644
--- a/src/solvers/h48/gendata_cocsep.h
+++ b/src/solvers/h48/gendata_cocsep.h
@@ -1,25 +1,3 @@
1#define COCSEP_CLASSES ((size_t)3393)
2#define COCSEP_TABLESIZE ((size_t)POW_3_7 << (size_t)7)
3#define COCSEP_VISITEDSIZE DIV_ROUND_UP(COCSEP_TABLESIZE, (size_t)8)
4#define COCSEP_FULLSIZE (INFOSIZE + (size_t)4 * COCSEP_TABLESIZE)
5
6#define VISITED_IND(i) ((uint32_t)(i) / UINT32_C(8))
7#define VISITED_MASK(i) (UINT32_C(1) << ((uint32_t)(i) % UINT32_C(8)))
8
9#define CBOUND_MASK UINT32_C(0xFF)
10#define CBOUND(x) ((x) & CBOUND_MASK)
11
12typedef struct {
13 cube_t cube;
14 uint8_t depth;
15 uint8_t maxdepth;
16 uint16_t *n;
17 uint32_t *buf32;
18 uint8_t *visited;
19 uint64_t *selfsim;
20 cube_t *rep;
21} cocsep_dfs_arg_t;
22
23STATIC_INLINE bool get_visited(const uint8_t *, int64_t); 1STATIC_INLINE bool get_visited(const uint8_t *, int64_t);
24STATIC_INLINE void set_visited(uint8_t *, int64_t); 2STATIC_INLINE void set_visited(uint8_t *, int64_t);
25 3
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index 6db3998..5da9dc3 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -1,16 +1,3 @@
1#define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * COMB_12_4 * COMB_8_4))
2#define H48_COORDMAX(h) (H48_COORDMAX_NOEO << (int64_t)(h))
3#define H48_DIV(k) ((size_t)8 / (size_t)(k))
4#define H48_TABLESIZE(h, k) DIV_ROUND_UP((size_t)H48_COORDMAX((h)), H48_DIV(k))
5
6#define H48_COEFF(k) (INT64_C(8) / (int64_t)(k))
7#define H48_INDEX(i, k) ((i) / H48_COEFF(k))
8#define H48_SHIFT(i, k) ((uint8_t)(k) * (uint8_t)((i) % H48_COEFF(k)))
9#define H48_MASK(i, k) ((UINT8_BIT(k) - UINT8_C(1)) << H48_SHIFT(i, k))
10
11#define MAXLEN 20
12#define CHUNKS COCSEP_CLASSES
13
14/* 1/*
15TODO: This loop over similar h48 coordinates can be improved by only 2TODO: This loop over similar h48 coordinates can be improved by only
16transforming edges, but we need to compose transformations (i.e. conjugate 3transforming edges, but we need to compose transformations (i.e. conjugate
@@ -30,66 +17,6 @@ _t by _ttrep).
30 ARG_ACTION \ 17 ARG_ACTION \
31 } 18 }
32 19
33typedef struct {
34 uint8_t h;
35 uint8_t k;
36 uint8_t base;
37 uint8_t maxdepth;
38 tableinfo_t info;
39 void *buf;
40 void *h48buf;
41 uint32_t *cocsepdata;
42 uint64_t selfsim[COCSEP_CLASSES];
43 cube_t crep[COCSEP_CLASSES];
44} gendata_h48_arg_t;
45
46typedef struct {
47 uint8_t maxdepth;
48 const uint32_t *cocsepdata;
49 const cube_t *crep;
50 const uint64_t *selfsim;
51 h48map_t *map;
52} gendata_h48short_arg_t;
53
54typedef struct {
55 uint8_t depth;
56 uint32_t *cocsepdata;
57 _Atomic uint8_t *table;
58 uint64_t *selfsim;
59 cube_t *crep;
60 uint64_t start;
61 uint64_t end;
62 pthread_mutex_t *table_mutex[CHUNKS];
63} h48h0k4_bfs_arg_t;
64
65typedef struct {
66 cube_t cube;
67 uint8_t h;
68 uint8_t k;
69 uint8_t base;
70 uint8_t shortdepth;
71 uint32_t *cocsepdata;
72 _Atomic uint8_t *table;
73 uint64_t *selfsim;
74 cube_t *crep;
75 h48map_t *shortcubes;
76 pthread_mutex_t *shortcubes_mutex;
77 pthread_mutex_t *table_mutex[CHUNKS];
78 uint64_t *next;
79 uint64_t *count;
80} h48k2_dfs_arg_t;
81
82typedef struct {
83 cube_t cube;
84 int8_t depth;
85 uint8_t h;
86 uint8_t k;
87 uint32_t *cocsepdata;
88 uint64_t *selfsim;
89 _Atomic uint8_t *table;
90 pthread_mutex_t **table_mutex;
91} gendata_h48_mark_t;
92
93STATIC uint64_t gendata_h48short(gendata_h48short_arg_t *); 20STATIC uint64_t gendata_h48short(gendata_h48short_arg_t *);
94STATIC size_t gendata_h48(gendata_h48_arg_t *); 21STATIC size_t gendata_h48(gendata_h48_arg_t *);
95STATIC size_t gendata_h48h0k4(gendata_h48_arg_t *); 22STATIC size_t gendata_h48h0k4(gendata_h48_arg_t *);
diff --git a/src/solvers/h48/gendata_types_macros.h b/src/solvers/h48/gendata_types_macros.h
new file mode 100644
index 0000000..4b503ab
--- /dev/null
+++ b/src/solvers/h48/gendata_types_macros.h
@@ -0,0 +1,94 @@
1#define COCSEP_CLASSES ((size_t)3393)
2#define COCSEP_TABLESIZE ((size_t)POW_3_7 << (size_t)7)
3#define COCSEP_VISITEDSIZE DIV_ROUND_UP(COCSEP_TABLESIZE, (size_t)8)
4#define COCSEP_FULLSIZE (INFOSIZE + (size_t)4 * COCSEP_TABLESIZE)
5
6#define VISITED_IND(i) ((uint32_t)(i) / UINT32_C(8))
7#define VISITED_MASK(i) (UINT32_C(1) << ((uint32_t)(i) % UINT32_C(8)))
8
9#define CBOUND_MASK UINT32_C(0xFF)
10#define CBOUND(x) ((x) & CBOUND_MASK)
11
12#define H48_COORDMAX_NOEO ((int64_t)(COCSEP_CLASSES * COMB_12_4 * COMB_8_4))
13#define H48_COORDMAX(h) (H48_COORDMAX_NOEO << (int64_t)(h))
14#define H48_DIV(k) ((size_t)8 / (size_t)(k))
15#define H48_TABLESIZE(h, k) DIV_ROUND_UP((size_t)H48_COORDMAX((h)), H48_DIV(k))
16
17#define H48_COEFF(k) (INT64_C(8) / (int64_t)(k))
18#define H48_INDEX(i, k) ((i) / H48_COEFF(k))
19#define H48_SHIFT(i, k) ((uint8_t)(k) * (uint8_t)((i) % H48_COEFF(k)))
20#define H48_MASK(i, k) ((UINT8_BIT(k) - UINT8_C(1)) << H48_SHIFT(i, k))
21
22#define MAXLEN 20
23#define CHUNKS COCSEP_CLASSES
24
25typedef struct {
26 cube_t cube;
27 uint8_t depth;
28 uint8_t maxdepth;
29 uint16_t *n;
30 uint32_t *buf32;
31 uint8_t *visited;
32 uint64_t *selfsim;
33 cube_t *rep;
34} cocsep_dfs_arg_t;
35
36typedef struct {
37 uint8_t h;
38 uint8_t k;
39 uint8_t base;
40 uint8_t maxdepth;
41 tableinfo_t info;
42 void *buf;
43 void *h48buf;
44 uint32_t *cocsepdata;
45 uint64_t selfsim[COCSEP_CLASSES];
46 cube_t crep[COCSEP_CLASSES];
47} gendata_h48_arg_t;
48
49typedef struct {
50 uint8_t maxdepth;
51 const uint32_t *cocsepdata;
52 const cube_t *crep;
53 const uint64_t *selfsim;
54 h48map_t *map;
55} gendata_h48short_arg_t;
56
57typedef struct {
58 uint8_t depth;
59 uint32_t *cocsepdata;
60 _Atomic uint8_t *table;
61 uint64_t *selfsim;
62 cube_t *crep;
63 uint64_t start;
64 uint64_t end;
65 pthread_mutex_t *table_mutex[CHUNKS];
66} h48h0k4_bfs_arg_t;
67
68typedef struct {
69 cube_t cube;
70 uint8_t h;
71 uint8_t k;
72 uint8_t base;
73 uint8_t shortdepth;
74 uint32_t *cocsepdata;
75 _Atomic uint8_t *table;
76 uint64_t *selfsim;
77 cube_t *crep;
78 h48map_t *shortcubes;
79 pthread_mutex_t *shortcubes_mutex;
80 pthread_mutex_t *table_mutex[CHUNKS];
81 uint64_t *next;
82 uint64_t *count;
83} h48k2_dfs_arg_t;
84
85typedef struct {
86 cube_t cube;
87 int8_t depth;
88 uint8_t h;
89 uint8_t k;
90 uint32_t *cocsepdata;
91 uint64_t *selfsim;
92 _Atomic uint8_t *table;
93 pthread_mutex_t **table_mutex;
94} gendata_h48_mark_t;
diff --git a/src/solvers/h48/h48.h b/src/solvers/h48/h48.h
index 176ce22..3cf02b7 100644
--- a/src/solvers/h48/h48.h
+++ b/src/solvers/h48/h48.h
@@ -1,5 +1,6 @@
1#include "coordinate.h" 1#include "coordinate.h"
2#include "map.h" 2#include "map.h"
3#include "gendata_types_macros.h"
3#include "gendata_cocsep.h" 4#include "gendata_cocsep.h"
4#include "gendata_h48.h" 5#include "gendata_h48.h"
5#include "stats.h" 6#include "stats.h"
diff --git a/src/solvers/h48/map.h b/src/solvers/h48/map.h
index e74a5dd..e6903ce 100644
--- a/src/solvers/h48/map.h
+++ b/src/solvers/h48/map.h
@@ -1,19 +1,5 @@
1#define MAP_UNSET UINT64_C(0xFFFFFFFFFFFFFFFF) 1/* Type definitions and macros are in a separate file for easier testing */
2#define MAP_KEYMASK UINT64_C(0xFFFFFFFFFF) 2#include "map_types_macros.h"
3#define MAP_KEYSHIFT UINT64_C(40)
4#define MAP_UNSET_VAL (MAP_UNSET >> MAP_KEYSHIFT)
5
6typedef struct {
7 uint64_t n;
8 uint64_t capacity;
9 uint64_t randomizer;
10 uint64_t *table;
11} h48map_t;
12
13typedef struct {
14 uint64_t key;
15 uint64_t val;
16} kvpair_t;
17 3
18STATIC void h48map_create(h48map_t *, uint64_t, uint64_t); 4STATIC void h48map_create(h48map_t *, uint64_t, uint64_t);
19STATIC void h48map_clear(h48map_t *); 5STATIC void h48map_clear(h48map_t *);
diff --git a/src/solvers/h48/map_types_macros.h b/src/solvers/h48/map_types_macros.h
new file mode 100644
index 0000000..b77c68a
--- /dev/null
+++ b/src/solvers/h48/map_types_macros.h
@@ -0,0 +1,16 @@
1#define MAP_UNSET UINT64_C(0xFFFFFFFFFFFFFFFF)
2#define MAP_KEYMASK UINT64_C(0xFFFFFFFFFF)
3#define MAP_KEYSHIFT UINT64_C(40)
4#define MAP_UNSET_VAL (MAP_UNSET >> MAP_KEYSHIFT)
5
6typedef struct {
7 uint64_t n;
8 uint64_t capacity;
9 uint64_t randomizer;
10 uint64_t *table;
11} h48map_t;
12
13typedef struct {
14 uint64_t key;
15 uint64_t val;
16} kvpair_t;

Generated with cgit - Back to sebastiano.tronto.net