Merge branch 'master' of ssh://yap.git.sourceforge.net/gitroot/yap/yap-6.3

Conflicts:
	H/Yap.h
	packages/YapR
This commit is contained in:
Joao 2011-04-14 20:00:35 +01:00
commit 4d537f1536
20 changed files with 179 additions and 103 deletions

View File

@ -1086,7 +1086,7 @@ Yap_absmi(int inp)
}
/* HEY, leave indexing block alone!! */
/* check if we are the ones using this code */
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
PELOCK(1, ap);
PP = ap;
DEC_CLREF_COUNT(cl);
@ -1387,7 +1387,7 @@ Yap_absmi(int inp)
}
/* HEY, leave indexing block alone!! */
/* check if we are the ones using this code */
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
PELOCK(2, ap);
PP = ap;
DEC_CLREF_COUNT(cl);
@ -1480,7 +1480,7 @@ Yap_absmi(int inp)
/* only meaningful with THREADS on! */
/* lock logical updates predicate. */
Op(lock_lu, p);
#if defined(YAPOR) || defined(THREADS)
#if PARALLEL_YAP
if (PP) {
GONext();
}
@ -1508,10 +1508,12 @@ Yap_absmi(int inp)
check_trail(TR);
/* say that an environment is using this clause */
/* we have our own copy for the clause */
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
{
LogUpdClause *cl = PREG->u.L.ClBase;
#if PARALLEL_YAP
PredEntry *ap = cl->ClPred;
#endif
/* always add an extra reference */
INC_CLREF_COUNT(cl);
@ -1581,7 +1583,7 @@ Yap_absmi(int inp)
}
setregs();
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
/* always add an extra reference */
INC_CLREF_COUNT(cl);
TRAIL_CLREF(cl);
@ -1633,7 +1635,7 @@ Yap_absmi(int inp)
/* say that an environment is using this clause */
/* we have our own copy for the clause */
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
/* always add an extra reference */
INC_CLREF_COUNT(cl);
TRAIL_CLREF(cl);
@ -1746,7 +1748,7 @@ Yap_absmi(int inp)
#endif /* YAPOR */
SET_BB(B_YREG);
ENDCACHE_Y();
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
INC_CLREF_COUNT(ClauseCodeToDynamicClause(PREG));
UNLOCK(DynamicLock(PREG));
TRAIL_CLREF(ClauseCodeToDynamicClause(PREG));
@ -1808,7 +1810,7 @@ Yap_absmi(int inp)
#endif /* FROZEN_STACKS */
SET_BB(B_YREG);
ENDCACHE_Y();
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
INC_CLREF_COUNT(ClauseCodeToDynamicClause(PREG));
TRAIL_CLREF(ClauseCodeToDynamicClause(PREG));
UNLOCK(DynamicLock(PREG));
@ -2067,7 +2069,7 @@ Yap_absmi(int inp)
if (IN_BETWEEN(H0,pt1,H) && IsAttVar(pt1))
goto failloop;
flags = *pt1;
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
if (FlagOn(DBClMask, flags)) {
DBRef dbr = DBStructFlagsToDBStruct(pt1);
int erase;
@ -2086,7 +2088,9 @@ Yap_absmi(int inp)
if (flags & IndexMask) {
LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt1);
int erase;
#if PARALLEL_YAP
PredEntry *ap = cl->ClPred;
#endif
PELOCK(8,ap);
DEC_CLREF_COUNT(cl);
@ -2110,7 +2114,9 @@ Yap_absmi(int inp)
} else {
LogUpdClause *cl = ClauseFlagsToLogUpdClause(pt1);
int erase;
#if PARALLEL_YAP
PredEntry *ap = cl->ClPred;
#endif
PELOCK(9,ap);
DEC_CLREF_COUNT(cl);
@ -7926,7 +7932,7 @@ Yap_absmi(int inp)
/* fprintf(stderr,"> %p/%p %d %d\n",cl,ap,ap->TimeStampOfPred,PREG->u.Ills.s);*/
PREG = PREG->u.Ills.l1;
/* indicate the indexing code is being used */
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
/* just store a reference */
INC_CLREF_COUNT(cl);
TRAIL_CLREF(cl);
@ -8032,7 +8038,7 @@ Yap_absmi(int inp)
}
/* HEY, leave indexing block alone!! */
/* check if we are the ones using this code */
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
DEC_CLREF_COUNT(cl);
/* clear the entry from the trail */
B->cp_tr--;

