Blame view

src/kernels/cl_constraints.h 4.17 KB
94b2b13d   Pedro Roque   PHACT source
1
2
3
4
/*
 * cl_constraints.h
 *
 *  Created on: 19/11/2014
4d26a735   Pedro Roque   Increased recogni...
5
 *      Author: Pedro
94b2b13d   Pedro Roque   PHACT source
6
7
8
9
10
 */

#ifndef SRC_KERNELS_CL_CONSTRAINTS_H_
#define SRC_KERNELS_CL_CONSTRAINTS_H_

4d26a735   Pedro Roque   Increased recogni...
11
12
13
14
15
#ifndef __OPENCL_VERSION__
#include <CL/cl.h>
#include "CL/cl_platform.h"
#endif

94b2b13d   Pedro Roque   PHACT source
16
17
18
// Constraint types
typedef enum {
	ALL_DIFFERENT,
4d26a735   Pedro Roque   Increased recogni...
19
20
21
22
23
24
	ARRAY_BOOL_AND,
	ARRAY_BOOL_ELEMENT,
	ARRAY_BOOL_OR,
	ARRAY_BOOL_XOR,
	ARRAY_INT_ELEMENT,
	ARRAY_VAR_INT_ELEMENT,
94b2b13d   Pedro Roque   PHACT source
25
26
27
	AT_LEAST,
	AT_MOST,
	AT_MOST_ONE,
94b2b13d   Pedro Roque   PHACT source
28
29
	BOOL_AND,
	BOOL_CLAUSE,
4d26a735   Pedro Roque   Increased recogni...
30
31
32
33
34
35
	BOOL_EQ,
	BOOL_LE,
	BOOL_LIN_EQ,
	BOOL_LIN_LE,
	BOOL_LT,
	BOOL_NOT,
94b2b13d   Pedro Roque   PHACT source
36
	BOOL_OR,
4d26a735   Pedro Roque   Increased recogni...
37
38
	BOOL_XOR,
	BOOL2INT,
94b2b13d   Pedro Roque   PHACT source
39
	ELEMENT,
4d26a735   Pedro Roque   Increased recogni...
40
	INT_EQ,
94b2b13d   Pedro Roque   PHACT source
41
42
	EXACTLY,
	EXACTLY_VAR,
4d26a735   Pedro Roque   Increased recogni...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	INT_DIV,
	INT_EQ_C,
	INT_LE,
	INT_LIN_EQ,
	INT_LIN_LE,
	INT_LIN_NE,
	INT_LIN_VAR,
	INT_LT,
	INT_MAX_,
	INT_MIN_,
	INT_MOD,
	INT_NE,
	INT_PLUS,
	INT_TIMES,
94b2b13d   Pedro Roque   PHACT source
57
	MAXIMIZE,
94b2b13d   Pedro Roque   PHACT source
58
59
60
	MINIMIZE,
	MINUS_EQ,
	MINUS_NE,
94b2b13d   Pedro Roque   PHACT source
61
62
63
64
65
	SUM,
	SUM_PROD,
	SUM_VAR,
	VAR_EQ_MINUS,
	VAR_EQ_MINUS_ABS,
94b2b13d   Pedro Roque   PHACT source
66
67
68
69
70
	N_C_TYPES
} c_kind;

// constraint structure used in kernel
struct cl_constrs_ {
4d26a735   Pedro Roque   Increased recogni...
71
72
	cl_uint v_idx; 			// index of the first variable constrained by this constraint in cs_vs_idx vector
	cl_uint const_idx;		// index of the first constant value (if more than one) constrained by this constraint in cs_const_idx vector
94b2b13d   Pedro Roque   PHACT source
73
	cl_uint reif_var_id;	// ID of the disjunction variable
4d26a735   Pedro Roque   Increased recogni...
74
75
	cl_uint kind;			// constraint type
	cl_uint c_id;			// ID of this constraint
94b2b13d   Pedro Roque   PHACT source
76
	cl_int constant_val;	// Constant value for multiple purposes, depending on the constraint type
4d26a735   Pedro Roque   Increased recogni...
77
	cl_ushort n_c_vs;		// number of constrained variables
94b2b13d   Pedro Roque   PHACT source
78
79
80
81
82
83
84
85
86
87
88
	cl_ushort n_c_consts;	// number of constant values (if more than one) constrained by this constraint in cs_const_idx vector
	cl_char reified;		// True if this constraint is reified
	cl_char boolean;		// True if all the variables constrained by this constraint are boolean
};

typedef struct cl_constrs_ cl_constr;

// Host configuration
#ifndef __OPENCL_VERSION__

