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

View File

@ -39,6 +39,21 @@
#define BFZ_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) **
** ------------------------------------------------ */
@ -49,16 +64,6 @@
** ------------------------------------------------ */
/* #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) **
** ------------------------------------------- */
@ -220,10 +225,11 @@
#ifndef TABLING
#undef BFZ_TRAIL_SCHEME
#undef BBREG_TRAIL_SCHEME
#undef TRIE_COMPACT_PAIRS
#undef TABLING_EARLY_COMPLETION
#undef DETERMINISTIC_TABLING
#undef LIMIT_TABLING
#undef INCOMPLETE_TABLING
#undef TRIE_COMPACT_PAIRS
#undef DETERMINISTIC_TABLING
#undef TABLING_ERRORS
#endif /* !TABLING */

View File

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

View File

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