fix tabling to compile with threads+ or-parallelism.

This commit is contained in:
Vitor Santos Costa 2010-07-27 23:09:17 +01:00
parent e2201f57e1
commit af056dd605
6 changed files with 26 additions and 20 deletions

View File

@ -210,7 +210,7 @@ MoveLocalAndTrail(void)
#endif
}
#if defined(THREADS) && defined(YAPOR)
#ifdef THREADS
static void
CopyLocalAndTrail(void)
@ -235,8 +235,6 @@ IncrementalCopyStacksFromWorker(void)
(size_t) (LOCAL_end_trail_copy - LOCAL_start_trail_copy));
}
#include "opt.mavar.h"
static CELL
worker_p_binding(int worker_p, CELL *aux_ptr)
{
@ -281,8 +279,9 @@ RestoreTrail(int worker_p)
} else if (IsPairTerm(aux_cell)) {
/* avoid frozen segments */
aux_cell = (CELL) RepPair(aux_cell);
if ((ADDR) aux_cell >= TrailBase)
if (IN_BETWEEN(Yap_TrailBase, aux_cell, Yap_TrailTop)) {
aux_tr = (tr_fr_ptr) aux_cell;
}
#endif /* TABLING */
#ifdef MULTI_ASSIGNMENT_VARIABLES
} else if (IsApplTerm(aux_cell)) {
@ -1867,9 +1866,9 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
LOCAL_end_local_copy =
(CELL)PtoLocAdjust((CELL *)LOCAL_end_local_copy);
LOCAL_start_trail_copy =
(CELL)PtoTRAdjust((CELL *)LOCAL_start_trail_copy);
(CELL)PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy);
LOCAL_end_trail_copy =
(CELL)PtoTRAdjust((CELL *)LOCAL_end_trail_copy);
(CELL)PtoTRAdjust((tr_fr_ptr)LOCAL_end_trail_copy);
AdjustStacksAndTrail(0, STACK_INCREMENTAL_COPYING);
RestoreTrail(worker_p);
TR = (tr_fr_ptr) LOCAL_end_trail_copy;

View File

@ -40,7 +40,7 @@
#error Do not define multiple or-parallel models
#endif /* (ENV_COPY && (ACOW || SBA)) || (ACOW && SBA) */
#if defined(ENV_COPY) || defined(ACOW) || defined(SBA)
#if defined(ENV_COPY) || defined(ACOW) || defined(SBA) || defined(THREADS)
#define YAPOR 1
#endif /* ENV_COPY || ACOW || SBA */

View File

@ -20,9 +20,12 @@
/**********************************************************
** memory alloc scheme (mandatory, define one) **
**********************************************************/
#ifdef USE_SYSTEM_MALLOC
#define MALLOC_MEMORY_ALLOC_SCHEME 1
#else
#define YAP_MEMORY_ALLOC_SCHEME 1
#endif
/* #define SHM_MEMORY_ALLOC_SCHEME 1 */
/* #define MALLOC_MEMORY_ALLOC_SCHEME 1 */

View File

@ -296,9 +296,9 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
return FALSE;
}
OPTYAP_ERROR_MESSAGE(move_up_one_node, B_FZ != DepFr_cons_cp(LOCAL_top_dep_fr));
OPTYAP_ERROR_MESSAGE(move_up_one_node, LOCAL_top_susp_or_fr && EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp(), B_FZ) && YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), LOCAL_top_cp));
OPTYAP_ERROR_MESSAGE(move_up_one_node, LOCAL_top_susp_or_fr && YOUNGER_CP(B_FZ, Get_LOCAL_top_cp()) && YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), B_FZ));
OPTYAP_ERROR_CHECKING(move_up_one_node, B_FZ != DepFr_cons_cp(LOCAL_top_dep_fr));
OPTYAP_ERROR_CHECKING(move_up_one_node, LOCAL_top_susp_or_fr && EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp(), B_FZ) && YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), Get_LOCAL_top_cp()));
OPTYAP_ERROR_CHECKING(move_up_one_node, LOCAL_top_susp_or_fr && YOUNGER_CP(B_FZ, Get_LOCAL_top_cp()) && YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), B_FZ));
#ifdef TABLING
/* frozen stacks on branch ? */
@ -406,9 +406,9 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
return TRUE;
}
OPTYAP_ERROR_MESSAGE(move_up_one_node, OrFr_alternative(LOCAL_top_or_fr) && ! YAMOP_SEQ(OrFr_alternative(LOCAL_top_or_fr)));
OPTYAP_ERROR_MESSAGE(move_up_one_node, Get_LOCAL_top_cp() == DepFr_cons_cp(LOCAL_top_dep_fr));
OPTYAP_ERROR_MESSAGE(move_up_one_node, Get_LOCAL_top_cp() != Get_LOCAL_top_cp_on_stack());
OPTYAP_ERROR_CHECKING(move_up_one_node, OrFr_alternative(LOCAL_top_or_fr) && ! YAMOP_SEQ(OrFr_alternative(LOCAL_top_or_fr)));
OPTYAP_ERROR_CHECKING(move_up_one_node, Get_LOCAL_top_cp() == DepFr_cons_cp(LOCAL_top_dep_fr));
OPTYAP_ERROR_CHECKING(move_up_one_node, Get_LOCAL_top_cp() != Get_LOCAL_top_cp_on_stack());
/* no frozen nodes */
Set_LOCAL_top_cp_on_stack(GetOrFr_node(OrFr_next_on_stack(LOCAL_top_or_fr)));

