From f0c0913490a2e68cbf32b0964f701e41e27d58b8 Mon Sep 17 00:00:00 2001 From: Ricardo Rocha Date: Wed, 6 Jun 2012 15:19:38 +0100 Subject: [PATCH] fix multithreading with mode-directed tabling --- OPTYap/tab.tries.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OPTYap/tab.tries.c b/OPTYap/tab.tries.c index aed6e875b..d42a99b6f 100644 --- a/OPTYap/tab.tries.c +++ b/OPTYap/tab.tries.c @@ -1186,7 +1186,7 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) { } else { LOCK_ANSWER_NODE(current_ans_node); if (TrNode_child(current_ans_node) == NULL) { -#ifdef THREADS +#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) struct answer_trie_node virtual_ans_node; /* necessary because the answer_search_loop() procedure also locks the parent node */ ans_node_ptr parent_ans_node = current_ans_node; AnsNode_init_lock_field(&virtual_ans_node); @@ -1194,9 +1194,10 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) { TrNode_child(&virtual_ans_node) = NULL; current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS); TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node); + TrNode_parent(TrNode_child(&virtual_ans_node)) = parent_ans_node; #else current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS); -#endif /* THREADS */ +#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */ } else if (mode == MODE_DIRECTED_MIN || mode == MODE_DIRECTED_MAX) { ans_node_ptr parent_ans_node = current_ans_node; invalid_ans_node = TrNode_child(parent_ans_node); /* by default, assume a better answer */ @@ -1207,7 +1208,7 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) { invalid_ans_node = TrNode_child(current_ans_node); current_ans_node = answer_search_sum(sg_fr, current_ans_node, Deref(subs_ptr[i]) PASS_REGS); } else if (mode == MODE_DIRECTED_LAST) { -#ifdef THREADS +#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) struct answer_trie_node virtual_ans_node; /* necessary because the answer_search_loop() procedure also locks the parent node */ ans_node_ptr parent_ans_node = current_ans_node; invalid_ans_node = TrNode_child(parent_ans_node); @@ -1216,11 +1217,12 @@ ans_node_ptr mode_directed_answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) { TrNode_child(&virtual_ans_node) = NULL; current_ans_node = answer_search_loop(sg_fr, &virtual_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS); TrNode_child(parent_ans_node) = TrNode_child(&virtual_ans_node); + TrNode_parent(TrNode_child(&virtual_ans_node)) = parent_ans_node; #else invalid_ans_node = TrNode_child(current_ans_node); TrNode_child(current_ans_node) = NULL; current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity PASS_REGS); -#endif /* THREADS */ +#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */ } else if (mode == MODE_DIRECTED_FIRST) { current_ans_node = NULL; } else