YAP 7.1.0
opt.config.h
1/************************************************************************
2** **
3** The YapTab/YapOr/OPTYap systems **
4** **
5** YapTab extends the Yap Prolog engine to support sequential tabling **
6** YapOr extends the Yap Prolog engine to support or-parallelism **
7** OPTYap extends the Yap Prolog engine to support or-parallel tabling **
8** **
9** **
10** Yap Prolog was developed at University of Porto, Portugal **
11** **
12************************************************************************/
13
14
15
16/****************************************************************
17** Configuration Parameters **
18****************************************************************/
19
20/****************************
21** default sizes **
22****************************/
23#define MAX_TABLE_VARS 1000
24#define TRIE_LOCK_BUCKETS 512
25#define THREADS_DIRECT_BUCKETS 32
26#define THREADS_INDIRECT_BUCKETS ((MAX_THREADS - THREADS_DIRECT_BUCKETS) / THREADS_DIRECT_BUCKETS) /* (1024 - 32) / 32 = 31 */
27#define THREADS_NUM_BUCKETS (THREADS_DIRECT_BUCKETS + THREADS_INDIRECT_BUCKETS)
28#define TG_ANSWER_SLOTS 20
29#define MAX_BRANCH_DEPTH 1000
30
31/**********************************************************************
32** memory mapping scheme for YapOr (mandatory, define one) **
33**********************************************************************/
34#define MMAP_MEMORY_MAPPING_SCHEME 1
35/* #define SHM_MEMORY_MAPPING_SCHEME 1 */
36
37/****************************************************************
38** use shared pages memory alloc scheme ? (optional) **
39****************************************************************/
40/* #define USE_PAGES_MALLOC 1 */
41
42/**********************************************************************
43** trail freeze scheme for tabling (mandatory, define one) **
44**********************************************************************/
45#define BFZ_TRAIL_SCHEME 1
46/* #define BBREG_TRAIL_SCHEME 1 */
47
48/************************************************************************
49** multithreading design for tabling (mandatory, define one) **
50************************************************************************/
51#define THREADS_NO_SHARING 1
52/* #define THREADS_SUBGOAL_SHARING 1 */
53/* #define THREADS_FULL_SHARING 1 */
54/* #define THREADS_CONSUMER_SHARING 1 */
55
56/*************************************************************************
57** tries locking scheme (mandatory, define one per trie type) **
58**************************************************************************
59** The (TRIE_TYPE)_LOCK_AT_ENTRY_LEVEL scheme locks the access to the **
60** table space in the entry data structure. It restricts the number of **
61** lock operations needed to go through the table data structures. **
62** **
63** The (TRIE_TYPE)_LOCK_AT_NODE_LEVEL scheme locks each data structure **
64** before accessing it. It decreases concurrrency for workers accessing **
65** commom parts of the table space. **
66** **
67** The (TRIE_TYPE)_LOCK_AT_WRITE_LEVEL scheme is an hibrid scheme, it **
68** only locks a table data structure when it is going to update it. You **
69** can use (TRIE_TYPE)_ALLOC_BEFORE_CHECK with this scheme to allocate **
70** a node before checking if it will be necessary. **
71*************************************************************************/
72/* #define SUBGOAL_TRIE_LOCK_AT_ENTRY_LEVEL 1 */
73#define SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL 1
74/* #define SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL 1 */
75/* #define SUBGOAL_TRIE_ALLOC_BEFORE_CHECK 1 */
76
77/* #define ANSWER_TRIE_LOCK_AT_ENTRY_LEVEL 1 */
78#define ANSWER_TRIE_LOCK_AT_NODE_LEVEL 1
79/* #define ANSWER_TRIE_LOCK_AT_WRITE_LEVEL 1 */
80/* #define ANSWER_TRIE_ALLOC_BEFORE_CHECK 1 */
81
82#define GLOBAL_TRIE_LOCK_AT_NODE_LEVEL 1
83/* #define GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL 1 */
84/* #define GLOBAL_TRIE_ALLOC_BEFORE_CHECK 1 */
85
86/*******************************************************************
87** tries locking data structure (mandatory, define one) **
88********************************************************************
89** Data structure to be used for locking the trie when using the **
90** (TRIE_TYPE)_LOCK_AT_[NODE|WRITE]_LEVEL schemes **
91*******************************************************************/
92#define TRIE_LOCK_USING_NODE_FIELD 1
93/* #define TRIE_LOCK_USING_GLOBAL_ARRAY 1 */
94
95/*********************************************************
96** support mode directed tabling ? (optional) **
97*********************************************************/
98#define MODE_DIRECTED_TABLING 1
99
100/****************************************************************
101** support early completion for tabling ? (optional) **
102*****************************************************************/
103#define TABLING_EARLY_COMPLETION 1
104
105/******************************************************
106** support trie compact pairs ? (optional) **
107******************************************************/
108#define TRIE_COMPACT_PAIRS 1
109
110/************************************************************
111** support global trie for subterms ? (optional) **
112************************************************************/
113/* #define GLOBAL_TRIE_FOR_SUBTERMS 1 */
114
115/******************************************************
116** support incomplete tabling ? (optional) **
117******************************************************/
118/* #define INCOMPLETE_TABLING 1 */
119
120/******************************************************
121** limit the table space size ? (optional) **
122******************************************************/
123/* #define LIMIT_TABLING 1 */
124
125/*********************************************************
126** support deterministic tabling ? (optional) **
127*********************************************************/
128/* #define DETERMINISTIC_TABLING 1 */
129
130/******************************************************************
131** support tabling inner cuts with OPTYap ? (optional) **
132******************************************************************/
133#define TABLING_INNER_CUTS 1
134
135/*********************************************************************
136** use timestamps for suspension with OPTYap ? (optional) **
137*********************************************************************/
138#define TIMESTAMP_CHECK 1
139
140/*************************************************
141** enable error checking ? (optional) **
142*************************************************/
143/* #define DEBUG_TABLING 1 */
144/* #define DEBUG_YAPOR 1 */
145
146/**************************************************
147** enable output checking ? (optional) **
148**************************************************/
149/* #define OUTPUT_THREADS_TABLING 1 */
150
151/*********************************************************
152** support rational terms ? (optional) **
153*********************************************************/
154#define TRIE_RATIONAL_TERMS 1
155
156
157
158
159/************************************************************************
160** Parameter Checks **
161************************************************************************/
162
163#ifdef YAPOR
164#ifdef i386 /* For i386 machines we use shared memory segments */
165#undef MMAP_MEMORY_MAPPING_SCHEME
166#define SHM_MEMORY_MAPPING_SCHEME
167#endif
168#if !defined(MMAP_MEMORY_MAPPING_SCHEME) && !defined(SHM_MEMORY_MAPPING_SCHEME)
169#error Define a memory mapping scheme
170#endif
171#if defined(MMAP_MEMORY_MAPPING_SCHEME) && defined(SHM_MEMORY_MAPPING_SCHEME)
172#error Do not define multiple memory mapping schemes
173#endif
174#else /* ! YAPOR */
175#undef MMAP_MEMORY_MAPPING_SCHEME
176#undef SHM_MEMORY_MAPPING_SCHEME
177#undef DEBUG_YAPOR
178#endif /* YAPOR */
179
180#ifdef TABLING
181#if !defined(BFZ_TRAIL_SCHEME) && !defined(BBREG_TRAIL_SCHEME)
182#error Define a trail scheme
183#endif
184#if defined(BFZ_TRAIL_SCHEME) && defined(BBREG_TRAIL_SCHEME)
185#error Do not define multiple trail schemes
186#endif
187#else /* ! TABLING */
188#undef BFZ_TRAIL_SCHEME
189#undef BBREG_TRAIL_SCHEME
190#undef MODE_DIRECTED_TABLING
191#undef TABLING_EARLY_COMPLETION
192#undef TRIE_COMPACT_PAIRS
193#undef GLOBAL_TRIE_FOR_SUBTERMS
194#undef INCOMPLETE_TABLING
195#undef LIMIT_TABLING
196#undef DETERMINISTIC_TABLING
197#undef DEBUG_TABLING
198#endif /* TABLING */
199
200#if defined(TABLING) && (defined(YAPOR) || defined(THREADS))
201/* SUBGOAL_TRIE_LOCK_LEVEL */
202#if !defined(SUBGOAL_TRIE_LOCK_AT_ENTRY_LEVEL) && !defined(SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL) && !defined(SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL)
203#error Define a subgoal trie lock scheme
204#endif
205#if defined(SUBGOAL_TRIE_LOCK_AT_ENTRY_LEVEL) && defined(SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL)
206#error Do not define multiple subgoal trie lock schemes
207#endif
208#if defined(SUBGOAL_TRIE_LOCK_AT_ENTRY_LEVEL) && defined(SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL)
209#error Do not define multiple subgoal trie lock schemes
210#endif
211#if defined(SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL) && defined(SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL)
212#error Do not define multiple subgoal trie lock schemes
213#endif
214#ifndef SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL
215#undef SUBGOAL_TRIE_ALLOC_BEFORE_CHECK
216#endif
217/* ANSWER_TRIE_LOCK_LEVEL */
218#if !defined(ANSWER_TRIE_LOCK_AT_ENTRY_LEVEL) && !defined(ANSWER_TRIE_LOCK_AT_NODE_LEVEL) && !defined(ANSWER_TRIE_LOCK_AT_WRITE_LEVEL)
219#error Define a answer trie lock scheme
220#endif
221#if defined(ANSWER_TRIE_LOCK_AT_ENTRY_LEVEL) && defined(ANSWER_TRIE_LOCK_AT_NODE_LEVEL)
222#error Do not define multiple answer trie lock schemes
223#endif
224#if defined(ANSWER_TRIE_LOCK_AT_ENTRY_LEVEL) && defined(ANSWER_TRIE_LOCK_AT_WRITE_LEVEL)
225#error Do not define multiple answer trie lock schemes
226#endif
227#if defined(ANSWER_TRIE_LOCK_AT_NODE_LEVEL) && defined(ANSWER_TRIE_LOCK_AT_WRITE_LEVEL)
228#error Do not define multiple answer trie lock schemes
229#endif
230#ifndef ANSWER_TRIE_LOCK_AT_WRITE_LEVEL
231#undef ANSWER_TRIE_ALLOC_BEFORE_CHECK
232#endif
233/* GLOBAL_TRIE_LOCK_LEVEL */
234#if !defined(GLOBAL_TRIE_LOCK_AT_NODE_LEVEL) && !defined(GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL)
235#error Define a global trie lock scheme
236#endif
237#if defined(GLOBAL_TRIE_LOCK_AT_NODE_LEVEL) && defined(GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL)
238#error Do not define multiple global trie lock schemes
239#endif
240#ifndef GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL
241#undef GLOBAL_TRIE_ALLOC_BEFORE_CHECK
242#endif
243/* TRIE_LOCK_USING */
244#if !defined(TRIE_LOCK_USING_NODE_FIELD) && !defined(TRIE_LOCK_USING_GLOBAL_ARRAY)
245#error Define a trie lock data structure
246#endif
247#if defined(TRIE_LOCK_USING_NODE_FIELD) && defined(TRIE_LOCK_USING_GLOBAL_ARRAY)
248#error Do not define multiple trie lock data structures
249#endif
250#else /* ! TABLING || (! YAPOR && ! THREADS) */
251#undef SUBGOAL_TRIE_LOCK_AT_ENTRY_LEVEL
252#undef SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL
253#undef SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL
254#undef SUBGOAL_TRIE_ALLOC_BEFORE_CHECK
255#undef ANSWER_TRIE_LOCK_AT_ENTRY_LEVEL
256#undef ANSWER_TRIE_LOCK_AT_NODE_LEVEL
257#undef ANSWER_TRIE_LOCK_AT_WRITE_LEVEL
258#undef ANSWER_TRIE_ALLOC_BEFORE_CHECK
259#undef GLOBAL_TRIE_LOCK_AT_NODE_LEVEL
260#undef GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL
261#undef GLOBAL_TRIE_ALLOC_BEFORE_CHECK
262#undef TRIE_LOCK_USING_NODE_FIELD
263#undef TRIE_LOCK_USING_GLOBAL_ARRAY
264#endif /* TABLING && (YAPOR || THREADS) */
265
266#if defined(TABLING) && defined(THREADS)
267#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING)
268#error Define a multithreading table design
269#endif
270#if defined(THREADS_NO_SHARING) && defined(THREADS_SUBGOAL_SHARING)
271#error Do not define multiple multithreading table designs
272#endif
273#if defined(THREADS_NO_SHARING) && defined(THREADS_FULL_SHARING)
274#error Do not define multiple multithreading table designs
275#endif
276#if defined(THREADS_NO_SHARING) && defined(THREADS_CONSUMER_SHARING)
277#error Do not define multiple multithreading table designs
278#endif
279#if defined(THREADS_SUBGOAL_SHARING) && defined(THREADS_FULL_SHARING)
280#error Do not define multiple multithreading table designs
281#endif
282#if defined(THREADS_SUBGOAL_SHARING) && defined(THREADS_CONSUMER_SHARING)
283#error Do not define multiple multithreading table designs
284#endif
285#if defined(THREADS_FULL_SHARING) && defined(THREADS_CONSUMER_SHARING)
286#error Do not define multiple multithreading table designs
287#endif
288#ifdef THREADS_NO_SHARING
289#undef SUBGOAL_TRIE_LOCK_AT_ENTRY_LEVEL
290#undef SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL
291#undef SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL
292#undef SUBGOAL_TRIE_ALLOC_BEFORE_CHECK
293#endif
294#if defined(THREADS_NO_SHARING) || defined(THREADS_SUBGOAL_SHARING)
295#undef ANSWER_TRIE_LOCK_AT_ENTRY_LEVEL
296#undef ANSWER_TRIE_LOCK_AT_NODE_LEVEL
297#undef ANSWER_TRIE_LOCK_AT_WRITE_LEVEL
298#undef ANSWER_TRIE_ALLOC_BEFORE_CHECK
299#endif
300#else /* ! TABLING || ! THREADS */
301#undef THREADS_NO_SHARING
302#undef THREADS_SUBGOAL_SHARING
303#undef THREADS_FULL_SHARING
304#undef THREADS_CONSUMER_SHARING
305#endif /* TABLING && THREADS */
306
307#ifdef TRIE_LOCK_USING_NODE_FIELD
308#if defined(SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL) || defined(SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL)
309#define SUBGOAL_TRIE_LOCK_USING_NODE_FIELD 1
310#endif
311#if defined(ANSWER_TRIE_LOCK_AT_NODE_LEVEL) || defined(ANSWER_TRIE_LOCK_AT_WRITE_LEVEL)
312#define ANSWER_TRIE_LOCK_USING_NODE_FIELD 1
313#endif
314#if defined(GLOBAL_TRIE_LOCK_AT_NODE_LEVEL) || defined(GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL)
315#define GLOBAL_TRIE_LOCK_USING_NODE_FIELD 1
316#endif
317#elif defined(TRIE_LOCK_USING_GLOBAL_ARRAY)
318#if defined(SUBGOAL_TRIE_LOCK_AT_NODE_LEVEL) || defined(SUBGOAL_TRIE_LOCK_AT_WRITE_LEVEL)
319#define SUBGOAL_TRIE_LOCK_USING_GLOBAL_ARRAY 1
320#endif
321#if defined(ANSWER_TRIE_LOCK_AT_NODE_LEVEL) || defined(ANSWER_TRIE_LOCK_AT_WRITE_LEVEL)
322#define ANSWER_TRIE_LOCK_USING_GLOBAL_ARRAY 1
323#endif
324#if defined(GLOBAL_TRIE_LOCK_AT_NODE_LEVEL) || defined(GLOBAL_TRIE_LOCK_AT_WRITE_LEVEL)
325#define GLOBAL_TRIE_LOCK_USING_GLOBAL_ARRAY 1
326#endif
327#endif
328
329#if !defined(TABLING) || !defined(YAPOR)
330#undef TABLING_INNER_CUTS
331#undef TIMESTAMP_CHECK
332#endif
333
334#if !defined(TABLING) || !defined(THREADS)
335#undef OUTPUT_THREADS_TABLING
336#endif
337
338#if defined(DEBUG_YAPOR) && defined(DEBUG_TABLING)
339#define DEBUG_OPTYAP
340#endif
341
342#if defined(LIMIT_TABLING) && !defined(USE_PAGES_MALLOC)
343#error LIMIT_TABLING requires USE_PAGES_MALLOC
344#endif
345
346#if defined(YAPOR) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
347#undef TABLING_EARLY_COMPLETION
348#endif
349
350#if defined(YAPOR) || defined(THREADS)
351#undef INCOMPLETE_TABLING
352#undef LIMIT_TABLING
353#undef DETERMINISTIC_TABLING
354#endif
355
356#if defined(YAPOR)
357#undef MODE_DIRECTED_TABLING
358#endif