View File

@ -152,8 +152,8 @@ int q_share_work(int worker_p) {
Set_LOCAL_prune_request(NULL);
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
OPTYAP_ERROR_MESSAGE(q_share_work, Get_LOCAL_top_cp() != Get_LOCAL_top_cp_on_stack());
OPTYAP_ERROR_MESSAGE(q_share_work, YOUNGER_CP(B_FZ, Get_LOCAL_top_cp()));
OPTYAP_ERROR_CHECKING(q_share_work, Get_LOCAL_top_cp() != Get_LOCAL_top_cp_on_stack());
OPTYAP_ERROR_CHECKING(q_share_work, YOUNGER_CP(B_FZ, Get_LOCAL_top_cp()));
YAPOR_ERROR_CHECKING(q_share_work, LOCAL_reply_signal != worker_ready);
/* make sharing request */
@ -374,7 +374,7 @@ void share_private_nodes(int worker_q) {
if (next_node_on_branch == sharing_node)
next_node_on_branch = NULL;
#endif /* TABLING */
OPTYAP_ERROR_MESSAGE(share_private_nodes, next_node_on_branch && YOUNGER_CP(next_node_on_branch, sharing_node));
OPTYAP_ERROR_CHECKING(share_private_nodes, next_node_on_branch && YOUNGER_CP(next_node_on_branch, sharing_node));
}
/* initialize last or-frame pointer */

View File

@ -163,11 +163,15 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
#define STACK_POP_DOWN(STACK) *(STACK)++
#define STACK_NOT_EMPTY(STACK, STACK_BASE) (STACK) != (STACK_BASE)
#define AUX_STACK_CHECK_EXPAND(STACK, STACK_LIMIT) if ((STACK_LIMIT) >= (STACK)) EXPAND_AUX_STACK(STACK)
#ifdef YAPOR
#define EXPAND_AUX_STACK(STACK) Yap_Error(INTERNAL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)");
#define STACK_CHECK_EXPAND(STACK, STACK_LIMIT) if ((STACK_LIMIT) >= (STACK)+4096) EXPAND_STACK(STACK)
#ifdef YAPOR && !defined(THREADS)
#define EXPAND_AUX_STACK(STACK) Yap_Error(INTERNAL_ERROR, TermNil, "stack full (AUX_STACK_CHECK_EXPAND)");
#define EXPAND_STACK(STACK) Yap_Error(INTERNAL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)");
#else
#define EXPAND_AUX_STACK(STACK) STACK = expand_auxiliary_stack(STACK)
#define EXPAND_STACK(STACK) Yap_Error(INTERNAL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)");
#endif /* YAPOR */
#define OPTYAP_ERROR_MESSAGE(OP, COND)
@ -331,7 +335,7 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
SuspFr_global_reg(SUSP_FR) = (void *) (H_REG); \
SuspFr_local_reg(SUSP_FR) = (void *) (B_REG); \
SuspFr_trail_reg(SUSP_FR) = (void *) (TR_REG); \
ALLOC_BLOCK(SuspFr_global_start(SUSP_FR), H_SIZE + B_SIZE + TR_SIZE); \
ALLOC_BLOCK(SuspFr_global_start(SUSP_FR), H_SIZE + B_SIZE + TR_SIZE, void *); \
SuspFr_local_start(SUSP_FR) = SuspFr_global_start(SUSP_FR) + H_SIZE; \
SuspFr_trail_start(SUSP_FR) = SuspFr_local_start(SUSP_FR) + B_SIZE; \
SuspFr_global_size(SUSP_FR) = H_SIZE; \