diff --git a/OPTYap/opt.config.h b/OPTYap/opt.config.h index 7361cbf6d..5024f3f58 100644 --- a/OPTYap/opt.config.h +++ b/OPTYap/opt.config.h @@ -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 */ diff --git a/OPTYap/tab.insts.i b/OPTYap/tab.insts.i index 5c045297b..802193cda 100644 --- a/OPTYap/tab.insts.i +++ b/OPTYap/tab.insts.i @@ -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; } diff --git a/OPTYap/tab.macros.h b/OPTYap/tab.macros.h index 6be6aec68..b0ff35016 100644 --- a/OPTYap/tab.macros.h +++ b/OPTYap/tab.macros.h @@ -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 */