View File

@ -3052,7 +3052,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
}
cl_u->luc.ClExt = NULL;
cl_u->luc.ClPrev = cl_u->luc.ClNext = NULL;
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
//INIT_LOCK(cl_u->luc.ClLock);
INIT_CLREF_COUNT(&(cl_u->luc));
#endif
@ -3071,6 +3071,8 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
cl_u->ic.ClRefCount = 0;
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(cl_u->ic.ClLock);
#endif
#ifdef MULTIPLE_STACKS
INIT_CLREF_COUNT(&(cl_u->ic));
#endif
}
@ -3122,7 +3124,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
cl_u->lui.ClSize = size;
cl_u->lui.ClRefCount = 0;
// INIT_LOCK(cl_u->lui.ClLock);
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
INIT_CLREF_COUNT(&(cl_u->lui));
#endif
}

View File

@ -392,7 +392,7 @@ AccessNamedArray(Atom a, Int indx USES_REGS)
if (TRef != 0L) {
DBRef ref = DBRefOfTerm(TRef);
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
LOCK(ref->lock);
INC_DBREF_COUNT(ref);
TRAIL_REF(ref); /* So that fail will erase it */
@ -2305,17 +2305,17 @@ p_static_array_to_term( USES_REGS1 )
if (TRef != 0L) {
DBRef ref = DBRefOfTerm(TRef);
#if defined(YAPOR) || defined(THREADS)
LOCK(ref->lock);
#if MULTIPLE_STACKS
INC_DBREF_COUNT(ref);
TRAIL_REF(ref); /* So that fail will erase it */
UNLOCK(ref->lock);
#else
if (!(ref->Flags & InUseMask)) {
ref->Flags |= InUseMask;
TRAIL_REF(ref); /* So that fail will erase it */
}
#endif
UNLOCK(ref->lock);
} else {
TRef = TermNil;
}

View File

@ -1451,12 +1451,12 @@ Yap_kill_iblock(ClauseUnion *blk, ClauseUnion *parent_blk, PredEntry *ap)
LogUpdIndex *c = (LogUpdIndex *)blk;
if (parent_blk != NULL) {
LogUpdIndex *cl = (LogUpdIndex *)parent_blk;
#if defined(THREADS) || defined(YAPOR)
#if MULTIPLE_STACKS
/* protect against attempts at erasing */
cl->ClRefCount++;
#endif
kill_first_log_iblock(c, cl, ap);
#if defined(THREADS) || defined(YAPOR)
#if MULTIPLE_STACKS
cl->ClRefCount--;
#endif
} else {
@ -1501,12 +1501,12 @@ Yap_ErLogUpdIndex(LogUpdIndex *clau)
if (clau->ClFlags & SwitchRootMask) {
kill_first_log_iblock(clau, NULL, clau->ClPred);
} else {
#if defined(THREADS) || defined(YAPOR)
#if MULTIPLE_STACKS
/* protect against attempts at erasing */
clau->ClRefCount++;
#endif
kill_first_log_iblock(clau, clau->ParentIndex, clau->ClPred);
#if defined(THREADS) || defined(YAPOR)
#if MULTIPLE_STACKS
/* protect against attempts at erasing */
clau->ClRefCount--;
#endif
@ -2274,7 +2274,7 @@ addclause(Term t, yamop *cp, int mode, Term mod, Term *t4ref)
if (pflags & LogUpdatePredFlag) {
LogUpdClause *cl = (LogUpdClause *)ClauseCodeToLogUpdClause(cp);
tf = MkDBRefTerm((DBRef)cl);
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
TRAIL_CLREF(cl); /* So that fail will erase it */
INC_CLREF_COUNT(cl);
#else
@ -4428,7 +4428,7 @@ fetch_next_lu_clause(PredEntry *pe, yamop *i_code, Term th, Term tb, Term tr, ya
return FALSE;
}
rtn = MkDBRefTerm((DBRef)cl);
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
TRAIL_CLREF(cl); /* So that fail will erase it */
INC_CLREF_COUNT(cl);
#else
@ -4575,7 +4575,7 @@ fetch_next_lu_clause_erase(PredEntry *pe, yamop *i_code, Term th, Term tb, Term
return FALSE;
}
rtn = MkDBRefTerm((DBRef)cl);
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
TRAIL_CLREF(cl); /* So that fail will erase it */
INC_CLREF_COUNT(cl);
#else
@ -5071,7 +5071,7 @@ p_nth_clause( USES_REGS1 )
return FALSE;
}
if (pe->PredFlags & LogUpdatePredFlag) {
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
TRAIL_CLREF(cl); /* So that fail will erase it */
INC_CLREF_COUNT(cl);
#else

View File

@ -113,7 +113,7 @@ typedef struct idb_queue
{
Functor id; /* identify this as being pointed to by a DBRef */
SMALLUNSGN Flags; /* always required */
#if defined(YAPOR) || defined(THREADS)
#if PARALLEL_YAP
rwlock_t QRWLock; /* a simple lock to protect this entry */
#endif
QueueEntry *FirstInQueue, *LastInQueue;
@ -1670,7 +1670,7 @@ record(int Flag, Term key, Term t_data, Term t_code USES_REGS)
else
x->Flags |= DBNoCode;
x->Parent = p;
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
x->Flags |= DBClMask;
x->ref_count = 1;
#else
@ -1742,7 +1742,7 @@ record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS)
else
x->Flags |= DBNoCode;
x->Parent = p;
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
x->Flags |= DBClMask;
x->ref_count = 1;
#else
@ -1806,7 +1806,7 @@ new_lu_db_entry(Term t, PredEntry *pe)
struct db_globs dbg;
int d_flag = 0;
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
/* we cannot allow sharing between threads (for now) */
if (!(pe->PredFlags & ThreadLocalPredFlag))
d_flag |= InQueue;
@ -1838,7 +1838,7 @@ new_lu_db_entry(Term t, PredEntry *pe)
cl->ClTimeStart = 0L;
}
cl->ClTimeEnd = TIMESTAMP_EOT;
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
// INIT_LOCK(cl->ClLock);
INIT_CLREF_COUNT(cl);
ipc->opc = Yap_opcode(_copy_idb_term);
@ -1960,7 +1960,7 @@ p_rcda( USES_REGS1 )
cl = record_lu(pe, Deref(ARG2), MkFirst);
if (cl != NULL) {
TRAIL_CLREF(cl);
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
INC_CLREF_COUNT(cl);
#else
cl->ClFlags |= InUseMask;
@ -2070,7 +2070,7 @@ p_rcdz( USES_REGS1 )
cl = record_lu(pe, t2, MkLast);
if (cl != NULL) {
TRAIL_CLREF(cl);
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
INC_CLREF_COUNT(cl);
#else
cl->ClFlags |= InUseMask;
@ -2917,7 +2917,7 @@ lu_nth_recorded(PredEntry *pe, Int Count USES_REGS)
cl = Yap_NthClause(pe, Count);
if (cl == NULL)
return FALSE;
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
PELOCK(65,pe);
TRAIL_CLREF(cl); /* So that fail will erase it */
INC_CLREF_COUNT(cl);
@ -2959,7 +2959,7 @@ nth_recorded(DBProp AtProp, Int Count USES_REGS)
return FALSE;
}
}
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
LOCK(ref->lock);
READ_UNLOCK(AtProp->DBRWLock);
TRAIL_REF(ref); /* So that fail will erase it */
@ -3276,7 +3276,7 @@ i_recorded(DBProp AtProp, Term t3 USES_REGS)
/* This should be after any non-tagged terms, because the routines in grow.c
go from upper to lower addresses */
TRef = MkDBRefTerm(ref);
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
LOCK(ref->lock);
TRAIL_REF(ref); /* So that fail will erase it */
INC_DBREF_COUNT(ref);
@ -3421,7 +3421,7 @@ c_recorded(int flags USES_REGS)
READ_UNLOCK(ref0->Parent->DBRWLock);
TRef = MkDBRefTerm(ref);
EXTRA_CBACK_ARG(3,1) = (CELL)ref;
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
LOCK(ref->lock);
TRAIL_REF(ref); /* So that fail will erase it */
INC_DBREF_COUNT(ref);
@ -3664,17 +3664,17 @@ p_first_instance( USES_REGS1 )
}
TRef = MkDBRefTerm(ref);
/* we have a pointer to the term available */
#if defined(YAPOR) || defined(THREADS)
LOCK(ref->lock);
#if MULTIPLE_STACKS
TRAIL_REF(ref); /* So that fail will erase it */
INC_DBREF_COUNT(ref);
UNLOCK(ref->lock);
#else
if (!(ref->Flags & InUseMask)) {
ref->Flags |= InUseMask;
TRAIL_REF(ref); /* So that fail will erase it */
}
#endif
UNLOCK(ref->lock);
while ((TermDB = GetDBTermFromDBEntry(ref PASS_REGS)) == (CELL)0) {
/* oops, we are in trouble, not enough stack space */
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
@ -3942,7 +3942,7 @@ RemoveDBEntry(DBRef entryref USES_REGS)
|| B->cp_ap == RETRY_C_RECORDEDP_CODE) &&
EXTRA_CBACK_ARG(3,1) == (CELL)entryref) {
/* make it clear the entry has been released */
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
DEC_DBREF_COUNT(entryref);
#else
entryref->Flags &= ~InUseMask;
@ -3993,7 +3993,7 @@ find_next_clause(DBRef ref0 USES_REGS)
newp = ref->Code;
/* and next let's tell the world this clause is being used, just
like if we were executing a standard retry_and_mark */
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
{
DynamicClause *cl = ClauseCodeToDynamicClause(newp);
@ -4805,7 +4805,7 @@ Yap_LUInstance(LogUpdClause *cl, UInt arity)
}
}
}
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
cl->ClRefCount++;
TRAIL_CLREF(cl); /* So that fail will erase it */
#else
@ -5427,17 +5427,17 @@ p_fetch_reference_from_index( USES_REGS1 )
return FALSE;
pos = IntOfTerm(t2);
el = (DBRef)(table->DBT.Contents[pos]);
#if defined(YAPOR) || defined(THREADS)
LOCK(el->lock);
#if MULTIPLE_STACKS
TRAIL_REF(el); /* So that fail will erase it */
INC_DBREF_COUNT(el);
UNLOCK(el->lock);
#else
if (!(el->Flags & InUseMask)) {
el->Flags |= InUseMask;
TRAIL_REF(el);
}
#endif
UNLOCK(el->lock);
return Yap_unify(ARG3, MkDBRefTerm(el));
}

