reducing the number of macros for error checking in the OPTYap files
This commit is contained in:
parent
d68c7854bd
commit
73d210c991
11
C/grow.c
11
C/grow.c
@ -268,14 +268,9 @@ RestoreTrail(int worker_p)
|
|||||||
while (TR != aux_tr) {
|
while (TR != aux_tr) {
|
||||||
CELL aux_cell = TrailTerm(--aux_tr);
|
CELL aux_cell = TrailTerm(--aux_tr);
|
||||||
if (IsVarTerm(aux_cell)) {
|
if (IsVarTerm(aux_cell)) {
|
||||||
if (aux_cell < LOCAL_start_global_copy ||
|
if (aux_cell < LOCAL_start_global_copy || EQUAL_OR_YOUNGER_CP((choiceptr)LOCAL_end_local_copy, (choiceptr)aux_cell)) {
|
||||||
EQUAL_OR_YOUNGER_CP((choiceptr)LOCAL_end_local_copy, (choiceptr)aux_cell)) {
|
YAPOR_ERROR_CHECKING((CELL *)aux_cell < H0, "RestoreTrail: aux_cell < H0");
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING((ADDR)aux_cell > Yap_LocalBase, "RestoreTrail: aux_cell > LocalBase");
|
||||||
if ((CELL *)aux_cell < H0)
|
|
||||||
YAPOR_ERROR_MESSAGE("aux_cell < H0 (q_share_work)");
|
|
||||||
if ((ADDR)aux_cell > Yap_LocalBase)
|
|
||||||
YAPOR_ERROR_MESSAGE("aux_cell > LocalBase (q_share_work)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
*((CELL *) aux_cell) = TrailVal(aux_tr);
|
*((CELL *) aux_cell) = TrailVal(aux_tr);
|
||||||
#else
|
#else
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
/*************************************************
|
/*************************************************
|
||||||
** enable error checking ? (optional) **
|
** enable error checking ? (optional) **
|
||||||
*************************************************/
|
*************************************************/
|
||||||
/* #define TABLING_ERRORS 1 */
|
/* #define DEBUG_TABLING 1 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -99,7 +99,7 @@
|
|||||||
/*************************************************
|
/*************************************************
|
||||||
** enable error checking ? (optional) **
|
** enable error checking ? (optional) **
|
||||||
*************************************************/
|
*************************************************/
|
||||||
/* #define YAPOR_ERRORS 1 */
|
/* #define DEBUG_YAPOR 1 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -225,7 +225,7 @@
|
|||||||
#endif /* !TABLING || !YAPOR */
|
#endif /* !TABLING || !YAPOR */
|
||||||
|
|
||||||
#ifndef YAPOR
|
#ifndef YAPOR
|
||||||
#undef YAPOR_ERRORS
|
#undef DEBUG_YAPOR
|
||||||
#endif /* !YAPOR */
|
#endif /* !YAPOR */
|
||||||
|
|
||||||
#ifndef TABLING
|
#ifndef TABLING
|
||||||
@ -238,13 +238,13 @@
|
|||||||
#undef DETERMINISTIC_TABLING
|
#undef DETERMINISTIC_TABLING
|
||||||
#undef LIMIT_TABLING
|
#undef LIMIT_TABLING
|
||||||
#undef INCOMPLETE_TABLING
|
#undef INCOMPLETE_TABLING
|
||||||
#undef TABLING_ERRORS
|
#undef DEBUG_TABLING
|
||||||
#endif /* !TABLING */
|
#endif /* !TABLING */
|
||||||
|
|
||||||
#ifndef SHM_MEMORY_ALLOC_SCHEME
|
#ifndef SHM_MEMORY_ALLOC_SCHEME
|
||||||
#undef LIMIT_TABLING
|
#undef LIMIT_TABLING
|
||||||
#endif /* !SHM_MEMORY_ALLOC_SCHEME */
|
#endif /* !SHM_MEMORY_ALLOC_SCHEME */
|
||||||
|
|
||||||
#if defined(YAPOR_ERRORS) && defined(TABLING_ERRORS)
|
#if defined(DEBUG_YAPOR) && defined(DEBUG_TABLING)
|
||||||
#define OPTYAP_ERRORS
|
#define DEBUG_OPTYAP
|
||||||
#endif /* YAPOR_ERRORS && TABLING_ERRORS */
|
#endif /* DEBUG_YAPOR && DEBUG_TABLING */
|
||||||
|
@ -139,9 +139,9 @@ void Yap_init_global(int max_table_size, int n_workers, int sch_loop, int delay_
|
|||||||
GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS;
|
GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS;
|
||||||
INIT_LOCK(GLOBAL_LOCKS_heap_access);
|
INIT_LOCK(GLOBAL_LOCKS_heap_access);
|
||||||
INIT_LOCK(GLOBAL_LOCKS_alloc_block);
|
INIT_LOCK(GLOBAL_LOCKS_alloc_block);
|
||||||
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
#if defined(DEBUG_YAPOR) || defined(DEBUG_TABLING)
|
||||||
INIT_LOCK(GLOBAL_LOCKS_stderr_messages);
|
INIT_LOCK(GLOBAL_LOCKS_stderr_messages);
|
||||||
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
#endif /* DEBUG_YAPOR || DEBUG_TABLING */
|
||||||
if (number_workers == 1)
|
if (number_workers == 1)
|
||||||
PARALLEL_EXECUTION_MODE = FALSE;
|
PARALLEL_EXECUTION_MODE = FALSE;
|
||||||
else
|
else
|
||||||
|
@ -11,9 +11,9 @@
|
|||||||
** **
|
** **
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
/********************************
|
/************************************************************************
|
||||||
** Memory management **
|
** Memory management **
|
||||||
********************************/
|
************************************************************************/
|
||||||
|
|
||||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
@ -425,16 +425,15 @@ extern int Yap_page_size;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************
|
/************************************************************************
|
||||||
** Bitmap tests and operations **
|
** Bitmap manipulation **
|
||||||
******************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#define BITMAP_empty(b) ((b) == 0)
|
#define BITMAP_empty(b) ((b) == 0)
|
||||||
#define BITMAP_member(b,n) (((b) & (1<<(n))) != 0)
|
#define BITMAP_member(b,n) (((b) & (1<<(n))) != 0)
|
||||||
#define BITMAP_alone(b,n) ((b) == (1<<(n)))
|
#define BITMAP_alone(b,n) ((b) == (1<<(n)))
|
||||||
#define BITMAP_subset(b1,b2) (((b1) & (b2)) == b2)
|
#define BITMAP_subset(b1,b2) (((b1) & (b2)) == b2)
|
||||||
#define BITMAP_same(b1,b2) ((b1) == (b2))
|
#define BITMAP_same(b1,b2) ((b1) == (b2))
|
||||||
|
|
||||||
#define BITMAP_clear(b) ((b) = 0)
|
#define BITMAP_clear(b) ((b) = 0)
|
||||||
#define BITMAP_and(b1,b2) ((b1) &= (b2))
|
#define BITMAP_and(b1,b2) ((b1) &= (b2))
|
||||||
#define BITMAP_minus(b1,b2) ((b1) &= ~(b2))
|
#define BITMAP_minus(b1,b2) ((b1) &= ~(b2))
|
||||||
@ -446,26 +445,38 @@ extern int Yap_page_size;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************
|
/************************************************************************
|
||||||
** Message and debug macros **
|
** Debug macros **
|
||||||
***************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#define INFORMATION_MESSAGE(MESG, ARGS...) information_message(MESG, ##ARGS)
|
#define INFORMATION_MESSAGE(MESSAGE,ARGS...) \
|
||||||
|
fprintf(stderr, "[ " MESSAGE " ]\n", ##ARGS)
|
||||||
|
|
||||||
#ifdef YAPOR_ERRORS
|
#ifdef YAPOR
|
||||||
#define YAPOR_ERROR_MESSAGE(MESG, ARGS...) error_message(MESG, ##ARGS)
|
#define ERROR_MESSAGE(MESSAGE) \
|
||||||
|
Yap_Error(INTERNAL_ERROR, TermNil, "W%d - " MESSAGE, worker_id)
|
||||||
#else
|
#else
|
||||||
#define YAPOR_ERROR_MESSAGE(MESG, ARGS...)
|
#define ERROR_MESSAGE(MESSAGE) \
|
||||||
#endif /* YAPOR_ERRORS */
|
Yap_Error(INTERNAL_ERROR, TermNil, MESSAGE)
|
||||||
|
#endif /* YAPOR */
|
||||||
|
|
||||||
#ifdef TABLING_ERRORS
|
#ifdef DEBUG_TABLING
|
||||||
#define TABLING_ERROR_MESSAGE(MESG, ARGS...) error_message(MESG, ##ARGS)
|
#define TABLING_ERROR_CHECKING(PROCEDURE,TEST) \
|
||||||
|
if (TEST) ERROR_MESSAGE(#PROCEDURE ": " #TEST)
|
||||||
#else
|
#else
|
||||||
#define TABLING_ERROR_MESSAGE(MESG, ARGS...)
|
#define TABLING_ERROR_CHECKING(PROCEDURE,TEST)
|
||||||
#endif /* TABLING_ERRORS */
|
#endif /* DEBUG_TABLING */
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_YAPOR
|
||||||
#define OPTYAP_ERROR_MESSAGE(MESG, ARGS...) error_message(MESG, ##ARGS)
|
#define YAPOR_ERROR_CHECKING(PROCEDURE,TEST) \
|
||||||
|
if (TEST) ERROR_MESSAGE(#PROCEDURE ": " #TEST)
|
||||||
#else
|
#else
|
||||||
#define OPTYAP_ERROR_MESSAGE(MESG, ARGS...)
|
#define YAPOR_ERROR_CHECKING(PROCEDURE,TEST)
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_YAPOR */
|
||||||
|
|
||||||
|
#ifdef DEBUG_OPTYAP
|
||||||
|
#define OPTYAP_ERROR_CHECKING(PROCEDURE,TEST) \
|
||||||
|
if (TEST) ERROR_MESSAGE(#PROCEDURE ": " #TEST)
|
||||||
|
#else
|
||||||
|
#define OPTYAP_ERROR_CHECKING(PROCEDURE,TEST)
|
||||||
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
@ -17,15 +17,9 @@
|
|||||||
|
|
||||||
#include "Yap.h"
|
#include "Yap.h"
|
||||||
#if defined(YAPOR) || defined(TABLING)
|
#if defined(YAPOR) || defined(TABLING)
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#if HAVE_UNISTD_H
|
#if HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif /* HAVE_UNISTD_H */
|
#endif /* HAVE_UNISTD_H */
|
||||||
#if HAVE_STDARG_H
|
|
||||||
#include <stdarg.h>
|
|
||||||
#endif /* HAVE_STDARG_H */
|
|
||||||
#include "Yatom.h"
|
#include "Yatom.h"
|
||||||
#include "yapio.h"
|
#include "yapio.h"
|
||||||
|
|
||||||
@ -35,11 +29,9 @@
|
|||||||
** Global variables are defined here **
|
** Global variables are defined here **
|
||||||
************************************************/
|
************************************************/
|
||||||
|
|
||||||
#ifndef THREADS
|
#if defined(YAPOR) && ! defined(THREADS)
|
||||||
#ifdef YAPOR
|
|
||||||
struct worker WORKER;
|
struct worker WORKER;
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR && ! THREADS */
|
||||||
#endif /* ! THREADS */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -61,35 +53,4 @@ void itos(int i, char *s) {
|
|||||||
s[j] = 0;
|
s[j] = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void information_message(const char *mesg,...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, mesg);
|
|
||||||
fprintf(stderr, "[ ");
|
|
||||||
vfprintf(stderr, mesg, args);
|
|
||||||
fprintf(stderr, " ]\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
|
||||||
void error_message(const char *mesg, ...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, mesg);
|
|
||||||
#ifdef YAPOR
|
|
||||||
LOCK(GLOBAL_LOCKS_stderr_messages);
|
|
||||||
#endif /* YAPOR */
|
|
||||||
fprintf(stderr, "% POTENCIAL ERROR- ");
|
|
||||||
#ifdef YAPOR
|
|
||||||
fprintf(stderr, "W%d: ", worker_id);
|
|
||||||
#endif /* YAPOR */
|
|
||||||
vfprintf(stderr, mesg, args);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
#ifdef YAPOR
|
|
||||||
UNLOCK(GLOBAL_LOCKS_stderr_messages);
|
|
||||||
#endif /* YAPOR */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
|
||||||
#endif /* YAPOR || TABLING */
|
#endif /* YAPOR || TABLING */
|
||||||
|
@ -75,9 +75,9 @@ static Int p_tabling_statistics(void);
|
|||||||
static Int p_opt_statistics(void);
|
static Int p_opt_statistics(void);
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
|
|
||||||
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
#if defined(DEBUG_YAPOR) || defined(DEBUG_TABLING)
|
||||||
static int p_debug_prolog(void);
|
static int p_debug_prolog(void);
|
||||||
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
#endif /* DEBUG_YAPOR || DEBUG_TABLING */
|
||||||
|
|
||||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||||
static void shm_pages(long pages_in_use, long bytes_in_use);
|
static void shm_pages(long pages_in_use, long bytes_in_use);
|
||||||
@ -163,9 +163,9 @@ void Yap_init_optyap_preds(void) {
|
|||||||
#if defined(YAPOR) && defined(TABLING)
|
#if defined(YAPOR) && defined(TABLING)
|
||||||
Yap_InitCPred("opt_statistics", 0, p_opt_statistics, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("opt_statistics", 0, p_opt_statistics, SafePredFlag|SyncPredFlag);
|
||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
#if defined(DEBUG_YAPOR) || defined(DEBUG_TABLING)
|
||||||
Yap_InitCPred("debug_prolog", 1, p_debug_prolog, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("debug_prolog", 1, p_debug_prolog, SafePredFlag|SyncPredFlag);
|
||||||
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
#endif /* DEBUG_YAPOR || DEBUG_TABLING */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -976,7 +976,7 @@ Int p_opt_statistics(void) {
|
|||||||
#endif /* YAPOR && TABLING */
|
#endif /* YAPOR && TABLING */
|
||||||
|
|
||||||
|
|
||||||
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
#if defined(DEBUG_YAPOR) || defined(DEBUG_TABLING)
|
||||||
static
|
static
|
||||||
int p_debug_prolog(void) {
|
int p_debug_prolog(void) {
|
||||||
Term t;
|
Term t;
|
||||||
@ -984,17 +984,17 @@ int p_debug_prolog(void) {
|
|||||||
if (IsAtomTerm(t)) {
|
if (IsAtomTerm(t)) {
|
||||||
char *s;
|
char *s;
|
||||||
s = RepAtom(AtomOfTerm(t))->StrOfAE;
|
s = RepAtom(AtomOfTerm(t))->StrOfAE;
|
||||||
#ifdef YAPOR_ERRORS
|
#ifdef DEBUG_YAPOR
|
||||||
fprintf(Yap_stderr, "W%d: %s\n", worker_id, s);
|
fprintf(Yap_stderr, "W%d: %s\n", worker_id, s);
|
||||||
#else /* TABLING_ERRORS */
|
#else /* DEBUG_TABLING */
|
||||||
fprintf(Yap_stderr, "%s\n", s);
|
fprintf(Yap_stderr, "%s\n", s);
|
||||||
#endif /* YAPOR_ERRORS */
|
#endif
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
} else {
|
} else {
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
#endif /* DEBUG_YAPOR || DEBUG_TABLING */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,10 +34,6 @@ void remap_memory(void);
|
|||||||
*************************/
|
*************************/
|
||||||
|
|
||||||
void itos(int, char *);
|
void itos(int, char *);
|
||||||
void information_message(const char *,...);
|
|
||||||
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
|
||||||
void error_message(const char *, ...);
|
|
||||||
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,9 +149,9 @@ struct global_locks {
|
|||||||
int who_locked_heap;
|
int who_locked_heap;
|
||||||
lockvar heap_access;
|
lockvar heap_access;
|
||||||
lockvar alloc_block;
|
lockvar alloc_block;
|
||||||
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
#if defined(DEBUG_YAPOR) || defined(DEBUG_TABLING)
|
||||||
lockvar stderr_messages;
|
lockvar stderr_messages;
|
||||||
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
#endif /* DEBUG_YAPOR || DEBUG_TABLING */
|
||||||
};
|
};
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
|
@ -121,11 +121,7 @@ int q_share_work(int worker_p) {
|
|||||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(q_share_work, OrFr_pend_prune_cp(LOCAL_top_or_fr) && BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr));
|
||||||
if (OrFr_pend_prune_cp(LOCAL_top_or_fr) &&
|
|
||||||
BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr))
|
|
||||||
YAPOR_ERROR_MESSAGE("prune ltt > worker_p branch ltt (q_share_work)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
/* there is no pending prune with worker p at right --> safe move to worker p branch */
|
/* there is no pending prune with worker p at right --> safe move to worker p branch */
|
||||||
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = BRANCH(worker_p, OrFr_depth(LOCAL_top_or_fr));
|
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = BRANCH(worker_p, OrFr_depth(LOCAL_top_or_fr));
|
||||||
LOCAL_prune_request = NULL;
|
LOCAL_prune_request = NULL;
|
||||||
|
@ -103,10 +103,7 @@ void prune_shared_branch(choiceptr prune_cp) {
|
|||||||
SCH_update_local_or_tops();
|
SCH_update_local_or_tops();
|
||||||
} while (Get_LOCAL_top_cp() != prune_cp);
|
} while (Get_LOCAL_top_cp() != prune_cp);
|
||||||
|
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(prune_shared_branch, Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()));
|
||||||
if (Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()))
|
|
||||||
YAPOR_ERROR_MESSAGE("EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, LOCAL_top_cp) (prune_shared_branch)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
/* store answers not pruned */
|
/* store answers not pruned */
|
||||||
if (qg_solutions)
|
if (qg_solutions)
|
||||||
CUT_join_answers_in_an_unique_frame(qg_solutions);
|
CUT_join_answers_in_an_unique_frame(qg_solutions);
|
||||||
@ -193,10 +190,7 @@ void prune_shared_branch(choiceptr prune_cp) {
|
|||||||
SCH_update_local_or_tops();
|
SCH_update_local_or_tops();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(prune_shared_branch, Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()));
|
||||||
if (Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()))
|
|
||||||
YAPOR_ERROR_MESSAGE("EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, Get_LOCAL_top_cp()) (prune_shared_branch)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
/* store answers not pruned */
|
/* store answers not pruned */
|
||||||
if (qg_solutions)
|
if (qg_solutions)
|
||||||
CUT_join_answers_in_an_unique_frame(qg_solutions);
|
CUT_join_answers_in_an_unique_frame(qg_solutions);
|
||||||
|
@ -203,11 +203,7 @@ int q_share_work(int worker_p) {
|
|||||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(q_share_work, Get_OrFr_pend_prune_cp(LOCAL_top_or_fr) && BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr));
|
||||||
if (Get_OrFr_pend_prune_cp(LOCAL_top_or_fr) &&
|
|
||||||
BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr))
|
|
||||||
YAPOR_ERROR_MESSAGE("prune ltt > worker_p branch ltt (q_share_work)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
/* there is no pending prune with worker p at right --> safe move to worker p branch */
|
/* there is no pending prune with worker p at right --> safe move to worker p branch */
|
||||||
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = BRANCH(worker_p, OrFr_depth(LOCAL_top_or_fr));
|
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = BRANCH(worker_p, OrFr_depth(LOCAL_top_or_fr));
|
||||||
LOCAL_prune_request = NULL;
|
LOCAL_prune_request = NULL;
|
||||||
@ -215,10 +211,7 @@ int q_share_work(int worker_p) {
|
|||||||
|
|
||||||
/* unbind variables */
|
/* unbind variables */
|
||||||
aux_tr = LOCAL_top_cp->cp_tr;
|
aux_tr = LOCAL_top_cp->cp_tr;
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(q_share_work, TR < aux_tr);
|
||||||
if (TR < aux_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("TR < aux_tr (q_share_work)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
while (aux_tr != TR) {
|
while (aux_tr != TR) {
|
||||||
aux_cell = TrailTerm(--TR);
|
aux_cell = TrailTerm(--TR);
|
||||||
/* check for global or local variables */
|
/* check for global or local variables */
|
||||||
@ -230,12 +223,8 @@ int q_share_work(int worker_p) {
|
|||||||
if (IN_BETWEEN(Yap_TrailBase, aux_cell, Yap_TrailTop)) {
|
if (IN_BETWEEN(Yap_TrailBase, aux_cell, Yap_TrailTop)) {
|
||||||
/* avoid frozen segments */
|
/* avoid frozen segments */
|
||||||
TR = (tr_fr_ptr) aux_cell;
|
TR = (tr_fr_ptr) aux_cell;
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(q_share_work, TR > (tr_fr_ptr) Yap_TrailTop);
|
||||||
if (TR > (tr_fr_ptr) Yap_TrailTop)
|
TABLING_ERROR_CHECKING(q_share_work, TR < aux_tr);
|
||||||
TABLING_ERROR_MESSAGE("TR > Yap_TrailTop (q_share_work)");
|
|
||||||
if (TR < aux_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("TR < aux_tr (q_share_work)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
}
|
}
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
@ -247,16 +236,9 @@ int q_share_work(int worker_p) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
OPTYAP_ERROR_CHECKING(q_share_work, LOCAL_top_cp != LOCAL_top_cp_on_stack);
|
||||||
if (LOCAL_top_cp != LOCAL_top_cp_on_stack)
|
OPTYAP_ERROR_CHECKING(q_share_work, YOUNGER_CP(B_FZ, LOCAL_top_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp != LOCAL_top_cp_on_stack (q_share_work)");
|
YAPOR_ERROR_CHECKING(q_share_work, LOCAL_reply_signal != ready);
|
||||||
if (YOUNGER_CP(B_FZ, LOCAL_top_cp))
|
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(B_FZ, LOCAL_top_cp) (q_share_work)");
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
#ifdef YAPOR_ERRORS
|
|
||||||
if (LOCAL_reply_signal != ready)
|
|
||||||
YAPOR_ERROR_MESSAGE("LOCAL_reply_signal != ready (q_share_work)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
|
|
||||||
/* make sharing request */
|
/* make sharing request */
|
||||||
LOCK_WORKER(worker_p);
|
LOCK_WORKER(worker_p);
|
||||||
@ -324,14 +306,9 @@ sync_with_p:
|
|||||||
while (TR != aux_tr) {
|
while (TR != aux_tr) {
|
||||||
aux_cell = TrailTerm(--aux_tr);
|
aux_cell = TrailTerm(--aux_tr);
|
||||||
if (IsVarTerm(aux_cell)) {
|
if (IsVarTerm(aux_cell)) {
|
||||||
if (aux_cell < LOCAL_start_global_copy ||
|
if (aux_cell < LOCAL_start_global_copy || EQUAL_OR_YOUNGER_CP((choiceptr)LOCAL_end_local_copy, (choiceptr)aux_cell)) {
|
||||||
EQUAL_OR_YOUNGER_CP((choiceptr)LOCAL_end_local_copy, (choiceptr)aux_cell)) {
|
YAPOR_ERROR_CHECKING(q_share_work, (CELL *)aux_cell < H0);
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(q_share_work, (ADDR)aux_cell > Yap_LocalBase);
|
||||||
if ((CELL *)aux_cell < H0)
|
|
||||||
YAPOR_ERROR_MESSAGE("aux_cell < H0 (q_share_work)");
|
|
||||||
if ((ADDR)aux_cell > Yap_LocalBase)
|
|
||||||
YAPOR_ERROR_MESSAGE("aux_cell > LocalBase (q_share_work)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
*((CELL *) aux_cell) = TrailVal(aux_tr);
|
*((CELL *) aux_cell) = TrailVal(aux_tr);
|
||||||
#else
|
#else
|
||||||
@ -388,24 +365,16 @@ static
|
|||||||
void share_private_nodes(int worker_q) {
|
void share_private_nodes(int worker_q) {
|
||||||
choiceptr sharing_node = B;
|
choiceptr sharing_node = B;
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack)) {
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack));
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack) (share_private_nodes)");
|
{ choiceptr aux_cp = B;
|
||||||
} else {
|
|
||||||
choiceptr aux_cp = B;
|
|
||||||
while (aux_cp != LOCAL_top_cp) {
|
while (aux_cp != LOCAL_top_cp) {
|
||||||
if (YOUNGER_CP(LOCAL_top_cp, aux_cp)) {
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(LOCAL_top_cp, aux_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp not in branch (share_private_nodes)");
|
OPTYAP_ERROR_CHECKING(share_private_nodes, EQUAL_OR_YOUNGER_CP(LOCAL_top_cp_on_stack, aux_cp));
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (EQUAL_OR_YOUNGER_CP(LOCAL_top_cp_on_stack, aux_cp)) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("shared frozen segments in branch (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
/* check if the branch is already shared */
|
/* check if the branch is already shared */
|
||||||
@ -414,18 +383,15 @@ void share_private_nodes(int worker_q) {
|
|||||||
sg_fr_ptr sg_frame;
|
sg_fr_ptr sg_frame;
|
||||||
dep_fr_ptr dep_frame;
|
dep_fr_ptr dep_frame;
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
{ or_fr_ptr aux_or_fr;
|
{ or_fr_ptr aux_or_fr;
|
||||||
aux_or_fr = LOCAL_top_or_fr;
|
aux_or_fr = LOCAL_top_or_fr;
|
||||||
while (aux_or_fr != REMOTE_top_or_fr(worker_q)) {
|
while (aux_or_fr != REMOTE_top_or_fr(worker_q)) {
|
||||||
if (YOUNGER_CP(OrFr_node(REMOTE_top_or_fr(worker_q)), OrFr_node(aux_or_fr))) {
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(OrFr_node(REMOTE_top_or_fr(worker_q)), OrFr_node(aux_or_fr)));
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(OrFr_node(REMOTE_top_or_fr(worker_q)), OrFr_node(aux_or_fr)) (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
/* update old shared nodes */
|
/* update old shared nodes */
|
||||||
or_frame = LOCAL_top_or_fr;
|
or_frame = LOCAL_top_or_fr;
|
||||||
@ -494,29 +460,22 @@ void share_private_nodes(int worker_q) {
|
|||||||
while (sharing_node != LOCAL_top_cp) {
|
while (sharing_node != LOCAL_top_cp) {
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (next_node_on_branch) {
|
if (next_node_on_branch) {
|
||||||
choiceptr aux_cp = B;
|
choiceptr aux_cp = B;
|
||||||
while (aux_cp != next_node_on_branch) {
|
while (aux_cp != next_node_on_branch) {
|
||||||
if (sharing_node == aux_cp)
|
OPTYAP_ERROR_CHECKING(share_private_nodes, sharing_node == aux_cp);
|
||||||
OPTYAP_ERROR_MESSAGE("sharing_node on branch (share_private_nodes)");
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(next_node_on_branch, aux_cp));
|
||||||
if (YOUNGER_CP(next_node_on_branch, aux_cp)) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("next_node_on_branch not in branch (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
choiceptr aux_cp = B;
|
choiceptr aux_cp = B;
|
||||||
while (aux_cp != sharing_node) {
|
while (aux_cp != sharing_node) {
|
||||||
if (YOUNGER_CP(sharing_node, aux_cp)) {
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(sharing_node, aux_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("sharing_node not in branch (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
ALLOC_OR_FRAME(or_frame);
|
ALLOC_OR_FRAME(or_frame);
|
||||||
if (previous_or_frame) {
|
if (previous_or_frame) {
|
||||||
@ -546,10 +505,7 @@ void share_private_nodes(int worker_q) {
|
|||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
OrFr_members(or_frame) = bm_workers;
|
OrFr_members(or_frame) = bm_workers;
|
||||||
|
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(share_private_nodes, sharing_node->cp_ap == GETWORK || sharing_node->cp_ap == GETWORK_SEQ);
|
||||||
if (sharing_node->cp_ap == GETWORK || sharing_node->cp_ap == GETWORK_SEQ)
|
|
||||||
YAPOR_ERROR_MESSAGE("choicepoint already shared (share_private_nodes)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
if (sharing_node->cp_ap && YAMOP_SEQ(sharing_node->cp_ap)) {
|
if (sharing_node->cp_ap && YAMOP_SEQ(sharing_node->cp_ap)) {
|
||||||
sharing_node->cp_ap = GETWORK_SEQ;
|
sharing_node->cp_ap = GETWORK_SEQ;
|
||||||
} else {
|
} else {
|
||||||
@ -579,10 +535,7 @@ void share_private_nodes(int worker_q) {
|
|||||||
if (next_node_on_branch == sharing_node)
|
if (next_node_on_branch == sharing_node)
|
||||||
next_node_on_branch = NULL;
|
next_node_on_branch = NULL;
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef OPTYAP_ERRORS
|
OPTYAP_ERROR_CHECKING(share_private_nodes, next_node_on_branch && YOUNGER_CP(next_node_on_branch, sharing_node));
|
||||||
if (next_node_on_branch && YOUNGER_CP(next_node_on_branch, sharing_node))
|
|
||||||
OPTYAP_ERROR_MESSAGE("frozen node greater than next_node_on_branch (share_private_nodes)");
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize last or-frame pointer */
|
/* initialize last or-frame pointer */
|
||||||
@ -625,20 +578,15 @@ void share_private_nodes(int worker_q) {
|
|||||||
or_frame = OrFr_next_on_stack(or_frame);
|
or_frame = OrFr_next_on_stack(or_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(share_private_nodes, depth != OrFr_depth(LOCAL_top_or_fr));
|
||||||
if (depth != OrFr_depth(LOCAL_top_or_fr))
|
|
||||||
YAPOR_ERROR_MESSAGE("incorrect depth value (share_private_nodes)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
{ or_fr_ptr aux_or_fr = B->cp_or_fr;
|
{ or_fr_ptr aux_or_fr = B->cp_or_fr;
|
||||||
choiceptr aux_cp;
|
choiceptr aux_cp;
|
||||||
while (aux_or_fr != LOCAL_top_cp_on_stack->cp_or_fr) {
|
while (aux_or_fr != LOCAL_top_cp_on_stack->cp_or_fr) {
|
||||||
aux_cp = OrFr_node(aux_or_fr);
|
aux_cp = OrFr_node(aux_or_fr);
|
||||||
if (OrFr_next(aux_or_fr) != aux_cp->cp_b->cp_or_fr)
|
OPTYAP_ERROR_CHECKING(share_private_nodes, OrFr_next(aux_or_fr) != aux_cp->cp_b->cp_or_fr);
|
||||||
OPTYAP_ERROR_MESSAGE("OrFr_next not in branch (share_private_nodes)");
|
OPTYAP_ERROR_CHECKING(share_private_nodes, OrFr_nearest_livenode(aux_or_fr) != aux_cp->cp_b->cp_or_fr);
|
||||||
if (OrFr_nearest_livenode(aux_or_fr) != aux_cp->cp_b->cp_or_fr)
|
|
||||||
OPTYAP_ERROR_MESSAGE("OrFr_nearest_livenode not in branch (share_private_nodes)");
|
|
||||||
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
||||||
}
|
}
|
||||||
aux_or_fr = B->cp_or_fr;
|
aux_or_fr = B->cp_or_fr;
|
||||||
@ -646,16 +594,13 @@ void share_private_nodes(int worker_q) {
|
|||||||
or_fr_ptr nearest_leftnode = OrFr_nearest_leftnode(aux_or_fr);
|
or_fr_ptr nearest_leftnode = OrFr_nearest_leftnode(aux_or_fr);
|
||||||
aux_cp = OrFr_node(aux_or_fr);
|
aux_cp = OrFr_node(aux_or_fr);
|
||||||
while (OrFr_node(nearest_leftnode) != aux_cp) {
|
while (OrFr_node(nearest_leftnode) != aux_cp) {
|
||||||
if (YOUNGER_CP(OrFr_node(nearest_leftnode), aux_cp)) {
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(OrFr_node(nearest_leftnode), aux_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("OrFr_nearest_leftnode not in branch (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
/* update old shared nodes */
|
/* update old shared nodes */
|
||||||
while (or_frame != REMOTE_top_or_fr(worker_q)) {
|
while (or_frame != REMOTE_top_or_fr(worker_q)) {
|
||||||
@ -711,7 +656,7 @@ void share_private_nodes(int worker_q) {
|
|||||||
}
|
}
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
{ dep_fr_ptr aux_dep_fr = LOCAL_top_dep_fr;
|
{ dep_fr_ptr aux_dep_fr = LOCAL_top_dep_fr;
|
||||||
while(aux_dep_fr != GLOBAL_root_dep_fr) {
|
while(aux_dep_fr != GLOBAL_root_dep_fr) {
|
||||||
choiceptr top_cp_on_branch;
|
choiceptr top_cp_on_branch;
|
||||||
@ -719,12 +664,11 @@ void share_private_nodes(int worker_q) {
|
|||||||
while (YOUNGER_CP(top_cp_on_branch, B)) {
|
while (YOUNGER_CP(top_cp_on_branch, B)) {
|
||||||
top_cp_on_branch = top_cp_on_branch->cp_b;
|
top_cp_on_branch = top_cp_on_branch->cp_b;
|
||||||
}
|
}
|
||||||
if (top_cp_on_branch->cp_or_fr != DepFr_top_or_fr(aux_dep_fr))
|
OPTYAP_ERROR_CHECKING(share_private_nodes, top_cp_on_branch->cp_or_fr != DepFr_top_or_fr(aux_dep_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_top_or_fr (share_private_nodes)");
|
|
||||||
aux_dep_fr = DepFr_next(aux_dep_fr);
|
aux_dep_fr = DepFr_next(aux_dep_fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
/* update top shared nodes */
|
/* update top shared nodes */
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
|
@ -152,11 +152,7 @@ int q_share_work(int worker_p) {
|
|||||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(q_share_work, OrFr_pend_prune_cp(LOCAL_top_or_fr) && BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr));
|
||||||
if (OrFr_pend_prune_cp(LOCAL_top_or_fr) &&
|
|
||||||
BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr))
|
|
||||||
YAPOR_ERROR_MESSAGE("prune ltt > worker_p branch ltt (q_share_work)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
/* there is no pending prune with worker p at right --> safe move to worker p branch */
|
/* there is no pending prune with worker p at right --> safe move to worker p branch */
|
||||||
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = BRANCH(worker_p, OrFr_depth(LOCAL_top_or_fr));
|
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = BRANCH(worker_p, OrFr_depth(LOCAL_top_or_fr));
|
||||||
LOCAL_prune_request = NULL;
|
LOCAL_prune_request = NULL;
|
||||||
|
@ -100,10 +100,7 @@ void PUT_OUT_ROOT_NODE(int worker_num) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void move_up_to_prune_request(void) {
|
void move_up_to_prune_request(void) {
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(move_up_to_prune_request, EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()));
|
||||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()))
|
|
||||||
YAPOR_ERROR_MESSAGE("invalid LOCAL_prune_request (move_up_to_prune_request)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
@ -268,15 +265,9 @@ int get_work(void) {
|
|||||||
|
|
||||||
static
|
static
|
||||||
int move_up_one_node(or_fr_ptr nearest_livenode) {
|
int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(move_up_one_node, Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()));
|
||||||
if (Get_LOCAL_prune_request() && EQUAL_OR_YOUNGER_CP(Get_LOCAL_prune_request(), Get_LOCAL_top_cp()))
|
|
||||||
YAPOR_ERROR_MESSAGE("invalid LOCAL_prune_request (move_up_one_node)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
|
|
||||||
|
|
||||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
|
|
||||||
|
|
||||||
/* last worker in a sequential choicepoint ? */
|
/* last worker in a sequential choicepoint ? */
|
||||||
if (OrFr_alternative(LOCAL_top_or_fr)
|
if (OrFr_alternative(LOCAL_top_or_fr)
|
||||||
&& YAMOP_SEQ(OrFr_alternative(LOCAL_top_or_fr))
|
&& YAMOP_SEQ(OrFr_alternative(LOCAL_top_or_fr))
|
||||||
@ -285,7 +276,6 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* pending prune ? */
|
/* pending prune ? */
|
||||||
if (Get_OrFr_pend_prune_cp(LOCAL_top_or_fr)
|
if (Get_OrFr_pend_prune_cp(LOCAL_top_or_fr)
|
||||||
&& ! Get_LOCAL_prune_request()
|
&& ! Get_LOCAL_prune_request()
|
||||||
@ -306,18 +296,9 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OPTYAP_ERROR_MESSAGE(move_up_one_node, B_FZ != DepFr_cons_cp(LOCAL_top_dep_fr));
|
||||||
#ifdef OPTYAP_ERRORS
|
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));
|
||||||
if (B_FZ != DepFr_cons_cp(LOCAL_top_dep_fr))
|
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_MESSAGE("B_FZ != DepFr_cons_cp(LOCAL_top_dep_fr) (move_up_one_node)");
|
|
||||||
if (LOCAL_top_susp_or_fr) {
|
|
||||||
if (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("YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), Get_LOCAL_top_cp()) (move_up_one_node)");
|
|
||||||
if (YOUNGER_CP(B_FZ, Get_LOCAL_top_cp()) && YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), B_FZ))
|
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), B_FZ) (move_up_one_node)");
|
|
||||||
}
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
/* frozen stacks on branch ? */
|
/* frozen stacks on branch ? */
|
||||||
@ -358,7 +339,6 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* suspension frames to resume ? */
|
/* suspension frames to resume ? */
|
||||||
if (OrFr_suspensions(LOCAL_top_or_fr)) {
|
if (OrFr_suspensions(LOCAL_top_or_fr)) {
|
||||||
susp_fr_ptr resume_fr;
|
susp_fr_ptr resume_fr;
|
||||||
@ -386,7 +366,6 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
|||||||
OrFr_nearest_suspnode(LOCAL_top_or_fr) = LOCAL_top_or_fr;
|
OrFr_nearest_suspnode(LOCAL_top_or_fr) = LOCAL_top_or_fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* top node frozen ? */
|
/* top node frozen ? */
|
||||||
if (B_FZ == Get_LOCAL_top_cp()) {
|
if (B_FZ == Get_LOCAL_top_cp()) {
|
||||||
if (nearest_livenode)
|
if (nearest_livenode)
|
||||||
@ -427,21 +406,13 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OPTYAP_ERROR_MESSAGE(move_up_one_node, OrFr_alternative(LOCAL_top_or_fr) && ! YAMOP_SEQ(OrFr_alternative(LOCAL_top_or_fr)));
|
||||||
#ifdef OPTYAP_ERRORS
|
OPTYAP_ERROR_MESSAGE(move_up_one_node, Get_LOCAL_top_cp() == DepFr_cons_cp(LOCAL_top_dep_fr));
|
||||||
if (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() != Get_LOCAL_top_cp_on_stack());
|
||||||
OPTYAP_ERROR_MESSAGE("OrFr_alternative(LOCAL_top_or_fr) not sequential (move_up_one_node)");
|
|
||||||
if (Get_LOCAL_top_cp() == DepFr_cons_cp(LOCAL_top_dep_fr))
|
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp == DepFr_cons_cp(LOCAL_top_dep_fr) (move_up_one_node)");
|
|
||||||
if (Get_LOCAL_top_cp() != Get_LOCAL_top_cp_on_stack())
|
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp != LOCAL_top_cp_on_stack (move_up_one_node)");
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
|
|
||||||
|
|
||||||
/* no frozen nodes */
|
/* no frozen nodes */
|
||||||
Set_LOCAL_top_cp_on_stack(GetOrFr_node(OrFr_next_on_stack(LOCAL_top_or_fr)));
|
Set_LOCAL_top_cp_on_stack(GetOrFr_node(OrFr_next_on_stack(LOCAL_top_or_fr)));
|
||||||
|
|
||||||
|
|
||||||
/* no more owners ? */
|
/* no more owners ? */
|
||||||
if (OrFr_owners(LOCAL_top_or_fr) == 1) {
|
if (OrFr_owners(LOCAL_top_or_fr) == 1) {
|
||||||
if (OrFr_suspensions(LOCAL_top_or_fr)) {
|
if (OrFr_suspensions(LOCAL_top_or_fr)) {
|
||||||
@ -500,7 +471,6 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* more owners */
|
/* more owners */
|
||||||
if (nearest_livenode)
|
if (nearest_livenode)
|
||||||
OrFr_nearest_livenode(LOCAL_top_or_fr) = nearest_livenode;
|
OrFr_nearest_livenode(LOCAL_top_or_fr) = nearest_livenode;
|
||||||
|
@ -146,26 +146,15 @@ int q_share_work(int worker_p) {
|
|||||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(q_share_work, Get_OrFr_pend_prune_cp(LOCAL_top_or_fr) && BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr));
|
||||||
if (Get_OrFr_pend_prune_cp(LOCAL_top_or_fr) &&
|
|
||||||
BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr))
|
|
||||||
YAPOR_ERROR_MESSAGE("prune ltt > worker_p branch ltt (q_share_work)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
/* there is no pending prune with worker p at right --> safe move to worker p branch */
|
/* there is no pending prune with worker p at right --> safe move to worker p branch */
|
||||||
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = BRANCH(worker_p, OrFr_depth(LOCAL_top_or_fr));
|
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = BRANCH(worker_p, OrFr_depth(LOCAL_top_or_fr));
|
||||||
Set_LOCAL_prune_request(NULL);
|
Set_LOCAL_prune_request(NULL);
|
||||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
OPTYAP_ERROR_MESSAGE(q_share_work, Get_LOCAL_top_cp() != Get_LOCAL_top_cp_on_stack());
|
||||||
if (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_MESSAGE("LOCAL_top_cp != LOCAL_top_cp_on_stack (q_share_work)");
|
YAPOR_ERROR_CHECKING(q_share_work, LOCAL_reply_signal != worker_ready);
|
||||||
if (YOUNGER_CP(B_FZ, Get_LOCAL_top_cp()))
|
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(B_FZ, LOCAL_top_cp) (q_share_work)");
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
#ifdef YAPOR_ERRORS
|
|
||||||
if (LOCAL_reply_signal != worker_ready)
|
|
||||||
YAPOR_ERROR_MESSAGE("LOCAL_reply_signal != worker_ready (q_share_work)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
|
|
||||||
/* make sharing request */
|
/* make sharing request */
|
||||||
LOCK_WORKER(worker_p);
|
LOCK_WORKER(worker_p);
|
||||||
@ -213,24 +202,17 @@ static
|
|||||||
void share_private_nodes(int worker_q) {
|
void share_private_nodes(int worker_q) {
|
||||||
choiceptr sharing_node = B;
|
choiceptr sharing_node = B;
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack())) {
|
#ifdef DEBUG_OPTYAP
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack) (share_private_nodes)");
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()));
|
||||||
} else {
|
{ choiceptr aux_cp = B;
|
||||||
choiceptr aux_cp = B;
|
|
||||||
while (aux_cp != Get_LOCAL_top_cp()) {
|
while (aux_cp != Get_LOCAL_top_cp()) {
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp)) {
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp not in branch (share_private_nodes)");
|
OPTYAP_ERROR_CHECKING(share_private_nodes, EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp));
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp)) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("shared frozen segments in branch (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
/* check if the branch is already shared */
|
/* check if the branch is already shared */
|
||||||
@ -239,18 +221,15 @@ void share_private_nodes(int worker_q) {
|
|||||||
sg_fr_ptr sg_frame;
|
sg_fr_ptr sg_frame;
|
||||||
dep_fr_ptr dep_frame;
|
dep_fr_ptr dep_frame;
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
{ or_fr_ptr aux_or_fr;
|
{ or_fr_ptr aux_or_fr;
|
||||||
aux_or_fr = LOCAL_top_or_fr;
|
aux_or_fr = LOCAL_top_or_fr;
|
||||||
while (aux_or_fr != REMOTE_top_or_fr(worker_q)) {
|
while (aux_or_fr != REMOTE_top_or_fr(worker_q)) {
|
||||||
if (YOUNGER_CP(GetOrFr_node(REMOTE_top_or_fr(worker_q)), GetOrFr_node(aux_or_fr))) {
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(GetOrFr_node(REMOTE_top_or_fr(worker_q)), GetOrFr_node(aux_or_fr)));
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(GetOrFr_node(REMOTE_top_or_fr(worker_q)), OrFr_node(aux_or_fr)) (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
/* update old shared nodes */
|
/* update old shared nodes */
|
||||||
or_frame = LOCAL_top_or_fr;
|
or_frame = LOCAL_top_or_fr;
|
||||||
@ -320,29 +299,22 @@ void share_private_nodes(int worker_q) {
|
|||||||
while (sharing_node != Get_LOCAL_top_cp()) {
|
while (sharing_node != Get_LOCAL_top_cp()) {
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (next_node_on_branch) {
|
if (next_node_on_branch) {
|
||||||
choiceptr aux_cp = B;
|
choiceptr aux_cp = B;
|
||||||
while (aux_cp != next_node_on_branch) {
|
while (aux_cp != next_node_on_branch) {
|
||||||
if (sharing_node == aux_cp)
|
OPTYAP_ERROR_CHECKING(share_private_nodes, sharing_node == aux_cp);
|
||||||
OPTYAP_ERROR_MESSAGE("sharing_node on branch (share_private_nodes)");
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(next_node_on_branch, aux_cp));
|
||||||
if (YOUNGER_CP(next_node_on_branch, aux_cp)) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("next_node_on_branch not in branch (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
choiceptr aux_cp = B;
|
choiceptr aux_cp = B;
|
||||||
while (aux_cp != sharing_node) {
|
while (aux_cp != sharing_node) {
|
||||||
if (YOUNGER_CP(sharing_node, aux_cp)) {
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(sharing_node, aux_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("sharing_node not in branch (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
ALLOC_OR_FRAME(or_frame);
|
ALLOC_OR_FRAME(or_frame);
|
||||||
if (previous_or_frame) {
|
if (previous_or_frame) {
|
||||||
@ -372,10 +344,7 @@ void share_private_nodes(int worker_q) {
|
|||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
OrFr_members(or_frame) = bm_workers;
|
OrFr_members(or_frame) = bm_workers;
|
||||||
|
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(share_private_nodes, sharing_node->cp_ap == GETWORK || sharing_node->cp_ap == GETWORK_SEQ);
|
||||||
if (sharing_node->cp_ap == GETWORK || sharing_node->cp_ap == GETWORK_SEQ)
|
|
||||||
YAPOR_ERROR_MESSAGE("choicepoint already shared (share_private_nodes)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
if (sharing_node->cp_ap && YAMOP_SEQ(sharing_node->cp_ap)) {
|
if (sharing_node->cp_ap && YAMOP_SEQ(sharing_node->cp_ap)) {
|
||||||
sharing_node->cp_ap = GETWORK_SEQ;
|
sharing_node->cp_ap = GETWORK_SEQ;
|
||||||
} else {
|
} else {
|
||||||
@ -405,10 +374,7 @@ void share_private_nodes(int worker_q) {
|
|||||||
if (next_node_on_branch == sharing_node)
|
if (next_node_on_branch == sharing_node)
|
||||||
next_node_on_branch = NULL;
|
next_node_on_branch = NULL;
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
#ifdef OPTYAP_ERRORS
|
OPTYAP_ERROR_MESSAGE(share_private_nodes, next_node_on_branch && YOUNGER_CP(next_node_on_branch, sharing_node));
|
||||||
if (next_node_on_branch && YOUNGER_CP(next_node_on_branch, sharing_node))
|
|
||||||
OPTYAP_ERROR_MESSAGE("frozen node greater than next_node_on_branch (share_private_nodes)");
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize last or-frame pointer */
|
/* initialize last or-frame pointer */
|
||||||
@ -451,20 +417,15 @@ void share_private_nodes(int worker_q) {
|
|||||||
or_frame = OrFr_next_on_stack(or_frame);
|
or_frame = OrFr_next_on_stack(or_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef YAPOR_ERRORS
|
YAPOR_ERROR_CHECKING(share_private_nodes, depth != OrFr_depth(LOCAL_top_or_fr));
|
||||||
if (depth != OrFr_depth(LOCAL_top_or_fr))
|
|
||||||
YAPOR_ERROR_MESSAGE("incorrect depth value (share_private_nodes)");
|
|
||||||
#endif /* YAPOR_ERRORS */
|
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
{ or_fr_ptr aux_or_fr = B->cp_or_fr;
|
{ or_fr_ptr aux_or_fr = B->cp_or_fr;
|
||||||
choiceptr aux_cp;
|
choiceptr aux_cp;
|
||||||
while (aux_or_fr != Get_LOCAL_top_cp_on_stack()->cp_or_fr) {
|
while (aux_or_fr != Get_LOCAL_top_cp_on_stack()->cp_or_fr) {
|
||||||
aux_cp = GetOrFr_node(aux_or_fr);
|
aux_cp = GetOrFr_node(aux_or_fr);
|
||||||
if (OrFr_next(aux_or_fr) != aux_cp->cp_b->cp_or_fr)
|
OPTYAP_ERROR_CHECKING(share_private_nodes, OrFr_next(aux_or_fr) != aux_cp->cp_b->cp_or_fr);
|
||||||
OPTYAP_ERROR_MESSAGE("OrFr_next not in branch (share_private_nodes)");
|
OPTYAP_ERROR_CHECKING(share_private_nodes, OrFr_nearest_livenode(aux_or_fr) != aux_cp->cp_b->cp_or_fr);
|
||||||
if (OrFr_nearest_livenode(aux_or_fr) != aux_cp->cp_b->cp_or_fr)
|
|
||||||
OPTYAP_ERROR_MESSAGE("OrFr_nearest_livenode not in branch (share_private_nodes)");
|
|
||||||
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
||||||
}
|
}
|
||||||
aux_or_fr = B->cp_or_fr;
|
aux_or_fr = B->cp_or_fr;
|
||||||
@ -472,16 +433,13 @@ void share_private_nodes(int worker_q) {
|
|||||||
or_fr_ptr nearest_leftnode = OrFr_nearest_leftnode(aux_or_fr);
|
or_fr_ptr nearest_leftnode = OrFr_nearest_leftnode(aux_or_fr);
|
||||||
aux_cp = GetOrFr_node(aux_or_fr);
|
aux_cp = GetOrFr_node(aux_or_fr);
|
||||||
while (GetOrFr_node(nearest_leftnode) != aux_cp) {
|
while (GetOrFr_node(nearest_leftnode) != aux_cp) {
|
||||||
if (YOUNGER_CP(GetOrFr_node(nearest_leftnode), aux_cp)) {
|
OPTYAP_ERROR_CHECKING(share_private_nodes, YOUNGER_CP(GetOrFr_node(nearest_leftnode), aux_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("OrFr_nearest_leftnode not in branch (share_private_nodes)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
aux_or_fr = OrFr_next_on_stack(aux_or_fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
/* update old shared nodes */
|
/* update old shared nodes */
|
||||||
while (or_frame != REMOTE_top_or_fr(worker_q)) {
|
while (or_frame != REMOTE_top_or_fr(worker_q)) {
|
||||||
@ -537,7 +495,7 @@ void share_private_nodes(int worker_q) {
|
|||||||
}
|
}
|
||||||
#endif /* TABLING */
|
#endif /* TABLING */
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
{ dep_fr_ptr aux_dep_fr = LOCAL_top_dep_fr;
|
{ dep_fr_ptr aux_dep_fr = LOCAL_top_dep_fr;
|
||||||
while(aux_dep_fr != GLOBAL_root_dep_fr) {
|
while(aux_dep_fr != GLOBAL_root_dep_fr) {
|
||||||
choiceptr top_cp_on_branch;
|
choiceptr top_cp_on_branch;
|
||||||
@ -545,12 +503,11 @@ void share_private_nodes(int worker_q) {
|
|||||||
while (YOUNGER_CP(top_cp_on_branch, B)) {
|
while (YOUNGER_CP(top_cp_on_branch, B)) {
|
||||||
top_cp_on_branch = top_cp_on_branch->cp_b;
|
top_cp_on_branch = top_cp_on_branch->cp_b;
|
||||||
}
|
}
|
||||||
if (top_cp_on_branch->cp_or_fr != DepFr_top_or_fr(aux_dep_fr))
|
OPTYAP_ERROR_CHECKING(share_private_nodes, top_cp_on_branch->cp_or_fr != DepFr_top_or_fr(aux_dep_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_top_or_fr (share_private_nodes)");
|
|
||||||
aux_dep_fr = DepFr_next(aux_dep_fr);
|
aux_dep_fr = DepFr_next(aux_dep_fr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
/* update top shared nodes */
|
/* update top shared nodes */
|
||||||
#ifdef TABLING
|
#ifdef TABLING
|
||||||
|
@ -16,25 +16,15 @@
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#ifdef LOW_LEVEL_TRACER
|
#ifdef LOW_LEVEL_TRACER
|
||||||
#define store_low_level_trace_info(CP, TAB_ENT) CP->cp_pred_entry = TabEnt_pe(TAB_ENT)
|
#define store_low_level_trace_info(CP, TAB_ENT) \
|
||||||
|
CP->cp_pred_entry = TabEnt_pe(TAB_ENT)
|
||||||
#else
|
#else
|
||||||
#define store_low_level_trace_info(CP, TAB_ENT)
|
#define store_low_level_trace_info(CP, TAB_ENT)
|
||||||
#endif /* LOW_LEVEL_TRACER */
|
#endif /* LOW_LEVEL_TRACER */
|
||||||
|
|
||||||
|
#define TABLING_ERROR_CHECKING_STACK \
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(store_node, Unsigned(H) + 1024 > Unsigned(B)); \
|
||||||
#define TABLING_ERRORS_check_stack \
|
TABLING_ERROR_CHECKING(store_node, Unsigned(H_FZ) + 1024 > Unsigned(B))
|
||||||
if (Unsigned(H) + 1024 > Unsigned(B)) \
|
|
||||||
TABLING_ERROR_MESSAGE("H + 1024 > B (check_stack)"); \
|
|
||||||
if (Unsigned(H_FZ) + 1024 > Unsigned(B)) \
|
|
||||||
TABLING_ERROR_MESSAGE("H_FZ + 1024 > B (check_stack)")
|
|
||||||
#define TABLING_ERRORS_consume_answer_and_procceed \
|
|
||||||
if (IS_BATCHED_GEN_CP(B)) \
|
|
||||||
TABLING_ERROR_MESSAGE("IS_BATCHED_GEN_CP(B) (consume_answer_and_procceed)")
|
|
||||||
#else
|
|
||||||
#define TABLING_ERRORS_check_stack
|
|
||||||
#define TABLING_ERRORS_consume_answer_and_procceed
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
|
|
||||||
|
|
||||||
#define store_generator_node(TAB_ENT, SG_FR, ARITY, AP) \
|
#define store_generator_node(TAB_ENT, SG_FR, ARITY, AP) \
|
||||||
@ -83,7 +73,7 @@
|
|||||||
B = gcp; \
|
B = gcp; \
|
||||||
YAPOR_SET_LOAD(B); \
|
YAPOR_SET_LOAD(B); \
|
||||||
SET_BB(B); \
|
SET_BB(B); \
|
||||||
TABLING_ERRORS_check_stack; \
|
TABLING_ERROR_CHECKING_STACK; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -107,7 +97,7 @@
|
|||||||
B = gcp; \
|
B = gcp; \
|
||||||
YAPOR_SET_LOAD(B); \
|
YAPOR_SET_LOAD(B); \
|
||||||
SET_BB(B); \
|
SET_BB(B); \
|
||||||
TABLING_ERRORS_check_stack; \
|
TABLING_ERROR_CHECKING_STACK; \
|
||||||
}
|
}
|
||||||
#endif /* DETERMINISTIC_TABLING */
|
#endif /* DETERMINISTIC_TABLING */
|
||||||
|
|
||||||
@ -188,7 +178,7 @@
|
|||||||
B = ccp; \
|
B = ccp; \
|
||||||
YAPOR_SET_LOAD(B); \
|
YAPOR_SET_LOAD(B); \
|
||||||
SET_BB(B); \
|
SET_BB(B); \
|
||||||
TABLING_ERRORS_check_stack; \
|
TABLING_ERROR_CHECKING_STACK; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -206,7 +196,7 @@
|
|||||||
if (B == DepFr_leader_cp(DEP_FR)) { \
|
if (B == DepFr_leader_cp(DEP_FR)) { \
|
||||||
/* B is a generator-consumer node */ \
|
/* B is a generator-consumer node */ \
|
||||||
/* never here if batched scheduling */ \
|
/* never here if batched scheduling */ \
|
||||||
TABLING_ERRORS_consume_answer_and_procceed; \
|
TABLING_ERROR_CHECKING(generator_consumer, IS_BATCHED_GEN_CP(B)); \
|
||||||
subs_ptr = (CELL *) (GEN_CP(B) + 1); \
|
subs_ptr = (CELL *) (GEN_CP(B) + 1); \
|
||||||
subs_ptr += SgFr_arity(GEN_CP(B)->cp_sg_fr); \
|
subs_ptr += SgFr_arity(GEN_CP(B)->cp_sg_fr); \
|
||||||
} else { \
|
} else { \
|
||||||
@ -238,7 +228,7 @@
|
|||||||
B = lcp; \
|
B = lcp; \
|
||||||
YAPOR_SET_LOAD(B); \
|
YAPOR_SET_LOAD(B); \
|
||||||
SET_BB(B); \
|
SET_BB(B); \
|
||||||
TABLING_ERRORS_check_stack; \
|
TABLING_ERROR_CHECKING_STACK; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -451,21 +441,19 @@
|
|||||||
UNLOCK(SgFr_lock(sg_fr));
|
UNLOCK(SgFr_lock(sg_fr));
|
||||||
find_leader_node(leader_cp, leader_dep_on_stack);
|
find_leader_node(leader_cp, leader_dep_on_stack);
|
||||||
store_consumer_node(tab_ent, sg_fr, leader_cp, leader_dep_on_stack);
|
store_consumer_node(tab_ent, sg_fr, leader_cp, leader_dep_on_stack);
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (PARALLEL_EXECUTION_MODE) {
|
if (PARALLEL_EXECUTION_MODE) {
|
||||||
choiceptr aux_cp;
|
choiceptr aux_cp;
|
||||||
aux_cp = B;
|
aux_cp = B;
|
||||||
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
if (aux_cp->cp_or_fr != DepFr_top_or_fr(LOCAL_top_dep_fr))
|
OPTYAP_ERROR_CHECKING(table_try_single, aux_cp->cp_or_fr != DepFr_top_or_fr(LOCAL_top_dep_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_top_or_fr (table_try_single)");
|
|
||||||
aux_cp = B;
|
aux_cp = B;
|
||||||
while (YOUNGER_CP(aux_cp, DepFr_leader_cp(LOCAL_top_dep_fr)))
|
while (YOUNGER_CP(aux_cp, DepFr_leader_cp(LOCAL_top_dep_fr)))
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
if (aux_cp != DepFr_leader_cp(LOCAL_top_dep_fr))
|
OPTYAP_ERROR_CHECKING(table_try_single, aux_cp != DepFr_leader_cp(LOCAL_top_dep_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_leader_cp (table_try_single)");
|
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
goto answer_resolution;
|
goto answer_resolution;
|
||||||
} else {
|
} else {
|
||||||
/* subgoal completed */
|
/* subgoal completed */
|
||||||
@ -564,21 +552,19 @@
|
|||||||
UNLOCK(SgFr_lock(sg_fr));
|
UNLOCK(SgFr_lock(sg_fr));
|
||||||
find_leader_node(leader_cp, leader_dep_on_stack);
|
find_leader_node(leader_cp, leader_dep_on_stack);
|
||||||
store_consumer_node(tab_ent, sg_fr, leader_cp, leader_dep_on_stack);
|
store_consumer_node(tab_ent, sg_fr, leader_cp, leader_dep_on_stack);
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (PARALLEL_EXECUTION_MODE) {
|
if (PARALLEL_EXECUTION_MODE) {
|
||||||
choiceptr aux_cp;
|
choiceptr aux_cp;
|
||||||
aux_cp = B;
|
aux_cp = B;
|
||||||
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
if (aux_cp->cp_or_fr != DepFr_top_or_fr(LOCAL_top_dep_fr))
|
OPTYAP_ERROR_CHECKING(table_try_me, aux_cp->cp_or_fr != DepFr_top_or_fr(LOCAL_top_dep_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_top_or_fr (table_try_me)");
|
|
||||||
aux_cp = B;
|
aux_cp = B;
|
||||||
while (YOUNGER_CP(aux_cp, DepFr_leader_cp(LOCAL_top_dep_fr)))
|
while (YOUNGER_CP(aux_cp, DepFr_leader_cp(LOCAL_top_dep_fr)))
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
if (aux_cp != DepFr_leader_cp(LOCAL_top_dep_fr))
|
OPTYAP_ERROR_CHECKING(table_try_me, aux_cp != DepFr_leader_cp(LOCAL_top_dep_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_leader_cp (table_try_me)");
|
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
goto answer_resolution;
|
goto answer_resolution;
|
||||||
} else {
|
} else {
|
||||||
/* subgoal completed */
|
/* subgoal completed */
|
||||||
@ -677,21 +663,19 @@
|
|||||||
UNLOCK(SgFr_lock(sg_fr));
|
UNLOCK(SgFr_lock(sg_fr));
|
||||||
find_leader_node(leader_cp, leader_dep_on_stack);
|
find_leader_node(leader_cp, leader_dep_on_stack);
|
||||||
store_consumer_node(tab_ent, sg_fr, leader_cp, leader_dep_on_stack);
|
store_consumer_node(tab_ent, sg_fr, leader_cp, leader_dep_on_stack);
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (PARALLEL_EXECUTION_MODE) {
|
if (PARALLEL_EXECUTION_MODE) {
|
||||||
choiceptr aux_cp;
|
choiceptr aux_cp;
|
||||||
aux_cp = B;
|
aux_cp = B;
|
||||||
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
if (aux_cp->cp_or_fr != DepFr_top_or_fr(LOCAL_top_dep_fr))
|
OPTYAP_ERROR_CHECKING(table_try, aux_cp->cp_or_fr != DepFr_top_or_fr(LOCAL_top_dep_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_top_or_fr (table_try)");
|
|
||||||
aux_cp = B;
|
aux_cp = B;
|
||||||
while (YOUNGER_CP(aux_cp, DepFr_leader_cp(LOCAL_top_dep_fr)))
|
while (YOUNGER_CP(aux_cp, DepFr_leader_cp(LOCAL_top_dep_fr)))
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
if (aux_cp != DepFr_leader_cp(LOCAL_top_dep_fr))
|
OPTYAP_ERROR_CHECKING(table_try, aux_cp != DepFr_leader_cp(LOCAL_top_dep_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_leader_cp (table_try)");
|
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
goto answer_resolution;
|
goto answer_resolution;
|
||||||
} else {
|
} else {
|
||||||
/* subgoal completed */
|
/* subgoal completed */
|
||||||
@ -861,7 +845,7 @@
|
|||||||
sg_fr = GEN_CP(gcp)->cp_sg_fr;
|
sg_fr = GEN_CP(gcp)->cp_sg_fr;
|
||||||
subs_ptr = (CELL *)(GEN_CP(gcp) + 1) + PREG->u.s.s;
|
subs_ptr = (CELL *)(GEN_CP(gcp) + 1) + PREG->u.s.s;
|
||||||
}
|
}
|
||||||
#if defined(TABLING_ERRORS) && !defined(DETERMINISTIC_TABLING)
|
#if defined(DEBUG_TABLING) && !defined(DETERMINISTIC_TABLING)
|
||||||
{
|
{
|
||||||
int i, j, arity_args, arity_subs;
|
int i, j, arity_args, arity_subs;
|
||||||
CELL *aux_args;
|
CELL *aux_args;
|
||||||
@ -877,11 +861,10 @@
|
|||||||
Term term_arg = Deref(*(aux_args + j));
|
Term term_arg = Deref(*(aux_args + j));
|
||||||
if (term_subs == term_arg) break;
|
if (term_subs == term_arg) break;
|
||||||
}
|
}
|
||||||
if (j == arity_args)
|
TABLING_ERROR_CHECKING(table_new_answer, j == arity_args);
|
||||||
TABLING_ERROR_MESSAGE("j == arity_args (table_new_answer)");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* TABLING_ERRORS && !DETERMINISTIC_TABLING */
|
#endif /* DEBUG_TABLING && !DETERMINISTIC_TABLING */
|
||||||
#ifdef TABLE_LOCK_AT_ENTRY_LEVEL
|
#ifdef TABLE_LOCK_AT_ENTRY_LEVEL
|
||||||
LOCK(SgFr_lock(sg_fr));
|
LOCK(SgFr_lock(sg_fr));
|
||||||
#endif /* TABLE_LOCK_LEVEL */
|
#endif /* TABLE_LOCK_LEVEL */
|
||||||
@ -1032,16 +1015,15 @@
|
|||||||
else
|
else
|
||||||
TrNode_child(SgFr_last_answer(sg_fr)) = ans_node;
|
TrNode_child(SgFr_last_answer(sg_fr)) = ans_node;
|
||||||
SgFr_last_answer(sg_fr) = ans_node;
|
SgFr_last_answer(sg_fr) = ans_node;
|
||||||
#ifdef TABLING_ERRORS
|
#ifdef DEBUG_TABLING
|
||||||
{
|
{
|
||||||
ans_node_ptr aux_ans_node = SgFr_first_answer(sg_fr);
|
ans_node_ptr aux_ans_node = SgFr_first_answer(sg_fr);
|
||||||
while (aux_ans_node != SgFr_last_answer(sg_fr)) {
|
while (aux_ans_node != SgFr_last_answer(sg_fr)) {
|
||||||
if (! IS_ANSWER_LEAF_NODE(aux_ans_node))
|
TABLING_ERROR_CHECKING(table_new_answer, !IS_ANSWER_LEAF_NODE(aux_ans_node));
|
||||||
TABLING_ERROR_MESSAGE("! IS_ANSWER_LEAF_NODE(aux_ans_node) (table_new_answer)");
|
|
||||||
aux_ans_node = TrNode_child(aux_ans_node);
|
aux_ans_node = TrNode_child(aux_ans_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* TABLING_ERRORS */
|
#endif /* DEBUG_TABLING */
|
||||||
UNLOCK(SgFr_lock(sg_fr));
|
UNLOCK(SgFr_lock(sg_fr));
|
||||||
if (IS_BATCHED_GEN_CP(gcp)) {
|
if (IS_BATCHED_GEN_CP(gcp)) {
|
||||||
#ifdef TABLING_EARLY_COMPLETION
|
#ifdef TABLING_EARLY_COMPLETION
|
||||||
@ -1116,15 +1098,8 @@
|
|||||||
dep_fr_ptr dep_fr;
|
dep_fr_ptr dep_fr;
|
||||||
ans_node_ptr ans_node;
|
ans_node_ptr ans_node;
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
OPTYAP_ERROR_CHECKING(answer_resolution, SCH_top_shared_cp(B) && B->cp_or_fr->alternative != ANSWER_RESOLUTION);
|
||||||
if (SCH_top_shared_cp(B)) {
|
OPTYAP_ERROR_CHECKING(answer_resolution, !SCH_top_shared_cp(B) && B->cp_ap != ANSWER_RESOLUTION);
|
||||||
if (B->cp_or_fr->alternative != ANSWER_RESOLUTION)
|
|
||||||
OPTYAP_ERROR_MESSAGE("B->cp_or_fr->alternative != ANSWER_RESOLUTION (answer_resolution)");
|
|
||||||
} else {
|
|
||||||
if (B->cp_ap != ANSWER_RESOLUTION)
|
|
||||||
OPTYAP_ERROR_MESSAGE("B->cp_ap != ANSWER_RESOLUTION (answer_resolution)");
|
|
||||||
}
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
dep_fr = CONS_CP(B)->cp_dep_fr;
|
dep_fr = CONS_CP(B)->cp_dep_fr;
|
||||||
LOCK(DepFr_lock(dep_fr));
|
LOCK(DepFr_lock(dep_fr));
|
||||||
ans_node = DepFr_last_answer(dep_fr);
|
ans_node = DepFr_last_answer(dep_fr);
|
||||||
@ -1140,10 +1115,7 @@
|
|||||||
if (B == DepFr_leader_cp(LOCAL_top_dep_fr)) {
|
if (B == DepFr_leader_cp(LOCAL_top_dep_fr)) {
|
||||||
/* B is a generator-consumer node **
|
/* B is a generator-consumer node **
|
||||||
** never here if batched scheduling */
|
** never here if batched scheduling */
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(answer_resolution, IS_BATCHED_GEN_CP(B));
|
||||||
if (IS_BATCHED_GEN_CP(B))
|
|
||||||
TABLING_ERROR_MESSAGE("IS_BATCHED_GEN_CP(B) (answer_resolution)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
goto completion;
|
goto completion;
|
||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
@ -1170,12 +1142,8 @@
|
|||||||
chain_cp = DepFr_leader_cp(LOCAL_top_dep_fr);
|
chain_cp = DepFr_leader_cp(LOCAL_top_dep_fr);
|
||||||
if (YOUNGER_CP(top_chain_cp, chain_cp))
|
if (YOUNGER_CP(top_chain_cp, chain_cp))
|
||||||
chain_cp = top_chain_cp;
|
chain_cp = top_chain_cp;
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(answer_resolution, EQUAL_OR_YOUNGER_CP(top_chain_cp, B));
|
||||||
if (EQUAL_OR_YOUNGER_CP(top_chain_cp, B))
|
TABLING_ERROR_CHECKING(answer_resolution, EQUAL_OR_YOUNGER_CP(chain_cp, B));
|
||||||
TABLING_ERROR_MESSAGE("EQUAL_OR_YOUNGER_CP(top_chain_cp, B) (answer_resolution)");
|
|
||||||
else if (EQUAL_OR_YOUNGER_CP(chain_cp, B))
|
|
||||||
TABLING_ERROR_MESSAGE("EQUAL_OR_YOUNGER_CP(chain_cp, B) (answer_resolution)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
|
|
||||||
/* check for dependency frames with unconsumed answers */
|
/* check for dependency frames with unconsumed answers */
|
||||||
dep_fr = DepFr_next(dep_fr);
|
dep_fr = DepFr_next(dep_fr);
|
||||||
@ -1244,37 +1212,22 @@
|
|||||||
pruning_over_tabling_data_structures();
|
pruning_over_tabling_data_structures();
|
||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (PARALLEL_EXECUTION_MODE) {
|
if (PARALLEL_EXECUTION_MODE) {
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack())) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(Get_LOCAL_top_cp(), LOCAL_top_cp_on_stack) (answer_resolution)");
|
|
||||||
} else {
|
|
||||||
choiceptr aux_cp;
|
choiceptr aux_cp;
|
||||||
|
OPTYAP_ERROR_CHECKING(completion, YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()));
|
||||||
aux_cp = chain_cp;
|
aux_cp = chain_cp;
|
||||||
while (aux_cp != Get_LOCAL_top_cp()) {
|
while (aux_cp != Get_LOCAL_top_cp()) {
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp)) {
|
OPTYAP_ERROR_CHECKING(completion, YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp not in branch (answer_resolution)");
|
OPTYAP_ERROR_CHECKING(completion, EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp));
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp)) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("shared frozen segments in branch (answer_resolution)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif /* DEBUG_OPTYAP */
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
/* restore bindings, update registers, consume answer and procceed */
|
/* restore bindings, update registers, consume answer and procceed */
|
||||||
restore_bindings(B->cp_tr, chain_cp->cp_tr);
|
restore_bindings(B->cp_tr, chain_cp->cp_tr);
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(answer_resolution, TR != B->cp_tr && !IsPairTerm((CELL)TrailTerm(TR - 1)));
|
||||||
if (TR != B->cp_tr) {
|
TABLING_ERROR_CHECKING(answer_resolution, TR != B->cp_tr && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
|
||||||
if(! IsPairTerm((CELL)TrailTerm(TR - 1)))
|
|
||||||
TABLING_ERROR_MESSAGE("! IsPairTerm((CELL)TrailTerm(TR - 1)) (answer_resolution)");
|
|
||||||
if ((tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr (answer_resolution)");
|
|
||||||
}
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
B = chain_cp;
|
B = chain_cp;
|
||||||
TR = TR_FZ;
|
TR = TR_FZ;
|
||||||
TRAIL_LINK(B->cp_tr);
|
TRAIL_LINK(B->cp_tr);
|
||||||
@ -1330,37 +1283,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (PARALLEL_EXECUTION_MODE) {
|
if (PARALLEL_EXECUTION_MODE) {
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack())) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()) (answer_resolution)");
|
|
||||||
} else {
|
|
||||||
choiceptr aux_cp;
|
choiceptr aux_cp;
|
||||||
|
OPTYAP_ERROR_CHECKING(completion, YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()));
|
||||||
aux_cp = chain_cp;
|
aux_cp = chain_cp;
|
||||||
while (aux_cp != Get_LOCAL_top_cp()) {
|
while (aux_cp != Get_LOCAL_top_cp()) {
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp)) {
|
OPTYAP_ERROR_CHECKING(completion, YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp not in branch (answer_resolution)");
|
OPTYAP_ERROR_CHECKING(completion, EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp));
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp)) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("shared frozen segments in branch (answer_resolution)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif /* DEBUG_OPTYAP */
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
/* unbind variables */
|
/* unbind variables */
|
||||||
unbind_variables(B->cp_tr, chain_cp->cp_tr);
|
unbind_variables(B->cp_tr, chain_cp->cp_tr);
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(answer_resolution, TR != B->cp_tr && !IsPairTerm((CELL)TrailTerm(TR - 1)));
|
||||||
if (TR != B->cp_tr) {
|
TABLING_ERROR_CHECKING(answer_resolution, TR != B->cp_tr && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
|
||||||
if(! IsPairTerm((CELL)TrailTerm(TR - 1)))
|
|
||||||
TABLING_ERROR_MESSAGE("! IsPairTerm((CELL)TrailTerm(TR - 1)) (answer_resolution)");
|
|
||||||
if ((tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr (answer_resolution)");
|
|
||||||
}
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
if (DepFr_leader_cp(LOCAL_top_dep_fr) == chain_cp && (
|
if (DepFr_leader_cp(LOCAL_top_dep_fr) == chain_cp && (
|
||||||
/* chain_cp is a leader node AND ... */
|
/* chain_cp is a leader node AND ... */
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
@ -1470,20 +1408,16 @@
|
|||||||
}
|
}
|
||||||
UNLOCK(DepFr_lock(dep_fr));
|
UNLOCK(DepFr_lock(dep_fr));
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (PARALLEL_EXECUTION_MODE) {
|
if (PARALLEL_EXECUTION_MODE) {
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack())) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack) (completion)");
|
|
||||||
} else {
|
|
||||||
choiceptr aux_cp;
|
choiceptr aux_cp;
|
||||||
|
OPTYAP_ERROR_CHECKING(completion, Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack());
|
||||||
aux_cp = DepFr_cons_cp(dep_fr);
|
aux_cp = DepFr_cons_cp(dep_fr);
|
||||||
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
if (aux_cp->cp_or_fr != DepFr_top_or_fr(dep_fr))
|
OPTYAP_ERROR_CHECKING(completion, aux_cp->cp_or_fr != DepFr_top_or_fr(dep_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_top_or_fr (completion)");
|
|
||||||
}
|
}
|
||||||
}
|
#endif /* DEBUG_OPTYAP */
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
#ifdef YAPOR
|
#ifdef YAPOR
|
||||||
/* update shared nodes */
|
/* update shared nodes */
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), Get_LOCAL_top_cp())) {
|
if (YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), Get_LOCAL_top_cp())) {
|
||||||
@ -1499,43 +1433,24 @@
|
|||||||
Set_LOCAL_top_cp(GetOrFr_node(LOCAL_top_or_fr));
|
Set_LOCAL_top_cp(GetOrFr_node(LOCAL_top_or_fr));
|
||||||
}
|
}
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (PARALLEL_EXECUTION_MODE) {
|
if (PARALLEL_EXECUTION_MODE) {
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack())) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack) (completion)");
|
|
||||||
} else {
|
|
||||||
choiceptr aux_cp;
|
choiceptr aux_cp;
|
||||||
|
OPTYAP_ERROR_CHECKING(completion, YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()));
|
||||||
aux_cp = DepFr_cons_cp(dep_fr);
|
aux_cp = DepFr_cons_cp(dep_fr);
|
||||||
while (aux_cp != Get_LOCAL_top_cp()) {
|
while (aux_cp != Get_LOCAL_top_cp()) {
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp)) {
|
OPTYAP_ERROR_CHECKING(completion, YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp));
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp not in branch (completion)");
|
OPTYAP_ERROR_CHECKING(completion, EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp));
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp)) {
|
|
||||||
OPTYAP_ERROR_MESSAGE("shared frozen segments in branch (completion)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
aux_cp = aux_cp->cp_b;
|
aux_cp = aux_cp->cp_b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif /* DEBUG_OPTYAP */
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
/* rebind variables, update registers, consume answer and procceed */
|
/* rebind variables, update registers, consume answer and procceed */
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(completion, EQUAL_OR_YOUNGER_CP(B, DepFr_cons_cp(dep_fr)));
|
||||||
if (EQUAL_OR_YOUNGER_CP(B, DepFr_cons_cp(dep_fr)))
|
TABLING_ERROR_CHECKING(completion, B->cp_tr > DepFr_cons_cp(dep_fr)->cp_tr);
|
||||||
TABLING_ERROR_MESSAGE("EQUAL_OR_YOUNGER_CP(B, DepFr_cons_cp(dep_fr)) (completion)");
|
|
||||||
if (B->cp_tr > DepFr_cons_cp(dep_fr)->cp_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("B->cp_tr > DepFr_cons_cp(dep_fr)->cp_tr (completion)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
rebind_variables(DepFr_cons_cp(dep_fr)->cp_tr, B->cp_tr);
|
rebind_variables(DepFr_cons_cp(dep_fr)->cp_tr, B->cp_tr);
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(completion, TR != B->cp_tr && !IsPairTerm((CELL)TrailTerm(TR - 1)));
|
||||||
if (TR != B->cp_tr) {
|
TABLING_ERROR_CHECKING(completion, TR != B->cp_tr && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
|
||||||
if(! IsPairTerm((CELL)TrailTerm(TR - 1)))
|
|
||||||
TABLING_ERROR_MESSAGE("! IsPairTerm((CELL)TrailTerm(TR - 1)) (completion)");
|
|
||||||
if ((tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr (completion)");
|
|
||||||
}
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
B = DepFr_cons_cp(dep_fr);
|
B = DepFr_cons_cp(dep_fr);
|
||||||
TR = TR_FZ;
|
TR = TR_FZ;
|
||||||
if (TR != B->cp_tr)
|
if (TR != B->cp_tr)
|
||||||
@ -1622,22 +1537,13 @@
|
|||||||
/* complete all */
|
/* complete all */
|
||||||
public_completion();
|
public_completion();
|
||||||
}
|
}
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(completion, TR != B->cp_tr && !IsPairTerm((CELL)TrailTerm(TR - 1)));
|
||||||
if (TR != B->cp_tr) {
|
TABLING_ERROR_CHECKING(completion, TR != B->cp_tr && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
|
||||||
if(! IsPairTerm((CELL)TrailTerm(TR - 1)))
|
|
||||||
TABLING_ERROR_MESSAGE("! IsPairTerm((CELL)TrailTerm(TR - 1)) (completion)");
|
|
||||||
if ((tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr (completion)");
|
|
||||||
}
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
if (B == DepFr_leader_cp(LOCAL_top_dep_fr)) {
|
if (B == DepFr_leader_cp(LOCAL_top_dep_fr)) {
|
||||||
/* B is a generator-consumer node */
|
/* B is a generator-consumer node */
|
||||||
/* never here if batched scheduling */
|
/* never here if batched scheduling */
|
||||||
ans_node_ptr ans_node;
|
ans_node_ptr ans_node;
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(completion, IS_BATCHED_GEN_CP(B));
|
||||||
if (IS_BATCHED_GEN_CP(B))
|
|
||||||
TABLING_ERROR_MESSAGE("IS_BATCHED_GEN_CP(B) (completion)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
TR = B->cp_tr;
|
TR = B->cp_tr;
|
||||||
SET_BB(B);
|
SET_BB(B);
|
||||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||||
@ -1710,14 +1616,8 @@
|
|||||||
SET_BB(PROTECT_FROZEN_B(B));
|
SET_BB(PROTECT_FROZEN_B(B));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(completion, TR != B->cp_tr && !IsPairTerm((CELL)TrailTerm(TR - 1)));
|
||||||
if (TR != B->cp_tr) {
|
TABLING_ERROR_CHECKING(completion, TR != B->cp_tr && (tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr);
|
||||||
if(! IsPairTerm((CELL)TrailTerm(TR - 1)))
|
|
||||||
TABLING_ERROR_MESSAGE("! IsPairTerm((CELL)TrailTerm(TR - 1)) (completion)");
|
|
||||||
if ((tr_fr_ptr) RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("RepPair((CELL)TrailTerm(TR - 1)) != B->cp_tr (completion)");
|
|
||||||
}
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
pop_generator_node(SgFr_arity(sg_fr));
|
pop_generator_node(SgFr_arity(sg_fr));
|
||||||
if (ans_node == SgFr_answer_trie(sg_fr)) {
|
if (ans_node == SgFr_answer_trie(sg_fr)) {
|
||||||
/* yes answer --> procceed */
|
/* yes answer --> procceed */
|
||||||
|
@ -449,10 +449,7 @@ void mark_as_completed(sg_fr_ptr sg_fr) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void unbind_variables(tr_fr_ptr unbind_tr, tr_fr_ptr end_tr) {
|
void unbind_variables(tr_fr_ptr unbind_tr, tr_fr_ptr end_tr) {
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(unbind_variables, unbind_tr < end_tr);
|
||||||
if (unbind_tr < end_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("unbind_tr < end_tr (function unbind_variables)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
/* unbind loop */
|
/* unbind loop */
|
||||||
while (unbind_tr != end_tr) {
|
while (unbind_tr != end_tr) {
|
||||||
CELL ref = (CELL) TrailTerm(--unbind_tr);
|
CELL ref = (CELL) TrailTerm(--unbind_tr);
|
||||||
@ -465,12 +462,8 @@ void unbind_variables(tr_fr_ptr unbind_tr, tr_fr_ptr end_tr) {
|
|||||||
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
||||||
/* avoid frozen segments */
|
/* avoid frozen segments */
|
||||||
unbind_tr = (tr_fr_ptr) ref;
|
unbind_tr = (tr_fr_ptr) ref;
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(unbind_variables, unbind_tr > (tr_fr_ptr) Yap_TrailTop);
|
||||||
if (unbind_tr > (tr_fr_ptr) Yap_TrailTop)
|
TABLING_ERROR_CHECKING(unbind_variables, unbind_tr < end_tr);
|
||||||
TABLING_ERROR_MESSAGE("unbind_tr > Yap_TrailTop (function unbind_variables)");
|
|
||||||
if (unbind_tr < end_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("unbind_tr < end_tr (function unbind_variables)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
}
|
}
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
} else {
|
} else {
|
||||||
@ -487,10 +480,7 @@ void unbind_variables(tr_fr_ptr unbind_tr, tr_fr_ptr end_tr) {
|
|||||||
|
|
||||||
static inline
|
static inline
|
||||||
void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
|
void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(rebind_variables, rebind_tr < end_tr);
|
||||||
if (rebind_tr < end_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("rebind_tr < end_tr (function rebind_variables)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
/* rebind loop */
|
/* rebind loop */
|
||||||
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
|
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
|
||||||
while (rebind_tr != end_tr) {
|
while (rebind_tr != end_tr) {
|
||||||
@ -504,12 +494,8 @@ void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
|
|||||||
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
||||||
/* avoid frozen segments */
|
/* avoid frozen segments */
|
||||||
rebind_tr = (tr_fr_ptr) ref;
|
rebind_tr = (tr_fr_ptr) ref;
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(rebind_variables, rebind_tr > (tr_fr_ptr) Yap_TrailTop);
|
||||||
if (rebind_tr > (tr_fr_ptr) Yap_TrailTop)
|
TABLING_ERROR_CHECKING(rebind_variables, rebind_tr < end_tr);
|
||||||
TABLING_ERROR_MESSAGE("rebind_tr > Yap_TrailTop (function rebind_variables)");
|
|
||||||
if (rebind_tr < end_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("rebind_tr < end_tr (function rebind_variables)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
}
|
}
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
} else {
|
} else {
|
||||||
@ -531,10 +517,7 @@ void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
|||||||
CELL ref;
|
CELL ref;
|
||||||
tr_fr_ptr end_tr;
|
tr_fr_ptr end_tr;
|
||||||
|
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(restore_variables, unbind_tr < rebind_tr);
|
||||||
if (unbind_tr < rebind_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("unbind_tr < rebind_tr (function restore_bindings)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
end_tr = rebind_tr;
|
end_tr = rebind_tr;
|
||||||
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
|
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
|
||||||
while (unbind_tr != end_tr) {
|
while (unbind_tr != end_tr) {
|
||||||
@ -548,10 +531,7 @@ void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
|||||||
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
||||||
/* avoid frozen segments */
|
/* avoid frozen segments */
|
||||||
unbind_tr = (tr_fr_ptr) ref;
|
unbind_tr = (tr_fr_ptr) ref;
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(restore_variables, unbind_tr > (tr_fr_ptr) Yap_TrailTop);
|
||||||
if (unbind_tr > (tr_fr_ptr) Yap_TrailTop)
|
|
||||||
TABLING_ERROR_MESSAGE("unbind_tr > Yap_TrailTop (function restore_bindings)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
}
|
}
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
} else if (IsApplTerm(ref)) {
|
} else if (IsApplTerm(ref)) {
|
||||||
@ -564,7 +544,7 @@ void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
|||||||
if (!Yap_lookup_ma_var(pt)) {
|
if (!Yap_lookup_ma_var(pt)) {
|
||||||
pt[0] = TrailVal(unbind_tr);
|
pt[0] = TrailVal(unbind_tr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* look for end */
|
/* look for end */
|
||||||
@ -575,10 +555,7 @@ void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
|||||||
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
||||||
/* avoid frozen segments */
|
/* avoid frozen segments */
|
||||||
end_tr = (tr_fr_ptr) ref;
|
end_tr = (tr_fr_ptr) ref;
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(restore_variables, end_tr > (tr_fr_ptr) Yap_TrailTop);
|
||||||
if (end_tr > (tr_fr_ptr) Yap_TrailTop)
|
|
||||||
TABLING_ERROR_MESSAGE("end_tr > Yap_TrailTop (function restore_bindings)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -593,12 +570,8 @@ void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
|||||||
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
if (IN_BETWEEN(Yap_TrailBase, ref, Yap_TrailTop)) {
|
||||||
/* avoid frozen segments */
|
/* avoid frozen segments */
|
||||||
rebind_tr = (tr_fr_ptr) ref;
|
rebind_tr = (tr_fr_ptr) ref;
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(restore_variables, rebind_tr > (tr_fr_ptr) Yap_TrailTop);
|
||||||
if (rebind_tr > (tr_fr_ptr) Yap_TrailTop)
|
TABLING_ERROR_CHECKING(restore_variables, rebind_tr < end_tr);
|
||||||
TABLING_ERROR_MESSAGE("rebind_tr > Yap_TrailTop (function restore_bindings)");
|
|
||||||
if (rebind_tr < end_tr)
|
|
||||||
TABLING_ERROR_MESSAGE("rebind_tr < end_tr (function restore_bindings)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
}
|
}
|
||||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||||
} else {
|
} else {
|
||||||
@ -811,12 +784,8 @@ void collect_suspension_frames(or_fr_ptr or_fr) {
|
|||||||
int depth;
|
int depth;
|
||||||
or_fr_ptr *susp_ptr;
|
or_fr_ptr *susp_ptr;
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
OPTYAP_ERROR_CHECKING(collect_suspension_frames, IS_UNLOCKED(or_fr));
|
||||||
if (IS_UNLOCKED(or_fr))
|
OPTYAP_ERROR_CHECKING(collect_suspension_frames, OrFr_suspensions(or_fr) == NULL);
|
||||||
OPTYAP_ERROR_MESSAGE("or_fr unlocked (collect_suspension_frames)");
|
|
||||||
if (OrFr_suspensions(or_fr) == NULL)
|
|
||||||
OPTYAP_ERROR_MESSAGE("OrFr_suspensions(or_fr) == NULL (collect_suspension_frames)");
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
|
|
||||||
/* order collected suspension frames by depth */
|
/* order collected suspension frames by depth */
|
||||||
depth = OrFr_depth(or_fr);
|
depth = OrFr_depth(or_fr);
|
||||||
|
@ -76,10 +76,7 @@ static void complete_suspension_branch(susp_fr_ptr susp_fr, choiceptr top_cp, or
|
|||||||
while (IS_UNLOCKED(OrFr_lock(aux_or_fr))) {
|
while (IS_UNLOCKED(OrFr_lock(aux_or_fr))) {
|
||||||
susp_fr_ptr aux_susp_fr;
|
susp_fr_ptr aux_susp_fr;
|
||||||
or_fr_ptr next_or_fr_on_stack;
|
or_fr_ptr next_or_fr_on_stack;
|
||||||
#ifdef OPTYAP_ERRORS
|
OPTYAP_ERROR_CHECKING(complete_suspension_branch, YOUNGER_CP(top_cp, GetOrFr_node(aux_or_fr)));
|
||||||
if (YOUNGER_CP(top_cp, GetOrFr_node(aux_or_fr)))
|
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(top_cp, GetOrFr_node(aux_or_fr)) (complete_suspension_branch)");
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
LOCK_OR_FRAME(aux_or_fr);
|
LOCK_OR_FRAME(aux_or_fr);
|
||||||
aux_susp_fr = OrFr_suspensions(aux_or_fr);
|
aux_susp_fr = OrFr_suspensions(aux_or_fr);
|
||||||
while (aux_susp_fr) {
|
while (aux_susp_fr) {
|
||||||
@ -285,24 +282,17 @@ void suspend_branch(void) {
|
|||||||
|
|
||||||
/* suspension only occurs in shared nodes that **
|
/* suspension only occurs in shared nodes that **
|
||||||
** are leaders with younger consumer nodes */
|
** are leaders with younger consumer nodes */
|
||||||
#ifdef OPTYAP_ERRORS
|
#ifdef DEBUG_OPTYAP
|
||||||
if (Get_LOCAL_top_cp()->cp_or_fr != LOCAL_top_or_fr)
|
OPTYAP_ERROR_CHECKING(suspend_branch, Get_LOCAL_top_cp()->cp_or_fr != LOCAL_top_or_fr);
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp->cp_or_fr != LOCAL_top_or_fr (suspend_branch)");
|
OPTYAP_ERROR_CHECKING(suspend_branch, B_FZ == Get_LOCAL_top_cp());
|
||||||
if (B_FZ == Get_LOCAL_top_cp())
|
OPTYAP_ERROR_CHECKING(suspend_branch, YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()));
|
||||||
OPTYAP_ERROR_MESSAGE("B_FZ = LOCAL_top_cp (suspend_branch)");
|
OPTYAP_ERROR_CHECKING(suspend_branch, Get_LOCAL_top_cp()->cp_or_fr != LOCAL_top_or_fr);
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()))
|
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack) (suspend_branch)");
|
|
||||||
if (Get_LOCAL_top_cp()->cp_or_fr != LOCAL_top_or_fr)
|
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp->cp_or_fr != LOCAL_top_or_fr (suspend_branch)");
|
|
||||||
or_frame = Get_LOCAL_top_cp_on_stack()->cp_or_fr;
|
or_frame = Get_LOCAL_top_cp_on_stack()->cp_or_fr;
|
||||||
while (or_frame != LOCAL_top_or_fr) {
|
while (or_frame != LOCAL_top_or_fr) {
|
||||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), GetOrFr_node(or_frame))) {
|
OPTYAP_ERROR_CHECKING(suspend_branch, YOUNGER_CP(Get_LOCAL_top_cp(), GetOrFr_node(or_frame)));
|
||||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(LOCAL_top_cp, GetOrFr_node(or_frame)) (suspend_branch)");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
or_frame = OrFr_next_on_stack(or_frame);
|
or_frame = OrFr_next_on_stack(or_frame);
|
||||||
}
|
}
|
||||||
#endif /* OPTYAP_ERRORS */
|
#endif /* DEBUG_OPTYAP */
|
||||||
|
|
||||||
or_frame = Get_LOCAL_top_cp_on_stack()->cp_or_fr;
|
or_frame = Get_LOCAL_top_cp_on_stack()->cp_or_fr;
|
||||||
LOCK_OR_FRAME(or_frame);
|
LOCK_OR_FRAME(or_frame);
|
||||||
@ -378,16 +368,10 @@ void resume_suspension_frame(susp_fr_ptr resume_fr, or_fr_ptr top_or_fr) {
|
|||||||
SuspFr_trail_start(resume_fr),
|
SuspFr_trail_start(resume_fr),
|
||||||
SuspFr_trail_size(resume_fr));
|
SuspFr_trail_size(resume_fr));
|
||||||
|
|
||||||
#ifdef OPTYAP_ERRORS
|
OPTYAP_ERROR_CHECKING(resume_suspension_frame, DepFr_cons_cp(SuspFr_top_dep_fr(resume_fr))->cp_h != SuspFr_global_reg(resume_fr) + SuspFr_global_size(resume_fr));
|
||||||
if (DepFr_cons_cp(SuspFr_top_dep_fr(resume_fr))->cp_h != SuspFr_global_reg(resume_fr) + SuspFr_global_size(resume_fr))
|
OPTYAP_ERROR_CHECKING(resume_suspension_frame, DepFr_cons_cp(SuspFr_top_dep_fr(resume_fr))->cp_tr != SuspFr_trail_reg(resume_fr) + SuspFr_trail_size(resume_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("DepFr_cons_cp(SuspFr_top_dep_fr)->cp_h != SuspFr_global_reg + SuspFr_global_size (resume_suspension_frame)");
|
OPTYAP_ERROR_CHECKING(resume_suspension_frame, DepFr_cons_cp(SuspFr_top_dep_fr(resume_fr)) != SuspFr_local_reg(resume_fr));
|
||||||
if (DepFr_cons_cp(SuspFr_top_dep_fr(resume_fr))->cp_tr != SuspFr_trail_reg(resume_fr) + SuspFr_trail_size(resume_fr))
|
OPTYAP_ERROR_CHECKING(resume_suspension_frame, (void *)Get_LOCAL_top_cp() < SuspFr_local_reg(resume_fr) + SuspFr_local_size(resume_fr));
|
||||||
OPTYAP_ERROR_MESSAGE("DepFr_cons_cp(SuspFr_top_dep_fr)->cp_tr != SuspFr_trail_reg + SuspFr_trail_size (resume_suspension_frame)");
|
|
||||||
if (DepFr_cons_cp(SuspFr_top_dep_fr(resume_fr)) != SuspFr_local_reg(resume_fr))
|
|
||||||
OPTYAP_ERROR_MESSAGE("DepFr_cons_cp(SuspFr_top_dep_fr) != SuspFr_local_reg (resume_suspension_frame)");
|
|
||||||
if ((void *)Get_LOCAL_top_cp() < SuspFr_local_reg(resume_fr) + SuspFr_local_size(resume_fr))
|
|
||||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp < SuspFr_local_reg + SuspFr_local_size (resume_suspension_frame)");
|
|
||||||
#endif /* OPTYAP_ERRORS */
|
|
||||||
|
|
||||||
/* update shared nodes */
|
/* update shared nodes */
|
||||||
or_frame = top_or_fr;
|
or_frame = top_or_fr;
|
||||||
|
@ -1106,10 +1106,7 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
|||||||
current_ans_node = SgFr_answer_trie(sg_fr);
|
current_ans_node = SgFr_answer_trie(sg_fr);
|
||||||
|
|
||||||
for (i = subs_arity; i >= 1; i--) {
|
for (i = subs_arity; i >= 1; i--) {
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(answer search, IsNonVarTerm(subs_ptr[i]));
|
||||||
if (IsNonVarTerm(subs_ptr[i]))
|
|
||||||
TABLING_ERROR_MESSAGE("IsNonVarTem(subs_ptr[i]) (answer_search)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity);
|
current_ans_node = answer_search_loop(sg_fr, current_ans_node, Deref(subs_ptr[i]), &vars_arity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,10 +1127,7 @@ void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
|
|||||||
CELL *stack_terms;
|
CELL *stack_terms;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(load_answer, H < H_FZ);
|
||||||
if (H < H_FZ)
|
|
||||||
TABLING_ERROR_MESSAGE("H < H_FZ (load_answer)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
if (subs_arity == 0)
|
if (subs_arity == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1143,10 +1137,7 @@ void load_answer(ans_node_ptr current_ans_node, CELL *subs_ptr) {
|
|||||||
Term t = STACK_POP_DOWN(stack_terms);
|
Term t = STACK_POP_DOWN(stack_terms);
|
||||||
Bind((CELL *) subs_ptr[i], t);
|
Bind((CELL *) subs_ptr[i], t);
|
||||||
}
|
}
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(load_answer, stack_terms != (CELL *)Yap_TrailTop);
|
||||||
if (stack_terms != (CELL *)Yap_TrailTop)
|
|
||||||
TABLING_ERROR_MESSAGE("stack_terms != Yap_TrailTop (load_answer)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
#undef subs_arity
|
#undef subs_arity
|
||||||
@ -1166,10 +1157,7 @@ CELL *exec_substitution(gt_node_ptr current_node, CELL *aux_stack) {
|
|||||||
subs_ptr = aux_stack + aux_stack[1] + 2;
|
subs_ptr = aux_stack + aux_stack[1] + 2;
|
||||||
t = STACK_POP_DOWN(stack_terms);
|
t = STACK_POP_DOWN(stack_terms);
|
||||||
Bind((CELL *) subs_ptr[subs_arity], t);
|
Bind((CELL *) subs_ptr[subs_arity], t);
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(exec_substitution, stack_terms != (CELL *)Yap_TrailTop);
|
||||||
if (stack_terms != (CELL *)Yap_TrailTop)
|
|
||||||
TABLING_ERROR_MESSAGE("stack_terms != Yap_TrailTop (exec_substitution)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
*subs_ptr = subs_arity - 1;
|
*subs_ptr = subs_arity - 1;
|
||||||
|
|
||||||
return aux_stack;
|
return aux_stack;
|
||||||
|
@ -383,11 +383,7 @@ static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr sg_fr, ans_n
|
|||||||
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
#endif /* MODE_GLOBAL_TRIE_ENTRY */
|
||||||
ans_node_ptr child_node;
|
ans_node_ptr child_node;
|
||||||
|
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(answer_trie_check_insert_(gt)_entry, IS_ANSWER_LEAF_NODE(parent_node));
|
||||||
if (IS_ANSWER_LEAF_NODE(parent_node))
|
|
||||||
TABLING_ERROR_MESSAGE("IS_ANSWER_LEAF_NODE(parent_node) (answer_trie_check_insert_(gt)_entry)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
|
|
||||||
LOCK_NODE(parent_node);
|
LOCK_NODE(parent_node);
|
||||||
child_node = TrNode_child(parent_node);
|
child_node = TrNode_child(parent_node);
|
||||||
if (child_node == NULL) {
|
if (child_node == NULL) {
|
||||||
@ -485,11 +481,7 @@ static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr sg_fr, ans_n
|
|||||||
ans_node_ptr child_node;
|
ans_node_ptr child_node;
|
||||||
ans_hash_ptr hash;
|
ans_hash_ptr hash;
|
||||||
|
|
||||||
#ifdef TABLING_ERRORS
|
TABLING_ERROR_CHECKING(answer_trie_check_insert_(gt)_entry, IS_ANSWER_LEAF_NODE(parent_node));
|
||||||
if (IS_ANSWER_LEAF_NODE(parent_node))
|
|
||||||
TABLING_ERROR_MESSAGE("IS_ANSWER_LEAF_NODE(parent_node) (answer_trie_check_insert_(gt)_entry)");
|
|
||||||
#endif /* TABLING_ERRORS */
|
|
||||||
|
|
||||||
child_node = TrNode_child(parent_node);
|
child_node = TrNode_child(parent_node);
|
||||||
if (child_node == NULL) {
|
if (child_node == NULL) {
|
||||||
#ifdef ALLOC_BEFORE_CHECK
|
#ifdef ALLOC_BEFORE_CHECK
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
B = cp; \
|
B = cp; \
|
||||||
YAPOR_SET_LOAD(B); \
|
YAPOR_SET_LOAD(B); \
|
||||||
SET_BB(B); \
|
SET_BB(B); \
|
||||||
TABLING_ERRORS_check_stack; \
|
TABLING_ERROR_CHECKING_STACK; \
|
||||||
} \
|
} \
|
||||||
copy_aux_stack()
|
copy_aux_stack()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user