minor changes for mode directed tabling
This commit is contained in:
parent
5c5fa5af55
commit
8f7983b6c4
|
@ -1110,20 +1110,22 @@
|
|||
if (TrNode_child(ans_node)) {
|
||||
/* unconsumed answers */
|
||||
#ifdef MODE_DIRECTED_TABLING
|
||||
ans_node_ptr first_ans_node, aux_ans_node;
|
||||
first_ans_node = ans_node;
|
||||
do {
|
||||
if (IS_INVALID_LEAF_NODE(TrNode_child(ans_node))) {
|
||||
ans_node_ptr first_ans_node, aux_ans_node;
|
||||
first_ans_node = ans_node;
|
||||
ans_node = TrNode_child(ans_node);
|
||||
} while (IS_INVALID_LEAF_NODE(ans_node));
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
while (aux_ans_node != ans_node) {
|
||||
TrNode_child(first_ans_node) = ans_node;
|
||||
first_ans_node = aux_ans_node;
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
}
|
||||
#else
|
||||
ans_node = TrNode_child(ans_node);
|
||||
do {
|
||||
ans_node = TrNode_child(ans_node);
|
||||
} while (IS_INVALID_LEAF_NODE(ans_node));
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
do {
|
||||
TrNode_child(first_ans_node) = ans_node;
|
||||
first_ans_node = aux_ans_node;
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
} while (aux_ans_node != ans_node);
|
||||
} else
|
||||
#endif /* MODE_DIRECTED_TABLING */
|
||||
ans_node = TrNode_child(ans_node);
|
||||
DepFr_last_answer(dep_fr) = ans_node;
|
||||
UNLOCK(DepFr_lock(dep_fr));
|
||||
consume_answer_and_procceed(dep_fr, ans_node);
|
||||
|
@ -1172,20 +1174,22 @@
|
|||
if (TrNode_child(ans_node)) {
|
||||
/* dependency frame with unconsumed answers */
|
||||
#ifdef MODE_DIRECTED_TABLING
|
||||
ans_node_ptr first_ans_node, aux_ans_node;
|
||||
first_ans_node = ans_node;
|
||||
do {
|
||||
if (IS_INVALID_LEAF_NODE(TrNode_child(ans_node))) {
|
||||
ans_node_ptr first_ans_node, aux_ans_node;
|
||||
first_ans_node = ans_node;
|
||||
ans_node = TrNode_child(ans_node);
|
||||
} while (IS_INVALID_LEAF_NODE(ans_node));
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
while (aux_ans_node != ans_node) {
|
||||
TrNode_child(first_ans_node) = ans_node;
|
||||
first_ans_node = aux_ans_node;
|
||||
do {
|
||||
ans_node = TrNode_child(ans_node);
|
||||
} while (IS_INVALID_LEAF_NODE(ans_node));
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
}
|
||||
#else
|
||||
ans_node = TrNode_child(ans_node);
|
||||
do {
|
||||
TrNode_child(first_ans_node) = ans_node;
|
||||
first_ans_node = aux_ans_node;
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
} while (aux_ans_node != ans_node);
|
||||
} else
|
||||
#endif /* MODE_DIRECTED_TABLING */
|
||||
ans_node = TrNode_child(ans_node);
|
||||
DepFr_last_answer(dep_fr) = ans_node;
|
||||
#ifdef YAPOR
|
||||
if (YOUNGER_CP(DepFr_backchain_cp(dep_fr), top_chain_cp))
|
||||
|
@ -1429,20 +1433,22 @@
|
|||
if (TrNode_child(ans_node)) {
|
||||
/* dependency frame with unconsumed answers */
|
||||
#ifdef MODE_DIRECTED_TABLING
|
||||
ans_node_ptr first_ans_node, aux_ans_node;
|
||||
first_ans_node = ans_node;
|
||||
do {
|
||||
if (IS_INVALID_LEAF_NODE(TrNode_child(ans_node))) {
|
||||
ans_node_ptr first_ans_node, aux_ans_node;
|
||||
first_ans_node = ans_node;
|
||||
ans_node = TrNode_child(ans_node);
|
||||
} while (IS_INVALID_LEAF_NODE(ans_node));
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
while (aux_ans_node != ans_node) {
|
||||
TrNode_child(first_ans_node) = ans_node;
|
||||
first_ans_node = aux_ans_node;
|
||||
do {
|
||||
ans_node = TrNode_child(ans_node);
|
||||
} while (IS_INVALID_LEAF_NODE(ans_node));
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
}
|
||||
#else
|
||||
ans_node = TrNode_child(ans_node);
|
||||
do {
|
||||
TrNode_child(first_ans_node) = ans_node;
|
||||
first_ans_node = aux_ans_node;
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
} while (aux_ans_node != ans_node);
|
||||
} else
|
||||
#endif /* MODE_DIRECTED_TABLING */
|
||||
ans_node = TrNode_child(ans_node);
|
||||
DepFr_last_answer(dep_fr) = ans_node;
|
||||
if (B->cp_ap) {
|
||||
#ifdef YAPOR
|
||||
|
@ -1602,20 +1608,22 @@
|
|||
/* unconsumed answers */
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
#ifdef MODE_DIRECTED_TABLING
|
||||
ans_node_ptr first_ans_node, aux_ans_node;
|
||||
first_ans_node = ans_node;
|
||||
do {
|
||||
if (IS_INVALID_LEAF_NODE(TrNode_child(ans_node))) {
|
||||
ans_node_ptr first_ans_node, aux_ans_node;
|
||||
first_ans_node = ans_node;
|
||||
ans_node = TrNode_child(ans_node);
|
||||
} while (IS_INVALID_LEAF_NODE(ans_node));
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
while (aux_ans_node != ans_node) {
|
||||
TrNode_child(first_ans_node) = ans_node;
|
||||
first_ans_node = aux_ans_node;
|
||||
do {
|
||||
ans_node = TrNode_child(ans_node);
|
||||
} while (IS_INVALID_LEAF_NODE(ans_node));
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
}
|
||||
#else
|
||||
ans_node = TrNode_child(ans_node);
|
||||
do {
|
||||
TrNode_child(first_ans_node) = ans_node;
|
||||
first_ans_node = aux_ans_node;
|
||||
aux_ans_node = TrNode_child(first_ans_node);
|
||||
} while (aux_ans_node != ans_node);
|
||||
} else
|
||||
#endif /* MODE_DIRECTED_TABLING */
|
||||
ans_node = TrNode_child(ans_node);
|
||||
DepFr_last_answer(LOCAL_top_dep_fr) = ans_node;
|
||||
UNLOCK(DepFr_lock(LOCAL_top_dep_fr));
|
||||
consume_answer_and_procceed(LOCAL_top_dep_fr, ans_node);
|
||||
|
|
|
@ -220,13 +220,13 @@ typedef struct subgoal_frame {
|
|||
struct answer_trie_node *answer_trie;
|
||||
struct answer_trie_node *first_answer;
|
||||
struct answer_trie_node *last_answer;
|
||||
#ifdef MODE_DIRECTED_TABLING
|
||||
int* mode_directed_array;
|
||||
struct answer_trie_node *invalid_chain;
|
||||
#endif /*MODE_DIRECTED_TABLING*/
|
||||
#ifdef INCOMPLETE_TABLING
|
||||
struct answer_trie_node *try_answer;
|
||||
#endif /* INCOMPLETE_TABLING */
|
||||
#ifdef MODE_DIRECTED_TABLING
|
||||
struct answer_trie_node *invalid_chain;
|
||||
int* mode_directed_array;
|
||||
#endif /*MODE_DIRECTED_TABLING*/
|
||||
#ifdef LIMIT_TABLING
|
||||
struct subgoal_frame *previous;
|
||||
#endif /* LIMIT_TABLING */
|
||||
|
@ -245,9 +245,9 @@ typedef struct subgoal_frame {
|
|||
#define SgFr_answer_trie(X) ((X)->answer_trie)
|
||||
#define SgFr_first_answer(X) ((X)->first_answer)
|
||||
#define SgFr_last_answer(X) ((X)->last_answer)
|
||||
#define SgFr_try_answer(X) ((X)->try_answer)
|
||||
#define SgFr_invalid_chain(X) ((X)->invalid_chain)
|
||||
#define SgFr_mode_directed(X) ((X)->mode_directed_array)
|
||||
#define SgFr_invalid_chain(X) ((X)->invalid_chain)
|
||||
#define SgFr_try_answer(X) ((X)->try_answer)
|
||||
#define SgFr_previous(X) ((X)->previous)
|
||||
#define SgFr_next(X) ((X)->next)
|
||||
|
||||
|
@ -269,11 +269,11 @@ typedef struct subgoal_frame {
|
|||
It is used to check for/insert new answers.
|
||||
SgFr_first_answer: a pointer to the bottom answer trie node of the first available answer.
|
||||
SgFr_last_answer: a pointer to the bottom answer trie node of the last available answer.
|
||||
SgFr_mode_directed: a pointer to the mode directed array.
|
||||
SgFr_invalid_chain: a pointer to the first invalid leaf node when using mode directed tabling.
|
||||
SgFr_try_answer: a pointer to the bottom answer trie node of the last tried answer.
|
||||
It is used when a subgoal was not completed during the previous evaluation.
|
||||
Not completed subgoals start by trying the answers already found.
|
||||
SgFr_invalid_chain: a pointer to the first invalid leaf node when using mode directed tabling.
|
||||
SgFr_mode_directed: a pointer to the mode directed array.
|
||||
SgFr_previous: a pointer to the previous subgoal frame on the chain.
|
||||
SgFr_next: a pointer to the next subgoal frame on the chain.
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
#define LOCK_NODE(NODE) LOCK_TABLE(NODE)
|
||||
#define UNLOCK_NODE(NODE) UNLOCK_TABLE(NODE)
|
||||
#elif defined(TABLE_LOCK_AT_NODE_LEVEL)
|
||||
#define LOCK_NODE(NODE) TRIE_LOCK(TrNode_lock(NODE))
|
||||
#define LOCK_NODE(NODE) LOCK(TrNode_lock(NODE))
|
||||
#define UNLOCK_NODE(NODE) UNLOCK(TrNode_lock(NODE))
|
||||
#else /* TABLE_LOCK_AT_ENTRY_LEVEL || ! YAPOR */
|
||||
#define LOCK_NODE(NODE)
|
||||
|
@ -1308,7 +1308,9 @@ static void invalidate_answer_trie(ans_node_ptr current_node, sg_fr_ptr sg_fr, i
|
|||
invalidate_answer_trie(TrNode_child(current_node), sg_fr, TRAVERSE_POSITION_FIRST);
|
||||
FREE_ANSWER_TRIE_NODE(current_node);
|
||||
} else {
|
||||
LOCK_NODE(current_ans_node);
|
||||
TAG_AS_INVALID_LEAF_NODE(current_node);
|
||||
UNLOCK_NODE(current_ans_node);
|
||||
TrNode_next(current_node) = SgFr_invalid_chain(sg_fr);
|
||||
SgFr_invalid_chain(sg_fr) = current_node;
|
||||
}
|
||||
|
|
Reference in New Issue