make the support for early completion optional (macro TABLING_EARLY_COMPLETION)

This commit is contained in:
Ricardo Rocha 2009-08-06 02:27:59 +01:00
parent cf5d68edda
commit 36e6925776
3 changed files with 34 additions and 20 deletions

@ -39,6 +39,21 @@
#define BFZ_TRAIL_SCHEME 1 #define BFZ_TRAIL_SCHEME 1
/* #define BBREG_TRAIL_SCHEME 1 */ /* #define BBREG_TRAIL_SCHEME 1 */
/* ------------------------------------------------ **
** support trie compact pairs? (optional) **
** ------------------------------------------------ */
/* #define TRIE_COMPACT_PAIRS 1 */
/* ----------------------------------------------- **
** support early completion ? (optional) **
** ----------------------------------------------- */
#define TABLING_EARLY_COMPLETION 1
/* --------------------------------------------------- **
** support deterministic tabling? (optional) **
** --------------------------------------------------- */
/* #define DETERMINISTIC_TABLING 1 */
/* ------------------------------------------------ ** /* ------------------------------------------------ **
** limit the table space size? (optional) ** ** limit the table space size? (optional) **
** ------------------------------------------------ */ ** ------------------------------------------------ */
@ -49,16 +64,6 @@
** ------------------------------------------------ */ ** ------------------------------------------------ */
/* #define INCOMPLETE_TABLING 1 */ /* #define INCOMPLETE_TABLING 1 */
/* ------------------------------------------------ **
** support trie compact pairs? (optional) **
** ------------------------------------------------ */
/* #define TRIE_COMPACT_PAIRS 1 */
/* --------------------------------------------------- **
** support deterministic tabling? (optional) **
** --------------------------------------------------- */
/* #define DETERMINISTIC_TABLING 1 */
/* ---------------------------------------- -- ** /* ---------------------------------------- -- **
** enable error checking? (optional) ** ** enable error checking? (optional) **
** ------------------------------------------- */ ** ------------------------------------------- */
@ -220,10 +225,11 @@
#ifndef TABLING #ifndef TABLING
#undef BFZ_TRAIL_SCHEME #undef BFZ_TRAIL_SCHEME
#undef BBREG_TRAIL_SCHEME #undef BBREG_TRAIL_SCHEME
#undef TRIE_COMPACT_PAIRS
#undef TABLING_EARLY_COMPLETION
#undef DETERMINISTIC_TABLING
#undef LIMIT_TABLING #undef LIMIT_TABLING
#undef INCOMPLETE_TABLING #undef INCOMPLETE_TABLING
#undef TRIE_COMPACT_PAIRS
#undef DETERMINISTIC_TABLING
#undef TABLING_ERRORS #undef TABLING_ERRORS
#endif /* !TABLING */ #endif /* !TABLING */

@ -1001,8 +1001,7 @@
#endif /* TABLING_ERRORS */ #endif /* TABLING_ERRORS */
UNLOCK(SgFr_lock(sg_fr)); UNLOCK(SgFr_lock(sg_fr));
if (IS_BATCHED_GEN_CP(gcp)) { if (IS_BATCHED_GEN_CP(gcp)) {
/* if the number of substitution variables is zero, #ifdef TABLING_EARLY_COMPLETION
an answer is sufficient to perform an early completion */
#ifdef DETERMINISTIC_TABLING #ifdef DETERMINISTIC_TABLING
if (IS_DET_GEN_CP(gcp) && gcp == B) { if (IS_DET_GEN_CP(gcp) && gcp == B) {
private_completion(sg_fr); private_completion(sg_fr);
@ -1010,10 +1009,14 @@
SET_BB(PROTECT_FROZEN_B(B)); SET_BB(PROTECT_FROZEN_B(B));
} else } else
#endif /* DETERMINISTIC_TABLING */ #endif /* DETERMINISTIC_TABLING */
if (*subs_ptr == 0 && gcp->cp_ap != NULL) { /* if the number of substitution variables is zero,
gcp->cp_ap = COMPLETION; an answer is sufficient to perform an early completion */
if (*subs_ptr == 0) {
if (gcp->cp_ap != NULL)
gcp->cp_ap = COMPLETION;
mark_as_completed(sg_fr); mark_as_completed(sg_fr);
} }
#endif /* TABLING_EARLY_COMPLETION */
/* deallocate and procceed */ /* deallocate and procceed */
PREG = (yamop *) YENV[E_CP]; PREG = (yamop *) YENV[E_CP];
PREFETCH_OP(PREG); PREFETCH_OP(PREG);
@ -1025,12 +1028,15 @@
#endif /* DEPTH_LIMIT */ #endif /* DEPTH_LIMIT */
GONext(); GONext();
} else { } else {
#ifdef TABLING_EARLY_COMPLETION
/* if the number of substitution variables is zero, /* if the number of substitution variables is zero,
an answer is sufficient to perform an early completion */ an answer is sufficient to perform an early completion */
if (*subs_ptr == 0 && gcp->cp_ap != ANSWER_RESOLUTION) { if (*subs_ptr == 0) {
gcp->cp_ap = COMPLETION; if (gcp->cp_ap != ANSWER_RESOLUTION)
gcp->cp_ap = COMPLETION;
mark_as_completed(sg_fr); mark_as_completed(sg_fr);
} }
#endif /* TABLING_EARLY_COMPLETION */
/* fail */ /* fail */
goto fail; goto fail;
} }

@ -608,8 +608,10 @@ void abolish_incomplete_subgoals(choiceptr prune_cp) {
UNLOCK(SgFr_lock(sg_fr)); UNLOCK(SgFr_lock(sg_fr));
} else if (SgFr_first_answer(sg_fr) == SgFr_answer_trie(sg_fr)) { } else if (SgFr_first_answer(sg_fr) == SgFr_answer_trie(sg_fr)) {
/* yes answer --> complete */ /* yes answer --> complete */
/* at this point the subgoal should be already completed (early completion) */ #ifndef TABLING_EARLY_COMPLETION
/* SgFr_state(sg_fr) = complete; */ /* with early completion, at this point the subgoal should be already completed */
SgFr_state(sg_fr) = complete;
#endif /* TABLING_EARLY_COMPLETION */
UNLOCK(SgFr_lock(sg_fr)); UNLOCK(SgFr_lock(sg_fr));
} else { } else {
/* answers --> incomplete/ready */ /* answers --> incomplete/ready */