View File

@ -1024,7 +1024,7 @@ p_nb_linkval( USES_REGS1 )
static Int
p_nb_create_accumulator(void)
p_nb_create_accumulator( USES_REGS1 )
{
Term t = Deref(ARG1), acct, to;
CELL *destp;
@ -1041,7 +1041,7 @@ p_nb_create_accumulator(void)
if (!Yap_unify(ARG2, acct)) {
return FALSE;
}
to = CopyTermToArena(t, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
to = CopyTermToArena(t, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
if (to == 0L)
return FALSE;
destp = RepAppl(Deref(ARG2));
@ -1050,7 +1050,7 @@ p_nb_create_accumulator(void)
}
static Int
p_nb_add_to_accumulator(void)
p_nb_add_to_accumulator( USES_REGS1 )
{
Term t = Deref(ARG1), t0, tadd;
Functor f;
@ -1091,7 +1091,7 @@ p_nb_add_to_accumulator(void)
target[1] = source[1];
} else {
/* we need to create a new long int */
new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
destp = RepAppl(Deref(ARG1));
destp[1] = new;
}
@ -1118,7 +1118,7 @@ p_nb_add_to_accumulator(void)
new = Yap_MkApplTerm(FunctorPlus, 2, t2);
new = Yap_Eval(new);
new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena)));
new = CopyTermToArena(new, GlobalArena, TRUE, TRUE, 2, &GlobalArena, garena_overflow_size(ArenaPt(GlobalArena) PASS_REGS) PASS_REGS);
destp = RepAppl(Deref(ARG1));
destp[1] = new;
@ -1129,7 +1129,7 @@ p_nb_add_to_accumulator(void)
static Int
p_nb_accumulator_value(void)
p_nb_accumulator_value( USES_REGS1 )
{
Term t = Deref(ARG1), to;
Functor f;

View File

@ -214,7 +214,7 @@ MoveLocalAndTrail( USES_REGS1 )
#endif
}
#ifdef THREADS
#ifdef YAPOR_THREADS
static void
CopyLocalAndTrail( USES_REGS1 )
@ -401,14 +401,14 @@ AdjustTrail(int adjusting_heap, int thread_copying USES_REGS)
{
volatile tr_fr_ptr ptt, tr_base = (tr_fr_ptr)Yap_TrailBase;
#if defined(YAPOR) && defined(THREADS)
#if defined(YAPOR_THREADS)
if (thread_copying == STACK_INCREMENTAL_COPYING) {
ptt = (tr_fr_ptr)(LOCAL_end_trail_copy);
tr_base = (tr_fr_ptr)(LOCAL_start_trail_copy);
} else {
#endif
ptt = TR;
#if defined(YAPOR) && defined(THREADS)
#if defined(YAPOR_THREADS)
}
#endif
/* moving the trail is simple */
@ -462,7 +462,7 @@ AdjustLocal(int thread_copying USES_REGS)
register CELL reg, *pt, *pt_bot;
/* Adjusting the local */
#if defined(YAPOR) && defined(THREADS)
#if defined(YAPOR_THREADS)
if (thread_copying == STACK_INCREMENTAL_COPYING) {
pt = (CELL *) (LOCAL_end_local_copy);
pt_bot = (CELL *) (LOCAL_start_local_copy);
@ -470,7 +470,7 @@ AdjustLocal(int thread_copying USES_REGS)
#endif
pt = LCL0;
pt_bot = ASP;
#if defined(YAPOR) && defined(THREADS)
#if defined(YAPOR_THREADS)
}
#endif
while (pt > pt_bot) {
@ -551,7 +551,7 @@ AdjustGlobal(long sz, int thread_copying USES_REGS)
* to clean the global now that functors are just variables pointing to
* the code
*/
#if defined(YAPOR) && defined(THREADS)
#if defined(YAPOR_THREADS)
if (thread_copying == STACK_INCREMENTAL_COPYING) {
pt = (CELL *) (LOCAL_start_global_copy);
pt_max = (CELL *) (LOCAL_end_global_copy);
@ -559,7 +559,7 @@ AdjustGlobal(long sz, int thread_copying USES_REGS)
#endif
pt = H0;
pt_max = (H-sz/CellSize);
#if defined(YAPOR) && defined(THREADS)
#if defined(YAPOR_THREADS)
}
#endif
pt = H0;
@ -790,7 +790,7 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
gc_verbose = Yap_is_gc_verbose();
heap_overflows++;
if (gc_verbose) {
#if defined(YAPOR) || defined(THREADS)
#if defined(YAPOR_THREADS)
fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(Yap_stderr, "%% Database Overflow %d\n", heap_overflows);
@ -936,7 +936,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
vb_msg1 = 'D';
vb_msg2 = "Delay";
}
#if defined(YAPOR) || defined(THREADS)
#if defined(YAPOR_THREADS)
fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(Yap_stderr, "%% %cO %s Overflow %d\n", vb_msg1, vb_msg2, delay_overflows);
@ -1357,7 +1357,7 @@ growatomtable( USES_REGS1 )
}
atom_table_overflows++;
if (gc_verbose) {
#if defined(YAPOR) || defined(THREADS)
#if defined(YAPOR_THREADS)
fprintf(Yap_stderr, "%% Worker Id %d:\n", worker_id);
#endif
fprintf(Yap_stderr, "%% Atom Table Overflow %d\n", atom_table_overflows);
@ -1441,7 +1441,7 @@ Yap_growglobal(CELL **ptr)
CACHE_REGS
unsigned long sz = sizeof(CELL) * K16;
#if defined(YAPOR) && !defined(THREADS)
#if defined(YAPOR_THREADS)
if (Yap_number_workers != 1) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
return(FALSE);
@ -1837,7 +1837,7 @@ p_inform_heap_overflows( USES_REGS1 )
return(Yap_unify(tn, ARG1) && Yap_unify(tt, ARG2));
}
#if defined(THREADS) && defined(YAPOR)
#if defined(YAPOR_THREADS)
void
Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
{

View File

@ -839,6 +839,7 @@ sort_group(GroupDef *grp, CELL *top, struct intermediates *cint)
base = top;
while (top+2*max > (CELL *)Yap_TrailTop) {
if (!Yap_growtrail(2*max*CellSize, TRUE)) {
Yap_Error_Size = 2*max*CellSize;
save_machine_regs();
siglongjmp(cint->CompilerBotch,4);
return;
@ -2066,6 +2067,7 @@ groups_in(ClauseDef *min, ClauseDef *max, GroupDef *grp, struct intermediates *c
siglongjmp(cint->CompilerBotch,4);
#else
if (!Yap_growtrail(sz, TRUE)) {
Yap_Error_Size = sz;
save_machine_regs();
siglongjmp(cint->CompilerBotch,4);
return 0;
@ -2188,12 +2190,14 @@ emit_type_switch(compiler_vm_op op, struct intermediates *cint)
static yamop *
emit_switch_space(UInt n, UInt item_size, struct intermediates *cint, CELL func_mask)
{
CACHE_REGS
PredEntry *ap = cint->CurrentPred;
if (ap->PredFlags & LogUpdatePredFlag) {
UInt sz = sizeof(LogUpdIndex)+n*item_size;
LogUpdIndex *cl = (LogUpdIndex *)Yap_AllocCodeSpace(sz);
if (cl == NULL) {
Yap_Error_Size = sz;
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,2);
@ -2214,6 +2218,7 @@ emit_switch_space(UInt n, UInt item_size, struct intermediates *cint, CELL func_
UInt sz = sizeof(StaticIndex)+n*item_size;
StaticIndex *cl = (StaticIndex *)Yap_AllocCodeSpace(sz);
if (cl == NULL) {
Yap_Error_Size = sz;
/* grow stack */
save_machine_regs();
siglongjmp(cint->CompilerBotch,2);
@ -5214,7 +5219,7 @@ kill_clause(yamop *ipc, yamop *bg, yamop *lt, path_stack_entry *sp0, PredEntry *
return sp;
} else {
if (
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
blk->ClRefCount == 0
#else
!(blk->ClFlags & InUseMask)
@ -6817,7 +6822,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
}
*--ASP = MkIntegerTerm(ap->TimeStampOfPred);
/* indicate the indexing code is being used */
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
/* just store a reference */
INC_CLREF_COUNT(cl);
TRAIL_CLREF(cl);
@ -6879,7 +6884,7 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
} else {
newpc = ipc->u.OtILl.d;
}
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
B->cp_tr--;
TR--;
DEC_CLREF_COUNT(cl);

View File

@ -163,6 +163,10 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
LOCK(Yap_heap_regs->low_level_trace_lock);
sc = Yap_heap_regs;
vsc_count++;
if (vsc_count < 45000LL)
return;
if (vsc_count == 47456LL)
jmp_deb(1);
#ifdef THREADS
MY_ThreadHandle.thread_inst_count++;
#endif

View File

@ -146,7 +146,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
f = (Functor)(*ap2);
if (IsExtensionFunctor(f)) {
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
if (f == FunctorDBRef) {
DBRef entryref = DBRefOfTerm(d0);
if (entryref->Flags & LogUpdMask) {

18
H/Yap.h
View File

@ -20,17 +20,17 @@
#error Do not explicitly define YAPOR
#endif /* YAPOR */
#if (defined(YAPOR_COPY) && (defined(YAPOR_COW) || defined(YAPOR_SBA))) || (defined(YAPOR_COW) && defined(YAPOR_SBA))
#if (defined(YAPOR_COPY) && (defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_THREADS))) || (defined(YAPOR_COW) && (defined(YAPOR_SBA) || defined(YAPOR_THREADS))) || (defined(YAPOR_SBA) && defined(YAPOR_THREADS))
#error Do not define multiple or-parallel models
#endif /* (YAPOR_COPY && (YAPOR_COW || YAPOR_SBA)) || (YAPOR_COW && YAPOR_SBA) */
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(THREADS)
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_THREADS)
#define YAPOR 1
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */
#if defined(TABLING) && (defined(YAPOR_COW) || defined(YAPOR_SBA))
#if defined(TABLING) && (defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_THREADS))
#error Currently TABLING only works with YAPOR_COPY
#endif /* TABLING && (YAPOR_COW || YAPOR_SBA) */
#endif /* TABLING && (YAPOR_COW || YAPOR_SBA || YAPOR_THREADS) */
#include "config.h"
#if defined(YAPOR) || defined(TABLING) || defined(THREADS)
@ -60,6 +60,14 @@
#endif
#endif /* YAPOR */
#if defined(YAPOR) || defined(THREADS) || defined(TABLING)
#define MULTIPLE_STACKS 1
#endif
#if defined(YAPOR) || defined(THREADS)
#define PARALLEL_YAP 1
#endif
#if defined(YAPOR) || defined(TABLING)
#undef TRAILING_REQUIRES_BRANCH
#endif /* YAPOR || TABLING */
@ -76,7 +84,7 @@
#endif
#endif
#if defined(SUPPORT_THREADS) || defined(SUPPORT_CONDOR)
#if defined(THREADS) || defined(SUPPORT_CONDOR)
#define USE_SYSTEM_MALLOC 1
#endif

View File

@ -863,6 +863,8 @@ typedef struct DB_STRUCT
CELL Flags; /* Term Flags */
#if defined(YAPOR) || defined(THREADS)
lockvar lock; /* a simple lock to protect this entry */
#endif
#if MULTIPLE_STACKS
Int ref_count; /* how many branches are using this entry */
#endif
CELL NOfRefsTo; /* Number of references pointing here */
@ -880,7 +882,7 @@ typedef struct DB_STRUCT
#define DBStructFlagsToDBStruct(X) ((DBRef)((char *)(X) - (CELL) &(((DBRef) NULL)->Flags)))
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STAACKS
#define INIT_DBREF_COUNT(X) (X)->ref_count = 0
#define INC_DBREF_COUNT(X) (X)->ref_count++
#define DEC_DBREF_COUNT(X) (X)->ref_count--

View File

@ -267,9 +267,15 @@ Binding Macros for Multiple Assignment Variables.
#define REF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->Flags)))
#define CLREF_TO_TRENTRY(REF) AbsPair(((CELL *)&((REF)->ClFlags)))
#if FROZEN_STACKS
#define TRAIL_REF(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = REF_TO_TRENTRY(REF)
#define TRAIL_CLREF(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = CLREF_TO_TRENTRY(REF)
#define TRAIL_LINK(REF) RESET_VARIABLE(&TrailVal(TR)), TrailTerm(TR++) = AbsPair((CELL *)(REF))
#else
#define TRAIL_REF(REF) TrailTerm(TR++) = REF_TO_TRENTRY(REF)
#define TRAIL_CLREF(REF) TrailTerm(TR++) = CLREF_TO_TRENTRY(REF)
#define TRAIL_LINK(REF) TrailTerm(TR++) = AbsPair((CELL *)(REF))
#endif
#define TRAIL_FRAME(FR) DO_TRAIL(AbsPair((CELL *)(Yap_TrailBase)), FR)
extern void Yap_WakeUp(CELL *v);

View File

@ -182,7 +182,7 @@ typedef struct dbterm_list {
#define DynamicLock(X) (ClauseCodeToDynamicClause(X)->ClLock)
#if defined(YAPOR) || defined(THREADS)
#if MULTIPLE_STACKS
#define INIT_CLREF_COUNT(X) (X)->ClRefCount = 0
#define INC_CLREF_COUNT(X) (X)->ClRefCount++
#define DEC_CLREF_COUNT(X) (X)->ClRefCount--

View File

@ -83,7 +83,7 @@
int size;
pt0++;
size = TR - pt0;
memcpy(pbase, pt0, size * sizeof(struct trail_frame));
memmove(pbase, pt0, size * sizeof(struct trail_frame));
TR = pbase + size;
}
}

View File

@ -48,7 +48,6 @@
#undef HOST_ALIAS
#undef SUPPORT_CONDOR
#undef SUPPORT_THREADS
#undef USE_PTHREAD_LOCKING
#undef HAVE_SYS_WAIT_H

53
configure vendored
View File

@ -1425,7 +1425,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-tabling support tabling
--enable-or-parallelism support or-parallelism as: env-copy,sba,a-cow
--enable-or-parallelism support or-parallelism as: copy,sba,a-cow,threads
--enable-rational-trees support infinite rational trees
--enable-coroutining support co-routining, attributed variables and constraints
--enable-depth-limit support depth-bound computation
@ -5962,8 +5962,6 @@ fi
if test "$threads" = yes
then
$as_echo "#define SUPPORT_THREADS 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5
$as_echo_n "checking for pthread_create in -lpthread... " >&6; }
if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then :
@ -7488,19 +7486,46 @@ if test "$threads" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -D_GNU_SOURCE"
fi
case "$orparallelism" in
sba)
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "--or-parallelism=sba incompatible with threads
;;
a-cow
See \`config.log' for more details" "$LINENO" 5 ; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "--or-parallelism=a-cow incompatible with threads
;;
copy
See \`config.log' for more details" "$LINENO" 5 ; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "--or-parallelism=copy incompatible with threads
;;
yes|threads
See \`config.log' for more details" "$LINENO" 5 ; }
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_THREADS=1"
;;
esac
else
case "$orparallelism" in
sba)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_SBA=1"
;;
a-cow)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_COW=1"
;;
threads)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_THREADS=1"
;;
yes|copy)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_COPY=1"
;;
esac
fi
case "$orparallelism" in
sba)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_SBA=1"
;;
a-cow)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_COW=1"
;;
yes|env-copy)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_COPY=1"
;;
esac
if test "$cutc" = "yes"
then

View File

@ -60,7 +60,7 @@ AC_ARG_ENABLE(tabling,
[ --enable-tabling support tabling ],
tabling="$enableval", tabling=no)
AC_ARG_ENABLE(or-parallelism,
[ --enable-or-parallelism support or-parallelism as: env-copy,sba,a-cow ],
[ --enable-or-parallelism support or-parallelism as: copy,sba,a-cow,threads ],
orparallelism="$enableval", orparallelism=no)
AC_ARG_ENABLE(rational-trees,
[ --enable-rational-trees support infinite rational trees ],
@ -733,7 +733,6 @@ fi
if test "$threads" = yes
then
AC_DEFINE(SUPPORT_THREADS, 1)
AC_CHECK_LIB(pthread,pthread_create)
AC_CHECK_HEADERS(pthread.h)
AC_CHECK_FUNCS(pthread_mutexattr_setkind_np pthread_mutexattr_settype)
@ -1271,20 +1270,41 @@ if test "$threads" = "yes"
if test "$GCC" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -D_GNU_SOURCE"
fi
fi
case "$orparallelism" in
sba)
AC_MSG_FAILURE(
[--or-parallelism=sba incompatible with threads]
;;
a-cow)
AC_MSG_FAILURE(
[--or-parallelism=a-cow incompatible with threads]
;;
copy)
AC_MSG_FAILURE(
[--or-parallelism=copy incompatible with threads]
;;
yes|threads)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_THREADS=1"
;;
esac
else
case "$orparallelism" in
sba)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_SBA=1"
;;
a-cow)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_COW=1"
;;
threads)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_THREADS=1"
;;
yes|copy)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_COPY=1"
;;
esac
fi
case "$orparallelism" in
sba)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_SBA=1"
;;
a-cow)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_COW=1"
;;
yes|env-copy)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_COPY=1"
;;
esac
if test "$cutc" = "yes"
then

View File

@ -149,7 +149,7 @@ struct PL_local_data *Yap_ld_ PL_local_data_p =Yap_InitThreadIO(wid)
struct open_query_struct* _execution execution =NULL
// Ricardo's stuff
#if (defined(YAPOR) || defined(TABLING)) && defined(THREADS)
#if MULTIPLE_STACKS
struct worker worker WORKER void
#endif

@ -1 +0,0 @@
Subproject commit c9d945820be9d1a9d6bc3e216721668f6b311feb