// only for syntax highlighting on cl_propagators
94b2b13d   Pedro Roque   PHACT source
89
#define CS_ALL_DIFFERENT 1
4d26a735   Pedro Roque   Increased recogni...
90
91
92
93
94
95
#define CS_ARRAY_BOOL_AND 1
#define CS_ARRAY_BOOL_ELEMENT 1
#define CS_ARRAY_BOOL_OR 1
#define CS_ARRAY_BOOL_XOR 1
#define CS_ARRAY_INT_ELEMENT 1
#define CS_ARRAY_VAR_INT_ELEMENT 1
94b2b13d   Pedro Roque   PHACT source
96
97
98
#define CS_AT_LEAST 1
#define CS_AT_MOST 1
#define CS_AT_MOST_ONE 1
94b2b13d   Pedro Roque   PHACT source
99
100
#define CS_BOOL_AND 1
#define CS_BOOL_CLAUSE 1
4d26a735   Pedro Roque   Increased recogni...
101
102
103
104
105
106
#define CS_BOOL_EQ 1
#define CS_BOOL_LE 1
#define CS_BOOL_LIN_EQ 1
#define CS_BOOL_LIN_LE 1
#define CS_BOOL_LT 1
#define CS_BOOL_NOT 1
94b2b13d   Pedro Roque   PHACT source
107
#define CS_BOOL_OR 1
4d26a735   Pedro Roque   Increased recogni...
108
109
#define CS_BOOL_XOR 1
#define CS_BOOL2INT 1
94b2b13d   Pedro Roque   PHACT source
110
#define CS_ELEMENT 1
94b2b13d   Pedro Roque   PHACT source
111
112
#define CS_EXACTLY 1
#define CS_EXACTLY_VAR 1
4d26a735   Pedro Roque   Increased recogni...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#define CS_INT_DIV 1
#define CS_INT_EQ 1
#define CS_INT_EQ_C 1
#define CS_INT_LE 1
#define CS_INT_LIN_EQ 1
#define CS_INT_LIN_LE 1
#define CS_INT_LIN_NE 1
#define CS_INT_LIN_VAR 1
#define CS_INT_LT 1
#define CS_INT_MAX_ 1
#define CS_INT_MIN_ 1
#define CS_INT_MOD 1
#define CS_INT_NE 1
#define CS_INT_PLUS 1
#define CS_INT_TIMES 1
94b2b13d   Pedro Roque   PHACT source
128
#define CS_MAXIMIZE 1
94b2b13d   Pedro Roque   PHACT source
129
130
131
#define CS_MINIMIZE 1
#define CS_MINUS_EQ 1
#define CS_MINUS_NE 1
94b2b13d   Pedro Roque   PHACT source
132
133
134
135
136
#define CS_SUM 1
#define CS_SUM_PROD 1
#define CS_SUM_VAR 1
#define CS_VAR_EQ_MINUS 1
#define CS_VAR_EQ_MINUS_ABS 1
94b2b13d   Pedro Roque   PHACT source
137
138

#define CS_R_ALL_DIFFERENT 1
4d26a735   Pedro Roque   Increased recogni...
139
140
141
142
143
144
#define CS_R_ARRAY_BOOL_AND 1
#define CS_R_ARRAY_BOOL_ELEMENT 1
#define CS_R_ARRAY_BOOL_OR 1
#define CS_R_ARRAY_BOOL_XOR 1
#define CS_R_ARRAY_INT_ELEMENT 1
#define CS_R_ARRAY_VAR_INT_ELEMENT 1
94b2b13d   Pedro Roque   PHACT source
145
146
147
#define CS_R_AT_LEAST 1
#define CS_R_AT_MOST 1
#define CS_R_AT_MOST_ONE 1
94b2b13d   Pedro Roque   PHACT source
148
149
#define CS_R_BOOL_AND 1
#define CS_R_BOOL_CLAUSE 1
4d26a735   Pedro Roque   Increased recogni...
150
151
152
153
154
155
#define CS_R_BOOL_EQ 1
#define CS_R_BOOL_LE 1
#define CS_R_BOOL_LIN_EQ 1
#define CS_R_BOOL_LIN_LE 1
#define CS_R_BOOL_LT 1
#define CS_R_BOOL_NOT 1
94b2b13d   Pedro Roque   PHACT source
156
#define CS_R_BOOL_OR 1
4d26a735   Pedro Roque   Increased recogni...
157
158
#define CS_R_BOOL_XOR 1
#define CS_R_BOOL2INT 1
94b2b13d   Pedro Roque   PHACT source
159
#define CS_R_ELEMENT 1
94b2b13d   Pedro Roque   PHACT source
160
161
#define CS_R_EXACTLY 1
#define CS_R_EXACTLY_VAR 1
4d26a735   Pedro Roque   Increased recogni...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#define CS_R_INT_DIV 1
#define CS_R_INT_EQ 1
#define CS_R_INT_EQ_C 1
#define CS_R_INT_LE 1
#define CS_R_INT_LIN_EQ 1
#define CS_R_INT_LIN_LE 1
#define CS_R_INT_LIN_NE 1
#define CS_R_INT_LIN_VAR 1
#define CS_R_INT_LT 1
#define CS_R_INT_MAX_ 1
#define CS_R_INT_MIN_ 1
#define CS_R_INT_MOD 1
#define CS_R_INT_NE 1
#define CS_R_INT_PLUS 1
#define CS_R_INT_TIMES 1
94b2b13d   Pedro Roque   PHACT source
177
#define CS_R_MAXIMIZE 1
94b2b13d   Pedro Roque   PHACT source
178
179
180
#define CS_R_MINIMIZE 1
#define CS_R_MINUS_EQ 1
#define CS_R_MINUS_NE 1
94b2b13d   Pedro Roque   PHACT source
181
182
183
184
185
#define CS_R_SUM 1
#define CS_R_SUM_PROD 1
#define CS_R_SUM_VAR 1
#define CS_R_VAR_EQ_MINUS 1
#define CS_R_VAR_EQ_MINUS_ABS 1
94b2b13d   Pedro Roque   PHACT source
186
187
188
#endif

#endif /* SRC_CL_CONSTRAINTS_H_ */