experiment in or-parallel threads.
This commit is contained in:
parent
ac104aac9c
commit
5ef31fbfd2
@ -1824,7 +1824,7 @@ Yap_absmi(int inp)
|
||||
|
||||
#ifdef YAPOR
|
||||
shared_fail:
|
||||
B = LOCAL_top_cp;
|
||||
B = Get_LOCAL_top_cp();
|
||||
SET_BB(PROTECT_FROZEN_B(B));
|
||||
goto fail;
|
||||
#endif /* YAPOR */
|
||||
|
@ -2245,6 +2245,11 @@ YAP_Init(YAP_init_args *yap_init)
|
||||
yap_init->ErrorCause = "could not allocate stack space for main thread";
|
||||
return YAP_BOOT_FROM_SAVED_ERROR;;
|
||||
}
|
||||
#if THREADS
|
||||
/* don't forget this is a thread */
|
||||
ThreadHandle[worker_id].stack_address = Yap_GlobalBase;
|
||||
ThreadHandle[worker_id].ssize = Trail+Stack;
|
||||
#endif
|
||||
#endif
|
||||
Yap_AllowGlobalExpansion = TRUE;
|
||||
Yap_AllowLocalExpansion = TRUE;
|
||||
|
2
C/exec.c
2
C/exec.c
@ -1435,7 +1435,7 @@ static int is_cleanup_cp(choiceptr cp_b)
|
||||
if (cp_b->cp_ap->opc != ORLAST_OPCODE)
|
||||
return FALSE;
|
||||
#ifdef YAPOR
|
||||
pe = cp_b->cp_ap->u.Osblp.p;
|
||||
pe = cp_b->cp_ap->u.Osblp.p0;
|
||||
#else
|
||||
pe = cp_b->cp_ap->u.p.p;
|
||||
#endif /* YAPOR */
|
||||
|
85
C/grow.c
85
C/grow.c
@ -65,7 +65,7 @@ STATIC_PROTO(int growstack, (long));
|
||||
STATIC_PROTO(void MoveGlobal, (void));
|
||||
STATIC_PROTO(void MoveLocalAndTrail, (void));
|
||||
STATIC_PROTO(void SetHeapRegs, (void));
|
||||
STATIC_PROTO(void AdjustTrail, (int));
|
||||
STATIC_PROTO(void AdjustTrail, (int, int));
|
||||
STATIC_PROTO(void AdjustLocal, (void));
|
||||
STATIC_PROTO(void AdjustGlobal, (long));
|
||||
STATIC_PROTO(void AdjustGrowStack, (void));
|
||||
@ -73,7 +73,7 @@ STATIC_PROTO(int static_growheap, (long,int,struct intermediates *,tr_fr_ptr *,
|
||||
STATIC_PROTO(void cpcellsd, (CELL *, CELL *, CELL));
|
||||
STATIC_PROTO(CELL AdjustAppl, (CELL));
|
||||
STATIC_PROTO(CELL AdjustPair, (CELL));
|
||||
STATIC_PROTO(void AdjustStacksAndTrail, (long));
|
||||
STATIC_PROTO(void AdjustStacksAndTrail, (long, int));
|
||||
STATIC_PROTO(void AdjustRegs, (int));
|
||||
|
||||
static void
|
||||
@ -212,6 +212,15 @@ MoveLocalAndTrail(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
CopyLocalAndTrail(void)
|
||||
{
|
||||
/* cpcellsd(To,From,NOfCells) - copy the cells downwards */
|
||||
#if USE_SYSTEM_MALLOC
|
||||
cpcellsd((void *)ASP, (void *)OldASP, (CELL *)OldTR - OldASP);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
MoveGlobal(void)
|
||||
{
|
||||
@ -297,7 +306,7 @@ AdjustPair(register CELL t0)
|
||||
}
|
||||
|
||||
static void
|
||||
AdjustTrail(int adjusting_heap)
|
||||
AdjustTrail(int adjusting_heap, int duplicate_references)
|
||||
{
|
||||
volatile tr_fr_ptr ptt;
|
||||
|
||||
@ -318,7 +327,7 @@ AdjustTrail(int adjusting_heap)
|
||||
else if (IsOldTrail(reg))
|
||||
TrailTerm(ptt) = TrailAdjust(reg);
|
||||
} else if (IsPairTerm(reg)) {
|
||||
TrailTerm(ptt) = AdjustPair(reg);
|
||||
TrailTerm(ptt) = AdjustPair(reg);
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES /* does not work with new structures */
|
||||
/* check it whether we are protecting a
|
||||
multi-assignment */
|
||||
@ -491,9 +500,9 @@ AdjustGlobal(long sz)
|
||||
* (just once) the trail cells pointing both to the global and to the local
|
||||
*/
|
||||
static void
|
||||
AdjustStacksAndTrail(long sz)
|
||||
AdjustStacksAndTrail(long sz, int copying_threads)
|
||||
{
|
||||
AdjustTrail(TRUE);
|
||||
AdjustTrail(TRUE, copying_threads);
|
||||
AdjustLocal();
|
||||
AdjustGlobal(sz);
|
||||
}
|
||||
@ -501,7 +510,7 @@ AdjustStacksAndTrail(long sz)
|
||||
void
|
||||
Yap_AdjustStacksAndTrail(void)
|
||||
{
|
||||
AdjustStacksAndTrail(0);
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -511,7 +520,7 @@ Yap_AdjustStacksAndTrail(void)
|
||||
static void
|
||||
AdjustGrowStack(void)
|
||||
{
|
||||
AdjustTrail(FALSE);
|
||||
AdjustTrail(FALSE, FALSE);
|
||||
AdjustLocal();
|
||||
}
|
||||
|
||||
@ -690,10 +699,10 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
|
||||
nTR = TR;
|
||||
*old_trp = PtoTRAdjust(*old_trp);
|
||||
TR = *old_trp;
|
||||
AdjustStacksAndTrail(0);
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
TR = nTR;
|
||||
} else {
|
||||
AdjustStacksAndTrail(0);
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
}
|
||||
AdjustRegs(MaxTemps);
|
||||
YAPLeaveCriticalSection();
|
||||
@ -864,9 +873,9 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit)
|
||||
}
|
||||
/* don't run through garbage */
|
||||
if (hsplit && (OldH != hsplit)) {
|
||||
AdjustStacksAndTrail(request);
|
||||
AdjustStacksAndTrail(request, FALSE);
|
||||
} else {
|
||||
AdjustStacksAndTrail(0);
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
}
|
||||
AdjustRegs(MaxTemps);
|
||||
if (ptr) {
|
||||
@ -1411,10 +1420,10 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
|
||||
nTR = TR;
|
||||
*old_trp = PtoTRAdjust(*old_trp);
|
||||
TR = *old_trp;
|
||||
AdjustStacksAndTrail(0);
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
TR = nTR;
|
||||
} else {
|
||||
AdjustStacksAndTrail(0);
|
||||
AdjustStacksAndTrail(0, FALSE);
|
||||
}
|
||||
AdjustRegs(MaxTemps);
|
||||
#ifdef TABLING
|
||||
@ -1687,6 +1696,54 @@ p_inform_heap_overflows(void)
|
||||
return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2));
|
||||
}
|
||||
|
||||
#if THREADS
|
||||
void
|
||||
Yap_CopyThreadStacks(int worker_q, int worker_p)
|
||||
{
|
||||
Int size;
|
||||
|
||||
/* make sure both stacks have same size */
|
||||
Int p_size = ThreadHandle[worker_p].ssize+ThreadHandle[worker_p].tsize;
|
||||
Int q_size = ThreadHandle[worker_q].ssize+ThreadHandle[worker_q].tsize;
|
||||
if (p_size != q_size) {
|
||||
if (!(ThreadHandle[worker_q].stack_address = malloc(p_size*1024))) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
ThreadHandle[worker_q].ssize = ThreadHandle[worker_p].ssize;
|
||||
ThreadHandle[worker_q].tsize = ThreadHandle[worker_p].tsize;
|
||||
/* compute offset indicators */
|
||||
Yap_GlobalBase = Yap_thread_gl[worker_p].global_base;
|
||||
Yap_LocalBase = Yap_thread_gl[worker_p].local_base;
|
||||
Yap_TrailBase = Yap_thread_gl[worker_p].trail_base;
|
||||
Yap_TrailTop = Yap_thread_gl[worker_p].trail_top;
|
||||
size = ThreadHandle[worker_q].stack_address-ThreadHandle[worker_p].stack_address;
|
||||
TrDiff = LDiff = GDiff = GDiff0 = DelayDiff = BaseDiff = size;
|
||||
XDiff = HDiff = 0;
|
||||
GSplit = NULL;
|
||||
H = ThreadHandle[worker_p].current_yaam_regs->H_;
|
||||
H0 = ThreadHandle[worker_p].current_yaam_regs->H0_;
|
||||
B = ThreadHandle[worker_p].current_yaam_regs->B_;
|
||||
ENV = ThreadHandle[worker_p].current_yaam_regs->ENV_;
|
||||
YENV = ThreadHandle[worker_p].current_yaam_regs->YENV_;
|
||||
ASP = ThreadHandle[worker_p].current_yaam_regs->ASP_;
|
||||
if (ASP > CellPtr(B))
|
||||
ASP = CellPtr(B);
|
||||
LCL0 = ThreadHandle[worker_p].current_yaam_regs->LCL0_;
|
||||
DelayedVars = ThreadHandle[worker_p].current_yaam_regs->DelayedVars_;
|
||||
TR = ThreadHandle[worker_p].current_yaam_regs->TR_;
|
||||
CurrentDelayTop = (CELL *)DelayTop();
|
||||
DynamicArrays = NULL;
|
||||
StaticArrays = NULL;
|
||||
GlobalVariables = NULL;
|
||||
SetHeapRegs();
|
||||
CopyLocalAndTrail();
|
||||
MoveGlobal();
|
||||
AdjustStacksAndTrail(0, TRUE);
|
||||
AdjustRegs(MaxTemps);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* :- grow_stack(Size) */
|
||||
static Int
|
||||
p_growstack(void)
|
||||
|
10
C/init.c
10
C/init.c
@ -1215,8 +1215,8 @@ InitCodes(void)
|
||||
modp->PredFlags |= MetaPredFlag;
|
||||
}
|
||||
#ifdef YAPOR
|
||||
Yap_heap_regs->getwork_code.u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetwork, PROLOG_MODULE));
|
||||
Yap_heap_regs->getwork_seq_code.u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetworkSeq, PROLOG_MODULE));
|
||||
Yap_heap_regs->getwork_code->u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetwork, PROLOG_MODULE));
|
||||
Yap_heap_regs->getwork_seq_code->u.Otapl.p = RepPredProp(PredPropByAtom(AtomGetworkSeq, PROLOG_MODULE));
|
||||
#endif /* YAPOR */
|
||||
|
||||
}
|
||||
@ -1274,7 +1274,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
||||
Atts = 2048*sizeof(CELL);
|
||||
else
|
||||
Atts = AdjustPageSize(Atts * K);
|
||||
#ifdef YAPOR
|
||||
#if defined(YAPOR) && !defined(THREADS)
|
||||
worker_id = 0;
|
||||
if (n_workers > MAX_WORKERS)
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "excessive number of workers (Yap_InitWorkspace)");
|
||||
@ -1288,7 +1288,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
||||
map_memory(Heap, Stack+Atts, Trail, n_workers);
|
||||
#else
|
||||
Yap_InitMemory (Trail, Heap, Stack+Atts);
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR && !THREADS */
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
Yap_init_global(max_table_size, n_workers, sch_loop, delay_load);
|
||||
#endif /* YAPOR || TABLING */
|
||||
@ -1328,7 +1328,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
|
||||
void
|
||||
Yap_exit (int value)
|
||||
{
|
||||
#if defined(YAPOR)
|
||||
#if defined(YAPOR) && !defined(THREADS)
|
||||
unmap_memory();
|
||||
#endif /* YAPOR */
|
||||
|
||||
|
@ -162,6 +162,9 @@ setup_engine(int myworker_id)
|
||||
CurrentModule = ThreadHandle[myworker_id].cmod;
|
||||
Yap_InitTime();
|
||||
Yap_InitYaamRegs();
|
||||
#ifdef YAPOR
|
||||
Yap_init_local();
|
||||
#endif
|
||||
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
|
||||
/* I exist */
|
||||
NOfThreadsCreated++;
|
||||
|
3
H/Regs.h
3
H/Regs.h
@ -147,9 +147,6 @@ typedef struct
|
||||
Term XTERMS[MaxTemps]; /* 29 */
|
||||
#endif
|
||||
yamop *ARITH_EXCEPTION_;
|
||||
int isint_[MaxArithms];
|
||||
Int Ints_[MaxArithms];
|
||||
Float Floats_[MaxArithms];
|
||||
}
|
||||
REGSTORE;
|
||||
|
||||
|
8
H/Yap.h
8
H/Yap.h
@ -50,6 +50,11 @@
|
||||
|
||||
#ifdef YAPOR
|
||||
#define FIXED_STACKS 1
|
||||
#ifdef THREADS
|
||||
#undef ACOW
|
||||
#undef SBA
|
||||
#undef ENV_COPY
|
||||
#endif
|
||||
#endif /* YAPOR */
|
||||
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
@ -396,8 +401,7 @@ typedef pthread_rwlock_t rwlock_t;
|
||||
#endif
|
||||
#ifdef YAPOR
|
||||
#define MAX_AGENTS MAX_WORKERS
|
||||
#endif
|
||||
#ifdef THREADS
|
||||
#elif defined(THREADS)
|
||||
#define MAX_AGENTS MAX_THREADS
|
||||
#endif
|
||||
#endif
|
||||
|
10
H/YapHeap.h
10
H/YapHeap.h
@ -185,6 +185,12 @@ typedef struct worker_local_struct {
|
||||
UInt global_arena_overflows;
|
||||
Term global_delay_arena;
|
||||
yamop trust_lu_code[3];
|
||||
#if (defined(YAPOR) || defined(TABLING) ) && defined(THREADS)
|
||||
struct local_data *local;
|
||||
#ifdef YAPOR
|
||||
struct worker worker;
|
||||
#endif /* YAPOR */
|
||||
#endif
|
||||
} worker_local;
|
||||
|
||||
#ifdef THREADS
|
||||
@ -363,6 +369,10 @@ extern struct various_codes *Yap_heap_regs;
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
#define GLOBAL Yap_heap_regs->global
|
||||
#define REMOTE Yap_heap_regs->remote
|
||||
#ifdef THREADS
|
||||
#define LOCAL Yap_heap_regs->WL.local
|
||||
#define WORKER Yap_heap_regs->WL.worker
|
||||
#endif
|
||||
#endif /* YAPOR || TABLING */
|
||||
|
||||
#define UPDATE_MODE_IMMEDIATE 0
|
||||
|
@ -205,6 +205,9 @@ int STD_PROTO(Yap_growstack, (long));
|
||||
int STD_PROTO(Yap_growtrail, (long, int));
|
||||
int STD_PROTO(Yap_growglobal, (CELL **));
|
||||
CELL **STD_PROTO(Yap_shift_visit, (CELL **, CELL ***));
|
||||
#ifdef THREADS
|
||||
void STD_PROTO(Yap_CopyThreadStacks, (int, int));
|
||||
#endif
|
||||
|
||||
/* heapgc.c */
|
||||
Int STD_PROTO(Yap_total_gc_time,(void));
|
||||
|
@ -192,6 +192,7 @@ C_SOURCES= \
|
||||
$(srcdir)/OPTYap/opt.init.c \
|
||||
$(srcdir)/OPTYap/opt.preds.c $(srcdir)/OPTYap/or.engine.c \
|
||||
$(srcdir)/OPTYap/or.cowengine.c $(srcdir)/OPTYap/or.sbaengine.c \
|
||||
$(srcdir)/OPTYap/or.threadengine.c \
|
||||
$(srcdir)/OPTYap/or.scheduler.c $(srcdir)/OPTYap/or.cut.c \
|
||||
$(srcdir)/OPTYap/tab.tries.c $(srcdir)/OPTYap/tab.suspend.c \
|
||||
$(srcdir)/library/mpi/mpi.c $(srcdir)/library/mpi/mpe.c \
|
||||
@ -266,7 +267,8 @@ C_INTERFACE_OBJECTS = \
|
||||
|
||||
OR_OBJECTS = \
|
||||
opt.memory.o opt.misc.o opt.init.o opt.preds.o \
|
||||
or.engine.o or.cowengine.o or.sbaengine.o or.scheduler.o or.cut.o \
|
||||
or.engine.o or.cowengine.o or.sbaengine.o or.threadengine.o \
|
||||
or.scheduler.o or.cut.o \
|
||||
tab.tries.o tab.suspend.o
|
||||
|
||||
BEAM_OBJECTS = \
|
||||
@ -396,6 +398,9 @@ or.cowengine.o: $(srcdir)/OPTYap/or.cowengine.c
|
||||
or.sbaengine.o: $(srcdir)/OPTYap/or.sbaengine.c
|
||||
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.sbaengine.c -o $@
|
||||
|
||||
or.threadengine.o: $(srcdir)/OPTYap/or.threadengine.c
|
||||
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.threadengine.c -o $@
|
||||
|
||||
or.scheduler.o: $(srcdir)/OPTYap/or.scheduler.c
|
||||
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.scheduler.c -o $@
|
||||
|
||||
|
@ -176,7 +176,7 @@ void Yap_init_local(void) {
|
||||
#ifdef YAPOR
|
||||
/* local data related to or-parallelism */
|
||||
LOCAL = REMOTE + worker_id;
|
||||
LOCAL_top_cp = B_BASE;
|
||||
Set_LOCAL_top_cp(B_BASE);
|
||||
LOCAL_top_or_fr = GLOBAL_root_or_fr;
|
||||
LOCAL_load = 0;
|
||||
LOCAL_share_request = MAX_WORKERS;
|
||||
@ -193,7 +193,7 @@ void Yap_init_local(void) {
|
||||
LOCAL_top_sg_fr = NULL;
|
||||
LOCAL_top_dep_fr = GLOBAL_root_dep_fr;
|
||||
#ifdef YAPOR
|
||||
LOCAL_top_cp_on_stack = B_BASE; /* ??? */
|
||||
Set_LOCAL_top_cp_on_stack(B_BASE); /* ??? */
|
||||
LOCAL_top_susp_or_fr = GLOBAL_root_or_fr;
|
||||
#endif /* YAPOR */
|
||||
#endif /* TABLING */
|
||||
@ -210,7 +210,7 @@ void make_root_frames(void) {
|
||||
INIT_LOCK(OrFr_lock(or_fr));
|
||||
OrFr_alternative(or_fr) = NULL;
|
||||
BITMAP_copy(OrFr_members(or_fr), GLOBAL_bm_present_workers);
|
||||
OrFr_node(or_fr) = B_BASE;
|
||||
SetOrFr_node(or_fr, B_BASE);
|
||||
OrFr_nearest_livenode(or_fr) = NULL;
|
||||
OrFr_depth(or_fr) = 0;
|
||||
OrFr_pend_prune_cp(or_fr) = NULL;
|
||||
@ -240,6 +240,9 @@ void make_root_frames(void) {
|
||||
#ifdef YAPOR
|
||||
void init_workers(void) {
|
||||
int proc;
|
||||
#ifdef THREADS
|
||||
return;
|
||||
#endif
|
||||
NOfThreads = number_workers;
|
||||
#ifdef ACOW
|
||||
if (number_workers > 1) {
|
||||
|
@ -33,11 +33,12 @@
|
||||
** Global variables are defined here **
|
||||
** ------------------------------------------- */
|
||||
|
||||
#ifndef THREADS
|
||||
struct local_data *LOCAL;
|
||||
#ifdef YAPOR
|
||||
struct worker WORKER;
|
||||
#endif /* YAPOR */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* -------------------------- **
|
||||
|
@ -46,6 +46,7 @@ static qg_ans_fr_ptr actual_answer;
|
||||
** Local functions declaration **
|
||||
** ------------------------------------- */
|
||||
|
||||
static Int p_yapor_threads(void);
|
||||
#ifdef YAPOR
|
||||
static realtime current_time(void);
|
||||
static Int p_yapor_on(void);
|
||||
@ -60,6 +61,7 @@ static int parallel_new_answer_putchar(int sno, int ch);
|
||||
static void show_answers(void);
|
||||
static void answer_to_stdout(char *answer);
|
||||
static Int p_or_statistics(void);
|
||||
static Int p_worker(void);
|
||||
#endif /* YAPOR */
|
||||
|
||||
#ifdef TABLING
|
||||
@ -123,7 +125,9 @@ static void shm_suspension_frames(long *pages_in_use, long *bytes_in_use);
|
||||
** -------------------------- */
|
||||
|
||||
void Yap_init_optyap_preds(void) {
|
||||
Yap_InitCPred("$yapor_threads", 1, p_yapor_threads, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
#ifdef YAPOR
|
||||
Yap_InitCPred("$worker", 0, p_worker, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$yapor_on", 0, p_yapor_on, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$start_yapor", 0, p_start_yapor, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$sequential", 1, p_sequential, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
@ -173,6 +177,16 @@ void finish_yapor(void) {
|
||||
** Local functions **
|
||||
** ------------------------- */
|
||||
|
||||
static
|
||||
Int p_yapor_threads(void) {
|
||||
#if defined(YAPOR) && defined(THREADS)
|
||||
return Yap_unify(MkIntegerTerm(number_workers),ARG1);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef YAPOR
|
||||
static
|
||||
realtime current_time(void) {
|
||||
@ -193,7 +207,6 @@ Int p_yapor_on(void) {
|
||||
return (PARALLEL_EXECUTION_MODE);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
Int p_start_yapor(void) {
|
||||
#ifdef TIMESTAMP_CHECK
|
||||
@ -214,6 +227,12 @@ Int p_start_yapor(void) {
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static
|
||||
Int p_worker(void) {
|
||||
CurrentModule = USER_MODULE;
|
||||
P = GETWORK_FIRST_TIME;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
Int p_sequential(void) {
|
||||
|
@ -97,40 +97,15 @@ void resume_suspension_frame(susp_fr_ptr resume_fr, or_fr_ptr top_or_fr);
|
||||
|
||||
|
||||
/* ------------- **
|
||||
** or.engine.c **
|
||||
** or.*engine.c **
|
||||
** ------------- */
|
||||
|
||||
#ifdef ENV_COPY
|
||||
void make_root_choice_point(void);
|
||||
void free_root_choice_point(void);
|
||||
int q_share_work(int p);
|
||||
void p_share_work(void);
|
||||
#endif /* ENV_COPY */
|
||||
|
||||
|
||||
/* ---------------- **
|
||||
** or.cowengine.c **
|
||||
** ---------------- */
|
||||
|
||||
#ifdef ACOW
|
||||
#ifdef YAPOR
|
||||
void make_root_choice_point(void);
|
||||
void free_root_choice_point(void);
|
||||
int q_share_work(int p);
|
||||
int p_share_work(void);
|
||||
#endif /* ACOW */
|
||||
|
||||
|
||||
/* ---------------- **
|
||||
** or.sbaengine.c **
|
||||
** ---------------- */
|
||||
|
||||
#ifdef SBA
|
||||
void make_root_choice_point(void);
|
||||
void free_root_choice_point(void);
|
||||
int q_share_work(int p);
|
||||
void p_share_work(void);
|
||||
#endif /* SBA */
|
||||
|
||||
#endif /* YAPOR */
|
||||
|
||||
/* ---------------- **
|
||||
** or.scheduler.c **
|
||||
|
@ -17,6 +17,20 @@ typedef double realtime;
|
||||
typedef unsigned long bitmap;
|
||||
|
||||
|
||||
#ifdef THREADS
|
||||
/* Threads may not assume addresses are the same at different workers */
|
||||
static inline choiceptr
|
||||
offset_to_cptr(Int node)
|
||||
{
|
||||
return (choiceptr)(LCL0-node);
|
||||
}
|
||||
|
||||
static inline Int
|
||||
cptr_to_offset(choiceptr node)
|
||||
{
|
||||
return (Int)(LCL0-(CELL *)node);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ---------------------------- **
|
||||
** Struct page_header **
|
||||
@ -151,7 +165,11 @@ struct global_data{
|
||||
char performance_mode; /* PERFORMANCE_OFF / PERFORMANCE_ON / PERFORMANCE_IN_EXECUTION */
|
||||
|
||||
/* global data related to or-parallelism */
|
||||
#if THREADS
|
||||
Int root_choice_point_offset;
|
||||
#else
|
||||
choiceptr root_choice_point;
|
||||
#endif
|
||||
struct or_frame *root_or_frame;
|
||||
bitmap present_workers;
|
||||
volatile bitmap idle_workers;
|
||||
@ -217,7 +235,14 @@ struct global_data{
|
||||
#define GLOBAL_best_times(time) (GLOBAL.best_execution_times[time])
|
||||
#define GLOBAL_number_goals (GLOBAL.number_of_executed_goals)
|
||||
#define GLOBAL_performance_mode (GLOBAL.performance_mode)
|
||||
#if THREADS
|
||||
#define Get_GLOBAL_root_cp() offset_to_cptr(GLOBAL.root_choice_point_offset)
|
||||
#define Set_GLOBAL_root_cp(bptr) (GLOBAL.root_choice_point_offset = cptr_to_offset(bptr))
|
||||
#else
|
||||
#define GLOBAL_root_cp (GLOBAL.root_choice_point)
|
||||
#define Get_GLOBAL_root_cp() (GLOBAL.root_choice_point)
|
||||
#define Set_GLOBAL_root_cp(bptr) (GLOBAL.root_choice_point = (bptr))
|
||||
#endif
|
||||
#define GLOBAL_root_or_fr (GLOBAL.root_or_frame)
|
||||
#define GLOBAL_bm_present_workers (GLOBAL.present_workers)
|
||||
#define GLOBAL_bm_idle_workers (GLOBAL.idle_workers)
|
||||
@ -260,7 +285,7 @@ struct global_data{
|
||||
|
||||
#ifdef YAPOR
|
||||
struct local_signals{
|
||||
#ifdef ENV_COPY
|
||||
#if defined(ENV_COPY) || defined(THREADS)
|
||||
lockvar lock;
|
||||
volatile enum {
|
||||
Q_idle = 0,
|
||||
@ -269,7 +294,7 @@ struct local_signals{
|
||||
local = 3,
|
||||
P_idle = 4
|
||||
} P_fase, Q_fase;
|
||||
#endif /* ENV_COPY */
|
||||
#endif /* ENV_COPY || THREADS */
|
||||
volatile enum {
|
||||
no_sharing = 0,
|
||||
sharing = 1,
|
||||
@ -293,7 +318,11 @@ struct local_data{
|
||||
#ifdef YAPOR
|
||||
/* local data related to or-parallelism */
|
||||
volatile int load;
|
||||
#if THREADS
|
||||
Int top_choice_point_offset;
|
||||
#else
|
||||
choiceptr top_choice_point;
|
||||
#endif
|
||||
struct or_frame *top_or_frame;
|
||||
choiceptr prune_request;
|
||||
volatile int share_request;
|
||||
@ -323,7 +352,14 @@ extern struct local_data *LOCAL;
|
||||
|
||||
#define LOCAL_lock (LOCAL->lock)
|
||||
#define LOCAL_load (LOCAL->load)
|
||||
#if THREADS
|
||||
#define Get_LOCAL_top_cp() offset_to_cptr(LOCAL->top_choice_point_offset)
|
||||
#define Set_LOCAL_top_cp(cpt) (LOCAL->top_choice_point_offset = cptr_to_offset(cpt))
|
||||
#else
|
||||
#define LOCAL_top_cp (LOCAL->top_choice_point)
|
||||
#define Get_LOCAL_top_cp() (LOCAL->top_choice_point)
|
||||
#define Set_LOCAL_top_cp(cpt) (LOCAL->top_choice_point = cpt)
|
||||
#endif
|
||||
#define LOCAL_top_or_fr (LOCAL->top_or_frame)
|
||||
#define LOCAL_prune_request (LOCAL->prune_request)
|
||||
#define LOCAL_share_request (LOCAL->share_request)
|
||||
@ -341,12 +377,25 @@ extern struct local_data *LOCAL;
|
||||
#define LOCAL_top_sg_fr (LOCAL->top_subgoal_frame)
|
||||
#define LOCAL_top_dep_fr (LOCAL->top_dependency_frame)
|
||||
#define LOCAL_pruning_scope (LOCAL->bottom_pruning_scope)
|
||||
#if THREADS
|
||||
#define Get_LOCAL_top_cp_on_stack() offset_to_cptr(LOCAL->top_choice_point_on_stack_offset)
|
||||
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL->top_choice_point_on_stack_offset = cptr_to_offset(cpt))
|
||||
#else
|
||||
#define LOCAL_top_cp_on_stack (LOCAL->top_choice_point_on_stack)
|
||||
#define Get_LOCAL_top_cp_on_stack() (LOCAL->top_choice_point_on_stack)
|
||||
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL->top_choice_point_on_stack = cpt)
|
||||
#endif
|
||||
#define LOCAL_top_susp_or_fr (LOCAL->top_or_frame_with_suspensions)
|
||||
|
||||
#define REMOTE_lock(worker) (REMOTE[worker].lock)
|
||||
#define REMOTE_load(worker) (REMOTE[worker].load)
|
||||
#if THREADS
|
||||
#define REMOTE_top_cp(worker) offset_to_cptr(REMOTE[worker].top_choice_point_offset)
|
||||
#define Set_REMOTE_top_cp(worker, bptr) (REMOTE[worker].top_choice_point_offset = cptr_to_offset(bptr))
|
||||
#else
|
||||
#define REMOTE_top_cp(worker) (REMOTE[worker].top_choice_point)
|
||||
#define Set_REMOTE_top_cp(worker, bptr) (REMOTE[worker].top_choice_point = (bptr))
|
||||
#endif
|
||||
#define REMOTE_top_or_fr(worker) (REMOTE[worker].top_or_frame)
|
||||
#define REMOTE_prune_request(worker) (REMOTE[worker].prune_request)
|
||||
#define REMOTE_share_request(worker) (REMOTE[worker].share_request)
|
||||
@ -364,7 +413,13 @@ extern struct local_data *LOCAL;
|
||||
#define REMOTE_top_sg_fr(worker) (REMOTE[worker].top_subgoal_frame)
|
||||
#define REMOTE_top_dep_fr(worker) (REMOTE[worker].top_dependency_frame)
|
||||
#define REMOTE_pruning_scope(worker) (REMOTE[worker].bottom_pruning_scope)
|
||||
#define REMOTE_top_cp_on_stack(worker) (REMOTE[worker].top_choice_point_on_stack)
|
||||
#if THREADS
|
||||
#define REMOTE_top_cp_on_stack(worker) offset_to_cptr(REMOTE[worker].top_choice_point_on_stack_offset)
|
||||
#define Set_REMOTE_top_cp_on_stack(worker, bptr) (REMOTE[worker].top_choice_point_on_stack_offset = cptr_to_offset(bptr))
|
||||
#else
|
||||
#define REMOTE_top_cp_on_stack(worker) (REMOTE[worker].top_choice_point_on_stack)
|
||||
#define Set_REMOTE_top_cp_on_stack(worker, bptr) (REMOTE[worker].top_choice_point_on_stack = (bptr))
|
||||
#endif
|
||||
#define REMOTE_top_susp_or_fr(worker) (REMOTE[worker].top_or_frame_with_suspensions)
|
||||
|
||||
|
||||
|
@ -178,7 +178,7 @@ void share_private_nodes(int worker_q) {
|
||||
depth++;
|
||||
ALLOC_OR_FRAME(or_frame);
|
||||
INIT_LOCK(OrFr_lock(or_frame));
|
||||
OrFr_node(or_frame) = AuxB;
|
||||
SetOrFr_node(or_frame, AuxB);
|
||||
OrFr_alternative(or_frame) = AuxB->cp_ap;
|
||||
OrFr_pend_prune_cp(or_frame) = NULL;
|
||||
OrFr_nearest_leftnode(or_frame) = LOCAL_top_or_fr;
|
||||
|
@ -39,7 +39,7 @@ void prune_shared_branch(choiceptr prune_cp) {
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
|
||||
leftmost_or_fr = CUT_leftmost_or_frame();
|
||||
leftmost_cp = OrFr_node(leftmost_or_fr);
|
||||
leftmost_cp = GetOrFr_node(leftmost_or_fr);
|
||||
qg_solutions = NULL;
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
tg_solutions = NULL;
|
||||
@ -99,7 +99,7 @@ void prune_shared_branch(choiceptr prune_cp) {
|
||||
}
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
SCH_update_local_or_tops();
|
||||
} while (LOCAL_top_cp != prune_cp);
|
||||
} while (Get_LOCAL_top_cp() != prune_cp);
|
||||
|
||||
#ifdef YAPOR_ERRORS
|
||||
if (LOCAL_prune_request && EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, LOCAL_top_cp))
|
||||
@ -151,7 +151,7 @@ void prune_shared_branch(choiceptr prune_cp) {
|
||||
UNLOCK_OR_FRAME(leftmost_or_fr);
|
||||
|
||||
/* move up to leftmost_cp */
|
||||
while (LOCAL_top_cp != leftmost_cp) {
|
||||
while (Get_LOCAL_top_cp() != leftmost_cp) {
|
||||
ltt = BRANCH_LTT(worker_id, OrFr_depth(LOCAL_top_or_fr));
|
||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
if (OrFr_pend_prune_cp(LOCAL_top_or_fr))
|
||||
@ -192,8 +192,8 @@ void prune_shared_branch(choiceptr prune_cp) {
|
||||
}
|
||||
|
||||
#ifdef YAPOR_ERRORS
|
||||
if (LOCAL_prune_request && EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, LOCAL_top_cp))
|
||||
YAPOR_ERROR_MESSAGE("EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, LOCAL_top_cp) (prune_shared_branch)");
|
||||
if (LOCAL_prune_request && EQUAL_OR_YOUNGER_CP(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 */
|
||||
if (qg_solutions)
|
||||
@ -256,7 +256,7 @@ void prune_shared_branch(choiceptr prune_cp) {
|
||||
end_prune_more:
|
||||
CUT_reset_prune_request();
|
||||
#ifdef TABLING
|
||||
LOCAL_top_cp_on_stack = LOCAL_top_cp;
|
||||
Set_LOCAL_top_cp_on_stack(LOCAL_top_cp);
|
||||
#endif /* TABLING */
|
||||
|
||||
return;
|
||||
|
@ -43,14 +43,14 @@
|
||||
|
||||
PBOp(getwork,Otapl)
|
||||
#ifdef TABLING
|
||||
if (DepFr_leader_cp(LOCAL_top_dep_fr) == LOCAL_top_cp) {
|
||||
if (DepFr_leader_cp(LOCAL_top_dep_fr) == Get_LOCAL_top_cp()) {
|
||||
/* the current top node is a leader node with consumer nodes below */
|
||||
if (DepFr_leader_dep_is_on_stack(LOCAL_top_dep_fr)) {
|
||||
/* the frozen branch depends on the current top node **
|
||||
** this means that the current top node is a generator node */
|
||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
if (OrFr_alternative(LOCAL_top_or_fr) == NULL ||
|
||||
(OrFr_alternative(LOCAL_top_or_fr) == ANSWER_RESOLUTION && B_FZ != LOCAL_top_cp)) {
|
||||
(OrFr_alternative(LOCAL_top_or_fr) == ANSWER_RESOLUTION && B_FZ != Get_LOCAL_top_cp())) {
|
||||
/* there are no unexploited alternatives **
|
||||
** (NULL if batched scheduling OR ANSWER_RESOLUTION if local scheduling) */
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
@ -66,7 +66,7 @@
|
||||
#ifdef batched scheduling
|
||||
if (OrFr_alternative(LOCAL_top_or_fr) != NULL) {
|
||||
#else local scheduling
|
||||
if (OrFr_alternative(LOCAL_top_or_fr) != ANSWER_RESOLUTION || B_FZ == LOCAL_top_cp) {
|
||||
if (OrFr_alternative(LOCAL_top_or_fr) != ANSWER_RESOLUTION || B_FZ == Get_LOCAL_top_cp()) {
|
||||
#endif
|
||||
PREG = OrFr_alternative(LOCAL_top_or_fr);
|
||||
PREFETCH_OP(PREG);
|
||||
|
@ -118,7 +118,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
|
||||
** Scheduler Macros **
|
||||
** -------------------------- */
|
||||
|
||||
#define SCH_top_shared_cp(CP) (LOCAL_top_cp == CP)
|
||||
#define SCH_top_shared_cp(CP) (Get_LOCAL_top_cp() == CP)
|
||||
|
||||
#define SCH_any_share_request (LOCAL_share_request != MAX_WORKERS)
|
||||
|
||||
@ -133,10 +133,13 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
|
||||
SCHEDULER_GET_WORK(); \
|
||||
}
|
||||
|
||||
#if defined(ENV_COPY) || defined(SBA)
|
||||
#if defined(ENV_COPY) || defined(SBA) || defined(THREADS)
|
||||
#define SCH_check_share_request() \
|
||||
if (SCH_any_share_request) { \
|
||||
ASP = YENV; \
|
||||
saveregs(); \
|
||||
p_share_work(); \
|
||||
setregs(); \
|
||||
}
|
||||
#else /* ACOW */
|
||||
#define SCH_check_share_request() \
|
||||
@ -163,10 +166,10 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
|
||||
** -------------------- */
|
||||
|
||||
#define CUT_prune_to(PRUNE_CP) \
|
||||
if (YOUNGER_CP(LOCAL_top_cp, PRUNE_CP)) { \
|
||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), PRUNE_CP)) { \
|
||||
if (! LOCAL_prune_request) \
|
||||
prune_shared_branch(PRUNE_CP); \
|
||||
PRUNE_CP = LOCAL_top_cp; \
|
||||
PRUNE_CP = Get_LOCAL_top_cp(); \
|
||||
}
|
||||
|
||||
#define CUT_wait_leftmost() \
|
||||
@ -279,8 +282,8 @@ void PUT_OUT_REQUESTABLE(int p) {
|
||||
|
||||
static inline
|
||||
void SCH_update_local_or_tops(void) {
|
||||
LOCAL_top_cp = LOCAL_top_cp->cp_b;
|
||||
LOCAL_top_or_fr = LOCAL_top_cp->cp_or_fr;
|
||||
Set_LOCAL_top_cp(Get_LOCAL_top_cp()->cp_b);
|
||||
LOCAL_top_or_fr = Get_LOCAL_top_cp()->cp_or_fr;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -349,7 +352,7 @@ void CUT_send_prune_request(int worker, choiceptr prune_cp) {
|
||||
static inline
|
||||
void CUT_reset_prune_request(void) {
|
||||
LOCK_WORKER(worker_id);
|
||||
if (LOCAL_prune_request && EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, LOCAL_top_cp))
|
||||
if (LOCAL_prune_request && EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, Get_LOCAL_top_cp()))
|
||||
LOCAL_prune_request = NULL;
|
||||
UNLOCK_WORKER(worker_id);
|
||||
return;
|
||||
@ -434,7 +437,7 @@ or_fr_ptr CUT_leftmost_until(or_fr_ptr start_or_fr, int until_depth) {
|
||||
for (i = 0; i < number_workers; i++) {
|
||||
if (BITMAP_member(members, i) &&
|
||||
BRANCH_LTT(i, depth) > ltt &&
|
||||
EQUAL_OR_YOUNGER_CP(OrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i)))
|
||||
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i)))
|
||||
return leftmost_or_fr;
|
||||
}
|
||||
BITMAP_minus(prune_members, members);
|
||||
@ -449,7 +452,7 @@ or_fr_ptr CUT_leftmost_until(or_fr_ptr start_or_fr, int until_depth) {
|
||||
for (i = 0; i < number_workers; i++) {
|
||||
if (BITMAP_member(members, i) &&
|
||||
BRANCH_LTT(i, depth) > ltt &&
|
||||
EQUAL_OR_YOUNGER_CP(OrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i))) {
|
||||
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i))) {
|
||||
/* update nearest leftnode data */
|
||||
OrFr_nearest_leftnode(start_or_fr) = leftmost_or_fr;
|
||||
start_or_fr = OrFr_nearest_leftnode(start_or_fr);
|
||||
|
@ -99,7 +99,7 @@ void PUT_OUT_ROOT_NODE(int worker_num) {
|
||||
static inline
|
||||
void move_up_to_prune_request(void) {
|
||||
#ifdef YAPOR_ERRORS
|
||||
if (EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, LOCAL_top_cp))
|
||||
if (EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, Get_LOCAL_top_cp()))
|
||||
YAPOR_ERROR_MESSAGE("invalid LOCAL_prune_request (move_up_to_prune_request)");
|
||||
#endif /* YAPOR_ERRORS */
|
||||
|
||||
@ -123,12 +123,12 @@ void move_up_to_prune_request(void) {
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
}
|
||||
SCH_update_local_or_tops();
|
||||
} while (LOCAL_top_cp != LOCAL_prune_request);
|
||||
} while (Get_LOCAL_top_cp() != LOCAL_prune_request);
|
||||
|
||||
CUT_reset_prune_request();
|
||||
#ifdef TABLING
|
||||
LOCAL_top_cp_on_stack = LOCAL_top_cp;
|
||||
abolish_incomplete_subgoals(LOCAL_top_cp - 1); /* do not include LOCAL_top_cp */
|
||||
Set_LOCAL_top_cp_on_stack( Get_LOCAL_top_cp());
|
||||
abolish_incomplete_subgoals(Get_LOCAL_top_cp() - 1); /* do not include LOCAL_top_cp */
|
||||
#endif /* TABLIG */
|
||||
|
||||
return;
|
||||
@ -173,7 +173,7 @@ int get_work(void) {
|
||||
if (or_fr_with_work) {
|
||||
/* move up to the nearest node with available work */
|
||||
#ifdef TABLING
|
||||
if (leader_node && YOUNGER_CP(leader_node, OrFr_node(or_fr_with_work)))
|
||||
if (leader_node && YOUNGER_CP(leader_node, GetOrFr_node(or_fr_with_work)))
|
||||
/* there is a leader node before the nearest node with work */
|
||||
or_fr_to_move_to = leader_node->cp_or_fr;
|
||||
else
|
||||
@ -216,14 +216,14 @@ int get_work(void) {
|
||||
BITMAP_difference(stable_busy, OrFr_members(LOCAL_top_or_fr), GLOBAL_bm_idle_workers);
|
||||
while (1) {
|
||||
while (BITMAP_subset(GLOBAL_bm_idle_workers, OrFr_members(LOCAL_top_or_fr)) &&
|
||||
LOCAL_top_cp != GLOBAL_root_cp) {
|
||||
Get_LOCAL_top_cp() != Get_GLOBAL_root_cp()) {
|
||||
/* no busy workers here and below */
|
||||
if (! move_up_one_node(NULL)) {
|
||||
PUT_BUSY(worker_id);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
if (LOCAL_top_cp == GLOBAL_root_cp) {
|
||||
if (Get_LOCAL_top_cp() == Get_GLOBAL_root_cp()) {
|
||||
if (! BITMAP_member(GLOBAL_bm_root_cp_workers, worker_id))
|
||||
PUT_IN_ROOT_NODE(worker_id);
|
||||
if (BITMAP_same(GLOBAL_bm_idle_workers, GLOBAL_bm_root_cp_workers) &&
|
||||
@ -267,7 +267,7 @@ int get_work(void) {
|
||||
static
|
||||
int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
#ifdef YAPOR_ERRORS
|
||||
if (LOCAL_prune_request && EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, LOCAL_top_cp))
|
||||
if (LOCAL_prune_request && EQUAL_OR_YOUNGER_CP(LOCAL_prune_request, Get_LOCAL_top_cp()))
|
||||
YAPOR_ERROR_MESSAGE("invalid LOCAL_prune_request (move_up_one_node)");
|
||||
#endif /* YAPOR_ERRORS */
|
||||
|
||||
@ -289,7 +289,7 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
&& ! LOCAL_prune_request
|
||||
&& CUT_last_worker_left_pending_prune(LOCAL_top_or_fr)) {
|
||||
#ifdef TABLING
|
||||
choiceptr aux_cp = LOCAL_top_cp;
|
||||
choiceptr aux_cp = Get_LOCAL_top_cp();
|
||||
#endif /* TABLIG */
|
||||
choiceptr prune_cp = OrFr_pend_prune_cp(LOCAL_top_or_fr);
|
||||
OrFr_pend_prune_cp(LOCAL_top_or_fr) = NULL;
|
||||
@ -297,7 +297,7 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
prune_shared_branch(prune_cp);
|
||||
#ifdef TABLING
|
||||
while (YOUNGER_CP(aux_cp->cp_b, LOCAL_top_cp))
|
||||
while (YOUNGER_CP(aux_cp->cp_b, Get_LOCAL_top_cp()))
|
||||
aux_cp = aux_cp->cp_b;
|
||||
abolish_incomplete_subgoals(aux_cp);
|
||||
#endif /* TABLIG */
|
||||
@ -309,17 +309,17 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
if (B_FZ != DepFr_cons_cp(LOCAL_top_dep_fr))
|
||||
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(LOCAL_top_cp, B_FZ) && YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), LOCAL_top_cp))
|
||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), LOCAL_top_cp) (move_up_one_node)");
|
||||
if (YOUNGER_CP(B_FZ, LOCAL_top_cp) && YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), B_FZ))
|
||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), B_FZ) (move_up_one_node)");
|
||||
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
|
||||
/* frozen stacks on branch ? */
|
||||
if (YOUNGER_CP(B_FZ, LOCAL_top_cp)) {
|
||||
if (YOUNGER_CP(B_FZ, Get_LOCAL_top_cp())) {
|
||||
if (nearest_livenode)
|
||||
OrFr_nearest_livenode(LOCAL_top_or_fr) = nearest_livenode;
|
||||
BITMAP_delete(OrFr_members(LOCAL_top_or_fr), worker_id);
|
||||
@ -371,7 +371,7 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
OrFr_nearest_suspnode(LOCAL_top_or_fr) = LOCAL_top_or_fr;
|
||||
}
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
unbind_variables(TR, LOCAL_top_cp->cp_tr);
|
||||
unbind_variables(TR, Get_LOCAL_top_cp()->cp_tr);
|
||||
resume_suspension_frame(resume_fr, LOCAL_top_or_fr);
|
||||
return FALSE;
|
||||
}
|
||||
@ -386,7 +386,7 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
|
||||
|
||||
/* top node frozen ? */
|
||||
if (B_FZ == LOCAL_top_cp) {
|
||||
if (B_FZ == Get_LOCAL_top_cp()) {
|
||||
if (nearest_livenode)
|
||||
OrFr_nearest_livenode(LOCAL_top_or_fr) = nearest_livenode;
|
||||
BITMAP_delete(OrFr_members(LOCAL_top_or_fr), worker_id);
|
||||
@ -429,15 +429,15 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
#ifdef OPTYAP_ERRORS
|
||||
if (OrFr_alternative(LOCAL_top_or_fr) && ! YAMOP_SEQ(OrFr_alternative(LOCAL_top_or_fr)))
|
||||
OPTYAP_ERROR_MESSAGE("OrFr_alternative(LOCAL_top_or_fr) not sequential (move_up_one_node)");
|
||||
if (LOCAL_top_cp == DepFr_cons_cp(LOCAL_top_dep_fr))
|
||||
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 (LOCAL_top_cp != LOCAL_top_cp_on_stack)
|
||||
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 */
|
||||
LOCAL_top_cp_on_stack = OrFr_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 ? */
|
||||
@ -445,7 +445,7 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
if (OrFr_suspensions(LOCAL_top_or_fr)) {
|
||||
complete_suspension_frames(LOCAL_top_or_fr);
|
||||
}
|
||||
if (LOCAL_top_sg_fr && LOCAL_top_cp == SgFr_gen_cp(LOCAL_top_sg_fr)) {
|
||||
if (LOCAL_top_sg_fr && Get_LOCAL_top_cp() == SgFr_gen_cp(LOCAL_top_sg_fr)) {
|
||||
mark_as_completed(LOCAL_top_sg_fr);
|
||||
LOCAL_top_sg_fr = SgFr_next(LOCAL_top_sg_fr);
|
||||
}
|
||||
@ -535,7 +535,7 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
update_local_tops3:
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
if (LOCAL_top_sg_fr && LOCAL_top_cp == SgFr_gen_cp(LOCAL_top_sg_fr)) {
|
||||
if (LOCAL_top_sg_fr && Get_LOCAL_top_cp() == SgFr_gen_cp(LOCAL_top_sg_fr)) {
|
||||
LOCAL_top_sg_fr = SgFr_next(LOCAL_top_sg_fr);
|
||||
}
|
||||
#endif /* TABLING */
|
||||
@ -556,7 +556,7 @@ int get_work_below(void){
|
||||
BITMAP_difference(idle_below, OrFr_members(LOCAL_top_or_fr), busy_below);
|
||||
BITMAP_delete(idle_below, worker_id);
|
||||
for (i = 0; i < number_workers; i++) {
|
||||
if (BITMAP_member(idle_below ,i) && YOUNGER_CP(REMOTE_top_cp(i), LOCAL_top_cp))
|
||||
if (BITMAP_member(idle_below ,i) && YOUNGER_CP(REMOTE_top_cp(i), Get_LOCAL_top_cp()))
|
||||
BITMAP_minus(busy_below, OrFr_members(REMOTE_top_or_fr(i)));
|
||||
}
|
||||
if (BITMAP_empty(busy_below))
|
||||
@ -664,7 +664,7 @@ int search_for_hidden_shared_work(bitmap stable_busy){
|
||||
BITMAP_intersection(idle_below, OrFr_members(LOCAL_top_or_fr), GLOBAL_bm_idle_workers);
|
||||
BITMAP_delete(idle_below, worker_id);
|
||||
for (i = 0; i < number_workers; i++) {
|
||||
if (BITMAP_member(idle_below ,i) && YOUNGER_CP(REMOTE_top_cp(i), LOCAL_top_cp))
|
||||
if (BITMAP_member(idle_below ,i) && YOUNGER_CP(REMOTE_top_cp(i), Get_LOCAL_top_cp()))
|
||||
BITMAP_minus(invisible_work, OrFr_members(REMOTE_top_or_fr(i)));
|
||||
}
|
||||
if (BITMAP_empty(invisible_work))
|
||||
|
@ -31,7 +31,11 @@ typedef struct or_frame {
|
||||
lockvar lock;
|
||||
yamop *alternative;
|
||||
volatile bitmap members;
|
||||
#ifdef THREADS
|
||||
Int node_offset;
|
||||
#else
|
||||
choiceptr node;
|
||||
#endif
|
||||
struct or_frame *nearest_livenode;
|
||||
/* cut support */
|
||||
int depth;
|
||||
@ -55,7 +59,14 @@ typedef struct or_frame {
|
||||
#define OrFr_lock(X) ((X)->lock)
|
||||
#define OrFr_alternative(X) ((X)->alternative)
|
||||
#define OrFr_members(X) ((X)->members)
|
||||
#ifdef THREADS
|
||||
#define GetOrFr_node(X) offset_to_cptr((X)->node_offset)
|
||||
#define SetOrFr_node(X,V) ((X)->node_offset = cptr_to_offset(V))
|
||||
#else
|
||||
#define OrFr_node(X) ((X)->node)
|
||||
#define GetOrFr_node(X) ((X)->node)
|
||||
#define SetOrFr_node(X,V) ((X)->node = V)
|
||||
#endif
|
||||
#define OrFr_nearest_livenode(X) ((X)->nearest_livenode)
|
||||
#define OrFr_depth(X) ((X)->depth)
|
||||
#define OrFr_pend_prune_cp(X) ((X)->pending_prune_cp)
|
||||
|
557
OPTYap/or.threadengine.c
Normal file
557
OPTYap/or.threadengine.c
Normal file
@ -0,0 +1,557 @@
|
||||
/**********************************************************************
|
||||
|
||||
The OPTYap Prolog system
|
||||
OPTYap extends the Yap Prolog system to support or-parallel tabling
|
||||
|
||||
Copyright: R. Rocha and NCC - University of Porto, Portugal
|
||||
File: or.threadengine.c
|
||||
version: $Id: or.engine.c,v 1.11 2008-03-25 16:45:53 vsc Exp $
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
/* ------------------ **
|
||||
** Includes **
|
||||
** ------------------ */
|
||||
|
||||
#include "Yap.h"
|
||||
#ifdef THREADS
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "or.macros.h"
|
||||
#ifdef TABLING
|
||||
#include "tab.macros.h"
|
||||
#else
|
||||
#include "opt.mavar.h"
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------- **
|
||||
** Local functions declaration **
|
||||
** ------------------------------------- */
|
||||
|
||||
static void share_private_nodes(int worker_q);
|
||||
|
||||
|
||||
|
||||
/* ---------------------- **
|
||||
** Local macros **
|
||||
** ---------------------- */
|
||||
|
||||
/* -------------------------- **
|
||||
** Global functions **
|
||||
** -------------------------- */
|
||||
|
||||
void make_root_choice_point(void) {
|
||||
if (worker_id == 0) {
|
||||
SetOrFr_node(GLOBAL_root_or_fr, B);
|
||||
Set_LOCAL_top_cp(B);
|
||||
Set_GLOBAL_root_cp(B);
|
||||
} else {
|
||||
Set_LOCAL_top_cp(Get_GLOBAL_root_cp());
|
||||
B = Get_GLOBAL_root_cp();
|
||||
B->cp_tr = TR = ((choiceptr) (worker_offset(0) + (CELL)(B)))->cp_tr;
|
||||
}
|
||||
B->cp_h = H0;
|
||||
B->cp_ap = GETWORK;
|
||||
B->cp_or_fr = GLOBAL_root_or_fr;
|
||||
LOCAL_top_or_fr = GLOBAL_root_or_fr;
|
||||
LOCAL_load = 0;
|
||||
LOCAL_prune_request = NULL;
|
||||
BRANCH(worker_id, 0) = 0;
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
LOCAL_pruning_scope = NULL;
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
#ifdef TABLING
|
||||
Set_LOCAL_top_cp_on_stack(Get_LOCAL_top_cp());
|
||||
adjust_freeze_registers();
|
||||
#endif /* TABLING */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void free_root_choice_point(void) {
|
||||
B = Get_LOCAL_top_cp()->cp_b;
|
||||
#ifdef TABLING
|
||||
Set_LOCAL_top_cp_on_stack(B_BASE);
|
||||
#endif /* TABLING */
|
||||
Set_GLOBAL_root_cp( B_BASE );
|
||||
Set_LOCAL_top_cp( B_BASE );
|
||||
SetOrFr_node(GLOBAL_root_or_fr, B_BASE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int p_share_work(void) {
|
||||
int worker_q = LOCAL_share_request;
|
||||
|
||||
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
|
||||
B == REMOTE_top_cp(worker_q) ||
|
||||
(LOCAL_load <= DELAYED_RELEASE_LOAD && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
|
||||
/* refuse sharing request */
|
||||
REMOTE_reply_signal(LOCAL_share_request) = no_sharing;
|
||||
LOCAL_share_request = MAX_WORKERS;
|
||||
PUT_OUT_REQUESTABLE(worker_id);
|
||||
return TRUE;
|
||||
}
|
||||
/* sharing request accepted */
|
||||
REMOTE_q_fase_signal(worker_q) = Q_idle;
|
||||
REMOTE_p_fase_signal(worker_q) = P_idle;
|
||||
#ifndef TABLING
|
||||
/* wait for incomplete installations */
|
||||
while (LOCAL_reply_signal != ready);
|
||||
#endif /* TABLING */
|
||||
LOCAL_reply_signal = sharing;
|
||||
REMOTE_reply_signal(worker_q) = sharing;
|
||||
share_private_nodes(worker_q);
|
||||
REMOTE_reply_signal(worker_q) = nodes_shared;
|
||||
while (LOCAL_reply_signal == sharing);
|
||||
LOCAL_share_request = MAX_WORKERS;
|
||||
PUT_IN_REQUESTABLE(worker_id);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int q_share_work(int worker_p) {
|
||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
if (REMOTE_prune_request(worker_p)) {
|
||||
/* worker p with prune request */
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
return FALSE;
|
||||
}
|
||||
#ifdef YAPOR_ERRORS
|
||||
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 */
|
||||
BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = BRANCH(worker_p, OrFr_depth(LOCAL_top_or_fr));
|
||||
LOCAL_prune_request = NULL;
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
|
||||
#ifdef OPTYAP_ERRORS
|
||||
if (Get_LOCAL_top_cp() != Get_LOCAL_top_cp_on_stack())
|
||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp != LOCAL_top_cp_on_stack (q_share_work)");
|
||||
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 != ready)
|
||||
YAPOR_ERROR_MESSAGE("LOCAL_reply_signal != ready (q_share_work)");
|
||||
#endif /* YAPOR_ERRORS */
|
||||
|
||||
/* make sharing request */
|
||||
LOCK_WORKER(worker_p);
|
||||
if (BITMAP_member(GLOBAL_bm_idle_workers, worker_p) ||
|
||||
REMOTE_share_request(worker_p) != MAX_WORKERS) {
|
||||
/* worker p is idle or has another request */
|
||||
UNLOCK_WORKER(worker_p);
|
||||
return FALSE;
|
||||
}
|
||||
REMOTE_share_request(worker_p) = worker_id;
|
||||
UNLOCK_WORKER(worker_p);
|
||||
|
||||
/* wait for an answer */
|
||||
while (LOCAL_reply_signal == ready);
|
||||
if (LOCAL_reply_signal == no_sharing) {
|
||||
/* sharing request refused */
|
||||
LOCAL_reply_signal = ready;
|
||||
return FALSE;
|
||||
}
|
||||
while (LOCAL_reply_signal == sharing);
|
||||
|
||||
Yap_CopyThreadStacks(worker_id, worker_p);
|
||||
|
||||
/* update registers and return */
|
||||
#ifndef TABLING
|
||||
REMOTE_reply_signal(worker_p) = ready;
|
||||
#endif /* TABLING */
|
||||
LOCAL_reply_signal = ready;
|
||||
PUT_IN_REQUESTABLE(worker_id);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------- **
|
||||
** Local functions **
|
||||
** ------------------------- */
|
||||
|
||||
static
|
||||
void share_private_nodes(int worker_q) {
|
||||
choiceptr sharing_node = B;
|
||||
|
||||
#ifdef OPTYAP_ERRORS
|
||||
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) (share_private_nodes)");
|
||||
} else {
|
||||
choiceptr aux_cp = B;
|
||||
while (aux_cp != Get_LOCAL_top_cp()) {
|
||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp)) {
|
||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp not in branch (share_private_nodes)");
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endif /* OPTYAP_ERRORS */
|
||||
|
||||
#ifdef TABLING
|
||||
/* check if the branch is already shared */
|
||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), sharing_node)) {
|
||||
or_fr_ptr or_frame;
|
||||
sg_fr_ptr sg_frame;
|
||||
dep_fr_ptr dep_frame;
|
||||
|
||||
#ifdef OPTYAP_ERRORS
|
||||
{ or_fr_ptr aux_or_fr;
|
||||
aux_or_fr = LOCAL_top_or_fr;
|
||||
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_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);
|
||||
}
|
||||
}
|
||||
#endif /* OPTYAP_ERRORS */
|
||||
|
||||
/* update old shared nodes */
|
||||
or_frame = LOCAL_top_or_fr;
|
||||
while (or_frame != REMOTE_top_or_fr(worker_q)) {
|
||||
LOCK_OR_FRAME(or_frame);
|
||||
BRANCH(worker_q, OrFr_depth(or_frame)) = BRANCH(worker_id, OrFr_depth(or_frame));
|
||||
OrFr_owners(or_frame)++;
|
||||
if (BITMAP_member(OrFr_members(or_frame), worker_id))
|
||||
BITMAP_insert(OrFr_members(or_frame), worker_q);
|
||||
UNLOCK_OR_FRAME(or_frame);
|
||||
or_frame = OrFr_next_on_stack(or_frame);
|
||||
}
|
||||
|
||||
/* update worker Q top subgoal frame */
|
||||
sg_frame = LOCAL_top_sg_fr;
|
||||
while (sg_frame && YOUNGER_CP(SgFr_gen_cp(sg_frame), sharing_node)) {
|
||||
sg_frame = SgFr_next(sg_frame);
|
||||
}
|
||||
REMOTE_top_sg_fr(worker_q) = sg_frame;
|
||||
|
||||
/* update worker Q top dependency frame */
|
||||
dep_frame = LOCAL_top_dep_fr;
|
||||
while (YOUNGER_CP(DepFr_cons_cp(dep_frame), sharing_node)) {
|
||||
dep_frame = DepFr_next(dep_frame);
|
||||
}
|
||||
REMOTE_top_dep_fr(worker_q) = dep_frame;
|
||||
|
||||
/* update worker Q top shared nodes */
|
||||
Set_REMOTE_top_cp_on_stack(worker_q, Get_LOCAL_top_cp());
|
||||
Set_REMOTE_top_cp(worker_q, Get_LOCAL_top_cp());
|
||||
REMOTE_top_or_fr(worker_q) = LOCAL_top_or_fr;
|
||||
} else
|
||||
#endif /* TABLING */
|
||||
{
|
||||
int depth;
|
||||
bitmap bm_workers;
|
||||
or_fr_ptr or_frame, previous_or_frame;
|
||||
#ifdef TABLING
|
||||
choiceptr consumer_cp, next_node_on_branch;
|
||||
dep_fr_ptr dep_frame;
|
||||
sg_fr_ptr sg_frame;
|
||||
CELL *stack, *stack_base, *stack_limit;
|
||||
|
||||
/* find top dependency frame above current choice point */
|
||||
dep_frame = LOCAL_top_dep_fr;
|
||||
while (EQUAL_OR_YOUNGER_CP(DepFr_cons_cp(dep_frame), sharing_node)) {
|
||||
dep_frame = DepFr_next(dep_frame);
|
||||
}
|
||||
/* initialize tabling auxiliary variables */
|
||||
consumer_cp = DepFr_cons_cp(dep_frame);
|
||||
next_node_on_branch = NULL;
|
||||
stack_limit = (CELL *)TR;
|
||||
stack_base = stack = (CELL *)Yap_TrailTop;
|
||||
#endif /* TABLING */
|
||||
|
||||
/* initialize auxiliary variables */
|
||||
BITMAP_clear(bm_workers);
|
||||
BITMAP_insert(bm_workers, worker_id);
|
||||
BITMAP_insert(bm_workers, worker_q);
|
||||
previous_or_frame = NULL;
|
||||
depth = OrFr_depth(LOCAL_top_or_fr);
|
||||
|
||||
/* sharing loop */
|
||||
#ifdef TABLING
|
||||
while (YOUNGER_CP(sharing_node, Get_LOCAL_top_cp_on_stack())) {
|
||||
#else
|
||||
while (sharing_node != Get_LOCAL_top_cp()) {
|
||||
#endif /* TABLING */
|
||||
|
||||
#ifdef OPTYAP_ERRORS
|
||||
if (next_node_on_branch) {
|
||||
choiceptr aux_cp = B;
|
||||
while (aux_cp != next_node_on_branch) {
|
||||
if (sharing_node == aux_cp)
|
||||
OPTYAP_ERROR_MESSAGE("sharing_node on branch (share_private_nodes)");
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
choiceptr aux_cp = B;
|
||||
while (aux_cp != sharing_node) {
|
||||
if (YOUNGER_CP(sharing_node, aux_cp)) {
|
||||
OPTYAP_ERROR_MESSAGE("sharing_node not in branch (share_private_nodes)");
|
||||
break;
|
||||
}
|
||||
aux_cp = aux_cp->cp_b;
|
||||
}
|
||||
}
|
||||
#endif /* OPTYAP_ERRORS */
|
||||
|
||||
ALLOC_OR_FRAME(or_frame);
|
||||
if (previous_or_frame) {
|
||||
#ifdef TABLING
|
||||
OrFr_next_on_stack(previous_or_frame) =
|
||||
#endif /* TABLING */
|
||||
OrFr_nearest_livenode(previous_or_frame) = OrFr_next(previous_or_frame) = or_frame;
|
||||
}
|
||||
previous_or_frame = or_frame;
|
||||
depth++;
|
||||
INIT_LOCK(OrFr_lock(or_frame));
|
||||
SetOrFr_node(or_frame, sharing_node);
|
||||
OrFr_alternative(or_frame) = sharing_node->cp_ap;
|
||||
OrFr_pend_prune_cp(or_frame) = NULL;
|
||||
OrFr_nearest_leftnode(or_frame) = LOCAL_top_or_fr;
|
||||
OrFr_qg_solutions(or_frame) = NULL;
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
OrFr_tg_solutions(or_frame) = NULL;
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
#ifdef TABLING
|
||||
OrFr_suspensions(or_frame) = NULL;
|
||||
OrFr_nearest_suspnode(or_frame) = or_frame;
|
||||
OrFr_owners(or_frame) = 2;
|
||||
if (next_node_on_branch)
|
||||
BITMAP_clear(OrFr_members(or_frame));
|
||||
else
|
||||
#endif /* TABLING */
|
||||
OrFr_members(or_frame) = bm_workers;
|
||||
|
||||
#ifdef YAPOR_ERRORS
|
||||
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)) {
|
||||
sharing_node->cp_ap = GETWORK_SEQ;
|
||||
} else {
|
||||
sharing_node->cp_ap = GETWORK;
|
||||
}
|
||||
sharing_node->cp_or_fr = or_frame;
|
||||
sharing_node = sharing_node->cp_b;
|
||||
|
||||
#ifdef TABLING
|
||||
/* when next_node_on_branch is not NULL the **
|
||||
** sharing_node belongs to a frozen branch. */
|
||||
if (YOUNGER_CP(consumer_cp, sharing_node)) {
|
||||
/* frozen stack segment */
|
||||
if (! next_node_on_branch)
|
||||
next_node_on_branch = sharing_node;
|
||||
STACK_PUSH_UP(or_frame, stack);
|
||||
STACK_CHECK_EXPAND1(stack, stack_limit, stack_base);
|
||||
STACK_PUSH(sharing_node, stack);
|
||||
STACK_CHECK_EXPAND1(stack, stack_limit, stack_base);
|
||||
sharing_node = consumer_cp;
|
||||
dep_frame = DepFr_next(dep_frame);
|
||||
consumer_cp = DepFr_cons_cp(dep_frame);
|
||||
} else if (consumer_cp == sharing_node) {
|
||||
dep_frame = DepFr_next(dep_frame);
|
||||
consumer_cp = DepFr_cons_cp(dep_frame);
|
||||
}
|
||||
if (next_node_on_branch == sharing_node)
|
||||
next_node_on_branch = NULL;
|
||||
#endif /* TABLING */
|
||||
#ifdef OPTYAP_ERRORS
|
||||
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 */
|
||||
or_frame = sharing_node->cp_or_fr;
|
||||
if (previous_or_frame) {
|
||||
#ifdef TABLING
|
||||
OrFr_next_on_stack(previous_or_frame) =
|
||||
#endif /* TABLING */
|
||||
OrFr_nearest_livenode(previous_or_frame) = OrFr_next(previous_or_frame) = or_frame;
|
||||
}
|
||||
|
||||
#ifdef TABLING
|
||||
/* update or-frames stored in auxiliary stack */
|
||||
while (STACK_NOT_EMPTY(stack, stack_base)) {
|
||||
next_node_on_branch = (choiceptr) STACK_POP_DOWN(stack);
|
||||
or_frame = (or_fr_ptr) STACK_POP_DOWN(stack);
|
||||
OrFr_nearest_livenode(or_frame) = OrFr_next(or_frame) = next_node_on_branch->cp_or_fr;
|
||||
}
|
||||
#endif /* TABLING */
|
||||
|
||||
/* update depth */
|
||||
if (depth >= MAX_BRANCH_DEPTH)
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "maximum depth exceded (share_private_nodes)");
|
||||
or_frame = B->cp_or_fr;
|
||||
#ifdef TABLING
|
||||
previous_or_frame = Get_LOCAL_top_cp_on_stack()->cp_or_fr;
|
||||
while (or_frame != previous_or_frame) {
|
||||
#else
|
||||
while (or_frame != LOCAL_top_or_fr) {
|
||||
#endif /* TABLING */
|
||||
unsigned int branch;
|
||||
if (OrFr_alternative(or_frame)) {
|
||||
branch = YAMOP_OR_ARG(OrFr_alternative(or_frame)) + 1;
|
||||
} else {
|
||||
branch = 1;
|
||||
}
|
||||
branch |= YAMOP_CUT_FLAG; /* in doubt, assume cut */
|
||||
BRANCH(worker_id, depth) = BRANCH(worker_q, depth) = branch;
|
||||
OrFr_depth(or_frame) = depth--;
|
||||
or_frame = OrFr_next_on_stack(or_frame);
|
||||
}
|
||||
|
||||
#ifdef YAPOR_ERRORS
|
||||
if (depth != OrFr_depth(LOCAL_top_or_fr))
|
||||
YAPOR_ERROR_MESSAGE("incorrect depth value (share_private_nodes)");
|
||||
#endif /* YAPOR_ERRORS */
|
||||
|
||||
#ifdef OPTYAP_ERRORS
|
||||
{ or_fr_ptr aux_or_fr = B->cp_or_fr;
|
||||
choiceptr aux_cp;
|
||||
while (aux_or_fr != Get_LOCAL_top_cp_on_stack()->cp_or_fr) {
|
||||
aux_cp = GetOrFr_node(aux_or_fr);
|
||||
if (OrFr_next(aux_or_fr) != aux_cp->cp_b->cp_or_fr)
|
||||
OPTYAP_ERROR_MESSAGE("OrFr_next not in branch (share_private_nodes)");
|
||||
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 = B->cp_or_fr;
|
||||
while (aux_or_fr != Get_LOCAL_top_cp_on_stack()->cp_or_fr) {
|
||||
or_fr_ptr nearest_leftnode = OrFr_nearest_leftnode(aux_or_fr);
|
||||
aux_cp = GetOrFr_node(aux_or_fr);
|
||||
while (GetOrFr_node(nearest_leftnode) != aux_cp) {
|
||||
if (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_or_fr = OrFr_next_on_stack(aux_or_fr);
|
||||
}
|
||||
}
|
||||
#endif /* OPTYAP_ERRORS */
|
||||
|
||||
/* update old shared nodes */
|
||||
while (or_frame != REMOTE_top_or_fr(worker_q)) {
|
||||
LOCK_OR_FRAME(or_frame);
|
||||
BRANCH(worker_q, OrFr_depth(or_frame)) = BRANCH(worker_id, OrFr_depth(or_frame));
|
||||
#ifdef TABLING
|
||||
OrFr_owners(or_frame)++;
|
||||
if (BITMAP_member(OrFr_members(or_frame), worker_id))
|
||||
#endif /* TABLING */
|
||||
BITMAP_insert(OrFr_members(or_frame), worker_q);
|
||||
UNLOCK_OR_FRAME(or_frame);
|
||||
or_frame = OrFr_next_on_stack(or_frame);
|
||||
}
|
||||
|
||||
#ifdef TABLING
|
||||
/* update subgoal frames in the maintained private branches */
|
||||
sg_frame = LOCAL_top_sg_fr;
|
||||
while (sg_frame && YOUNGER_CP(SgFr_gen_cp(sg_frame), B)) {
|
||||
choiceptr top_cp_on_branch;
|
||||
top_cp_on_branch = SgFr_gen_cp(sg_frame);
|
||||
while (YOUNGER_CP(top_cp_on_branch, B)) {
|
||||
top_cp_on_branch = top_cp_on_branch->cp_b;
|
||||
}
|
||||
SgFr_gen_top_or_fr(sg_frame) = top_cp_on_branch->cp_or_fr;
|
||||
sg_frame = SgFr_next(sg_frame);
|
||||
}
|
||||
/* update worker Q top subgoal frame */
|
||||
REMOTE_top_sg_fr(worker_q) = sg_frame;
|
||||
/* update subgoal frames in the recently shared branches */
|
||||
while (sg_frame && YOUNGER_CP(SgFr_gen_cp(sg_frame), Get_LOCAL_top_cp_on_stack())) {
|
||||
SgFr_gen_worker(sg_frame) = MAX_WORKERS;
|
||||
SgFr_gen_top_or_fr(sg_frame) = SgFr_gen_cp(sg_frame)->cp_or_fr;
|
||||
sg_frame = SgFr_next(sg_frame);
|
||||
}
|
||||
|
||||
/* update dependency frames in the maintained private branches */
|
||||
dep_frame = LOCAL_top_dep_fr;
|
||||
while (YOUNGER_CP(DepFr_cons_cp(dep_frame), B)) {
|
||||
choiceptr top_cp_on_branch;
|
||||
top_cp_on_branch = DepFr_cons_cp(dep_frame);
|
||||
while (YOUNGER_CP(top_cp_on_branch, B)) {
|
||||
top_cp_on_branch = top_cp_on_branch->cp_b;
|
||||
}
|
||||
DepFr_top_or_fr(dep_frame) = top_cp_on_branch->cp_or_fr;
|
||||
dep_frame = DepFr_next(dep_frame);
|
||||
}
|
||||
/* update worker Q top dependency frame */
|
||||
REMOTE_top_dep_fr(worker_q) = dep_frame;
|
||||
/* update dependency frames in the recently shared branches */
|
||||
while (YOUNGER_CP(DepFr_cons_cp(dep_frame), Get_LOCAL_top_cp_on_stack())) {
|
||||
DepFr_top_or_fr(dep_frame) = DepFr_cons_cp(dep_frame)->cp_or_fr;
|
||||
dep_frame = DepFr_next(dep_frame);
|
||||
}
|
||||
#endif /* TABLING */
|
||||
|
||||
#ifdef OPTYAP_ERRORS
|
||||
{ dep_fr_ptr aux_dep_fr = LOCAL_top_dep_fr;
|
||||
while(aux_dep_fr != GLOBAL_root_dep_fr) {
|
||||
choiceptr top_cp_on_branch;
|
||||
top_cp_on_branch = DepFr_cons_cp(aux_dep_fr);
|
||||
while (YOUNGER_CP(top_cp_on_branch, 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_MESSAGE("Error on DepFr_top_or_fr (share_private_nodes)");
|
||||
aux_dep_fr = DepFr_next(aux_dep_fr);
|
||||
}
|
||||
}
|
||||
#endif /* OPTYAP_ERRORS */
|
||||
|
||||
/* update top shared nodes */
|
||||
#ifdef TABLING
|
||||
Set_REMOTE_top_cp_on_stack(worker_q,B);
|
||||
Set_LOCAL_top_cp_on_stack, B);
|
||||
#endif /* TABLING */
|
||||
Set_REMOTE_top_cp(worker_q,B);
|
||||
Set_LOCAL_top_cp(B);
|
||||
REMOTE_top_or_fr(worker_q) = LOCAL_top_or_fr = Get_LOCAL_top_cp()->cp_or_fr;
|
||||
}
|
||||
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
/* update worker Q pruning scope */
|
||||
if (LOCAL_pruning_scope && EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp(), LOCAL_pruning_scope)) {
|
||||
REMOTE_pruning_scope(worker_q) = LOCAL_pruning_scope;
|
||||
PUT_IN_PRUNING(worker_q);
|
||||
} else {
|
||||
PUT_OUT_PRUNING(worker_q);
|
||||
REMOTE_pruning_scope(worker_q) = NULL;
|
||||
}
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
|
||||
/* update worker Q prune request */
|
||||
if (LOCAL_prune_request) {
|
||||
CUT_send_prune_request(worker_q, LOCAL_prune_request);
|
||||
}
|
||||
|
||||
/* update load and return */
|
||||
REMOTE_load(worker_q) = LOCAL_load = 0;
|
||||
return;
|
||||
}
|
||||
#endif /* ENV_COPY */
|
@ -436,7 +436,7 @@
|
||||
if (PARALLEL_EXECUTION_MODE) {
|
||||
choiceptr aux_cp;
|
||||
aux_cp = B;
|
||||
while (YOUNGER_CP(aux_cp, LOCAL_top_cp_on_stack))
|
||||
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
||||
aux_cp = aux_cp->cp_b;
|
||||
if (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)");
|
||||
@ -547,7 +547,7 @@
|
||||
if (PARALLEL_EXECUTION_MODE) {
|
||||
choiceptr aux_cp;
|
||||
aux_cp = B;
|
||||
while (YOUNGER_CP(aux_cp, LOCAL_top_cp_on_stack))
|
||||
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
||||
aux_cp = aux_cp->cp_b;
|
||||
if (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)");
|
||||
@ -658,7 +658,7 @@
|
||||
if (PARALLEL_EXECUTION_MODE) {
|
||||
choiceptr aux_cp;
|
||||
aux_cp = B;
|
||||
while (YOUNGER_CP(aux_cp, LOCAL_top_cp_on_stack))
|
||||
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
||||
aux_cp = aux_cp->cp_b;
|
||||
if (aux_cp->cp_or_fr != DepFr_top_or_fr(LOCAL_top_dep_fr))
|
||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_top_or_fr (table_try)");
|
||||
@ -872,7 +872,7 @@
|
||||
for (i = 0; i < number_workers; i++) {
|
||||
if (BITMAP_member(members, i) &&
|
||||
BRANCH_LTT(i, depth) > ltt &&
|
||||
EQUAL_OR_YOUNGER_CP(LOCAL_top_cp, REMOTE_pruning_scope(i))) {
|
||||
EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp(), REMOTE_pruning_scope(i))) {
|
||||
leftmost_or_fr = LOCAL_top_or_fr;
|
||||
pending_table_new_answer:
|
||||
#if defined(TABLE_LOCK_AT_ENTRY_LEVEL)
|
||||
@ -1153,7 +1153,7 @@
|
||||
end_or_fr = DepFr_top_or_fr(dep_fr);
|
||||
if (start_or_fr != end_or_fr) {
|
||||
LOCAL_top_or_fr = end_or_fr;
|
||||
LOCAL_top_cp = OrFr_node(end_or_fr);
|
||||
Set_LOCAL_top_cp(OrFr_node(end_or_fr));
|
||||
do {
|
||||
while (YOUNGER_CP(OrFr_node(start_or_fr), OrFr_node(end_or_fr))) {
|
||||
LOCK_OR_FRAME(start_or_fr);
|
||||
@ -1201,17 +1201,17 @@
|
||||
#endif /* YAPOR */
|
||||
#ifdef OPTYAP_ERRORS
|
||||
if (PARALLEL_EXECUTION_MODE) {
|
||||
if (YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack)) {
|
||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack) (answer_resolution)");
|
||||
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;
|
||||
aux_cp = chain_cp;
|
||||
while (aux_cp != LOCAL_top_cp) {
|
||||
if (YOUNGER_CP(LOCAL_top_cp, aux_cp)) {
|
||||
while (aux_cp != Get_LOCAL_top_cp()) {
|
||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp)) {
|
||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp not in branch (answer_resolution)");
|
||||
break;
|
||||
}
|
||||
if (EQUAL_OR_YOUNGER_CP(LOCAL_top_cp_on_stack, aux_cp)) {
|
||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp)) {
|
||||
OPTYAP_ERROR_MESSAGE("shared frozen segments in branch (answer_resolution)");
|
||||
break;
|
||||
}
|
||||
@ -1242,12 +1242,12 @@
|
||||
/* no dependency frames with unconsumed answers found */
|
||||
#ifdef YAPOR
|
||||
/* update shared nodes */
|
||||
if (EQUAL_OR_YOUNGER_CP(LOCAL_top_cp_on_stack, chain_cp)) {
|
||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), chain_cp)) {
|
||||
end_or_fr = chain_cp->cp_or_fr;
|
||||
start_or_fr = LOCAL_top_or_fr;
|
||||
if (start_or_fr != end_or_fr) {
|
||||
LOCAL_top_or_fr = end_or_fr;
|
||||
LOCAL_top_cp = OrFr_node(end_or_fr);
|
||||
Set_LOCAL_top_cp(OrFr_node(end_or_fr));
|
||||
while (start_or_fr != end_or_fr) {
|
||||
LOCK_OR_FRAME(start_or_fr);
|
||||
BITMAP_delete(OrFr_members(start_or_fr), worker_id);
|
||||
@ -1287,17 +1287,17 @@
|
||||
#endif /* YAPOR */
|
||||
#ifdef OPTYAP_ERRORS
|
||||
if (PARALLEL_EXECUTION_MODE) {
|
||||
if (YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack)) {
|
||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack) (answer_resolution)");
|
||||
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;
|
||||
aux_cp = chain_cp;
|
||||
while (aux_cp != LOCAL_top_cp) {
|
||||
if (YOUNGER_CP(LOCAL_top_cp, aux_cp)) {
|
||||
while (aux_cp != Get_LOCAL_top_cp()) {
|
||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp)) {
|
||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp not in branch (answer_resolution)");
|
||||
break;
|
||||
}
|
||||
if (EQUAL_OR_YOUNGER_CP(LOCAL_top_cp_on_stack, aux_cp)) {
|
||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp)) {
|
||||
OPTYAP_ERROR_MESSAGE("shared frozen segments in branch (answer_resolution)");
|
||||
break;
|
||||
}
|
||||
@ -1423,12 +1423,12 @@
|
||||
|
||||
#ifdef OPTYAP_ERRORS
|
||||
if (PARALLEL_EXECUTION_MODE) {
|
||||
if (YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack)) {
|
||||
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;
|
||||
aux_cp = DepFr_cons_cp(dep_fr);
|
||||
while (YOUNGER_CP(aux_cp, LOCAL_top_cp_on_stack))
|
||||
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
|
||||
aux_cp = aux_cp->cp_b;
|
||||
if (aux_cp->cp_or_fr != DepFr_top_or_fr(dep_fr))
|
||||
OPTYAP_ERROR_MESSAGE("Error on DepFr_top_or_fr (completion)");
|
||||
@ -1437,7 +1437,7 @@
|
||||
#endif /* OPTYAP_ERRORS */
|
||||
#ifdef YAPOR
|
||||
/* update shared nodes */
|
||||
if (YOUNGER_CP(LOCAL_top_cp_on_stack, LOCAL_top_cp)) {
|
||||
if (YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), Get_LOCAL_top_cp())) {
|
||||
or_fr_ptr or_frame = DepFr_top_or_fr(dep_fr);
|
||||
while (or_frame != LOCAL_top_or_fr) {
|
||||
LOCK_OR_FRAME(or_frame);
|
||||
@ -1447,22 +1447,22 @@
|
||||
or_frame = OrFr_next(or_frame);
|
||||
}
|
||||
LOCAL_top_or_fr = DepFr_top_or_fr(dep_fr);
|
||||
LOCAL_top_cp = OrFr_node(LOCAL_top_or_fr);
|
||||
Set_LOCAL_top_cp(OrFr_node(LOCAL_top_or_fr));
|
||||
}
|
||||
#endif /* YAPOR */
|
||||
#ifdef OPTYAP_ERRORS
|
||||
if (PARALLEL_EXECUTION_MODE) {
|
||||
if (YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack)) {
|
||||
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;
|
||||
aux_cp = DepFr_cons_cp(dep_fr);
|
||||
while (aux_cp != LOCAL_top_cp) {
|
||||
if (YOUNGER_CP(LOCAL_top_cp, aux_cp)) {
|
||||
while (aux_cp != Get_LOCAL_top_cp()) {
|
||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), aux_cp)) {
|
||||
OPTYAP_ERROR_MESSAGE("LOCAL_top_cp not in branch (completion)");
|
||||
break;
|
||||
}
|
||||
if (EQUAL_OR_YOUNGER_CP(LOCAL_top_cp_on_stack, aux_cp)) {
|
||||
if (EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp_on_stack(), aux_cp)) {
|
||||
OPTYAP_ERROR_MESSAGE("shared frozen segments in branch (completion)");
|
||||
break;
|
||||
}
|
||||
@ -1508,7 +1508,7 @@
|
||||
if (YOUNGER_CP(B_FZ, B)) {
|
||||
suspend_branch();
|
||||
/* check for suspension frames to be resumed */
|
||||
while (YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), LOCAL_top_cp)) {
|
||||
while (YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), Get_LOCAL_top_cp())) {
|
||||
or_fr_ptr susp_or_fr;
|
||||
susp_fr_ptr resume_fr;
|
||||
susp_or_fr = LOCAL_top_susp_or_fr;
|
||||
@ -1526,7 +1526,7 @@
|
||||
UNLOCK_OR_FRAME(susp_or_fr);
|
||||
rebind_variables(OrFr_node(susp_or_fr)->cp_tr, B->cp_tr);
|
||||
resume_suspension_frame(resume_fr, susp_or_fr);
|
||||
B = LOCAL_top_cp;
|
||||
B = Get_LOCAL_top_cp();
|
||||
SET_BB(B_FZ);
|
||||
TR = TR_FZ;
|
||||
TRAIL_LINK(B->cp_tr);
|
||||
@ -1542,7 +1542,7 @@
|
||||
if (frame_with_suspensions_not_collected(LOCAL_top_or_fr))
|
||||
collect_suspension_frames(LOCAL_top_or_fr);
|
||||
/* check for suspension frames to be resumed */
|
||||
while (EQUAL_OR_YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), LOCAL_top_cp)) {
|
||||
while (EQUAL_OR_YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), Get_LOCAL_top_cp())) {
|
||||
or_fr_ptr susp_or_fr;
|
||||
susp_fr_ptr resume_fr;
|
||||
susp_or_fr = LOCAL_top_susp_or_fr;
|
||||
@ -1561,7 +1561,7 @@
|
||||
}
|
||||
rebind_variables(OrFr_node(susp_or_fr)->cp_tr, B->cp_tr);
|
||||
resume_suspension_frame(resume_fr, susp_or_fr);
|
||||
B = LOCAL_top_cp;
|
||||
B = Get_LOCAL_top_cp();
|
||||
SET_BB(B_FZ);
|
||||
TR = TR_FZ;
|
||||
TRAIL_LINK(B->cp_tr);
|
||||
@ -1605,12 +1605,12 @@
|
||||
UNLOCK(DepFr_lock(LOCAL_top_dep_fr));
|
||||
if (OrFr_owners(LOCAL_top_or_fr) > 1) {
|
||||
/* more owners -> move up one node */
|
||||
LOCAL_top_cp_on_stack = OrFr_node(OrFr_next_on_stack(LOCAL_top_or_fr));
|
||||
Set_LOCAL_top_cp_on_stack( OrFr_node(OrFr_next_on_stack(LOCAL_top_or_fr)) );
|
||||
BITMAP_delete(OrFr_members(LOCAL_top_or_fr), worker_id);
|
||||
OrFr_owners(LOCAL_top_or_fr)--;
|
||||
LOCAL_top_dep_fr = DepFr_next(LOCAL_top_dep_fr);
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
if (LOCAL_top_sg_fr && LOCAL_top_cp == SgFr_gen_cp(LOCAL_top_sg_fr)) {
|
||||
if (LOCAL_top_sg_fr && Get_LOCAL_top_cp() == SgFr_gen_cp(LOCAL_top_sg_fr)) {
|
||||
LOCAL_top_sg_fr = SgFr_next(LOCAL_top_sg_fr);
|
||||
}
|
||||
SCH_update_local_or_tops();
|
||||
|
@ -181,7 +181,7 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
or_fr_ptr aux_or_fr = SgFr_gen_top_or_fr(SG_FR); \
|
||||
while (! BITMAP_member(OrFr_members(aux_or_fr), worker_id)) \
|
||||
aux_or_fr = OrFr_next(aux_or_fr); \
|
||||
LEADER_CP = OrFr_node(aux_or_fr); \
|
||||
LEADER_CP = GetOrFr_node(aux_or_fr); \
|
||||
DEP_ON_STACK = (LEADER_CP == SgFr_gen_cp(SG_FR)); \
|
||||
}
|
||||
#define find_leader_node(LEADER_CP, DEP_ON_STACK) \
|
||||
@ -634,7 +634,7 @@ void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
||||
static inline
|
||||
void abolish_incomplete_subgoals(choiceptr prune_cp) {
|
||||
#ifdef YAPOR
|
||||
if (EQUAL_OR_YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), prune_cp))
|
||||
if (EQUAL_OR_YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), prune_cp))
|
||||
pruning_over_tabling_data_structures();
|
||||
#endif /* YAPOR */
|
||||
|
||||
@ -848,7 +848,7 @@ susp_fr_ptr suspension_frame_to_resume(or_fr_ptr susp_or_fr) {
|
||||
susp_fr_ptr *susp_ptr, susp_fr;
|
||||
dep_fr_ptr dep_fr;
|
||||
|
||||
top_cp = OrFr_node(susp_or_fr);
|
||||
top_cp = GetOrFr_node(susp_or_fr);
|
||||
susp_ptr = & OrFr_suspensions(susp_or_fr);
|
||||
susp_fr = *susp_ptr;
|
||||
while (susp_fr) {
|
||||
@ -943,7 +943,7 @@ tg_sol_fr_ptr CUT_store_tg_answers(or_fr_ptr or_frame, tg_sol_fr_ptr new_solutio
|
||||
choiceptr node, gen_cp;
|
||||
|
||||
old_solution_ptr = & OrFr_tg_solutions(or_frame);
|
||||
node = OrFr_node(or_frame);
|
||||
node = GetOrFr_node(or_frame);
|
||||
while (new_solution && YOUNGER_CP(node, TgSolFr_gen_cp(new_solution))) {
|
||||
next_new_solution = TgSolFr_next(new_solution);
|
||||
gen_cp = TgSolFr_gen_cp(new_solution);
|
||||
|
@ -40,18 +40,18 @@ void public_completion(void) {
|
||||
susp_fr_ptr susp_fr, next_susp_fr;
|
||||
qg_sol_fr_ptr solutions, aux_solutions;
|
||||
|
||||
if (YOUNGER_CP(LOCAL_top_cp, B_FZ)) {
|
||||
if (YOUNGER_CP(Get_LOCAL_top_cp(), B_FZ)) {
|
||||
/* the current node is a generator node without younger consumer **
|
||||
** nodes --> we only have the current node to complete */
|
||||
sg_fr_ptr top_sg_fr;
|
||||
|
||||
/* complete subgoals */
|
||||
#ifdef DETERMINISTIC_TABLING
|
||||
if (IS_DET_GEN_CP(LOCAL_top_cp))
|
||||
top_sg_fr = SgFr_next(DET_GEN_CP(LOCAL_top_cp)->cp_sg_fr);
|
||||
if (IS_DET_GEN_CP(Get_LOCAL_top_cp()))
|
||||
top_sg_fr = SgFr_next(DET_GEN_CP(Get_LOCAL_top_cp())->cp_sg_fr);
|
||||
else
|
||||
#endif /* DETERMINISTIC_TABLING */
|
||||
top_sg_fr = SgFr_next(GEN_CP(LOCAL_top_cp)->cp_sg_fr);
|
||||
top_sg_fr = SgFr_next(GEN_CP(Get_LOCAL_top_cp())->cp_sg_fr);
|
||||
do {
|
||||
mark_as_completed(LOCAL_top_sg_fr);
|
||||
LOCAL_top_sg_fr = SgFr_next(LOCAL_top_sg_fr);
|
||||
@ -68,13 +68,13 @@ void public_completion(void) {
|
||||
/* complete subgoals */
|
||||
if (DepFr_leader_dep_is_on_stack(LOCAL_top_dep_fr)) {
|
||||
while (LOCAL_top_sg_fr &&
|
||||
EQUAL_OR_YOUNGER_CP(SgFr_gen_cp(LOCAL_top_sg_fr), LOCAL_top_cp)) {
|
||||
EQUAL_OR_YOUNGER_CP(SgFr_gen_cp(LOCAL_top_sg_fr), Get_LOCAL_top_cp())) {
|
||||
mark_as_completed(LOCAL_top_sg_fr);
|
||||
LOCAL_top_sg_fr = SgFr_next(LOCAL_top_sg_fr);
|
||||
}
|
||||
} else {
|
||||
while (LOCAL_top_sg_fr &&
|
||||
YOUNGER_CP(SgFr_gen_cp(LOCAL_top_sg_fr), LOCAL_top_cp)) {
|
||||
YOUNGER_CP(SgFr_gen_cp(LOCAL_top_sg_fr), Get_LOCAL_top_cp())) {
|
||||
mark_as_completed(LOCAL_top_sg_fr);
|
||||
LOCAL_top_sg_fr = SgFr_next(LOCAL_top_sg_fr);
|
||||
}
|
||||
@ -82,7 +82,7 @@ void public_completion(void) {
|
||||
|
||||
/* chain dependency frames to release */
|
||||
chain_dep_fr = NULL;
|
||||
while (YOUNGER_CP(DepFr_cons_cp(LOCAL_top_dep_fr), LOCAL_top_cp)) {
|
||||
while (YOUNGER_CP(DepFr_cons_cp(LOCAL_top_dep_fr), Get_LOCAL_top_cp())) {
|
||||
LOCK(DepFr_lock(LOCAL_top_dep_fr));
|
||||
next_dep_fr = DepFr_next(LOCAL_top_dep_fr);
|
||||
DepFr_next(LOCAL_top_dep_fr) = chain_dep_fr;
|
||||
@ -96,13 +96,13 @@ void public_completion(void) {
|
||||
|
||||
/* chain or-frames to release */
|
||||
chain_or_fr = NULL;
|
||||
top_or_fr = LOCAL_top_cp_on_stack->cp_or_fr;
|
||||
top_or_fr = Get_LOCAL_top_cp_on_stack()->cp_or_fr;
|
||||
while (top_or_fr != LOCAL_top_or_fr) {
|
||||
or_fr_ptr next_or_fr_on_stack;
|
||||
LOCK_OR_FRAME(top_or_fr);
|
||||
susp_fr = OrFr_suspensions(top_or_fr);
|
||||
while (susp_fr) {
|
||||
complete_suspension_branch(susp_fr, OrFr_node(top_or_fr), &chain_or_fr, &chain_dep_fr);
|
||||
complete_suspension_branch(susp_fr, GetOrFr_node(top_or_fr), &chain_or_fr, &chain_dep_fr);
|
||||
next_susp_fr = SuspFr_next(susp_fr);
|
||||
FREE_SUSPENSION_FRAME(susp_fr);
|
||||
susp_fr = next_susp_fr;
|
||||
@ -115,7 +115,7 @@ void public_completion(void) {
|
||||
LOCK_OR_FRAME(top_or_fr);
|
||||
susp_fr = OrFr_suspensions(top_or_fr);
|
||||
while (susp_fr) {
|
||||
complete_suspension_branch(susp_fr, OrFr_node(top_or_fr), &chain_or_fr, &chain_dep_fr);
|
||||
complete_suspension_branch(susp_fr, GetOrFr_node(top_or_fr), &chain_or_fr, &chain_dep_fr);
|
||||
next_susp_fr = SuspFr_next(susp_fr);
|
||||
FREE_SUSPENSION_FRAME(susp_fr);
|
||||
susp_fr = next_susp_fr;
|
||||
@ -151,7 +151,7 @@ void public_completion(void) {
|
||||
}
|
||||
|
||||
/* adjust top register */
|
||||
LOCAL_top_cp_on_stack = LOCAL_top_cp;
|
||||
Set_LOCAL_top_cp_on_stack( Get_LOCAL_top_cp() );
|
||||
|
||||
return;
|
||||
}
|
||||
@ -169,7 +169,7 @@ void complete_suspension_frames(or_fr_ptr or_fr) {
|
||||
susp_fr = OrFr_suspensions(or_fr);
|
||||
do {
|
||||
susp_fr_ptr next_susp_fr;
|
||||
complete_suspension_branch(susp_fr, OrFr_node(or_fr), &chain_or_fr, &chain_dep_fr);
|
||||
complete_suspension_branch(susp_fr, GetOrFr_node(or_fr), &chain_or_fr, &chain_dep_fr);
|
||||
next_susp_fr = SuspFr_next(susp_fr);
|
||||
FREE_SUSPENSION_FRAME(susp_fr);
|
||||
susp_fr = next_susp_fr;
|
||||
@ -216,27 +216,27 @@ void suspend_branch(void) {
|
||||
/* suspension only occurs in shared nodes that **
|
||||
** are leaders with younger consumer nodes */
|
||||
#ifdef OPTYAP_ERRORS
|
||||
if (LOCAL_top_cp->cp_or_fr != LOCAL_top_or_fr)
|
||||
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)");
|
||||
if (B_FZ == LOCAL_top_cp)
|
||||
if (B_FZ == Get_LOCAL_top_cp())
|
||||
OPTYAP_ERROR_MESSAGE("B_FZ = LOCAL_top_cp (suspend_branch)");
|
||||
if (YOUNGER_CP(LOCAL_top_cp, LOCAL_top_cp_on_stack))
|
||||
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 (LOCAL_top_cp->cp_or_fr != LOCAL_top_or_fr)
|
||||
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 = 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) {
|
||||
if (YOUNGER_CP(LOCAL_top_cp, OrFr_node(or_frame))) {
|
||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(LOCAL_top_cp, OrFr_node(or_frame)) (suspend_branch)");
|
||||
if (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);
|
||||
}
|
||||
#endif /* OPTYAP_ERRORS */
|
||||
|
||||
or_frame = LOCAL_top_cp_on_stack->cp_or_fr;
|
||||
or_frame = Get_LOCAL_top_cp_on_stack()->cp_or_fr;
|
||||
LOCK_OR_FRAME(or_frame);
|
||||
if (B_FZ == LOCAL_top_cp_on_stack && OrFr_owners(or_frame) > 1) {
|
||||
if (B_FZ == Get_LOCAL_top_cp_on_stack() && OrFr_owners(or_frame) > 1) {
|
||||
/* there are other workers sharing the whole branch **
|
||||
** --> we can avoid suspension <-- */
|
||||
|
||||
@ -258,11 +258,11 @@ void suspend_branch(void) {
|
||||
UNLOCK_OR_FRAME(or_frame);
|
||||
|
||||
/* alloc suspension frame */
|
||||
h_size = (unsigned long) H_FZ - (unsigned long) LOCAL_top_cp->cp_h;
|
||||
b_size = (unsigned long) LOCAL_top_cp - (unsigned long) B_FZ;
|
||||
tr_size = (unsigned long) TR_FZ - (unsigned long) LOCAL_top_cp->cp_tr;
|
||||
new_suspension_frame(new_susp_fr, LOCAL_top_cp_on_stack->cp_or_fr, LOCAL_top_dep_fr, LOCAL_top_sg_fr,
|
||||
LOCAL_top_cp->cp_h, B_FZ, LOCAL_top_cp->cp_tr, h_size, b_size, tr_size);
|
||||
h_size = (unsigned long) H_FZ - (unsigned long) Get_LOCAL_top_cp()->cp_h;
|
||||
b_size = (unsigned long) Get_LOCAL_top_cp() - (unsigned long) B_FZ;
|
||||
tr_size = (unsigned long) TR_FZ - (unsigned long) Get_LOCAL_top_cp()->cp_tr;
|
||||
new_suspension_frame(new_susp_fr, Get_LOCAL_top_cp_on_stack()->cp_or_fr, LOCAL_top_dep_fr, LOCAL_top_sg_fr,
|
||||
Get_LOCAL_top_cp()->cp_h, B_FZ, Get_LOCAL_top_cp()->cp_tr, h_size, b_size, tr_size);
|
||||
|
||||
/* store suspension frame in current top or-frame */
|
||||
LOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
@ -274,17 +274,17 @@ void suspend_branch(void) {
|
||||
}
|
||||
|
||||
/* adjust top pointers */
|
||||
while (LOCAL_top_sg_fr && YOUNGER_CP(SgFr_gen_cp(LOCAL_top_sg_fr), LOCAL_top_cp_on_stack)) {
|
||||
while (LOCAL_top_sg_fr && YOUNGER_CP(SgFr_gen_cp(LOCAL_top_sg_fr), Get_LOCAL_top_cp_on_stack())) {
|
||||
SgFr_gen_worker(LOCAL_top_sg_fr) = MAX_WORKERS;
|
||||
LOCAL_top_sg_fr = SgFr_next(LOCAL_top_sg_fr);
|
||||
}
|
||||
while (LOCAL_top_sg_fr && YOUNGER_CP(SgFr_gen_cp(LOCAL_top_sg_fr), LOCAL_top_cp)) {
|
||||
while (LOCAL_top_sg_fr && YOUNGER_CP(SgFr_gen_cp(LOCAL_top_sg_fr), Get_LOCAL_top_cp())) {
|
||||
LOCAL_top_sg_fr = SgFr_next(LOCAL_top_sg_fr);
|
||||
}
|
||||
while (YOUNGER_CP(DepFr_cons_cp(LOCAL_top_dep_fr), LOCAL_top_cp)) {
|
||||
while (YOUNGER_CP(DepFr_cons_cp(LOCAL_top_dep_fr), Get_LOCAL_top_cp())) {
|
||||
LOCAL_top_dep_fr = DepFr_next(LOCAL_top_dep_fr);
|
||||
}
|
||||
LOCAL_top_cp_on_stack = LOCAL_top_cp;
|
||||
Set_LOCAL_top_cp_on_stack( Get_LOCAL_top_cp() );
|
||||
|
||||
/* adjust freeze registers */
|
||||
adjust_freeze_registers();
|
||||
@ -315,7 +315,7 @@ void resume_suspension_frame(susp_fr_ptr resume_fr, or_fr_ptr top_or_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 *)LOCAL_top_cp < SuspFr_local_reg(resume_fr) + SuspFr_local_size(resume_fr))
|
||||
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 */
|
||||
|
||||
@ -338,10 +338,10 @@ void resume_suspension_frame(susp_fr_ptr resume_fr, or_fr_ptr top_or_fr) {
|
||||
|
||||
/* adjust top pointers */
|
||||
LOCAL_top_or_fr = top_or_fr;
|
||||
LOCAL_top_cp = OrFr_node(top_or_fr);
|
||||
SetOrFr_node(top_or_fr, Get_LOCAL_top_cp());
|
||||
LOCAL_top_sg_fr = SuspFr_top_sg_fr(resume_fr);
|
||||
LOCAL_top_dep_fr = SuspFr_top_dep_fr(resume_fr);
|
||||
LOCAL_top_cp_on_stack = OrFr_node(SuspFr_top_or_fr_on_stack(resume_fr));
|
||||
Set_LOCAL_top_cp_on_stack( OrFr_node(SuspFr_top_or_fr_on_stack(resume_fr)) );
|
||||
sg_frame = LOCAL_top_sg_fr;
|
||||
while (sg_frame && YOUNGER_CP(SgFr_gen_cp(sg_frame), LOCAL_top_cp_on_stack)) {
|
||||
SgFr_gen_worker(sg_frame) = worker_id;
|
||||
@ -411,14 +411,14 @@ void complete_suspension_branch(susp_fr_ptr susp_fr, choiceptr top_cp, or_fr_ptr
|
||||
susp_fr_ptr aux_susp_fr;
|
||||
or_fr_ptr next_or_fr_on_stack;
|
||||
#ifdef OPTYAP_ERRORS
|
||||
if (YOUNGER_CP(top_cp, OrFr_node(aux_or_fr)))
|
||||
OPTYAP_ERROR_MESSAGE("YOUNGER_CP(top_cp, OrFr_node(aux_or_fr)) (complete_suspension_branch)");
|
||||
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);
|
||||
aux_susp_fr = OrFr_suspensions(aux_or_fr);
|
||||
while (aux_susp_fr) {
|
||||
susp_fr_ptr next_susp_fr;
|
||||
complete_suspension_branch(aux_susp_fr, OrFr_node(aux_or_fr), chain_or_fr, chain_dep_fr);
|
||||
complete_suspension_branch(aux_susp_fr, GetOrFr_node(aux_or_fr), chain_or_fr, chain_dep_fr);
|
||||
next_susp_fr = SuspFr_next(aux_susp_fr);
|
||||
FREE_SUSPENSION_FRAME(aux_susp_fr);
|
||||
aux_susp_fr = next_susp_fr;
|
||||
|
@ -4698,6 +4698,10 @@ letters. The default value is @code{false}.
|
||||
If @code{true}, use @t{portray/1} to portray bound terms. The default
|
||||
value is @code{false}.
|
||||
|
||||
@item portray(+@var{Bool})
|
||||
If @code{true}, use @t{portray/1} to portray bound terms. The default
|
||||
value is @code{false}.
|
||||
|
||||
@item max_depth(+@var{Depth})
|
||||
If @code{Depth} is a positive integer, use @t{Depth} as
|
||||
the maximum depth to portray a term. The default is @code{0}, that is,
|
||||
|
12
pl/boot.yap
12
pl/boot.yap
@ -96,6 +96,7 @@ true :- true.
|
||||
'$startup_reconsult',
|
||||
'$startup_goals',
|
||||
'$set_input'(user_input),'$set_output'(user),
|
||||
'$init_or_threads',
|
||||
'$run_at_thread_start'.
|
||||
|
||||
'$init_consult' :-
|
||||
@ -107,6 +108,17 @@ true :- true.
|
||||
nb_setval('$consulting',false),
|
||||
nb_setval('$included_file',[]).
|
||||
|
||||
'$init_or_threads' :-
|
||||
'$yapor_threads'(W), !,
|
||||
'$start_orp_threads'(W).
|
||||
'$init_or_threads'.
|
||||
|
||||
'$start_orp_threads'(1) :- !.
|
||||
'$start_orp_threads'(W) :-
|
||||
thread_create('$worker',_,[detached(true)]),
|
||||
W1 is W-1,
|
||||
'$start_orp_threads'(W1).
|
||||
|
||||
|
||||
% Start file for yap
|
||||
|
||||
|
@ -948,3 +948,4 @@ threads :-
|
||||
'$mk_tstatus_key'(Id0, Key) :-
|
||||
atomic_concat('$thread_exit_status__',Id0,Key).
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user