YapTab: support for early completion

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2246 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
ricroc 2008-05-23 18:28:58 +00:00
parent fbc1f5e4a9
commit 501e3d7c30
3 changed files with 27 additions and 26 deletions

View File

@ -5,7 +5,7 @@
Copyright: R. Rocha and NCC - University of Porto, Portugal
File: tab.insts.i
version: $Id: tab.insts.i,v 1.25 2008-05-20 18:25:37 ricroc Exp $
version: $Id: tab.insts.i,v 1.26 2008-05-23 18:28:58 ricroc Exp $
**********************************************************************/
@ -739,8 +739,6 @@
sg_fr_ptr sg_fr;
ans_node_ptr ans_node;
/* possible optimization: when the number of substitution variables **
** is zero, an answer is sufficient to perform an early completion */
gcp = NORM_CP(YENV[E_B]);
sg_fr = GEN_CP(gcp)->cp_sg_fr;
subs_ptr = (CELL *)(GEN_CP(gcp) + 1) + PREG->u.s.s;

View File

@ -5,7 +5,7 @@
Copyright: R. Rocha and NCC - University of Porto, Portugal
File: tab.macros.h
version: $Id: tab.macros.h,v 1.21 2008-05-05 17:17:35 ricroc Exp $
version: $Id: tab.macros.h,v 1.22 2008-05-23 18:28:58 ricroc Exp $
**********************************************************************/
@ -547,29 +547,28 @@ void abolish_incomplete_subgoals(choiceptr prune_cp) {
/* no answers --> ready */
SgFr_state(sg_fr) = ready;
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; */
UNLOCK(SgFr_lock(sg_fr));
} else {
if (SgFr_first_answer(sg_fr) == SgFr_answer_trie(sg_fr)) {
/* yes answer --> complete */
SgFr_state(sg_fr) = complete;
UNLOCK(SgFr_lock(sg_fr));
} else {
/* answers --> incomplete/ready */
/* answers --> incomplete/ready */
#ifdef INCOMPLETE_TABLING
SgFr_state(sg_fr) = incomplete;
UNLOCK(SgFr_lock(sg_fr));
SgFr_state(sg_fr) = incomplete;
UNLOCK(SgFr_lock(sg_fr));
#else
ans_node_ptr node;
SgFr_state(sg_fr) = ready;
free_answer_hash_chain(SgFr_hash_chain(sg_fr));
SgFr_hash_chain(sg_fr) = NULL;
SgFr_first_answer(sg_fr) = NULL;
SgFr_last_answer(sg_fr) = NULL;
node = TrNode_child(SgFr_answer_trie(sg_fr));
TrNode_child(SgFr_answer_trie(sg_fr)) = NULL;
UNLOCK(SgFr_lock(sg_fr));
free_answer_trie_branch(node);
ans_node_ptr node;
SgFr_state(sg_fr) = ready;
free_answer_hash_chain(SgFr_hash_chain(sg_fr));
SgFr_hash_chain(sg_fr) = NULL;
SgFr_first_answer(sg_fr) = NULL;
SgFr_last_answer(sg_fr) = NULL;
node = TrNode_child(SgFr_answer_trie(sg_fr));
TrNode_child(SgFr_answer_trie(sg_fr)) = NULL;
UNLOCK(SgFr_lock(sg_fr));
free_answer_trie_branch(node);
#endif /* INCOMPLETE_TABLING */
}
}
#ifdef LIMIT_TABLING
insert_into_global_sg_fr_list(sg_fr);

View File

@ -5,7 +5,7 @@
Copyright: R. Rocha and NCC - University of Porto, Portugal
File: tab.suspend.c
version: $Id: tab.suspend.c,v 1.4 2005-05-31 08:24:24 ricroc Exp $
version: $Id: tab.suspend.c,v 1.5 2008-05-23 18:28:58 ricroc Exp $
**********************************************************************/
@ -369,14 +369,18 @@ void complete_suspension_branch(susp_fr_ptr susp_fr, choiceptr top_cp, or_fr_ptr
aux_sg_fr = SuspFr_top_sg_fr(susp_fr);
if (DepFr_leader_dep_is_on_stack(aux_dep_fr)) {
while (aux_sg_fr &&
SgFr_state(aux_sg_fr) == evaluating &&
/* continue if the subgoal was early completed */
/* SgFr_state(aux_sg_fr) == evaluating && */
(SgFr_state(aux_sg_fr) == evaluating || SgFr_first_answer(aux_sg_fr) == SgFr_answer_trie(aux_sg_fr)) &&
EQUAL_OR_YOUNGER_CP(SgFr_gen_cp(aux_sg_fr), top_cp)) {
mark_as_completed(aux_sg_fr);
aux_sg_fr = SgFr_next(aux_sg_fr);
}
} else {
while (aux_sg_fr &&
SgFr_state(aux_sg_fr) == evaluating &&
/* continue if the subgoal was early completed */
/* SgFr_state(aux_sg_fr) == evaluating && */
(SgFr_state(aux_sg_fr) == evaluating || SgFr_first_answer(aux_sg_fr) == SgFr_answer_trie(aux_sg_fr)) &&
YOUNGER_CP(SgFr_gen_cp(aux_sg_fr), top_cp)) {
mark_as_completed(aux_sg_fr);
aux_sg_fr = SgFr_next(aux_sg_fr);