-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathruler.h
165 lines (123 loc) · 3.4 KB
/
ruler.h
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef _ruler_h_INCLUDED
#define _ruler_h_INCLUDED
#include "barrier.h"
#include "clause.h"
#include "options.h"
#include "profile.h"
#include "ring.h"
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
struct ruler_trail {
unsigned *begin;
unsigned *propagate;
unsigned *volatile end;
};
#define LOCKS \
LOCK (rings) \
LOCK (simplify) \
LOCK (terminate) \
LOCK (units) \
LOCK (winner)
struct ruler_locks {
#define LOCK(NAME) pthread_mutex_t NAME;
LOCKS
#undef LOCK
};
#define BARRIERS \
BARRIER (copy) \
BARRIER (end) \
BARRIER (import) \
BARRIER (run) \
BARRIER (start) \
BARRIER (unclone)
struct ruler_barriers {
#define BARRIER(NAME) struct barrier NAME;
BARRIERS
#undef BARRIER
};
struct ruler_last {
unsigned fixed;
uint64_t garbage;
uint64_t search;
};
struct ruler_limits {
bool initialized;
uint64_t elimination;
uint64_t subsumption;
size_t clause_size_limit;
size_t occurrence_limit;
unsigned current_bound;
unsigned max_bound;
unsigned max_rounds;
};
struct ruler {
unsigned size;
unsigned compact;
struct ring *volatile winner;
volatile bool terminate;
volatile bool simplify;
bool eliminating;
bool inconsistent;
bool simplifying;
bool solving;
bool subsuming;
bool *eliminate;
bool *subsume;
struct clauses *occurrences;
pthread_t *threads;
unsigned *unmap;
signed char volatile *values;
struct ruler_barriers barriers;
struct ruler_locks locks;
struct clauses clauses;
struct unsigneds extension[2];
#ifndef NDEBUG
struct unsigneds *original;
#endif
struct rings rings;
struct ruler_trail units;
struct trace trace;
struct ruler_last last;
struct ruler_limits limits;
struct options options;
struct ruler_profiles profiles;
struct ruler_statistics statistics;
};
/*------------------------------------------------------------------------*/
#define OCCURRENCES(LIT) (ruler->occurrences[LIT])
/*------------------------------------------------------------------------*/
#define all_rings(RING) \
all_pointers_on_stack (struct ring, RING, ruler->rings)
#define all_ruler_indices(IDX) \
unsigned IDX = 0, END_##IDX = ruler->compact; \
IDX != END_##IDX; \
++IDX
#define all_ruler_literals(LIT) \
unsigned LIT = 0, END_##LIT = 2 * ruler->compact; \
LIT != END_##LIT; \
++LIT
#define all_positive_ruler_literals(LIT) \
unsigned LIT = 0, END_##LIT = 2 * ruler->compact; \
LIT != END_##LIT; \
LIT += 2
/*------------------------------------------------------------------------*/
struct ruler *new_ruler (size_t size, struct options *);
void delete_ruler (struct ruler *);
void flush_large_clause_occurrences (struct ruler *);
void new_ruler_binary_clause (struct ruler *, unsigned, unsigned);
void assign_ruler_unit (struct ruler *, unsigned unit);
void connect_large_clause (struct ruler *, struct clause *);
void disconnect_literal (struct ruler *, unsigned, struct clause *);
void push_ring (struct ruler *, struct ring *);
void detach_ring (struct ring *);
void set_winner (struct ring *);
void set_terminate (struct ruler *, struct ring *);
void print_ruler_profiles (struct ruler *);
/*------------------------------------------------------------------------*/
static inline void connect_literal (struct ruler *ruler, unsigned lit,
struct clause *clause) {
PUSH (OCCURRENCES (lit), clause);
}
struct ring *first_ring (struct ruler *);
#endif