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

This commit is contained in:
Vitor Santos Costa 2011-05-11 09:29:43 +01:00
commit 31679df9ce
34 changed files with 701 additions and 711 deletions

View File

@ -7711,14 +7711,14 @@ Yap_absmi(int inp)
{
PredEntry *pt0;
#ifdef THREADS
LOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
#endif
pt0 = SpyCode;
P_before_spy = PREG;
PREG = pt0->CodeOfPred;
/* for profiler */
#ifdef THREADS
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
#endif
save_pc();
CACHE_A1();

View File

@ -384,7 +384,7 @@ clean_atom_list(AtomHashEntry *HashPtr)
AtomEntry *at = RepAtom(atm);
if (AtomResetMark(at) ||
at->PropsOfAE != NIL ||
(Yap_AGCHook != NULL && !Yap_AGCHook(atm))) {
(GLOBAL_AGCHook != NULL && !GLOBAL_AGCHook(atm))) {
patm = &(at->NextOfAE);
atm = at->NextOfAE;
} else {
@ -463,7 +463,6 @@ atom_gc(USES_REGS1)
mark_stacks(PASS_REGS1);
restore_codes();
clean_atoms();
Yap_AGcLastCall = NOfAtoms;
YAPLeaveCriticalSection();
agc_time = Yap_cputime()-time_start;
tot_agc_time += agc_time;
@ -511,7 +510,7 @@ p_agc_threshold(USES_REGS1)
{
Term t = Deref(ARG1);
if (IsVarTerm(t)) {
return Yap_unify(ARG1, MkIntegerTerm(Yap_AGcThreshold));
return Yap_unify(ARG1, MkIntegerTerm(GLOBAL_AGcThreshold));
} else if (!IsIntegerTerm(t)) {
Yap_Error(TYPE_ERROR_INTEGER,t,"prolog_flag/2 agc_margin");
return FALSE;
@ -521,7 +520,7 @@ p_agc_threshold(USES_REGS1)
Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO,t,"prolog_flag/2 agc_margin");
return FALSE;
} else {
Yap_AGcThreshold = i;
GLOBAL_AGcThreshold = i;
return TRUE;
}
}

View File

@ -703,8 +703,8 @@ AllocHeap(unsigned long int size)
UNLOCK(HeapTopLock);
Yap_signal(YAP_CDOVF_SIGNAL);
} else {
if (size > Yap_SizeOfOverflow)
Yap_SizeOfOverflow = size*sizeof(CELL) + sizeof(YAP_SEG_SIZE);
if (size > GLOBAL_SizeOfOverflow)
GLOBAL_SizeOfOverflow = size*sizeof(CELL) + sizeof(YAP_SEG_SIZE);
/* big allocations, the caller must handle the problem */
UNLOCK(HeapUsedLock);
UNLOCK(HeapTopLock);

View File

@ -2781,9 +2781,9 @@ YAP_Init(YAP_init_args *yap_init)
LOCAL_ThreadHandle.ssize = Trail+Stack;
#endif
#endif
Yap_AllowGlobalExpansion = TRUE;
Yap_AllowLocalExpansion = TRUE;
Yap_AllowTrailExpansion = TRUE;
GLOBAL_AllowGlobalExpansion = TRUE;
GLOBAL_AllowLocalExpansion = TRUE;
GLOBAL_AllowTrailExpansion = TRUE;
Yap_InitExStacks (Trail, Stack);
if (yap_init->QuietMode) {
yap_flags[QUIET_MODE_FLAG] = TRUE;
@ -2849,19 +2849,19 @@ YAP_Init(YAP_init_args *yap_init)
}
/* make sure we do this after restore */
if (yap_init->MaxStackSize) {
Yap_AllowLocalExpansion = FALSE;
GLOBAL_AllowLocalExpansion = FALSE;
} else {
Yap_AllowLocalExpansion = TRUE;
GLOBAL_AllowLocalExpansion = TRUE;
}
if (yap_init->MaxGlobalSize) {
Yap_AllowGlobalExpansion = FALSE;
GLOBAL_AllowGlobalExpansion = FALSE;
} else {
Yap_AllowGlobalExpansion = TRUE;
GLOBAL_AllowGlobalExpansion = TRUE;
}
if (yap_init->MaxTrailSize) {
Yap_AllowTrailExpansion = FALSE;
GLOBAL_AllowTrailExpansion = FALSE;
} else {
Yap_AllowTrailExpansion = TRUE;
GLOBAL_AllowTrailExpansion = TRUE;
}
if (yap_init->YapPrologRCFile) {
Yap_PutValue(AtomConsultOnBoot, MkAtomTerm(Yap_LookupAtom(yap_init->YapPrologRCFile)));
@ -3029,7 +3029,7 @@ YAP_Reset(void)
}
/* reinitialise the engine */
Yap_InitYaamRegs();
Yap_Initialised = TRUE;
GLOBAL_Initialised = TRUE;
RECOVER_MACHINE_REGS();
return(TRUE);
@ -3290,8 +3290,8 @@ YAP_AtomReleaseHold(Atom at)
X_API Agc_hook
YAP_AGCRegisterHook(Agc_hook hook)
{
Agc_hook old = Yap_AGCHook;
Yap_AGCHook = hook;
Agc_hook old = GLOBAL_AGCHook;
GLOBAL_AGCHook = hook;
return old;
}
@ -3527,9 +3527,9 @@ YAP_SetYAPFlag(yap_flag_t flag, int val)
return TRUE;
case YAPC_ENABLE_AGC:
if (val) {
Yap_AGcThreshold = 10000;
GLOBAL_AGcThreshold = 10000;
} else {
Yap_AGcThreshold = 0;
GLOBAL_AGcThreshold = 0;
}
return TRUE;
default:

View File

@ -212,8 +212,8 @@ yapsbrk(long size)
UNLOCK(HeapTopLock);
Yap_signal(YAP_CDOVF_SIGNAL);
} else {
if (size > Yap_SizeOfOverflow)
Yap_SizeOfOverflow = size;
if (size > GLOBAL_SizeOfOverflow)
GLOBAL_SizeOfOverflow = size;
/* big allocations, the caller must handle the problem */
UNLOCK(HeapUsedLock);
UNLOCK(HeapTopLock);

View File

@ -903,12 +903,12 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
Yap_PrologMode |= GrowStackMode;
start_growth_time = Yap_cputime();
if (do_grow) {
if (!Yap_AllowGlobalExpansion) {
if (!GLOBAL_AllowGlobalExpansion) {
Yap_ErrorMessage = "Global Stack crashed against Local Stack";
LeaveGrowMode(GrowStackMode);
return 0;
}
if (!Yap_AllowGlobalExpansion || !Yap_ExtendWorkSpace(size)) {
if (!GLOBAL_AllowGlobalExpansion || !Yap_ExtendWorkSpace(size)) {
/* always fails when using malloc */
Yap_ErrorMessage = NULL;
size += AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+MinHeapGap);
@ -1256,10 +1256,10 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol
Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running");
return FALSE;
#endif
if (Yap_SizeOfOverflow > sz) {
if (GLOBAL_SizeOfOverflow > sz) {
if (size < YAP_ALLOC_SIZE)
size = YAP_ALLOC_SIZE;
sz = AdjustPageSize(Yap_SizeOfOverflow);
sz = AdjustPageSize(GLOBAL_SizeOfOverflow);
}
while(sz >= sizeof(CELL) * K16 && !static_growheap(sz, fix_code, cip, old_trp, tksp, vep PASS_REGS)) {
size = size/2;
@ -1401,7 +1401,7 @@ Yap_growheap(int fix_code, UInt in_size, void *cip)
if (NOfAtoms > 2*AtomHashTableSize) {
UInt n = NOfAtoms;
if (Yap_AGcThreshold)
if (GLOBAL_AGcThreshold)
Yap_atom_gc( PASS_REGS1 );
/* check if we have a significant improvement from agc */
if (n > NOfAtoms+ NOfAtoms/10 ||
@ -1442,12 +1442,12 @@ Yap_growglobal(CELL **ptr)
unsigned long sz = sizeof(CELL) * K16;
#if defined(YAPOR_THREADS)
if (Yap_number_workers != 1) {
if (GLOBAL_number_workers != 1) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
return(FALSE);
}
#elif defined(THREADS)
if (Yap_NOfThreads != 1) {
if (GLOBAL_NOfThreads != 1) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running");
return(FALSE);
}
@ -1493,7 +1493,7 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
long size = size0;
ADDR old_Yap_GlobalBase = Yap_GlobalBase;
if (!Yap_AllowGlobalExpansion) {
if (!GLOBAL_AllowGlobalExpansion) {
Yap_ErrorMessage = "Database crashed against stacks";
return FALSE;
}
@ -1703,7 +1703,7 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
fprintf(Yap_stderr, "%% growing the trail %ld bytes\n", size);
}
Yap_ErrorMessage = NULL;
if (!Yap_AllowTrailExpansion) {
if (!GLOBAL_AllowTrailExpansion) {
Yap_ErrorMessage = "Trail Overflow";
return FALSE;
}

View File

@ -1176,7 +1176,7 @@ void init_yapor_workers(void) {
return;
#endif /* YAPOR_THREADS */
#ifdef YAPOR_COW
if (Yap_number_workers > 1) {
if (GLOBAL_number_workers > 1) {
int son;
son = fork();
if (son == -1)
@ -1185,7 +1185,7 @@ void init_yapor_workers(void) {
/* I am the father, I must stay here and wait for my children to all die */
struct sigaction sigact;
Yap_master_worker = getpid();
GLOBAL_master_worker = getpid();
sigact.sa_handler = SIG_DFL;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_RESTART;
@ -1193,10 +1193,10 @@ void init_yapor_workers(void) {
pause();
exit(0);
} else
Yap_worker_pid(0) = getpid();
GLOBAL_worker_pid(0) = getpid();
}
#endif /* YAPOR_COW */
for (proc = 1; proc < Yap_number_workers; proc++) {
for (proc = 1; proc < GLOBAL_number_workers; proc++) {
int son;
son = fork();
if (son == -1)
@ -1209,7 +1209,7 @@ void init_yapor_workers(void) {
InitWorker(worker_id);
break;
} else
Yap_worker_pid(proc) = son;
GLOBAL_worker_pid(proc) = son;
}
}
#endif /* YAPOR */
@ -1447,17 +1447,17 @@ Yap_HaltRegisterHook (HaltHookFunc f, void * env)
return FALSE;
h->environment = env;
h->hook = f;
LOCK(Yap_BGL);
h->next = Yap_HaltHooks;
Yap_HaltHooks = h;
UNLOCK(Yap_BGL);
LOCK(GLOBAL_BGL);
h->next = GLOBAL_HaltHooks;
GLOBAL_HaltHooks = h;
UNLOCK(GLOBAL_BGL);
return TRUE;
}
static void
run_halt_hooks(int code)
{
struct halt_hook *hooke = Yap_HaltHooks;
struct halt_hook *hooke = GLOBAL_HaltHooks;
while (hooke) {
hooke->hook(code, hooke->environment);

View File

@ -616,14 +616,14 @@ p_save2( USES_REGS1 )
Term t;
#ifdef YAPOR
if (Yap_number_workers != 1) {
if (GLOBAL_number_workers != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,
"cannot perform save: more than a worker/thread running");
return(FALSE);
}
#endif /* YAPOR */
#ifdef THREADS
if (Yap_NOfThreads != 1) {
if (GLOBAL_NOfThreads != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,
"cannot perform save: more than a worker/thread running");
return(FALSE);
@ -1796,13 +1796,13 @@ p_restore( USES_REGS1 )
Term t1 = Deref(ARG1);
#ifdef YAPOR
if (Yap_number_workers != 1) {
if (GLOBAL_number_workers != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
return(FALSE);
}
#endif /* YAPOR */
#ifdef THREADS
if (Yap_NOfThreads != 1) {
if (GLOBAL_NOfThreads != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
return(FALSE);
}

View File

@ -3832,49 +3832,49 @@ p_set_yap_flags( USES_REGS1 )
#ifdef TABLING
case TABLING_MODE_FLAG:
if (value == 0) { /* default */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
TabEnt_mode(tab_ent) = TabEnt_flags(tab_ent);
tab_ent = TabEnt_next(tab_ent);
}
yap_flags[TABLING_MODE_FLAG] = 0;
} else if (value == 1) { /* batched */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_Batched(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_Batched(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 2) { /* local */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_Local(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_Local(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 3) { /* exec_answers */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_ExecAnswers(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_ExecAnswers(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 4) { /* load_answers */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_LoadAnswers(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_LoadAnswers(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 5) { /* local_trie */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_LocalTrie(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
}
SetMode_LocalTrie(yap_flags[TABLING_MODE_FLAG]);
} else if (value == 6) { /* global_trie */
tab_ent_ptr tab_ent = Yap_root_tab_ent;
tab_ent_ptr tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
SetMode_GlobalTrie(TabEnt_mode(tab_ent));
tab_ent = TabEnt_next(tab_ent);
@ -3913,14 +3913,14 @@ p_system_mode( USES_REGS1 )
static Int
p_lock_system( USES_REGS1 )
{
LOCK(Yap_BGL);
LOCK(GLOBAL_BGL);
return TRUE;
}
static Int
p_unlock_system( USES_REGS1 )
{
UNLOCK(Yap_BGL);
UNLOCK(GLOBAL_BGL);
return TRUE;
}

View File

@ -50,7 +50,7 @@ static int
allocate_new_tid(void)
{
int new_worker_id = 0;
LOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
while(new_worker_id < MAX_THREADS &&
Yap_local[new_worker_id] &&
(REMOTE_ThreadHandle(new_worker_id).in_use == TRUE ||
@ -72,7 +72,7 @@ allocate_new_tid(void)
} else {
new_worker_id = -1;
}
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
return new_worker_id;
}
@ -146,7 +146,7 @@ kill_thread_engine (int wid, int always_die)
free(REMOTE_ThreadHandle(wid).start_of_timesp);
free(REMOTE_ThreadHandle(wid).last_timep);
Yap_FreeCodeSpace((ADDR)REMOTE_ThreadHandle(wid).texit);
LOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
if (REMOTE_ThreadHandle(wid).tdetach == MkAtomTerm(AtomTrue) ||
always_die) {
REMOTE_ThreadHandle(wid).zombie = FALSE;
@ -154,7 +154,7 @@ kill_thread_engine (int wid, int always_die)
DEBUG_TLOCK_ACCESS(1, wid);
pthread_mutex_unlock(&(REMOTE_ThreadHandle(wid).tlock));
}
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
}
static void
@ -162,7 +162,7 @@ thread_die(int wid, int always_die)
{
if (!always_die) {
/* called by thread itself */
Yap_ThreadsTotalTime += Yap_cputime();
GLOBAL_ThreadsTotalTime += Yap_cputime();
}
kill_thread_engine(wid, always_die);
}
@ -188,7 +188,7 @@ setup_engine(int myworker_id, int init_thread)
Yap_InitYaamRegs();
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
/* I exist */
Yap_NOfThreadsCreated++;
GLOBAL_NOfThreadsCreated++;
DEBUG_TLOCK_ACCESS(2, myworker_id);
pthread_mutex_unlock(&(REMOTE_ThreadHandle(myworker_id).tlock));
}
@ -481,17 +481,17 @@ p_thread_join( USES_REGS1 )
{
Int tid = IntegerOfTerm(Deref(ARG1));
LOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
if (!REMOTE_ThreadHandle(tid).in_use &&
!REMOTE_ThreadHandle(tid).zombie) {
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
return FALSE;
}
if (!REMOTE_ThreadHandle(tid).tdetach == MkAtomTerm(AtomTrue)) {
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
return FALSE;
}
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
/* make sure this lock is accessible */
if (pthread_join(REMOTE_ThreadHandle(tid).pthread_handle, NULL) < 0) {
/* ERROR */
@ -506,12 +506,12 @@ p_thread_destroy( USES_REGS1 )
{
Int tid = IntegerOfTerm(Deref(ARG1));
LOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
REMOTE_ThreadHandle(tid).zombie = FALSE;
REMOTE_ThreadHandle(tid).in_use = FALSE;
DEBUG_TLOCK_ACCESS(32, tid);
pthread_mutex_unlock(&(REMOTE_ThreadHandle(tid).tlock));
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
return TRUE;
}
@ -747,16 +747,16 @@ p_thread_stacks( USES_REGS1 )
Int tid = IntegerOfTerm(Deref(ARG1));
Int status= TRUE;
LOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
if (!REMOTE_ThreadHandle(tid).in_use &&
!REMOTE_ThreadHandle(tid).zombie) {
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
return FALSE;
}
status &= Yap_unify(ARG2,MkIntegerTerm(REMOTE_ThreadHandle(tid).ssize));
status &= Yap_unify(ARG3,MkIntegerTerm(REMOTE_ThreadHandle(tid).tsize));
status &= Yap_unify(ARG4,MkIntegerTerm(REMOTE_ThreadHandle(tid).sysize));
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
return status;
}
@ -828,13 +828,13 @@ static Int
p_nof_threads( USES_REGS1 )
{ /* '$nof_threads'(+P) */
int i = 0, wid;
LOCK(Yap_ThreadHandlesLock);
LOCK(GLOBAL_ThreadHandlesLock);
for (wid = 0; wid < MAX_THREADS; wid++) {
if (!Yap_local[wid]) break;
if (REMOTE_ThreadHandle(wid).in_use)
i++;
}
UNLOCK(Yap_ThreadHandlesLock);
UNLOCK(GLOBAL_ThreadHandlesLock);
return Yap_unify(ARG1,MkIntegerTerm(i));
}
@ -853,13 +853,13 @@ p_max_threads( USES_REGS1 )
static Int
p_nof_threads_created( USES_REGS1 )
{ /* '$nof_threads'(+P) */
return Yap_unify(ARG1,MkIntTerm(Yap_NOfThreadsCreated));
return Yap_unify(ARG1,MkIntTerm(GLOBAL_NOfThreadsCreated));
}
static Int
p_thread_runtime( USES_REGS1 )
{ /* '$thread_runtime'(+P) */
return Yap_unify(ARG1,MkIntegerTerm(Yap_ThreadsTotalTime));
return Yap_unify(ARG1,MkIntegerTerm(GLOBAL_ThreadsTotalTime));
}
static Int

10
H/Yap.h
View File

@ -1208,9 +1208,9 @@ extern int Yap_PrologShouldHandleInterrupts;
#ifdef YAPOR
#define YAPEnterCriticalSection() \
{ \
if (worker_id != Yap_locks_who_locked_heap) { \
LOCK(Yap_locks_heap_access); \
Yap_locks_who_locked_heap = worker_id; \
if (worker_id != GLOBAL_locks_who_locked_heap) { \
LOCK(GLOBAL_locks_heap_access); \
GLOBAL_locks_who_locked_heap = worker_id; \
} \
Yap_PrologMode |= CritMode; \
Yap_CritLocks++; \
@ -1228,8 +1228,8 @@ extern int Yap_PrologShouldHandleInterrupts;
Yap_PrologMode &= ~AbortMode; \
Yap_Error(PURE_ABORT, 0, ""); \
} \
Yap_locks_who_locked_heap = MAX_WORKERS; \
UNLOCK(Yap_locks_heap_access); \
GLOBAL_locks_who_locked_heap = MAX_WORKERS; \
UNLOCK(GLOBAL_locks_heap_access); \
} \
}
#elif defined(THREADS)

View File

@ -21,39 +21,37 @@
#define Yap_Initialised Yap_global->initialised
#define Yap_InitialisedFromPL Yap_global->initialised_from_pl
#define Yap_PL_Argc Yap_global->pl_argc
#define Yap_PL_Argv Yap_global->pl_argv
#define GLOBAL_Initialised Yap_global->initialised
#define GLOBAL_InitialisedFromPL Yap_global->initialised_from_pl
#define GLOBAL_PL_Argc Yap_global->pl_argc
#define GLOBAL_PL_Argv Yap_global->pl_argv
#define Yap_HaltHooks Yap_global->yap_halt_hook
#define GLOBAL_HaltHooks Yap_global->yap_halt_hook
#define Yap_AllowLocalExpansion Yap_global->allow_local_expansion
#define Yap_AllowGlobalExpansion Yap_global->allow_global_expansion
#define Yap_AllowTrailExpansion Yap_global->allow_trail_expansion
#define Yap_SizeOfOverflow Yap_global->size_of_overflow
#define GLOBAL_AllowLocalExpansion Yap_global->allow_local_expansion
#define GLOBAL_AllowGlobalExpansion Yap_global->allow_global_expansion
#define GLOBAL_AllowTrailExpansion Yap_global->allow_trail_expansion
#define GLOBAL_SizeOfOverflow Yap_global->size_of_overflow
#define Yap_AGcLastCall Yap_global->agc_last_call
#define Yap_AGcThreshold Yap_global->agc_threshold
#define Yap_AGCHook Yap_global->agc_hook
#define GLOBAL_AGcThreshold Yap_global->agc_threshold
#define GLOBAL_AGCHook Yap_global->agc_hook
#if THREADS
#define Yap_NOfThreads Yap_global->n_of_threads
#define GLOBAL_NOfThreads Yap_global->n_of_threads
#define Yap_NOfThreadsCreated Yap_global->n_of_threads_created
#define GLOBAL_NOfThreadsCreated Yap_global->n_of_threads_created
#define Yap_ThreadsTotalTime Yap_global->threads_total_time
#define GLOBAL_ThreadsTotalTime Yap_global->threads_total_time
#endif
#if defined(YAPOR) || defined(THREADS)
#define Yap_BGL Yap_global->bgl
#define GLOBAL_BGL Yap_global->bgl
#endif
#ifdef THREADS
#define Yap_ThreadHandlesLock Yap_global->thread_handles_lock
#define GLOBAL_ThreadHandlesLock Yap_global->thread_handles_lock
#endif
#if defined(YAPOR) || defined(TABLING)
#define Yap_optyap_data Yap_global->optyap_data

View File

@ -33,8 +33,6 @@ typedef struct global_data {
int allow_trail_expansion;
UInt size_of_overflow;
UInt agc_last_call;
UInt agc_threshold;
Agc_hook agc_hook;

View File

@ -21,39 +21,37 @@
static void InitGlobal(void) {
Yap_Initialised = FALSE;
Yap_InitialisedFromPL = FALSE;
Yap_PL_Argc = 0;
Yap_PL_Argv = NULL;
GLOBAL_Initialised = FALSE;
GLOBAL_InitialisedFromPL = FALSE;
GLOBAL_PL_Argc = 0;
GLOBAL_PL_Argv = NULL;
Yap_HaltHooks = NULL;
GLOBAL_HaltHooks = NULL;
Yap_AllowLocalExpansion = TRUE;
Yap_AllowGlobalExpansion = TRUE;
Yap_AllowTrailExpansion = TRUE;
Yap_SizeOfOverflow = 0;
GLOBAL_AllowLocalExpansion = TRUE;
GLOBAL_AllowGlobalExpansion = TRUE;
GLOBAL_AllowTrailExpansion = TRUE;
GLOBAL_SizeOfOverflow = 0;
Yap_AGcLastCall = 0;
Yap_AGcThreshold = 10000;
Yap_AGCHook = NULL;
GLOBAL_AGcThreshold = 10000;
GLOBAL_AGCHook = NULL;
#if THREADS
Yap_NOfThreads = 1;
GLOBAL_NOfThreads = 1;
Yap_NOfThreadsCreated = 1;
GLOBAL_NOfThreadsCreated = 1;
Yap_ThreadsTotalTime = 0L;
GLOBAL_ThreadsTotalTime = 0L;
#endif
#if defined(YAPOR) || defined(THREADS)
INIT_LOCK(Yap_BGL);
INIT_LOCK(GLOBAL_BGL);
#endif
#ifdef THREADS
INIT_LOCK(Yap_ThreadHandlesLock);
INIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(TABLING)

View File

@ -36,8 +36,6 @@ static void RestoreGlobal(void) {
#if THREADS
@ -49,11 +47,11 @@ static void RestoreGlobal(void) {
#if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(Yap_BGL);
REINIT_LOCK(GLOBAL_BGL);
#endif
#ifdef THREADS
REINIT_LOCK(Yap_ThreadHandlesLock);
REINIT_LOCK(GLOBAL_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(TABLING)

View File

@ -65,94 +65,94 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop
/* global data related to memory management */
#ifdef LIMIT_TABLING
if (max_table_size)
Yap_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) * SHMMAX / Yap_page_size;
GLOBAL_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) * SHMMAX / Yap_page_size;
else
Yap_max_pages = -1;
GLOBAL_max_pages = -1;
#endif /* LIMIT_TABLING */
INIT_PAGES(Yap_pages_void, void *);
INIT_PAGES(GLOBAL_pages_void, void *);
#ifdef YAPOR
INIT_PAGES(Yap_pages_or_fr , struct or_frame);
INIT_PAGES(Yap_pages_qg_sol_fr , struct query_goal_solution_frame);
INIT_PAGES(Yap_pages_qg_ans_fr, struct query_goal_answer_frame);
INIT_PAGES(GLOBAL_pages_or_fr , struct or_frame);
INIT_PAGES(GLOBAL_pages_qg_sol_fr , struct query_goal_solution_frame);
INIT_PAGES(GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame);
#endif /* YAPOR */
#ifdef TABLING_INNER_CUTS
INIT_PAGES(Yap_pages_tg_sol_fr, struct table_subgoal_solution_frame);
INIT_PAGES(Yap_pages_tg_ans_fr, struct table_subgoal_answer_frame);
INIT_PAGES(GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame);
INIT_PAGES(GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame);
#endif /* TABLING_INNER_CUTS */
#ifdef TABLING
INIT_PAGES(Yap_pages_tab_ent, struct table_entry);
INIT_PAGES(Yap_pages_sg_fr, struct subgoal_frame);
INIT_PAGES(Yap_pages_dep_fr, struct dependency_frame);
INIT_PAGES(Yap_pages_sg_node, struct subgoal_trie_node);
INIT_PAGES(Yap_pages_ans_node, struct answer_trie_node);
INIT_PAGES(Yap_pages_gt_node, struct global_trie_node);
INIT_PAGES(Yap_pages_sg_hash, struct subgoal_trie_hash);
INIT_PAGES(Yap_pages_ans_hash, struct answer_trie_hash);
INIT_PAGES(Yap_pages_gt_hash, struct global_trie_hash);
INIT_PAGES(GLOBAL_pages_tab_ent, struct table_entry);
INIT_PAGES(GLOBAL_pages_sg_fr, struct subgoal_frame);
INIT_PAGES(GLOBAL_pages_dep_fr, struct dependency_frame);
INIT_PAGES(GLOBAL_pages_sg_node, struct subgoal_trie_node);
INIT_PAGES(GLOBAL_pages_ans_node, struct answer_trie_node);
INIT_PAGES(GLOBAL_pages_gt_node, struct global_trie_node);
INIT_PAGES(GLOBAL_pages_sg_hash, struct subgoal_trie_hash);
INIT_PAGES(GLOBAL_pages_ans_hash, struct answer_trie_hash);
INIT_PAGES(GLOBAL_pages_gt_hash, struct global_trie_hash);
#endif /* TABLING */
#if defined(YAPOR) && defined(TABLING)
INIT_PAGES(Yap_pages_susp_fr, struct suspension_frame);
INIT_PAGES(GLOBAL_pages_susp_fr, struct suspension_frame);
#endif /* YAPOR && TABLING */
#ifdef YAPOR
/* global static data */
Yap_number_workers= n_workers;
Yap_worker_pid(0) = getpid();
for (i = 1; i < Yap_number_workers; i++) Yap_worker_pid(i) = 0;
Yap_scheduler_loop = sch_loop;
Yap_delayed_release_load = delay_load;
GLOBAL_number_workers= n_workers;
GLOBAL_worker_pid(0) = getpid();
for (i = 1; i < GLOBAL_number_workers; i++) GLOBAL_worker_pid(i) = 0;
GLOBAL_scheduler_loop = sch_loop;
GLOBAL_delayed_release_load = delay_load;
/* global data related to or-performance */
Yap_number_goals = 0;
Yap_best_times(0) = 0;
Yap_performance_mode = PERFORMANCE_OFF;
GLOBAL_number_goals = 0;
GLOBAL_best_times(0) = 0;
GLOBAL_performance_mode = PERFORMANCE_OFF;
/* global data related to or-parallelism */
ALLOC_OR_FRAME(Yap_root_or_fr);
BITMAP_clear(Yap_bm_present_workers);
for (i = 0; i < Yap_number_workers; i++)
BITMAP_insert(Yap_bm_present_workers, i);
BITMAP_copy(Yap_bm_idle_workers, Yap_bm_present_workers);
BITMAP_clear(Yap_bm_root_cp_workers);
BITMAP_clear(Yap_bm_invisible_workers);
BITMAP_clear(Yap_bm_requestable_workers);
BITMAP_clear(Yap_bm_executing_workers);
BITMAP_copy(Yap_bm_finished_workers, Yap_bm_present_workers);
INIT_LOCK(Yap_locks_bm_idle_workers);
INIT_LOCK(Yap_locks_bm_root_cp_workers);
INIT_LOCK(Yap_locks_bm_invisible_workers);
INIT_LOCK(Yap_locks_bm_requestable_workers);
INIT_LOCK(Yap_locks_bm_executing_workers);
INIT_LOCK(Yap_locks_bm_finished_workers);
ALLOC_OR_FRAME(GLOBAL_root_or_fr);
BITMAP_clear(GLOBAL_bm_present_workers);
for (i = 0; i < GLOBAL_number_workers; i++)
BITMAP_insert(GLOBAL_bm_present_workers, i);
BITMAP_copy(GLOBAL_bm_idle_workers, GLOBAL_bm_present_workers);
BITMAP_clear(GLOBAL_bm_root_cp_workers);
BITMAP_clear(GLOBAL_bm_invisible_workers);
BITMAP_clear(GLOBAL_bm_requestable_workers);
BITMAP_clear(GLOBAL_bm_executing_workers);
BITMAP_copy(GLOBAL_bm_finished_workers, GLOBAL_bm_present_workers);
INIT_LOCK(GLOBAL_locks_bm_idle_workers);
INIT_LOCK(GLOBAL_locks_bm_root_cp_workers);
INIT_LOCK(GLOBAL_locks_bm_invisible_workers);
INIT_LOCK(GLOBAL_locks_bm_requestable_workers);
INIT_LOCK(GLOBAL_locks_bm_executing_workers);
INIT_LOCK(GLOBAL_locks_bm_finished_workers);
#ifdef TABLING_INNER_CUTS
INIT_LOCK(Yap_locks_bm_pruning_workers);
INIT_LOCK(GLOBAL_locks_bm_pruning_workers);
#endif /* TABLING_INNER_CUTS */
Yap_locks_who_locked_heap = MAX_WORKERS;
INIT_LOCK(Yap_locks_heap_access);
INIT_LOCK(Yap_locks_alloc_block);
if (Yap_number_workers== 1)
Yap_parallel_execution_mode = FALSE;
GLOBAL_locks_who_locked_heap = MAX_WORKERS;
INIT_LOCK(GLOBAL_locks_heap_access);
INIT_LOCK(GLOBAL_locks_alloc_block);
if (GLOBAL_number_workers== 1)
GLOBAL_parallel_execution_mode = FALSE;
else
Yap_parallel_execution_mode = TRUE;
GLOBAL_parallel_execution_mode = TRUE;
#endif /* YAPOR */
#ifdef TABLING
/* global data related to tabling */
new_global_trie_node(Yap_root_gt, 0, NULL, NULL, NULL);
Yap_root_tab_ent = NULL;
new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
GLOBAL_root_tab_ent = NULL;
#ifdef LIMIT_TABLING
Yap_first_sg_fr = NULL;
Yap_last_sg_fr = NULL;
Yap_check_sg_fr = NULL;
GLOBAL_first_sg_fr = NULL;
GLOBAL_last_sg_fr = NULL;
GLOBAL_check_sg_fr = NULL;
#endif /* LIMIT_TABLING */
new_dependency_frame(Yap_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, NULL);
new_dependency_frame(GLOBAL_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, NULL);
for (i = 0; i < MAX_TABLE_VARS; i++) {
CELL *pt = Yap_table_var_enumerator_addr(i);
CELL *pt = GLOBAL_table_var_enumerator_addr(i);
RESET_VARIABLE(pt);
}
#ifdef TABLE_LOCK_AT_WRITE_LEVEL
for (i = 0; i < TABLE_LOCK_BUCKETS; i++)
INIT_LOCK(Yap_table_lock(i));
INIT_LOCK(GLOBAL_table_lock(i));
#endif /* TABLE_LOCK_AT_WRITE_LEVEL */
#endif /* TABLING */
@ -165,7 +165,7 @@ void Yap_init_local_optyap_data(int wid) {
CACHE_REGS
/* local data related to or-parallelism */
Set_REMOTE_top_cp(wid, (choiceptr) Yap_LocalBase);
REMOTE_top_or_fr(wid) = Yap_root_or_fr;
REMOTE_top_or_fr(wid) = GLOBAL_root_or_fr;
REMOTE_load(wid) = 0;
REMOTE_share_request(wid) = MAX_WORKERS;
REMOTE_reply_signal(wid) = worker_ready;
@ -179,10 +179,10 @@ void Yap_init_local_optyap_data(int wid) {
/* local data related to tabling */
REMOTE_next_free_ans_node(wid) = NULL;
REMOTE_top_sg_fr(wid) = NULL;
REMOTE_top_dep_fr(wid) = Yap_root_dep_fr;
REMOTE_top_dep_fr(wid) = GLOBAL_root_dep_fr;
#ifdef YAPOR
Set_REMOTE_top_cp_on_stack(wid, (choiceptr) Yap_LocalBase); /* ??? */
REMOTE_top_susp_or_fr(wid) = Yap_root_or_fr;
REMOTE_top_susp_or_fr(wid) = GLOBAL_root_or_fr;
#endif /* YAPOR */
#endif /* TABLING */
return;
@ -194,10 +194,10 @@ void Yap_init_root_frames(void) {
#ifdef YAPOR
/* root or frame */
or_fr_ptr or_fr = Yap_root_or_fr;
or_fr_ptr or_fr = GLOBAL_root_or_fr;
INIT_LOCK(OrFr_lock(or_fr));
OrFr_alternative(or_fr) = NULL;
BITMAP_copy(OrFr_members(or_fr), Yap_bm_present_workers);
BITMAP_copy(OrFr_members(or_fr), GLOBAL_bm_present_workers);
SetOrFr_node(or_fr, (choiceptr) Yap_LocalBase);
OrFr_nearest_livenode(or_fr) = NULL;
OrFr_depth(or_fr) = 0;
@ -208,7 +208,7 @@ void Yap_init_root_frames(void) {
OrFr_tg_solutions(or_fr) = NULL;
#endif /* TABLING_INNER_CUTS */
#ifdef TABLING
OrFr_owners(or_fr) = Yap_number_workers;
OrFr_owners(or_fr) = GLOBAL_number_workers;
OrFr_next_on_stack(or_fr) = NULL;
OrFr_suspensions(or_fr) = NULL;
OrFr_nearest_suspnode(or_fr) = or_fr;
@ -218,7 +218,7 @@ void Yap_init_root_frames(void) {
#ifdef TABLING
/* root dependency frame */
DepFr_cons_cp(Yap_root_dep_fr) = B;
DepFr_cons_cp(GLOBAL_root_dep_fr) = B;
#endif /* TABLING */
}

View File

@ -86,11 +86,11 @@ extern int Yap_page_size;
** USE_PAGES_MALLOC **
*************************************************************************************************/
#define FREE_PAGE(PG_HD) \
LOCK(Pg_lock(Yap_pages_void)); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), -1); \
PgHd_next(PG_HD) = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PG_HD; \
UNLOCK(Pg_lock(Yap_pages_void))
LOCK(Pg_lock(GLOBAL_pages_void)); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), -1); \
PgHd_next(PG_HD) = Pg_free_pg(GLOBAL_pages_void); \
Pg_free_pg(GLOBAL_pages_void) = PG_HD; \
UNLOCK(Pg_lock(GLOBAL_pages_void))
#define FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \
{ pg_hd_ptr pg_hd; \
@ -152,22 +152,22 @@ extern int Yap_page_size;
if (shmctl(shmid, IPC_RMID, 0) != 0) \
Yap_Error(FATAL_ERROR, TermNil, "shmctl error (ALLOC_PAGE)"); \
aux_pg_hd = (pg_hd_ptr)(((void *)PG_HD) + Yap_page_size); \
Pg_free_pg(Yap_pages_void) = aux_pg_hd; \
Pg_free_pg(GLOBAL_pages_void) = aux_pg_hd; \
for (i = 2; i < SHMMAX / Yap_page_size; i++) { \
PgHd_next(aux_pg_hd) = (pg_hd_ptr)(((void *)aux_pg_hd) + Yap_page_size); \
aux_pg_hd = PgHd_next(aux_pg_hd); \
} \
PgHd_next(aux_pg_hd) = NULL; \
UPDATE_STATS(Pg_pg_alloc(Yap_pages_void), SHMMAX / Yap_page_size); \
UPDATE_STATS(Pg_pg_alloc(GLOBAL_pages_void), SHMMAX / Yap_page_size); \
}
#define RECOVER_UNUSED_SPACE(STR_PAGES) \
{ sg_fr_ptr sg_fr = Yap_check_sg_fr; \
{ sg_fr_ptr sg_fr = GLOBAL_check_sg_fr; \
do { \
if (sg_fr) \
sg_fr = SgFr_next(sg_fr); \
else \
sg_fr = Yap_first_sg_fr; \
sg_fr = GLOBAL_first_sg_fr; \
if (sg_fr == NULL) \
Yap_Error(FATAL_ERROR, TermNil, "no space left (RECOVER_UNUSED_SPACE)"); \
/* see function 'InteractSIGINT' in file 'sysbits.c' */ \
@ -185,8 +185,8 @@ extern int Yap_page_size;
TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST); \
TrNode_child(SgFr_answer_trie(sg_fr)) = NULL; \
} \
} while (Pg_free_pg(Yap_pages_void) == Pg_free_pg(STR_PAGES)); \
Yap_check_sg_fr = sg_fr; \
} while (Pg_free_pg(GLOBAL_pages_void) == Pg_free_pg(STR_PAGES)); \
GLOBAL_check_sg_fr = sg_fr; \
}
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \
@ -195,20 +195,20 @@ extern int Yap_page_size;
pg_hd = Pg_free_pg(STR_PAGES); \
while (pg_hd == NULL) { \
UNLOCK(Pg_lock(STR_PAGES)); \
LOCK(Pg_lock(Yap_pages_void)); \
if (Pg_free_pg(Yap_pages_void)) { \
pg_hd = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PgHd_next(pg_hd); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
UNLOCK(Pg_lock(Yap_pages_void)); \
LOCK(Pg_lock(GLOBAL_pages_void)); \
if (Pg_free_pg(GLOBAL_pages_void)) { \
pg_hd = Pg_free_pg(GLOBAL_pages_void); \
Pg_free_pg(GLOBAL_pages_void) = PgHd_next(pg_hd); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
INIT_PAGE(pg_hd, STR_PAGES, STR_TYPE); \
} else if (Yap_max_pages != Pg_pg_alloc(Yap_pages_void)) { \
} else if ( GLOBAL_max_pages != Pg_pg_alloc(GLOBAL_pages_void)) { \
ALLOC_PAGE(pg_hd); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
UNLOCK(Pg_lock(Yap_pages_void)); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
INIT_PAGE(pg_hd, STR_PAGES, STR_TYPE); \
} else { \
UNLOCK(Pg_lock(Yap_pages_void)); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
RECOVER_UNUSED_SPACE(STR_PAGES); \
LOCK(Pg_lock(STR_PAGES)); \
pg_hd = Pg_free_pg(STR_PAGES); \
@ -230,20 +230,20 @@ extern int Yap_page_size;
pg_hd = Pg_free_pg(STR_PAGES); \
while (pg_hd == NULL) { \
UNLOCK(Pg_lock(STR_PAGES)); \
LOCK(Pg_lock(Yap_pages_void)); \
if (Pg_free_pg(Yap_pages_void)) { \
pg_hd = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PgHd_next(pg_hd); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
UNLOCK(Pg_lock(Yap_pages_void)); \
LOCK(Pg_lock(GLOBAL_pages_void)); \
if (Pg_free_pg(GLOBAL_pages_void)) { \
pg_hd = Pg_free_pg(GLOBAL_pages_void); \
Pg_free_pg(GLOBAL_pages_void) = PgHd_next(pg_hd); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
INIT_PAGE(pg_hd, STR_PAGES, STR_TYPE); \
} else if (Yap_max_pages != Pg_pg_alloc(Yap_pages_void)) { \
} else if ( GLOBAL_max_pages != Pg_pg_alloc(GLOBAL_pages_void)) { \
ALLOC_PAGE(pg_hd); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
UNLOCK(Pg_lock(Yap_pages_void)); \
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
INIT_PAGE(pg_hd, STR_PAGES, STR_TYPE); \
} else { \
UNLOCK(Pg_lock(Yap_pages_void)); \
UNLOCK(Pg_lock(GLOBAL_pages_void)); \
RECOVER_UNUSED_SPACE(STR_PAGES); \
LOCK(Pg_lock(STR_PAGES)); \
pg_hd = Pg_free_pg(STR_PAGES); \
@ -263,8 +263,8 @@ extern int Yap_page_size;
** USE_PAGES_MALLOC && ! LIMIT_TABLING **
*************************************************************************************************/
#define ALLOC_PAGE(PG_HD) \
LOCK(Pg_lock(Yap_pages_void)); \
if (Pg_free_pg(Yap_pages_void) == NULL) { \
LOCK(Pg_lock(GLOBAL_pages_void)); \
if (Pg_free_pg(GLOBAL_pages_void) == NULL) { \
int i, shmid; \
pg_hd_ptr pg_hd, aux_pg_hd; \
if ((shmid = shmget(IPC_PRIVATE, SHMMAX, SHM_R|SHM_W)) == -1) \
@ -273,19 +273,19 @@ extern int Yap_page_size;
Yap_Error(FATAL_ERROR, TermNil, "shmat error (ALLOC_PAGE)"); \
if (shmctl(shmid, IPC_RMID, 0) != 0) \
Yap_Error(FATAL_ERROR, TermNil, "shmctl error (ALLOC_PAGE)"); \
Pg_free_pg(Yap_pages_void) = pg_hd; \
Pg_free_pg(GLOBAL_pages_void) = pg_hd; \
for (i = 1; i < SHMMAX / Yap_page_size; i++) { \
aux_pg_hd = (pg_hd_ptr)(((void *)pg_hd) + Yap_page_size); \
PgHd_next(pg_hd) = aux_pg_hd; \
pg_hd = aux_pg_hd; \
} \
PgHd_next(pg_hd) = NULL; \
UPDATE_STATS(Pg_pg_alloc(Yap_pages_void), SHMMAX / Yap_page_size); \
UPDATE_STATS(Pg_pg_alloc(GLOBAL_pages_void), SHMMAX / Yap_page_size); \
} \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), 1); \
PG_HD = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PgHd_next(PG_HD); \
UNLOCK(Pg_lock(Yap_pages_void))
UPDATE_STATS(Pg_str_in_use(GLOBAL_pages_void), 1); \
PG_HD = Pg_free_pg(GLOBAL_pages_void); \
Pg_free_pg(GLOBAL_pages_void) = PgHd_next(PG_HD); \
UNLOCK(Pg_lock(GLOBAL_pages_void))
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \
{ pg_hd_ptr pg_hd; \
@ -380,55 +380,55 @@ extern int Yap_page_size;
}
#define FREE_HASH_BUCKETS(BUCKET_PTR) FREE_BLOCK(BUCKET_PTR)
#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_or_fr , struct or_frame)
#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, Yap_pages_or_fr , struct or_frame)
#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_or_fr , struct or_frame)
#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_or_fr , struct or_frame)
#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_qg_sol_fr , struct query_goal_solution_frame)
#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, Yap_pages_qg_sol_fr , struct query_goal_solution_frame)
#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_qg_sol_fr , struct query_goal_solution_frame)
#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_qg_sol_fr , struct query_goal_solution_frame)
#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_qg_ans_fr, struct query_goal_answer_frame)
#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, Yap_pages_qg_ans_fr, struct query_goal_answer_frame)
#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame)
#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame)
#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_tg_sol_fr, struct table_subgoal_solution_frame)
#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, Yap_pages_tg_sol_fr, struct table_subgoal_solution_frame)
#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame)
#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame)
#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_tg_ans_fr, struct table_subgoal_answer_frame)
#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, Yap_pages_tg_ans_fr, struct table_subgoal_answer_frame)
#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame)
#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame)
#define ALLOC_TABLE_ENTRY(STR) ALLOC_STRUCT(STR, Yap_pages_tab_ent, struct table_entry)
#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, Yap_pages_tab_ent, struct table_entry)
#define ALLOC_TABLE_ENTRY(STR) ALLOC_STRUCT(STR, GLOBAL_pages_tab_ent, struct table_entry)
#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, GLOBAL_pages_tab_ent, struct table_entry)
#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_sg_fr, struct subgoal_frame)
#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, Yap_pages_sg_fr, struct subgoal_frame)
#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_sg_fr, struct subgoal_frame)
#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_sg_fr, struct subgoal_frame)
#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_dep_fr, struct dependency_frame)
#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, Yap_pages_dep_fr, struct dependency_frame)
#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_dep_fr, struct dependency_frame)
#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, GLOBAL_pages_dep_fr, struct dependency_frame)
#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, Yap_pages_susp_fr, struct suspension_frame)
#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_pages_susp_fr, struct suspension_frame)
#define FREE_SUSPENSION_FRAME(STR) FREE_BLOCK(SuspFr_global_start(STR)); \
FREE_STRUCT(STR, Yap_pages_susp_fr, struct suspension_frame)
FREE_STRUCT(STR, GLOBAL_pages_susp_fr, struct suspension_frame)
#define ALLOC_GLOBAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, Yap_pages_gt_node, struct global_trie_node)
#define FREE_GLOBAL_TRIE_NODE(STR) FREE_STRUCT(STR, Yap_pages_gt_node, struct global_trie_node)
#define ALLOC_GLOBAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_pages_gt_node, struct global_trie_node)
#define FREE_GLOBAL_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_pages_gt_node, struct global_trie_node)
#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, Yap_pages_sg_node, struct subgoal_trie_node)
#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, Yap_pages_sg_node, struct subgoal_trie_node)
#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_pages_sg_node, struct subgoal_trie_node)
#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_pages_sg_node, struct subgoal_trie_node)
#ifdef YAPOR
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_NEXT_FREE_STRUCT(STR, Yap_pages_ans_node, struct answer_trie_node)
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_NEXT_FREE_STRUCT(STR, GLOBAL_pages_ans_node, struct answer_trie_node)
#else /* TABLING */
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, Yap_pages_ans_node, struct answer_trie_node)
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_pages_ans_node, struct answer_trie_node)
#endif /* YAPOR - TABLING */
#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, Yap_pages_ans_node, struct answer_trie_node)
#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_pages_ans_node, struct answer_trie_node)
#define ALLOC_GLOBAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, Yap_pages_gt_hash, struct global_trie_hash)
#define FREE_GLOBAL_TRIE_HASH(STR) FREE_STRUCT(STR, Yap_pages_gt_hash, struct global_trie_hash)
#define ALLOC_GLOBAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_pages_gt_hash, struct global_trie_hash)
#define FREE_GLOBAL_TRIE_HASH(STR) FREE_STRUCT(STR, GLOBAL_pages_gt_hash, struct global_trie_hash)
#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, Yap_pages_sg_hash, struct subgoal_trie_hash)
#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, Yap_pages_sg_hash, struct subgoal_trie_hash)
#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_pages_sg_hash, struct subgoal_trie_hash)
#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, GLOBAL_pages_sg_hash, struct subgoal_trie_hash)
#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, Yap_pages_ans_hash, struct answer_trie_hash)
#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, Yap_pages_ans_hash, struct answer_trie_hash)
#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_pages_ans_hash, struct answer_trie_hash)
#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, GLOBAL_pages_ans_hash, struct answer_trie_hash)

View File

@ -168,17 +168,17 @@ void Yap_remap_optyap_memory(void) {
void *remap_addr = Yap_GlobalBase;
#ifdef MMAP_MEMORY_MAPPING_SCHEME
long remap_offset = (ADDR) remap_addr - (ADDR) Yap_local;
if (munmap(remap_addr, (size_t)(Yap_worker_area_size * Yap_number_workers)) == -1)
if (munmap(remap_addr, (size_t)(Yap_worker_area_size * GLOBAL_number_workers)) == -1)
Yap_Error(FATAL_ERROR, TermNil, "munmap error (Yap_remap_optyap_memory)");
for (i = 0; i < Yap_number_workers; i++)
for (i = 0; i < GLOBAL_number_workers; i++)
if (mmap(remap_addr + worker_offset(i), (size_t)Yap_worker_area_size, PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED, fd_mapfile, remap_offset + i * Yap_worker_area_size) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_remap_optyap_memory)");
#else /* SHM_MEMORY_MAPPING_SCHEME */
for (i = 0; i < Yap_number_workers; i++)
for (i = 0; i < GLOBAL_number_workers; i++)
if (shmdt(remap_addr + Yap_worker_area_size * i) == -1)
Yap_Error(FATAL_ERROR, TermNil, "shmdt error (Yap_remap_optyap_memory)");
for (i = 0; i < Yap_number_workers; i++)
for (i = 0; i < GLOBAL_number_workers; i++)
if(shmat(shm_mapid[i], remap_addr + worker_offset(i), 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "shmat error (Yap_remap_optyap_memory)");
#endif /* MEMORY_MAPPING_SCHEME */
@ -195,21 +195,21 @@ void Yap_unmap_optyap_memory (void) {
int proc;
INFORMATION_MESSAGE("Worker %d exiting...", worker_id);
for (proc = 0; proc < Yap_number_workers; proc++) {
if (proc != worker_id && Yap_worker_pid(proc) != 0) {
if (kill(Yap_worker_pid(proc), SIGKILL) != 0)
INFORMATION_MESSAGE("Can't kill process %d", Yap_worker_pid(proc));
for (proc = 0; proc < GLOBAL_number_workers; proc++) {
if (proc != worker_id && GLOBAL_worker_pid(proc) != 0) {
if (kill(GLOBAL_worker_pid(proc), SIGKILL) != 0)
INFORMATION_MESSAGE("Can't kill process %d", GLOBAL_worker_pid(proc));
else
INFORMATION_MESSAGE("Killing process %d", Yap_worker_pid(proc));
INFORMATION_MESSAGE("Killing process %d", GLOBAL_worker_pid(proc));
}
}
#ifdef YAPOR_COW
if (Yap_number_workers > 1) {
if (kill(Yap_master_worker, SIGINT) != 0)
INFORMATION_MESSAGE("Can't kill process %d", Yap_master_worker);
if (GLOBAL_number_workers > 1) {
if (kill(GLOBAL_master_worker, SIGINT) != 0)
INFORMATION_MESSAGE("Can't kill process %d", GLOBAL_master_worker);
else
INFORMATION_MESSAGE("Killing process %d", Yap_master_worker);
INFORMATION_MESSAGE("Killing process %d", GLOBAL_master_worker);
}
#endif /* YAPOR_COW */
@ -217,9 +217,9 @@ void Yap_unmap_optyap_memory (void) {
#ifdef MMAP_MEMORY_MAPPING_SCHEME
strcpy(MapFile,"./mapfile");
#ifdef YAPOR_COW
itos(Yap_master_worker, &MapFile[9]);
itos(GLOBAL_master_worker, &MapFile[9]);
#else /* YAPOR_COPY || YAPOR_SBA */
itos(Yap_worker_pid(0), &MapFile[9]);
itos(GLOBAL_worker_pid(0), &MapFile[9]);
#endif
if (remove(MapFile) == 0)
INFORMATION_MESSAGE("Removing mapfile \"%s\"", MapFile);
@ -229,7 +229,7 @@ void Yap_unmap_optyap_memory (void) {
#ifdef YAPOR_COW
i = 0;
#else /* YAPOR_COPY || YAPOR_SBA */
for (i = 0; i < Yap_number_workers + 1; i++)
for (i = 0; i < GLOBAL_number_workers + 1; i++)
#endif
{
if (shmctl(shm_mapid[i], IPC_RMID, 0) == 0)

View File

@ -158,7 +158,7 @@ void Yap_init_optyap_preds(void) {
#ifdef YAPOR
void finish_yapor(void) {
Yap_execution_time = current_time() - Yap_execution_time;
GLOBAL_execution_time = current_time() - GLOBAL_execution_time;
show_answers();
return;
}
@ -359,7 +359,7 @@ static Int p_abolish_all_tables( USES_REGS1 ) {
sg_hash_ptr hash;
sg_node_ptr sg_node;
tab_ent = Yap_root_tab_ent;
tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
hash = TabEnt_hash_chain(tab_ent);
TabEnt_hash_chain(tab_ent) = NULL;
@ -387,7 +387,7 @@ static Int p_abolish_all_tables( USES_REGS1 ) {
static Int p_show_tabled_predicates( USES_REGS1 ) {
tab_ent_ptr tab_ent;
tab_ent = Yap_root_tab_ent;
tab_ent = GLOBAL_root_tab_ent;
fprintf(Yap_stdout, "Tabled predicates\n");
if (tab_ent == NULL)
fprintf(Yap_stdout, " NONE\n");
@ -420,7 +420,7 @@ static Int p_show_table( USES_REGS1 ) {
static Int p_show_all_tables( USES_REGS1 ) {
tab_ent_ptr tab_ent;
tab_ent = Yap_root_tab_ent;
tab_ent = GLOBAL_root_tab_ent;
while(tab_ent) {
show_table(tab_ent, SHOW_MODE_STRUCTURE);
tab_ent = TabEnt_next(tab_ent);
@ -478,9 +478,9 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
total_bytes += aux_bytes;
#ifdef USE_PAGES_MALLOC
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
total_bytes, Pg_str_in_use(Yap_pages_void));
total_bytes, Pg_str_in_use(GLOBAL_pages_void));
fprintf(Yap_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
Pg_pg_alloc(Yap_pages_void) * Yap_page_size, Pg_pg_alloc(Yap_pages_void));
Pg_pg_alloc(GLOBAL_pages_void) * Yap_page_size, Pg_pg_alloc(GLOBAL_pages_void));
#else
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
#endif /* USE_PAGES_MALLOC */
@ -502,7 +502,7 @@ static Int p_show_statistics_global_trie( USES_REGS1 ) {
static Int p_yapor_threads( USES_REGS1 ) {
#ifdef YAPOR_THREADS
return Yap_unify(MkIntegerTerm(Yap_number_workers),ARG1);
return Yap_unify(MkIntegerTerm(GLOBAL_number_workers),ARG1);
#else
return FALSE;
#endif
@ -518,25 +518,25 @@ static Int p_worker( USES_REGS1 ) {
static Int p_yapor_on( USES_REGS1 ) {
return (Yap_parallel_execution_mode);
return (GLOBAL_parallel_execution_mode);
}
static Int p_start_yapor( USES_REGS1 ) {
#ifdef TIMESTAMP_CHECK
Yap_timestamp = 0;
GLOBAL_timestamp = 0;
#endif /* TIMESTAMP_CHECK */
Yap_answers = NO_ANSWER;
BITMAP_delete(Yap_bm_idle_workers, 0);
BITMAP_clear(Yap_bm_invisible_workers);
BITMAP_clear(Yap_bm_requestable_workers);
GLOBAL_answers = NO_ANSWER;
BITMAP_delete(GLOBAL_bm_idle_workers, 0);
BITMAP_clear(GLOBAL_bm_invisible_workers);
BITMAP_clear(GLOBAL_bm_requestable_workers);
#ifdef TABLING_INNER_CUTS
BITMAP_clear(Yap_bm_pruning_workers);
BITMAP_clear(GLOBAL_bm_pruning_workers);
#endif /* TABLING_INNER_CUTS */
make_root_choice_point();
Yap_performance_mode &= ~PERFORMANCE_IN_EXECUTION;
Yap_execution_time = current_time();
BITMAP_clear(Yap_bm_finished_workers);
GLOBAL_performance_mode &= ~PERFORMANCE_IN_EXECUTION;
GLOBAL_execution_time = current_time();
BITMAP_clear(GLOBAL_bm_finished_workers);
PUT_IN_EXECUTING(worker_id);
return (TRUE);
}
@ -575,7 +575,7 @@ static Int p_execution_mode( USES_REGS1 ) {
t = Deref(ARG1);
if (IsVarTerm(t)) {
Term ta;
if (Yap_parallel_execution_mode)
if (GLOBAL_parallel_execution_mode)
ta = MkAtomTerm(Yap_LookupAtom("parallel"));
else
ta = MkAtomTerm(Yap_LookupAtom("sequential"));
@ -586,11 +586,11 @@ static Int p_execution_mode( USES_REGS1 ) {
char *s;
s = RepAtom(AtomOfTerm(t))->StrOfAE;
if (strcmp(s,"parallel") == 0) {
Yap_parallel_execution_mode = TRUE;
GLOBAL_parallel_execution_mode = TRUE;
return(TRUE);
}
if (strcmp(s,"sequential") == 0) {
Yap_parallel_execution_mode = FALSE;
GLOBAL_parallel_execution_mode = FALSE;
return(TRUE);
}
}
@ -603,11 +603,11 @@ static Int p_performance( USES_REGS1 ) {
realtime one_worker_execution_time = 0;
int i;
Yap_performance_mode |= PERFORMANCE_IN_EXECUTION;
GLOBAL_performance_mode |= PERFORMANCE_IN_EXECUTION;
t = Deref(ARG1);
if (IsVarTerm(t)) {
Term ta;
if (Yap_performance_mode & PERFORMANCE_ON) {
if (GLOBAL_performance_mode & PERFORMANCE_ON) {
ta = MkAtomTerm(Yap_LookupAtom("on"));
} else {
ta = MkAtomTerm(Yap_LookupAtom("off"));
@ -619,16 +619,16 @@ static Int p_performance( USES_REGS1 ) {
char *s;
s = RepAtom(AtomOfTerm(t))->StrOfAE;
if (strcmp(s, "on") == 0) {
Yap_performance_mode |= PERFORMANCE_ON;
GLOBAL_performance_mode |= PERFORMANCE_ON;
return(TRUE);
}
if (strcmp(s,"off") == 0) {
Yap_performance_mode &= ~PERFORMANCE_ON;
GLOBAL_performance_mode &= ~PERFORMANCE_ON;
return(TRUE);
}
if (strcmp(s,"clear") == 0) {
Yap_number_goals = 0;
Yap_best_times(0) = 0;
GLOBAL_number_goals = 0;
GLOBAL_best_times(0) = 0;
return(TRUE);
}
}
@ -639,31 +639,31 @@ static Int p_performance( USES_REGS1 ) {
else
return(FALSE);
if (Yap_number_goals) {
if (GLOBAL_number_goals) {
fprintf(Yap_stdout, "[\n Best execution times:\n");
for (i = 1; i <= Yap_number_goals; i++) {
fprintf(Yap_stdout, " %d. time: %f seconds", i, Yap_best_times(i));
for (i = 1; i <= GLOBAL_number_goals; i++) {
fprintf(Yap_stdout, " %d. time: %f seconds", i, GLOBAL_best_times(i));
if (one_worker_execution_time != 0)
fprintf(Yap_stdout, " --> speedup %f (%6.2f %% )\n",
one_worker_execution_time / Yap_best_times(i),
one_worker_execution_time / Yap_best_times(i) / Yap_number_workers* 100 );
one_worker_execution_time / GLOBAL_best_times(i),
one_worker_execution_time / GLOBAL_best_times(i) / GLOBAL_number_workers* 100 );
else fprintf(Yap_stdout, "\n");
}
fprintf(Yap_stdout, " Average : %f seconds",
Yap_best_times(0) / Yap_number_goals);
GLOBAL_best_times(0) / GLOBAL_number_goals);
if (one_worker_execution_time != 0)
fprintf(Yap_stdout, " --> speedup %f (%6.2f %% )",
one_worker_execution_time * Yap_number_goals / Yap_best_times(0),
one_worker_execution_time * Yap_number_goals / Yap_best_times(0) / Yap_number_workers* 100 );
one_worker_execution_time * GLOBAL_number_goals / GLOBAL_best_times(0),
one_worker_execution_time * GLOBAL_number_goals / GLOBAL_best_times(0) / GLOBAL_number_workers* 100 );
if (Yap_number_goals >= 3) {
if (GLOBAL_number_goals >= 3) {
fprintf(Yap_stdout, "\n Average (best three): %f seconds",
(Yap_best_times(1) + Yap_best_times(2) + Yap_best_times(3)) / 3);
(GLOBAL_best_times(1) + GLOBAL_best_times(2) + GLOBAL_best_times(3)) / 3);
if (one_worker_execution_time != 0)
fprintf(Yap_stdout, " --> speedup %f (%6.2f %% ) ]\n\n",
one_worker_execution_time * 3 / (Yap_best_times(1) + Yap_best_times(2) + Yap_best_times(3)),
one_worker_execution_time * 3 / (Yap_best_times(1) + Yap_best_times(2) + Yap_best_times(3)) / Yap_number_workers* 100 );
one_worker_execution_time * 3 / (GLOBAL_best_times(1) + GLOBAL_best_times(2) + GLOBAL_best_times(3)),
one_worker_execution_time * 3 / (GLOBAL_best_times(1) + GLOBAL_best_times(2) + GLOBAL_best_times(3)) / GLOBAL_number_workers* 100 );
else fprintf(Yap_stdout, "\n]\n\n");
} else fprintf(Yap_stdout, "\n]\n\n");
return (TRUE);
@ -694,7 +694,7 @@ static Int p_parallel_new_answer( USES_REGS1 ) {
static Int p_parallel_yes_answer( USES_REGS1 ) {
Yap_answers = YES_ANSWER;
GLOBAL_answers = YES_ANSWER;
return (TRUE);
}
@ -715,9 +715,9 @@ static Int p_show_statistics_or( USES_REGS1 ) {
total_bytes += aux_bytes;
#ifdef USE_PAGES_MALLOC
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
total_bytes, Pg_str_in_use(Yap_pages_void));
total_bytes, Pg_str_in_use(GLOBAL_pages_void));
fprintf(Yap_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
Pg_pg_alloc(Yap_pages_void) * Yap_page_size, Pg_pg_alloc(Yap_pages_void));
Pg_pg_alloc(GLOBAL_pages_void) * Yap_page_size, Pg_pg_alloc(GLOBAL_pages_void));
#else
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
#endif /* USE_PAGES_MALLOC */
@ -771,9 +771,9 @@ static Int p_show_statistics_opt( USES_REGS1 ) {
total_bytes += aux_bytes;
#ifdef USE_PAGES_MALLOC
fprintf(Yap_stdout, "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
total_bytes, Pg_str_in_use(Yap_pages_void));
total_bytes, Pg_str_in_use(GLOBAL_pages_void));
fprintf(Yap_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
Pg_pg_alloc(Yap_pages_void) * Yap_page_size, Pg_pg_alloc(Yap_pages_void));
Pg_pg_alloc(GLOBAL_pages_void) * Yap_page_size, Pg_pg_alloc(GLOBAL_pages_void));
#else
fprintf(Yap_stdout, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
#endif /* USE_PAGES_MALLOC */
@ -791,99 +791,99 @@ static Int p_get_optyap_statistics( USES_REGS1 ) {
if (value == 0) { /* total_memory */
bytes = 0;
#ifdef TABLING
bytes += Pg_str_in_use(Yap_pages_tab_ent) * sizeof(struct table_entry);
bytes += Pg_str_in_use(Yap_pages_sg_fr) * sizeof(struct subgoal_frame);
bytes += Pg_str_in_use(Yap_pages_dep_fr) * sizeof(struct dependency_frame);
bytes += Pg_str_in_use(Yap_pages_sg_node) * sizeof(struct subgoal_trie_node);
bytes += Pg_str_in_use(Yap_pages_ans_node) * sizeof(struct answer_trie_node);
bytes += Pg_str_in_use(Yap_pages_sg_hash) * sizeof(struct subgoal_trie_hash);
bytes += Pg_str_in_use(Yap_pages_ans_hash) * sizeof(struct answer_trie_hash);
bytes += Pg_str_in_use(Yap_pages_gt_node) * sizeof(struct global_trie_node);
bytes += Pg_str_in_use(Yap_pages_gt_hash) * sizeof(struct global_trie_hash);
bytes += Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry);
bytes += Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame);
bytes += Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame);
bytes += Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node);
bytes += Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node);
bytes += Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash);
bytes += Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash);
bytes += Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node);
bytes += Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash);
#endif /* TABLING */
#ifdef YAPOR
bytes += Pg_str_in_use(Yap_pages_or_fr ) * sizeof(struct or_frame);
bytes += Pg_str_in_use(Yap_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame);
bytes += Pg_str_in_use(Yap_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
bytes += Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame);
bytes += Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame);
bytes += Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
#endif /* YAPOR */
#if defined(YAPOR) && defined(TABLING)
bytes += Pg_str_in_use(Yap_pages_susp_fr) * sizeof(struct suspension_frame);
bytes += Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame);
#ifdef TABLING_INNER_CUTS
bytes += Pg_str_in_use(Yap_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame);
bytes += Pg_str_in_use(Yap_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
bytes += Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame);
bytes += Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
#endif /* TABLING_INNER_CUTS */
#endif /* YAPOR && TABLING */
#ifdef USE_PAGES_MALLOC
structs = Pg_pg_alloc(Yap_pages_void) * Yap_page_size;
structs = Pg_pg_alloc(GLOBAL_pages_void) * Yap_page_size;
#else
structs = bytes;
#endif /* USE_PAGES_MALLOC */
}
#ifdef TABLING
if (value == 1) { /* table_entries */
bytes = Pg_str_in_use(Yap_pages_tab_ent) * sizeof(struct table_entry);
structs = Pg_str_in_use(Yap_pages_tab_ent);
bytes = Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry);
structs = Pg_str_in_use(GLOBAL_pages_tab_ent);
}
if (value == 2) { /* subgoal_frames */
bytes = Pg_str_in_use(Yap_pages_sg_fr) * sizeof(struct subgoal_frame);
structs = Pg_str_in_use(Yap_pages_sg_fr);
bytes = Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame);
structs = Pg_str_in_use(GLOBAL_pages_sg_fr);
}
if (value == 3) { /* dependency_frames */
bytes = Pg_str_in_use(Yap_pages_dep_fr) * sizeof(struct dependency_frame);
structs = Pg_str_in_use(Yap_pages_dep_fr);
bytes = Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame);
structs = Pg_str_in_use(GLOBAL_pages_dep_fr);
}
if (value == 6) { /* subgoal_trie_nodes */
bytes = Pg_str_in_use(Yap_pages_sg_node) * sizeof(struct subgoal_trie_node);
structs = Pg_str_in_use(Yap_pages_sg_node);
bytes = Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node);
structs = Pg_str_in_use(GLOBAL_pages_sg_node);
}
if (value == 7) { /* answer_trie_nodes */
bytes = Pg_str_in_use(Yap_pages_ans_node) * sizeof(struct answer_trie_node);
structs = Pg_str_in_use(Yap_pages_ans_node);
bytes = Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node);
structs = Pg_str_in_use(GLOBAL_pages_ans_node);
}
if (value == 8) { /* subgoal_trie_hashes */
bytes = Pg_str_in_use(Yap_pages_sg_hash) * sizeof(struct subgoal_trie_hash);
structs = Pg_str_in_use(Yap_pages_sg_hash);
bytes = Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash);
structs = Pg_str_in_use(GLOBAL_pages_sg_hash);
}
if (value == 9) { /* answer_trie_hashes */
bytes = Pg_str_in_use(Yap_pages_ans_hash) * sizeof(struct answer_trie_hash);
structs = Pg_str_in_use(Yap_pages_ans_hash);
bytes = Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash);
structs = Pg_str_in_use(GLOBAL_pages_ans_hash);
}
if (value == 10) { /* global_trie_nodes */
bytes = Pg_str_in_use(Yap_pages_gt_node) * sizeof(struct global_trie_node);
structs = Pg_str_in_use(Yap_pages_gt_node);
bytes = Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node);
structs = Pg_str_in_use(GLOBAL_pages_gt_node);
}
if (value == 11) { /* global_trie_hashes */
bytes = Pg_str_in_use(Yap_pages_gt_hash) * sizeof(struct global_trie_hash);
structs = Pg_str_in_use(Yap_pages_gt_hash);
bytes = Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash);
structs = Pg_str_in_use(GLOBAL_pages_gt_hash);
}
#endif /* TABLING */
#ifdef YAPOR
if (value == 4) { /* or_frames */
bytes = Pg_str_in_use(Yap_pages_or_fr ) * sizeof(struct or_frame);
structs = Pg_str_in_use(Yap_pages_or_fr );
bytes = Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame);
structs = Pg_str_in_use(GLOBAL_pages_or_fr );
}
if (value == 12) { /* query_goal_solution_frames */
bytes = Pg_str_in_use(Yap_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame);
structs = Pg_str_in_use(Yap_pages_qg_sol_fr );
bytes = Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame);
structs = Pg_str_in_use(GLOBAL_pages_qg_sol_fr );
}
if (value == 13) { /* query_goal_answer_frames */
bytes = Pg_str_in_use(Yap_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
structs = Pg_str_in_use(Yap_pages_qg_ans_fr);
bytes = Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
structs = Pg_str_in_use(GLOBAL_pages_qg_ans_fr);
}
#endif /* YAPOR */
#if defined(YAPOR) && defined(TABLING)
if (value == 5) { /* suspension_frames */
bytes = Pg_str_in_use(Yap_pages_susp_fr) * sizeof(struct suspension_frame);
structs = Pg_str_in_use(Yap_pages_susp_fr);
bytes = Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame);
structs = Pg_str_in_use(GLOBAL_pages_susp_fr);
}
#ifdef TABLING_INNER_CUTS
if (value == 14) { /* table_subgoal_solution_frames */
bytes = Pg_str_in_use(Yap_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame);
structs = Pg_str_in_use(Yap_pages_tg_sol_fr);
bytes = Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame);
structs = Pg_str_in_use(GLOBAL_pages_tg_sol_fr);
}
if (value == 15) { /* table_subgoal_answer_frames */
bytes = Pg_str_in_use(Yap_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
structs = Pg_str_in_use(Yap_pages_tg_ans_fr);
bytes = Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
structs = Pg_str_in_use(GLOBAL_pages_tg_ans_fr);
}
#endif /* TABLING_INNER_CUTS */
#endif /* YAPOR && TABLING */
@ -938,12 +938,12 @@ static inline void show_answers(void) {
aux_answer2 = aux_answer1;
aux_answer1 = AnsFr_next(aux_answer1);
FREE_QG_ANSWER_FRAME(aux_answer2);
Yap_answers++;
GLOBAL_answers++;
}
FREE_QG_SOLUTION_FRAME(OrFr_qg_solutions(LOCAL_top_or_fr));
OrFr_qg_solutions(LOCAL_top_or_fr) = NULL;
}
switch(Yap_answers) {
switch(GLOBAL_answers) {
case YES_ANSWER:
fprintf(Yap_stderr, "[ yes");
break;
@ -954,27 +954,27 @@ static inline void show_answers(void) {
fprintf(Yap_stderr, "[ 1 answer found");
break;
default:
fprintf(Yap_stderr, "[ %d answers found", Yap_answers);
fprintf(Yap_stderr, "[ %d answers found", GLOBAL_answers);
break;
}
fprintf(Yap_stderr, " (in %f seconds) ]\n\n", Yap_execution_time);
fprintf(Yap_stderr, " (in %f seconds) ]\n\n", GLOBAL_execution_time);
if (Yap_performance_mode == PERFORMANCE_ON) {
for (i = Yap_number_goals; i > 0; i--) {
if (Yap_best_times(i) > Yap_execution_time) {
if (GLOBAL_performance_mode == PERFORMANCE_ON) {
for (i = GLOBAL_number_goals; i > 0; i--) {
if (GLOBAL_best_times(i) > GLOBAL_execution_time) {
if (i + 1 < MAX_BEST_TIMES)
Yap_best_times(i + 1) = Yap_best_times(i);
GLOBAL_best_times(i + 1) = GLOBAL_best_times(i);
else {
Yap_best_times(0) -= Yap_best_times(i);
GLOBAL_best_times(0) -= GLOBAL_best_times(i);
}
}
else break;
}
if (i + 1 < MAX_BEST_TIMES) {
Yap_best_times(0) += Yap_execution_time;
Yap_best_times(i + 1) = Yap_execution_time;
if (Yap_number_goals + 1 < MAX_BEST_TIMES)
Yap_number_goals++;
GLOBAL_best_times(0) += GLOBAL_execution_time;
GLOBAL_best_times(i + 1) = GLOBAL_execution_time;
if (GLOBAL_number_goals + 1 < MAX_BEST_TIMES)
GLOBAL_number_goals++;
}
}
@ -1031,7 +1031,7 @@ static inline long show_statistics_table_entries(void) {
tab_ent_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_tab_ent);
pg_hd = Pg_free_pg(GLOBAL_pages_tab_ent);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1040,15 +1040,15 @@ static inline long show_statistics_table_entries(void) {
}
pg_hd = PgHd_next(pg_hd);
}
TABLING_ERROR_CHECKING(statistics_table_entries, Pg_str_free(Yap_pages_tab_ent) != cont);
TABLING_ERROR_CHECKING(statistics_table_entries, Pg_str_free(GLOBAL_pages_tab_ent) != cont);
#endif /* DEBUG_TABLING */
fprintf(Yap_stdout, " Table entries: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_tab_ent) * sizeof(struct table_entry), Pg_pg_alloc(Yap_pages_tab_ent), Pg_str_in_use(Yap_pages_tab_ent));
Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry), Pg_pg_alloc(GLOBAL_pages_tab_ent), Pg_str_in_use(GLOBAL_pages_tab_ent));
#else
fprintf(Yap_stdout, " Table entries: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_tab_ent) * sizeof(struct table_entry), Pg_str_in_use(Yap_pages_tab_ent));
Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry), Pg_str_in_use(GLOBAL_pages_tab_ent));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_tab_ent) * sizeof(struct table_entry);
return Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry);
}
@ -1059,7 +1059,7 @@ static inline long show_statistics_subgoal_frames(void) {
sg_fr_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_sg_fr);
pg_hd = Pg_free_pg(GLOBAL_pages_sg_fr);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1068,15 +1068,15 @@ static inline long show_statistics_subgoal_frames(void) {
}
pg_hd = PgHd_next(pg_hd);
}
TABLING_ERROR_CHECKING(statistics_subgoal_frames, Pg_str_free(Yap_pages_sg_fr) != cont);
TABLING_ERROR_CHECKING(statistics_subgoal_frames, Pg_str_free(GLOBAL_pages_sg_fr) != cont);
#endif /* DEBUG_TABLING */
fprintf(Yap_stdout, " Subgoal frames: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_sg_fr) * sizeof(struct subgoal_frame), Pg_pg_alloc(Yap_pages_sg_fr), Pg_str_in_use(Yap_pages_sg_fr));
Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame), Pg_pg_alloc(GLOBAL_pages_sg_fr), Pg_str_in_use(GLOBAL_pages_sg_fr));
#else
fprintf(Yap_stdout, " Subgoal frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_sg_fr) * sizeof(struct subgoal_frame), Pg_str_in_use(Yap_pages_sg_fr));
Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame), Pg_str_in_use(GLOBAL_pages_sg_fr));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_sg_fr) * sizeof(struct subgoal_frame);
return Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame);
}
@ -1087,7 +1087,7 @@ static inline long show_statistics_dependency_frames(void) {
dep_fr_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_dep_fr);
pg_hd = Pg_free_pg(GLOBAL_pages_dep_fr);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1096,15 +1096,15 @@ static inline long show_statistics_dependency_frames(void) {
}
pg_hd = PgHd_next(pg_hd);
}
TABLING_ERROR_CHECKING(statistics_dependency_frames, Pg_str_free(Yap_pages_dep_fr) != cont);
TABLING_ERROR_CHECKING(statistics_dependency_frames, Pg_str_free(GLOBAL_pages_dep_fr) != cont);
#endif /* DEBUG_TABLING */
fprintf(Yap_stdout, " Dependency frames: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_dep_fr) * sizeof(struct dependency_frame), Pg_pg_alloc(Yap_pages_dep_fr), Pg_str_in_use(Yap_pages_dep_fr));
Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame), Pg_pg_alloc(GLOBAL_pages_dep_fr), Pg_str_in_use(GLOBAL_pages_dep_fr));
#else
fprintf(Yap_stdout, " Dependency frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_dep_fr) * sizeof(struct dependency_frame), Pg_str_in_use(Yap_pages_dep_fr));
Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame), Pg_str_in_use(GLOBAL_pages_dep_fr));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_dep_fr) * sizeof(struct dependency_frame);
return Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame);
}
@ -1115,7 +1115,7 @@ static inline long show_statistics_subgoal_trie_nodes(void) {
sg_node_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_sg_node);
pg_hd = Pg_free_pg(GLOBAL_pages_sg_node);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1124,15 +1124,15 @@ static inline long show_statistics_subgoal_trie_nodes(void) {
}
pg_hd = PgHd_next(pg_hd);
}
TABLING_ERROR_CHECKING(statistics_subgoal_trie_nodes, Pg_str_free(Yap_pages_sg_node) != cont);
TABLING_ERROR_CHECKING(statistics_subgoal_trie_nodes, Pg_str_free(GLOBAL_pages_sg_node) != cont);
#endif /* DEBUG_TABLING */
fprintf(Yap_stdout, " Subgoal trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_sg_node) * sizeof(struct subgoal_trie_node), Pg_pg_alloc(Yap_pages_sg_node), Pg_str_in_use(Yap_pages_sg_node));
Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node), Pg_pg_alloc(GLOBAL_pages_sg_node), Pg_str_in_use(GLOBAL_pages_sg_node));
#else
fprintf(Yap_stdout, " Subgoal trie nodes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_sg_node) * sizeof(struct subgoal_trie_node), Pg_str_in_use(Yap_pages_sg_node));
Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node), Pg_str_in_use(GLOBAL_pages_sg_node));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_sg_node) * sizeof(struct subgoal_trie_node);
return Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node);
}
@ -1143,7 +1143,7 @@ static inline long show_statistics_answer_trie_nodes(void) {
ans_node_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_ans_node);
pg_hd = Pg_free_pg(GLOBAL_pages_ans_node);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1152,15 +1152,15 @@ static inline long show_statistics_answer_trie_nodes(void) {
}
pg_hd = PgHd_next(pg_hd);
}
TABLING_ERROR_CHECKING(statistics_answer_trie_nodes, Pg_str_free(Yap_pages_ans_node) != cont);
TABLING_ERROR_CHECKING(statistics_answer_trie_nodes, Pg_str_free(GLOBAL_pages_ans_node) != cont);
#endif /* DEBUG_TABLING */
fprintf(Yap_stdout, " Answer trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_ans_node) * sizeof(struct answer_trie_node), Pg_pg_alloc(Yap_pages_ans_node), Pg_str_in_use(Yap_pages_ans_node));
Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node), Pg_pg_alloc(GLOBAL_pages_ans_node), Pg_str_in_use(GLOBAL_pages_ans_node));
#else
fprintf(Yap_stdout, " Answer trie nodes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_ans_node) * sizeof(struct answer_trie_node), Pg_str_in_use(Yap_pages_ans_node));
Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node), Pg_str_in_use(GLOBAL_pages_ans_node));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_ans_node) * sizeof(struct answer_trie_node);
return Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node);
}
@ -1171,7 +1171,7 @@ static inline long show_statistics_subgoal_trie_hashes(void) {
sg_hash_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_sg_hash);
pg_hd = Pg_free_pg(GLOBAL_pages_sg_hash);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1180,15 +1180,15 @@ static inline long show_statistics_subgoal_trie_hashes(void) {
}
pg_hd = PgHd_next(pg_hd);
}
TABLING_ERROR_CHECKING(statistics_subgoal_trie_hashes, Pg_str_free(Yap_pages_sg_hash) != cont);
TABLING_ERROR_CHECKING(statistics_subgoal_trie_hashes, Pg_str_free(GLOBAL_pages_sg_hash) != cont);
#endif /* DEBUG_TABLING */
fprintf(Yap_stdout, " Subgoal trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_sg_hash) * sizeof(struct subgoal_trie_hash), Pg_pg_alloc(Yap_pages_sg_hash), Pg_str_in_use(Yap_pages_sg_hash));
Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash), Pg_pg_alloc(GLOBAL_pages_sg_hash), Pg_str_in_use(GLOBAL_pages_sg_hash));
#else
fprintf(Yap_stdout, " Subgoal trie hashes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_sg_hash) * sizeof(struct subgoal_trie_hash), Pg_str_in_use(Yap_pages_sg_hash));
Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash), Pg_str_in_use(GLOBAL_pages_sg_hash));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_sg_hash) * sizeof(struct subgoal_trie_hash);
return Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash);
}
@ -1199,7 +1199,7 @@ static inline long show_statistics_answer_trie_hashes(void) {
ans_hash_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_ans_hash);
pg_hd = Pg_free_pg(GLOBAL_pages_ans_hash);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1208,15 +1208,15 @@ static inline long show_statistics_answer_trie_hashes(void) {
}
pg_hd = PgHd_next(pg_hd);
}
TABLING_ERROR_CHECKING(statistics_answer_trie_hashes, Pg_str_free(Yap_pages_ans_hash) != cont);
TABLING_ERROR_CHECKING(statistics_answer_trie_hashes, Pg_str_free(GLOBAL_pages_ans_hash) != cont);
#endif /* DEBUG_TABLING */
fprintf(Yap_stdout, " Answer trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_ans_hash) * sizeof(struct answer_trie_hash), Pg_pg_alloc(Yap_pages_ans_hash), Pg_str_in_use(Yap_pages_ans_hash));
Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash), Pg_pg_alloc(GLOBAL_pages_ans_hash), Pg_str_in_use(GLOBAL_pages_ans_hash));
#else
fprintf(Yap_stdout, " Answer trie hashes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_ans_hash) * sizeof(struct answer_trie_hash), Pg_str_in_use(Yap_pages_ans_hash));
Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash), Pg_str_in_use(GLOBAL_pages_ans_hash));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_ans_hash) * sizeof(struct answer_trie_hash);
return Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash);
}
@ -1227,7 +1227,7 @@ static inline long show_statistics_global_trie_nodes(void) {
gt_node_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_gt_node);
pg_hd = Pg_free_pg(GLOBAL_pages_gt_node);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1236,15 +1236,15 @@ static inline long show_statistics_global_trie_nodes(void) {
}
pg_hd = PgHd_next(pg_hd);
}
TABLING_ERROR_CHECKING(statistics_global_trie_nodes, Pg_str_free(Yap_pages_gt_node) != cont);
TABLING_ERROR_CHECKING(statistics_global_trie_nodes, Pg_str_free(GLOBAL_pages_gt_node) != cont);
#endif /* DEBUG_TABLING */
fprintf(Yap_stdout, " Global trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_gt_node) * sizeof(struct global_trie_node), Pg_pg_alloc(Yap_pages_gt_node), Pg_str_in_use(Yap_pages_gt_node));
Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node), Pg_pg_alloc(GLOBAL_pages_gt_node), Pg_str_in_use(GLOBAL_pages_gt_node));
#else
fprintf(Yap_stdout, " Global trie nodes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_gt_node) * sizeof(struct global_trie_node), Pg_str_in_use(Yap_pages_gt_node));
Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node), Pg_str_in_use(GLOBAL_pages_gt_node));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_gt_node) * sizeof(struct global_trie_node);
return Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node);
}
@ -1255,7 +1255,7 @@ static inline long show_statistics_global_trie_hashes(void) {
gt_hash_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_gt_hash);
pg_hd = Pg_free_pg(GLOBAL_pages_gt_hash);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1264,15 +1264,15 @@ static inline long show_statistics_global_trie_hashes(void) {
}
pg_hd = PgHd_next(pg_hd);
}
TABLING_ERROR_CHECKING(statistics_global_trie_hashes, Pg_str_free(Yap_pages_gt_hash) != cont);
TABLING_ERROR_CHECKING(statistics_global_trie_hashes, Pg_str_free(GLOBAL_pages_gt_hash) != cont);
#endif /* DEBUG_TABLING */
fprintf(Yap_stdout, " Global trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_gt_hash) * sizeof(struct global_trie_hash), Pg_pg_alloc(Yap_pages_gt_hash), Pg_str_in_use(Yap_pages_gt_hash));
Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash), Pg_pg_alloc(GLOBAL_pages_gt_hash), Pg_str_in_use(GLOBAL_pages_gt_hash));
#else
fprintf(Yap_stdout, " Global trie hashes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_gt_hash) * sizeof(struct global_trie_hash), Pg_str_in_use(Yap_pages_gt_hash));
Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash), Pg_str_in_use(GLOBAL_pages_gt_hash));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_gt_hash) * sizeof(struct global_trie_hash);
return Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash);
}
#endif /* TABLING */
@ -1285,7 +1285,7 @@ static inline long show_statistics_or_frames(void) {
or_fr_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_or_fr );
pg_hd = Pg_free_pg(GLOBAL_pages_or_fr );
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1294,15 +1294,15 @@ static inline long show_statistics_or_frames(void) {
}
pg_hd = PgHd_next(pg_hd);
}
YAPOR_ERROR_CHECKING(statistics_or_frames, Pg_str_free(Yap_pages_or_fr ) != cont);
YAPOR_ERROR_CHECKING(statistics_or_frames, Pg_str_free(GLOBAL_pages_or_fr ) != cont);
#endif /* DEBUG_YAPOR */
fprintf(Yap_stdout, " Or-frames: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_or_fr ) * sizeof(struct or_frame), Pg_pg_alloc(Yap_pages_or_fr ), Pg_str_in_use(Yap_pages_or_fr ));
Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame), Pg_pg_alloc(GLOBAL_pages_or_fr ), Pg_str_in_use(GLOBAL_pages_or_fr ));
#else
fprintf(Yap_stdout, " Or-frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_or_fr ) * sizeof(struct or_frame), Pg_str_in_use(Yap_pages_or_fr ));
Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame), Pg_str_in_use(GLOBAL_pages_or_fr ));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_or_fr ) * sizeof(struct or_frame);
return Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame);
}
@ -1313,7 +1313,7 @@ static inline long show_statistics_query_goal_solution_frames(void) {
qg_sol_fr_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_qg_sol_fr );
pg_hd = Pg_free_pg(GLOBAL_pages_qg_sol_fr );
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1322,15 +1322,15 @@ static inline long show_statistics_query_goal_solution_frames(void) {
}
pg_hd = PgHd_next(pg_hd);
}
YAPOR_ERROR_CHECKING(statistics_query_goal_solution_frames, Pg_str_free(Yap_pages_qg_sol_fr ) != cont);
YAPOR_ERROR_CHECKING(statistics_query_goal_solution_frames, Pg_str_free(GLOBAL_pages_qg_sol_fr ) != cont);
#endif /* DEBUG_YAPOR */
fprintf(Yap_stdout, " Query goal solution frames: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame), Pg_pg_alloc(Yap_pages_qg_sol_fr ), Pg_str_in_use(Yap_pages_qg_sol_fr ));
Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame), Pg_pg_alloc(GLOBAL_pages_qg_sol_fr ), Pg_str_in_use(GLOBAL_pages_qg_sol_fr ));
#else
fprintf(Yap_stdout, " Query goal solution frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame), Pg_str_in_use(Yap_pages_qg_sol_fr ));
Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame), Pg_str_in_use(GLOBAL_pages_qg_sol_fr ));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame);
return Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame);
}
@ -1341,7 +1341,7 @@ static inline long show_statistics_query_goal_answer_frames(void) {
qg_ans_fr_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_qg_ans_fr);
pg_hd = Pg_free_pg(GLOBAL_pages_qg_ans_fr);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1350,15 +1350,15 @@ static inline long show_statistics_query_goal_answer_frames(void) {
}
pg_hd = PgHd_next(pg_hd);
}
YAPOR_ERROR_CHECKING(statistics_query_goal_answer_frames, Pg_str_free(Yap_pages_qg_ans_fr) != cont);
YAPOR_ERROR_CHECKING(statistics_query_goal_answer_frames, Pg_str_free(GLOBAL_pages_qg_ans_fr) != cont);
#endif /* DEBUG_YAPOR */
fprintf(Yap_stdout, " Query goal answer frames: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_pg_alloc(Yap_pages_qg_ans_fr), Pg_str_in_use(Yap_pages_qg_ans_fr));
Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_pg_alloc(GLOBAL_pages_qg_ans_fr), Pg_str_in_use(GLOBAL_pages_qg_ans_fr));
#else
fprintf(Yap_stdout, " Query goal answer frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_str_in_use(Yap_pages_qg_ans_fr));
Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_str_in_use(GLOBAL_pages_qg_ans_fr));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
return Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
}
#endif /* YAPOR */
@ -1371,7 +1371,7 @@ static inline long show_statistics_suspension_frames(void) {
susp_fr_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_susp_fr);
pg_hd = Pg_free_pg(GLOBAL_pages_susp_fr);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1380,15 +1380,15 @@ static inline long show_statistics_suspension_frames(void) {
}
pg_hd = PgHd_next(pg_hd);
}
OPTYAP_ERROR_CHECKING(statistics_suspension_frames, Pg_str_free(Yap_pages_susp_fr) != cont);
OPTYAP_ERROR_CHECKING(statistics_suspension_frames, Pg_str_free(GLOBAL_pages_susp_fr) != cont);
#endif /* DEBUG_OPTYAP */
fprintf(Yap_stdout, " Suspension frames: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_susp_fr) * sizeof(struct suspension_frame), Pg_pg_alloc(Yap_pages_susp_fr), Pg_str_in_use(Yap_pages_susp_fr));
Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame), Pg_pg_alloc(GLOBAL_pages_susp_fr), Pg_str_in_use(GLOBAL_pages_susp_fr));
#else
fprintf(Yap_stdout, " Suspension frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_susp_fr) * sizeof(struct suspension_frame), Pg_str_in_use(Yap_pages_susp_fr));
Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame), Pg_str_in_use(GLOBAL_pages_susp_fr));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_susp_fr) * sizeof(struct suspension_frame);
return Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame);
}
@ -1400,7 +1400,7 @@ static inline long show_statistics_table_subgoal_solution_frames(void) {
tg_sol_fr_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_tg_sol_fr);
pg_hd = Pg_free_pg(GLOBAL_pages_tg_sol_fr);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1409,15 +1409,15 @@ static inline long show_statistics_table_subgoal_solution_frames(void) {
}
pg_hd = PgHd_next(pg_hd);
}
OPTYAP_ERROR_CHECKING(statistics_table_subgoal_solution_frames, Pg_str_free(Yap_pages_tg_sol_fr) != cont);
OPTYAP_ERROR_CHECKING(statistics_table_subgoal_solution_frames, Pg_str_free(GLOBAL_pages_tg_sol_fr) != cont);
#endif /* DEBUG_OPTYAP */
fprintf(Yap_stdout, " Table subgoal solution frames: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame), Pg_pg_alloc(Yap_pages_tg_sol_fr), Pg_str_in_use(Yap_pages_tg_sol_fr));
Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame), Pg_pg_alloc(GLOBAL_pages_tg_sol_fr), Pg_str_in_use(GLOBAL_pages_tg_sol_fr));
#else
fprintf(Yap_stdout, " Table subgoal solution frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame), Pg_str_in_use(Yap_pages_tg_sol_fr));
Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame), Pg_str_in_use(GLOBAL_pages_tg_sol_fr));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame);
return Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame);
}
@ -1428,7 +1428,7 @@ static inline long show_statistics_table_subgoal_answer_frames(void) {
tg_ans_fr_ptr aux_ptr;
long cont = 0;
pg_hd = Pg_free_pg(Yap_pages_tg_ans_fr);
pg_hd = Pg_free_pg(GLOBAL_pages_tg_ans_fr);
while (pg_hd) {
aux_ptr = PgHd_free_str(pg_hd);
while (aux_ptr) {
@ -1437,15 +1437,15 @@ static inline long show_statistics_table_subgoal_answer_frames(void) {
}
pg_hd = PgHd_next(pg_hd);
}
OPTYAP_ERROR_CHECKING(statistics_table_subgoal_answer_frames, Pg_str_free(Yap_pages_tg_ans_fr) != cont);
OPTYAP_ERROR_CHECKING(statistics_table_subgoal_answer_frames, Pg_str_free(GLOBAL_pages_tg_ans_fr) != cont);
#endif /* DEBUG_OPTYAP */
fprintf(Yap_stdout, " Table subgoal answer frames: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame), Pg_pg_alloc(Yap_pages_tg_ans_fr), Pg_str_in_use(Yap_pages_tg_ans_fr));
Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame), Pg_pg_alloc(GLOBAL_pages_tg_ans_fr), Pg_str_in_use(GLOBAL_pages_tg_ans_fr));
#else
fprintf(Yap_stdout, " Table subgoal answer frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame), Pg_str_in_use(Yap_pages_tg_ans_fr));
Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame), Pg_str_in_use(GLOBAL_pages_tg_ans_fr));
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
return Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
}
#endif /* TABLING_INNER_CUTS */
#endif /* YAPOR && TABLING */

View File

@ -224,72 +224,72 @@ struct global_optyap_data {
#endif /* TABLING */
};
#define Yap_max_pages (Yap_optyap_data.pages.max_pages)
#define Yap_pages_void (Yap_optyap_data.pages.void_pages)
#define Yap_pages_or_fr (Yap_optyap_data.pages.or_frame_pages)
#define Yap_pages_qg_sol_fr (Yap_optyap_data.pages.query_goal_solution_frame_pages)
#define Yap_pages_qg_ans_fr (Yap_optyap_data.pages.query_goal_answer_frame_pages)
#define Yap_pages_tg_sol_fr (Yap_optyap_data.pages.table_subgoal_solution_frame_pages)
#define Yap_pages_tg_ans_fr (Yap_optyap_data.pages.table_subgoal_answer_frame_pages)
#define Yap_pages_tab_ent (Yap_optyap_data.pages.table_entry_pages)
#define Yap_pages_sg_fr (Yap_optyap_data.pages.subgoal_frame_pages)
#define Yap_pages_dep_fr (Yap_optyap_data.pages.dependency_frame_pages)
#define Yap_pages_sg_node (Yap_optyap_data.pages.subgoal_trie_node_pages)
#define Yap_pages_ans_node (Yap_optyap_data.pages.answer_trie_node_pages)
#define Yap_pages_gt_node (Yap_optyap_data.pages.global_trie_node_pages)
#define Yap_pages_sg_hash (Yap_optyap_data.pages.subgoal_trie_hash_pages)
#define Yap_pages_ans_hash (Yap_optyap_data.pages.answer_trie_hash_pages)
#define Yap_pages_gt_hash (Yap_optyap_data.pages.global_trie_hash_pages)
#define Yap_pages_susp_fr (Yap_optyap_data.pages.suspension_frame_pages)
#define Yap_scheduler_loop (Yap_optyap_data.scheduler_loop)
#define Yap_delayed_release_load (Yap_optyap_data.delayed_release_load)
#define Yap_number_workers (Yap_optyap_data.number_workers)
#define Yap_worker_pid(worker) (Yap_optyap_data.worker_pid[worker])
#define Yap_master_worker (Yap_optyap_data.master_worker)
#define Yap_execution_time (Yap_optyap_data.execution_time)
#define Yap_best_times(time) (Yap_optyap_data.best_execution_times[time])
#define Yap_number_goals (Yap_optyap_data.number_of_executed_goals)
#define Yap_performance_mode (Yap_optyap_data.performance_mode)
#define GLOBAL_max_pages (Yap_optyap_data.pages.max_pages)
#define GLOBAL_pages_void (Yap_optyap_data.pages.void_pages)
#define GLOBAL_pages_or_fr (Yap_optyap_data.pages.or_frame_pages)
#define GLOBAL_pages_qg_sol_fr (Yap_optyap_data.pages.query_goal_solution_frame_pages)
#define GLOBAL_pages_qg_ans_fr (Yap_optyap_data.pages.query_goal_answer_frame_pages)
#define GLOBAL_pages_tg_sol_fr (Yap_optyap_data.pages.table_subgoal_solution_frame_pages)
#define GLOBAL_pages_tg_ans_fr (Yap_optyap_data.pages.table_subgoal_answer_frame_pages)
#define GLOBAL_pages_tab_ent (Yap_optyap_data.pages.table_entry_pages)
#define GLOBAL_pages_sg_fr (Yap_optyap_data.pages.subgoal_frame_pages)
#define GLOBAL_pages_dep_fr (Yap_optyap_data.pages.dependency_frame_pages)
#define GLOBAL_pages_sg_node (Yap_optyap_data.pages.subgoal_trie_node_pages)
#define GLOBAL_pages_ans_node (Yap_optyap_data.pages.answer_trie_node_pages)
#define GLOBAL_pages_gt_node (Yap_optyap_data.pages.global_trie_node_pages)
#define GLOBAL_pages_sg_hash (Yap_optyap_data.pages.subgoal_trie_hash_pages)
#define GLOBAL_pages_ans_hash (Yap_optyap_data.pages.answer_trie_hash_pages)
#define GLOBAL_pages_gt_hash (Yap_optyap_data.pages.global_trie_hash_pages)
#define GLOBAL_pages_susp_fr (Yap_optyap_data.pages.suspension_frame_pages)
#define GLOBAL_scheduler_loop (Yap_optyap_data.scheduler_loop)
#define GLOBAL_delayed_release_load (Yap_optyap_data.delayed_release_load)
#define GLOBAL_number_workers (Yap_optyap_data.number_workers)
#define GLOBAL_worker_pid(worker) (Yap_optyap_data.worker_pid[worker])
#define GLOBAL_master_worker (Yap_optyap_data.master_worker)
#define GLOBAL_execution_time (Yap_optyap_data.execution_time)
#define GLOBAL_best_times(time) (Yap_optyap_data.best_execution_times[time])
#define GLOBAL_number_goals (Yap_optyap_data.number_of_executed_goals)
#define GLOBAL_performance_mode (Yap_optyap_data.performance_mode)
#ifdef YAPOR_THREADS
#define Get_Yap_root_cp() offset_to_cptr(Yap_optyap_data.root_choice_point_offset)
#define Set_Yap_root_cp(bptr) (Yap_optyap_data.root_choice_point_offset = cptr_to_offset(bptr))
#define Get_GLOBAL_root_cp() offset_to_cptr(Yap_optyap_data.root_choice_point_offset)
#define Set_GLOBAL_root_cp(bptr) (Yap_optyap_data.root_choice_point_offset = cptr_to_offset(bptr))
#else
#define Yap_root_cp (Yap_optyap_data.root_choice_point)
#define Get_Yap_root_cp() (Yap_optyap_data.root_choice_point)
#define Set_Yap_root_cp(bptr) (Yap_optyap_data.root_choice_point = (bptr))
#define GLOBAL_root_cp (Yap_optyap_data.root_choice_point)
#define Get_GLOBAL_root_cp() (Yap_optyap_data.root_choice_point)
#define Set_GLOBAL_root_cp(bptr) (Yap_optyap_data.root_choice_point = (bptr))
#endif
#define Yap_root_or_fr (Yap_optyap_data.root_or_frame)
#define Yap_bm_present_workers (Yap_optyap_data.present_workers)
#define Yap_bm_idle_workers (Yap_optyap_data.idle_workers)
#define Yap_bm_root_cp_workers (Yap_optyap_data.root_cp_workers)
#define Yap_bm_invisible_workers (Yap_optyap_data.invisible_workers)
#define Yap_bm_requestable_workers (Yap_optyap_data.requestable_workers)
#define Yap_bm_executing_workers (Yap_optyap_data.executing_workers)
#define Yap_bm_finished_workers (Yap_optyap_data.finished_workers)
#define Yap_bm_pruning_workers (Yap_optyap_data.pruning_workers)
#define Yap_locks_bm_idle_workers (Yap_optyap_data.locks.bitmap_idle_workers)
#define Yap_locks_bm_root_cp_workers (Yap_optyap_data.locks.bitmap_root_cp_workers)
#define Yap_locks_bm_invisible_workers (Yap_optyap_data.locks.bitmap_invisible_workers)
#define Yap_locks_bm_requestable_workers (Yap_optyap_data.locks.bitmap_requestable_workers)
#define Yap_locks_bm_executing_workers (Yap_optyap_data.locks.bitmap_executing_workers)
#define Yap_locks_bm_finished_workers (Yap_optyap_data.locks.bitmap_finished_workers)
#define Yap_locks_bm_pruning_workers (Yap_optyap_data.locks.bitmap_pruning_workers)
#define Yap_locks_who_locked_heap (Yap_optyap_data.locks.who_locked_heap)
#define Yap_locks_heap_access (Yap_optyap_data.locks.heap_access)
#define Yap_locks_alloc_block (Yap_optyap_data.locks.alloc_block)
#define Yap_branch(worker, depth) (Yap_optyap_data.branch[worker][depth])
#define Yap_parallel_execution_mode (Yap_optyap_data.parallel_execution_mode)
#define Yap_answers (Yap_optyap_data.answers)
#define Yap_root_gt (Yap_optyap_data.root_global_trie)
#define Yap_root_tab_ent (Yap_optyap_data.root_table_entry)
#define Yap_first_sg_fr (Yap_optyap_data.first_subgoal_frame)
#define Yap_last_sg_fr (Yap_optyap_data.last_subgoal_frame)
#define Yap_check_sg_fr (Yap_optyap_data.check_subgoal_frame)
#define Yap_root_dep_fr (Yap_optyap_data.root_dependency_frame)
#define Yap_table_var_enumerator(index) (Yap_optyap_data.table_var_enumerator[index])
#define Yap_table_var_enumerator_addr(index) (Yap_optyap_data.table_var_enumerator + (index))
#define Yap_table_lock(index) (Yap_optyap_data.table_lock[index])
#define Yap_timestamp (Yap_optyap_data.timestamp)
#define GLOBAL_root_or_fr (Yap_optyap_data.root_or_frame)
#define GLOBAL_bm_present_workers (Yap_optyap_data.present_workers)
#define GLOBAL_bm_idle_workers (Yap_optyap_data.idle_workers)
#define GLOBAL_bm_root_cp_workers (Yap_optyap_data.root_cp_workers)
#define GLOBAL_bm_invisible_workers (Yap_optyap_data.invisible_workers)
#define GLOBAL_bm_requestable_workers (Yap_optyap_data.requestable_workers)
#define GLOBAL_bm_executing_workers (Yap_optyap_data.executing_workers)
#define GLOBAL_bm_finished_workers (Yap_optyap_data.finished_workers)
#define GLOBAL_bm_pruning_workers (Yap_optyap_data.pruning_workers)
#define GLOBAL_locks_bm_idle_workers (Yap_optyap_data.locks.bitmap_idle_workers)
#define GLOBAL_locks_bm_root_cp_workers (Yap_optyap_data.locks.bitmap_root_cp_workers)
#define GLOBAL_locks_bm_invisible_workers (Yap_optyap_data.locks.bitmap_invisible_workers)
#define GLOBAL_locks_bm_requestable_workers (Yap_optyap_data.locks.bitmap_requestable_workers)
#define GLOBAL_locks_bm_executing_workers (Yap_optyap_data.locks.bitmap_executing_workers)
#define GLOBAL_locks_bm_finished_workers (Yap_optyap_data.locks.bitmap_finished_workers)
#define GLOBAL_locks_bm_pruning_workers (Yap_optyap_data.locks.bitmap_pruning_workers)
#define GLOBAL_locks_who_locked_heap (Yap_optyap_data.locks.who_locked_heap)
#define GLOBAL_locks_heap_access (Yap_optyap_data.locks.heap_access)
#define GLOBAL_locks_alloc_block (Yap_optyap_data.locks.alloc_block)
#define GLOBAL_branch(worker, depth) (Yap_optyap_data.branch[worker][depth])
#define GLOBAL_parallel_execution_mode (Yap_optyap_data.parallel_execution_mode)
#define GLOBAL_answers (Yap_optyap_data.answers)
#define GLOBAL_root_gt (Yap_optyap_data.root_global_trie)
#define GLOBAL_root_tab_ent (Yap_optyap_data.root_table_entry)
#define GLOBAL_first_sg_fr (Yap_optyap_data.first_subgoal_frame)
#define GLOBAL_last_sg_fr (Yap_optyap_data.last_subgoal_frame)
#define GLOBAL_check_sg_fr (Yap_optyap_data.check_subgoal_frame)
#define GLOBAL_root_dep_fr (Yap_optyap_data.root_dependency_frame)
#define GLOBAL_table_var_enumerator(index) (Yap_optyap_data.table_var_enumerator[index])
#define GLOBAL_table_var_enumerator_addr(index) (Yap_optyap_data.table_var_enumerator + (index))
#define GLOBAL_table_lock(index) (Yap_optyap_data.table_lock[index])
#define GLOBAL_timestamp (Yap_optyap_data.timestamp)

View File

@ -97,15 +97,15 @@ static void share_private_nodes(int worker_q);
void make_root_choice_point(void) {
if (worker_id == 0) {
LOCAL_top_cp = Yap_root_cp = OrFr_node(Yap_root_or_fr) = B;
LOCAL_top_cp = GLOBAL_root_cp = OrFr_node(GLOBAL_root_or_fr) = B;
} else {
B = LOCAL_top_cp = Yap_root_cp;
B = LOCAL_top_cp = 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 = Yap_root_or_fr;
LOCAL_top_or_fr = Yap_root_or_fr;
B->cp_or_fr = GLOBAL_root_or_fr;
LOCAL_top_or_fr = GLOBAL_root_or_fr;
LOCAL_load = 0;
Set_LOCAL_prune_request(NULL);
BRANCH(worker_id, 0) = 0;
@ -125,7 +125,7 @@ void free_root_choice_point(void) {
#ifdef TABLING
LOCAL_top_cp_on_stack =
#endif /* TABLING */
LOCAL_top_cp = Yap_root_cp = OrFr_node(Yap_root_or_fr) = (choiceptr) Yap_LocalBase;
LOCAL_top_cp = GLOBAL_root_cp = OrFr_node(GLOBAL_root_or_fr) = (choiceptr) Yap_LocalBase;
return;
}
@ -135,7 +135,7 @@ int p_share_work(void) {
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
B == REMOTE_top_cp(worker_q) ||
(LOCAL_load <= Yap_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
(LOCAL_load <= GLOBAL_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;
@ -242,7 +242,7 @@ int q_share_work(int worker_p) {
/* make sharing request */
LOCK_WORKER(worker_p);
if (BITMAP_member(Yap_bm_idle_workers, 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);
@ -658,7 +658,7 @@ void share_private_nodes(int worker_q) {
#ifdef DEBUG_OPTYAP
{ dep_fr_ptr aux_dep_fr = LOCAL_top_dep_fr;
while(aux_dep_fr != Yap_root_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)) {

View File

@ -43,9 +43,9 @@ STD_PROTO(static inline void PUT_BUSY, (int));
static inline
void PUT_BUSY(int worker_num) {
LOCK(Yap_locks_bm_idle_workers);
BITMAP_delete(Yap_bm_idle_workers, worker_num);
UNLOCK(Yap_locks_bm_idle_workers);
LOCK(GLOBAL_locks_bm_idle_workers);
BITMAP_delete(GLOBAL_bm_idle_workers, worker_num);
UNLOCK(GLOBAL_locks_bm_idle_workers);
return;
}
@ -57,15 +57,15 @@ void PUT_BUSY(int worker_num) {
void make_root_choice_point(void) {
if (worker_id == 0) {
LOCAL_top_cp = Yap_root_cp = OrFr_node(Yap_root_or_fr) = B;
LOCAL_top_cp = GLOBAL_root_cp = OrFr_node(GLOBAL_root_or_fr) = B;
} else {
B = LOCAL_top_cp = Yap_root_cp;
B = LOCAL_top_cp = 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 = Yap_root_or_fr;
LOCAL_top_or_fr = Yap_root_or_fr;
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;
@ -86,7 +86,7 @@ int p_share_work(void) {
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
B == REMOTE_top_cp(worker_q) ||
(LOCAL_load <= Yap_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
(LOCAL_load <= GLOBAL_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;
@ -105,7 +105,7 @@ int p_share_work(void) {
return FALSE;
} else {
Yap_worker_pid(worker_q) = son;
GLOBAL_worker_pid(worker_q) = son;
LOCAL_share_request = MAX_WORKERS;
PUT_IN_REQUESTABLE(worker_id);
@ -129,7 +129,7 @@ int q_share_work(int worker_p) {
/* make sharing request */
LOCK_WORKER(worker_p);
if (BITMAP_member(Yap_bm_idle_workers, 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);

View File

@ -58,7 +58,7 @@ void prune_shared_branch(choiceptr prune_cp) {
LOCK_OR_FRAME(prune_or_fr);
members = OrFr_members(prune_or_fr);
BITMAP_delete(members, worker_id);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) && ltt == BRANCH_LTT(i, depth)) {
CUT_send_prune_request(i, prune_cp);
}
@ -139,7 +139,7 @@ void prune_shared_branch(choiceptr prune_cp) {
LOCK_OR_FRAME(leftmost_or_fr);
members = OrFr_members(leftmost_or_fr);
BITMAP_delete(members, worker_id);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i)) {
if (ltt >= BRANCH_LTT(i, depth)) {
CUT_send_prune_request(i, leftmost_cp->cp_b);
@ -231,7 +231,7 @@ void prune_shared_branch(choiceptr prune_cp) {
ltt = BRANCH_LTT(worker_id, depth);
LOCK_OR_FRAME(leftmost_or_fr);
BITMAP_difference(members, OrFr_members(leftmost_or_fr), members);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i)) {
if (ltt > BRANCH_LTT(i, depth)) {
CUT_send_prune_request(i, leftmost_cp->cp_b);

View File

@ -17,22 +17,22 @@
PBOp(getwork_first_time,e)
/* wait for a new parallel goal */
while (BITMAP_same(Yap_bm_present_workers, Yap_bm_finished_workers));
while (BITMAP_same(GLOBAL_bm_present_workers, GLOBAL_bm_finished_workers));
make_root_choice_point();
PUT_IN_EXECUTING(worker_id);
/* wait until everyone else is executing! */
while (! BITMAP_same(Yap_bm_present_workers, Yap_bm_executing_workers));
while (! BITMAP_same(GLOBAL_bm_present_workers, GLOBAL_bm_executing_workers));
SCHEDULER_GET_WORK();
shared_end:
PUT_IN_FINISHED(worker_id);
/* wait until everyone else is finished! */
while (! BITMAP_same(Yap_bm_present_workers, Yap_bm_finished_workers));
while (! BITMAP_same(GLOBAL_bm_present_workers, GLOBAL_bm_finished_workers));
PUT_OUT_EXECUTING(worker_id);
if (worker_id == 0) {
finish_yapor();
free_root_choice_point();
/* wait until no one is executing */
while (! BITMAP_empty(Yap_bm_executing_workers));
while (! BITMAP_empty(GLOBAL_bm_executing_workers));
goto fail;
} else {
PREG = GETWORK_FIRST_TIME;

View File

@ -88,7 +88,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
#define PUT_YAMOP_SEQ(INST) (INST)->u.Otapl.or_arg |= YAMOP_SEQ_FLAG
#define PUT_YAMOP_CUT(INST) (INST)->u.Otapl.or_arg |= YAMOP_CUT_FLAG
#define BRANCH(WORKER, DEPTH) Yap_branch(WORKER, DEPTH)
#define BRANCH(WORKER, DEPTH) GLOBAL_branch(WORKER, DEPTH)
#define BRANCH_LTT(WORKER, DEPTH) (BRANCH(WORKER, DEPTH) & YAMOP_LTT_BITS)
#define BRANCH_CUT(WORKER, DEPTH) (BRANCH(WORKER, DEPTH) & YAMOP_CUT_FLAG)
@ -108,7 +108,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
** Engine Macros **
** ----------------------- */
#define worker_offset(X) ((Yap_number_workers + X - worker_id) % Yap_number_workers * Yap_worker_area_size)
#define worker_offset(X) ((GLOBAL_number_workers + X - worker_id) % GLOBAL_number_workers * Yap_worker_area_size)
#define LOCK_OR_FRAME(fr) LOCK(OrFr_lock(fr))
#define UNLOCK_OR_FRAME(fr) UNLOCK(OrFr_lock(fr))
@ -177,7 +177,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
}
#define CUT_wait_leftmost() \
if (Yap_parallel_execution_mode) { \
if (GLOBAL_parallel_execution_mode) { \
/* parallel execution mode --> wait until leftmost */ \
int i, loop, depth, ltt; \
bitmap members; \
@ -191,13 +191,13 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
SCH_check_requests(); \
BITMAP_copy(members, OrFr_members(leftmost_or_fr)); \
BITMAP_delete(members, worker_id); \
for (i = 0; i < Yap_number_workers; i++) { \
for (i = 0; i < GLOBAL_number_workers; i++) { \
/* not leftmost in current frame if there is a */ \
/* worker in a left branch and it is not idle or */ \
/* if it is idle it is in a younger node */ \
if (BITMAP_member(members, i) && \
BRANCH_LTT(i, depth) > ltt && \
(! BITMAP_member(Yap_bm_idle_workers, i) || \
(! BITMAP_member(GLOBAL_bm_idle_workers, i) || \
leftmost_or_fr != REMOTE_top_or_fr(i))) { \
loop = TRUE; \
break; \
@ -205,7 +205,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
} \
} while (loop); \
leftmost_or_fr = OrFr_nearest_leftnode(leftmost_or_fr); \
} while (leftmost_or_fr != Yap_root_or_fr); \
} while (leftmost_or_fr != GLOBAL_root_or_fr); \
}
@ -216,27 +216,27 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
static inline
void PUT_IN_EXECUTING(int w) {
LOCK(Yap_locks_bm_executing_workers);
BITMAP_insert(Yap_bm_executing_workers, w);
UNLOCK(Yap_locks_bm_executing_workers);
LOCK(GLOBAL_locks_bm_executing_workers);
BITMAP_insert(GLOBAL_bm_executing_workers, w);
UNLOCK(GLOBAL_locks_bm_executing_workers);
return;
}
static inline
void PUT_OUT_EXECUTING(int w) {
LOCK(Yap_locks_bm_executing_workers);
BITMAP_delete(Yap_bm_executing_workers, w);
UNLOCK(Yap_locks_bm_executing_workers);
LOCK(GLOBAL_locks_bm_executing_workers);
BITMAP_delete(GLOBAL_bm_executing_workers, w);
UNLOCK(GLOBAL_locks_bm_executing_workers);
return;
}
static inline
void PUT_IN_FINISHED(int w) {
LOCK(Yap_locks_bm_finished_workers);
BITMAP_insert(Yap_bm_finished_workers, w);
UNLOCK(Yap_locks_bm_finished_workers);
LOCK(GLOBAL_locks_bm_finished_workers);
BITMAP_insert(GLOBAL_bm_finished_workers, w);
UNLOCK(GLOBAL_locks_bm_finished_workers);
return;
}
@ -244,18 +244,18 @@ void PUT_IN_FINISHED(int w) {
#ifdef TABLING_INNER_CUTS
static inline
void PUT_IN_PRUNING(int w) {
LOCK(Yap_locks_bm_pruning_workers);
BITMAP_insert(Yap_bm_pruning_workers, w);
UNLOCK(Yap_locks_bm_pruning_workers);
LOCK(GLOBAL_locks_bm_pruning_workers);
BITMAP_insert(GLOBAL_bm_pruning_workers, w);
UNLOCK(GLOBAL_locks_bm_pruning_workers);
return;
}
static inline
void PUT_OUT_PRUNING(int w) {
LOCK(Yap_locks_bm_pruning_workers);
BITMAP_delete(Yap_bm_pruning_workers, w);
UNLOCK(Yap_locks_bm_pruning_workers);
LOCK(GLOBAL_locks_bm_pruning_workers);
BITMAP_delete(GLOBAL_bm_pruning_workers, w);
UNLOCK(GLOBAL_locks_bm_pruning_workers);
return;
}
#endif /* TABLING_INNER_CUTS */
@ -268,18 +268,18 @@ void PUT_OUT_PRUNING(int w) {
static inline
void PUT_IN_REQUESTABLE(int p) {
LOCK(Yap_locks_bm_requestable_workers);
BITMAP_insert(Yap_bm_requestable_workers, p);
UNLOCK(Yap_locks_bm_requestable_workers);
LOCK(GLOBAL_locks_bm_requestable_workers);
BITMAP_insert(GLOBAL_bm_requestable_workers, p);
UNLOCK(GLOBAL_locks_bm_requestable_workers);
return;
}
static inline
void PUT_OUT_REQUESTABLE(int p) {
LOCK(Yap_locks_bm_requestable_workers);
BITMAP_delete(Yap_bm_requestable_workers, p);
UNLOCK(Yap_locks_bm_requestable_workers);
LOCK(GLOBAL_locks_bm_requestable_workers);
BITMAP_delete(GLOBAL_bm_requestable_workers, p);
UNLOCK(GLOBAL_locks_bm_requestable_workers);
return;
}
@ -381,7 +381,7 @@ int CUT_last_worker_left_pending_prune(or_fr_ptr or_frame) {
ltt = OrFr_pend_prune_ltt(or_frame);
members = OrFr_members(or_frame);
BITMAP_delete(members, worker_id);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) && BRANCH_LTT(i, depth) > ltt)
return FALSE;
}
@ -404,7 +404,7 @@ or_fr_ptr CUT_leftmost_or_frame(void) {
ltt = BRANCH_LTT(worker_id, depth);
BITMAP_difference(members, OrFr_members(leftmost_or_fr), members);
if (members)
for (i = 0; i < Yap_number_workers; i++)
for (i = 0; i < GLOBAL_number_workers; i++)
if (BITMAP_member(members, i) && BRANCH_LTT(i, depth) > ltt)
goto update_nearest_leftnode_data;
BITMAP_copy(members, OrFr_members(leftmost_or_fr));
@ -438,12 +438,12 @@ or_fr_ptr CUT_leftmost_until(or_fr_ptr start_or_fr, int until_depth) {
leftmost_or_fr = OrFr_nearest_leftnode(start_or_fr);
depth = OrFr_depth(leftmost_or_fr);
if (depth > until_depth) {
BITMAP_copy(prune_members, Yap_bm_pruning_workers);
BITMAP_copy(prune_members, GLOBAL_bm_pruning_workers);
BITMAP_delete(prune_members, worker_id);
ltt = BRANCH_LTT(worker_id, depth);
BITMAP_intersection(members, prune_members, OrFr_members(leftmost_or_fr));
if (members) {
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) &&
BRANCH_LTT(i, depth) > ltt &&
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i)))
@ -458,7 +458,7 @@ or_fr_ptr CUT_leftmost_until(or_fr_ptr start_or_fr, int until_depth) {
ltt = BRANCH_LTT(worker_id, depth);
BITMAP_intersection(members, prune_members, OrFr_members(leftmost_or_fr));
if (members) {
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) &&
BRANCH_LTT(i, depth) > ltt &&
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i))) {

View File

@ -87,15 +87,15 @@ reset_trail(tr_fr_ptr tr_top, tr_fr_ptr trp)
void make_root_choice_point(void) {
if (worker_id == 0) {
LOCAL_top_cp = Yap_root_cp = OrFr_node(Yap_root_or_fr) = B;
LOCAL_top_cp = GLOBAL_root_cp = OrFr_node(GLOBAL_root_or_fr) = B;
B->cp_h = H0;
B->cp_ap = GETWORK;
B->cp_or_fr = Yap_root_or_fr;
B->cp_or_fr = GLOBAL_root_or_fr;
} else {
B = LOCAL_top_cp = Yap_root_cp;
B = LOCAL_top_cp = GLOBAL_root_cp;
TR = B->cp_tr;
}
LOCAL_top_or_fr = Yap_root_or_fr;
LOCAL_top_or_fr = GLOBAL_root_or_fr;
LOCAL_load = 0;
LOCAL_prune_request = NULL;
BRANCH(worker_id, 0) = 0;
@ -121,7 +121,7 @@ void p_share_work(void) {
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
B == REMOTE_top_cp(worker_q) ||
(LOCAL_load <= Yap_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
(LOCAL_load <= GLOBAL_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;
@ -163,7 +163,7 @@ int q_share_work(int worker_p) {
/* make sharing request */
LOCK_WORKER(worker_p);
if (BITMAP_member(Yap_bm_idle_workers, 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);

View File

@ -65,36 +65,36 @@ void PUT_NO_WORK_IN_UPPER_NODES(void) {
static inline
void PUT_IDLE(int worker_num) {
LOCK(Yap_locks_bm_idle_workers);
BITMAP_insert(Yap_bm_idle_workers, worker_num);
UNLOCK(Yap_locks_bm_idle_workers);
LOCK(GLOBAL_locks_bm_idle_workers);
BITMAP_insert(GLOBAL_bm_idle_workers, worker_num);
UNLOCK(GLOBAL_locks_bm_idle_workers);
return;
}
static inline
void PUT_BUSY(int worker_num) {
LOCK(Yap_locks_bm_idle_workers);
BITMAP_delete(Yap_bm_idle_workers, worker_num);
UNLOCK(Yap_locks_bm_idle_workers);
LOCK(GLOBAL_locks_bm_idle_workers);
BITMAP_delete(GLOBAL_bm_idle_workers, worker_num);
UNLOCK(GLOBAL_locks_bm_idle_workers);
return;
}
static inline
void PUT_IN_ROOT_NODE(int worker_num) {
LOCK(Yap_locks_bm_root_cp_workers);
BITMAP_insert(Yap_bm_root_cp_workers, worker_num);
UNLOCK(Yap_locks_bm_root_cp_workers);
LOCK(GLOBAL_locks_bm_root_cp_workers);
BITMAP_insert(GLOBAL_bm_root_cp_workers, worker_num);
UNLOCK(GLOBAL_locks_bm_root_cp_workers);
return;
}
static inline
void PUT_OUT_ROOT_NODE(int worker_num) {
LOCK(Yap_locks_bm_root_cp_workers);
BITMAP_delete(Yap_bm_root_cp_workers, worker_num);
UNLOCK(Yap_locks_bm_root_cp_workers);
LOCK(GLOBAL_locks_bm_root_cp_workers);
BITMAP_delete(GLOBAL_bm_root_cp_workers, worker_num);
UNLOCK(GLOBAL_locks_bm_root_cp_workers);
return;
}
@ -215,21 +215,21 @@ int get_work(void) {
SCH_refuse_share_request_if_any();
counter = 0;
BITMAP_difference(stable_busy, OrFr_members(LOCAL_top_or_fr), Yap_bm_idle_workers);
BITMAP_difference(stable_busy, OrFr_members(LOCAL_top_or_fr), GLOBAL_bm_idle_workers);
while (1) {
while (BITMAP_subset(Yap_bm_idle_workers, OrFr_members(LOCAL_top_or_fr)) &&
Get_LOCAL_top_cp() != Get_Yap_root_cp()) {
while (BITMAP_subset(GLOBAL_bm_idle_workers, OrFr_members(LOCAL_top_or_fr)) &&
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 (Get_LOCAL_top_cp() == Get_Yap_root_cp()) {
if (! BITMAP_member(Yap_bm_root_cp_workers, worker_id))
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(Yap_bm_idle_workers, Yap_bm_root_cp_workers) &&
BITMAP_same(Yap_bm_idle_workers, Yap_bm_present_workers)) {
if (BITMAP_same(GLOBAL_bm_idle_workers, GLOBAL_bm_root_cp_workers) &&
BITMAP_same(GLOBAL_bm_idle_workers, GLOBAL_bm_present_workers)) {
/* All workers are idle in root choicepoint. Execution
must finish as there is no available computation. */
return FALSE;
@ -247,15 +247,15 @@ int get_work(void) {
PUT_BUSY(worker_id);
return TRUE;
}
if (++counter == Yap_scheduler_loop) {
if (++counter == GLOBAL_scheduler_loop) {
if (search_for_hidden_shared_work(stable_busy)) {
PUT_BUSY(worker_id);
return TRUE;
}
counter = 0;
BITMAP_difference(stable_busy, OrFr_members(LOCAL_top_or_fr), Yap_bm_idle_workers);
BITMAP_difference(stable_busy, OrFr_members(LOCAL_top_or_fr), GLOBAL_bm_idle_workers);
} else {
BITMAP_minus(stable_busy, Yap_bm_idle_workers);
BITMAP_minus(stable_busy, GLOBAL_bm_idle_workers);
}
}
}
@ -347,7 +347,7 @@ int move_up_one_node(or_fr_ptr nearest_livenode) {
if (OrFr_suspensions(LOCAL_top_or_fr)) {
susp_fr_ptr resume_fr;
#ifdef TIMESTAMP_CHECK
resume_fr = suspension_frame_to_resume(LOCAL_top_or_fr, ++Yap_timestamp);
resume_fr = suspension_frame_to_resume(LOCAL_top_or_fr, ++GLOBAL_timestamp);
#else
resume_fr = suspension_frame_to_resume(LOCAL_top_or_fr);
#endif /* TIMESTAMP_CHECK */
@ -528,18 +528,18 @@ int get_work_below(void){
bitmap busy_below, idle_below;
worker_p = -1;
big_load = Yap_delayed_release_load ;
BITMAP_difference(busy_below, OrFr_members(LOCAL_top_or_fr), Yap_bm_idle_workers);
big_load = GLOBAL_delayed_release_load ;
BITMAP_difference(busy_below, OrFr_members(LOCAL_top_or_fr), GLOBAL_bm_idle_workers);
BITMAP_difference(idle_below, OrFr_members(LOCAL_top_or_fr), busy_below);
BITMAP_delete(idle_below, worker_id);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
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))
return FALSE;
/* choose the worker with highest load */
for (i = 0 ; i < Yap_number_workers; i++) {
for (i = 0 ; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(busy_below ,i) && REMOTE_load(i) > big_load) {
worker_p = i;
big_load = REMOTE_load(i);
@ -558,14 +558,14 @@ int get_work_above(void){
bitmap visible_busy_above, visible_idle_above;
worker_p = -1;
big_load = Yap_delayed_release_load ;
BITMAP_difference(visible_busy_above, Yap_bm_present_workers, OrFr_members(LOCAL_top_or_fr));
BITMAP_minus(visible_busy_above, Yap_bm_invisible_workers);
big_load = GLOBAL_delayed_release_load ;
BITMAP_difference(visible_busy_above, GLOBAL_bm_present_workers, OrFr_members(LOCAL_top_or_fr));
BITMAP_minus(visible_busy_above, GLOBAL_bm_invisible_workers);
BITMAP_copy(visible_idle_above, visible_busy_above);
BITMAP_minus(visible_busy_above, Yap_bm_idle_workers);
BITMAP_and(visible_idle_above, Yap_bm_idle_workers);
BITMAP_minus(visible_busy_above, GLOBAL_bm_idle_workers);
BITMAP_and(visible_idle_above, GLOBAL_bm_idle_workers);
BITMAP_insert(visible_busy_above, worker_id);
for (i = 0 ; i < Yap_number_workers; i++) {
for (i = 0 ; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(visible_idle_above, i))
BITMAP_minus(visible_busy_above, OrFr_members(REMOTE_top_or_fr(i)));
}
@ -573,7 +573,7 @@ int get_work_above(void){
return FALSE;
BITMAP_delete(visible_busy_above, worker_id);
/* choose the worker with higher load */
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(visible_busy_above ,i) && REMOTE_load(i) > big_load) {
worker_p = i;
big_load = REMOTE_load(i);
@ -582,14 +582,14 @@ int get_work_above(void){
if (worker_p == -1)
return FALSE;
/* put workers invisibles */
LOCK(Yap_locks_bm_invisible_workers);
if (BITMAP_member(Yap_bm_invisible_workers, worker_p)) {
UNLOCK(Yap_locks_bm_invisible_workers);
LOCK(GLOBAL_locks_bm_invisible_workers);
if (BITMAP_member(GLOBAL_bm_invisible_workers, worker_p)) {
UNLOCK(GLOBAL_locks_bm_invisible_workers);
return FALSE;
}
BITMAP_insert(Yap_bm_invisible_workers, worker_id);
BITMAP_insert(Yap_bm_invisible_workers, worker_p);
UNLOCK(Yap_locks_bm_invisible_workers);
BITMAP_insert(GLOBAL_bm_invisible_workers, worker_id);
BITMAP_insert(GLOBAL_bm_invisible_workers, worker_p);
UNLOCK(GLOBAL_locks_bm_invisible_workers);
/* move up to cp with worker_p */
do {
if (! move_up_one_node(NULL)) {
@ -597,10 +597,10 @@ int get_work_above(void){
}
} while (! BITMAP_member(OrFr_members(LOCAL_top_or_fr), worker_p));
/* put workers visibles */
LOCK(Yap_locks_bm_invisible_workers);
BITMAP_delete(Yap_bm_invisible_workers, worker_id);
BITMAP_delete(Yap_bm_invisible_workers, worker_p);
UNLOCK(Yap_locks_bm_invisible_workers);
LOCK(GLOBAL_locks_bm_invisible_workers);
BITMAP_delete(GLOBAL_bm_invisible_workers, worker_id);
BITMAP_delete(GLOBAL_bm_invisible_workers, worker_p);
UNLOCK(GLOBAL_locks_bm_invisible_workers);
return (q_share_work(worker_p));
}
@ -610,11 +610,11 @@ int find_a_better_position(void){
CACHE_REGS
int i;
bitmap busy_above, idle_above;
BITMAP_difference(busy_above, Yap_bm_present_workers, OrFr_members(LOCAL_top_or_fr));
BITMAP_difference(busy_above, GLOBAL_bm_present_workers, OrFr_members(LOCAL_top_or_fr));
BITMAP_copy(idle_above, busy_above);
BITMAP_minus(busy_above, Yap_bm_idle_workers);
BITMAP_and(idle_above, Yap_bm_idle_workers);
for (i = 0; i < Yap_number_workers; i++) {
BITMAP_minus(busy_above, GLOBAL_bm_idle_workers);
BITMAP_and(idle_above, GLOBAL_bm_idle_workers);
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(idle_above, i)) {
if (BITMAP_empty(busy_above))
break;
@ -640,17 +640,17 @@ int search_for_hidden_shared_work(bitmap stable_busy){
CACHE_REGS
int i;
bitmap invisible_work, idle_below;
BITMAP_intersection(invisible_work, stable_busy, Yap_bm_requestable_workers);
BITMAP_intersection(idle_below, OrFr_members(LOCAL_top_or_fr), Yap_bm_idle_workers);
BITMAP_intersection(invisible_work, stable_busy, GLOBAL_bm_requestable_workers);
BITMAP_intersection(idle_below, OrFr_members(LOCAL_top_or_fr), GLOBAL_bm_idle_workers);
BITMAP_delete(idle_below, worker_id);
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
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))
return FALSE;
/* choose the first available worker */
for (i = 0; i < Yap_number_workers; i++ ) {
for (i = 0; i < GLOBAL_number_workers; i++ ) {
if (BITMAP_member(invisible_work ,i))
break;
}

View File

@ -53,21 +53,21 @@ static void share_private_nodes(int worker_q);
void make_root_choice_point(void) {
CACHE_REGS
if (worker_id == 0) {
SetOrFr_node(Yap_root_or_fr, B);
SetOrFr_node(GLOBAL_root_or_fr, B);
Set_LOCAL_top_cp(B);
Set_Yap_root_cp(B);
Set_GLOBAL_root_cp(B);
} else {
choiceptr imageB;
Set_LOCAL_top_cp(Get_Yap_root_cp());
B = Get_Yap_root_cp();
Set_LOCAL_top_cp(Get_GLOBAL_root_cp());
B = Get_GLOBAL_root_cp();
/*
this is tricky, we need to get the B from some other stack
and convert back to our own stack;
*/
LOCAL_OldLCL0 = LCL0;
LCL0 = REMOTE_ThreadHandle(0).current_yaam_regs->LCL0_;
imageB = Get_Yap_root_cp();
imageB = Get_GLOBAL_root_cp();
/* we know B */
B->cp_tr = TR =
(tr_fr_ptr)((CELL)(imageB->cp_tr)+((CELL)LOCAL_OldLCL0-(CELL)LCL0));
@ -75,8 +75,8 @@ void make_root_choice_point(void) {
}
B->cp_h = H0;
B->cp_ap = GETWORK;
B->cp_or_fr = Yap_root_or_fr;
LOCAL_top_or_fr = Yap_root_or_fr;
B->cp_or_fr = GLOBAL_root_or_fr;
LOCAL_top_or_fr = GLOBAL_root_or_fr;
LOCAL_load = 0;
Set_LOCAL_prune_request(NULL);
BRANCH(worker_id, 0) = 0;
@ -97,9 +97,9 @@ void free_root_choice_point(void) {
#ifdef TABLING
Set_LOCAL_top_cp_on_stack((choiceptr) Yap_LocalBase);
#endif /* TABLING */
Set_Yap_root_cp((choiceptr) Yap_LocalBase);
Set_GLOBAL_root_cp((choiceptr) Yap_LocalBase);
Set_LOCAL_top_cp((choiceptr) Yap_LocalBase);
SetOrFr_node(Yap_root_or_fr, (choiceptr) Yap_LocalBase);
SetOrFr_node(GLOBAL_root_or_fr, (choiceptr) Yap_LocalBase);
return;
}
@ -110,7 +110,7 @@ int p_share_work() {
if (! BITMAP_member(OrFr_members(REMOTE_top_or_fr(worker_q)), worker_id) ||
B == REMOTE_top_cp(worker_q) ||
(LOCAL_load <= Yap_delayed_release_load && OrFr_nearest_livenode(LOCAL_top_or_fr) == NULL)) {
(LOCAL_load <= GLOBAL_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;
@ -157,7 +157,7 @@ int q_share_work(int worker_p) {
/* make sharing request */
LOCK_WORKER(worker_p);
if (BITMAP_member(Yap_bm_idle_workers, 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);
@ -497,7 +497,7 @@ void share_private_nodes(int worker_q) {
#ifdef DEBUG_OPTYAP
{ dep_fr_ptr aux_dep_fr = LOCAL_top_dep_fr;
while(aux_dep_fr != Yap_root_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)) {

View File

@ -442,7 +442,7 @@
find_leader_node(leader_cp, leader_dep_on_stack);
store_consumer_node(tab_ent, sg_fr, leader_cp, leader_dep_on_stack);
#ifdef DEBUG_OPTYAP
if (Yap_parallel_execution_mode) {
if (GLOBAL_parallel_execution_mode) {
choiceptr aux_cp;
aux_cp = B;
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
@ -553,7 +553,7 @@
find_leader_node(leader_cp, leader_dep_on_stack);
store_consumer_node(tab_ent, sg_fr, leader_cp, leader_dep_on_stack);
#ifdef DEBUG_OPTYAP
if (Yap_parallel_execution_mode) {
if (GLOBAL_parallel_execution_mode) {
choiceptr aux_cp;
aux_cp = B;
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
@ -664,7 +664,7 @@
find_leader_node(leader_cp, leader_dep_on_stack);
store_consumer_node(tab_ent, sg_fr, leader_cp, leader_dep_on_stack);
#ifdef DEBUG_OPTYAP
if (Yap_parallel_execution_mode) {
if (GLOBAL_parallel_execution_mode) {
choiceptr aux_cp;
aux_cp = B;
while (YOUNGER_CP(aux_cp, Get_LOCAL_top_cp_on_stack()))
@ -878,7 +878,7 @@
/* new answer */
#ifdef TABLING_INNER_CUTS
/* check for potencial prunings */
if (! BITMAP_empty(Yap_bm_pruning_workers)) {
if (! BITMAP_empty(GLOBAL_bm_pruning_workers)) {
int until_depth, depth;
until_depth = OrFr_depth(SgFr_gen_top_or_fr(sg_fr));
@ -888,12 +888,12 @@
bitmap prune_members, members;
or_fr_ptr leftmost_or_fr, or_fr, nearest_or_fr;
BITMAP_copy(prune_members, Yap_bm_pruning_workers);
BITMAP_copy(prune_members, GLOBAL_bm_pruning_workers);
BITMAP_delete(prune_members, worker_id);
ltt = BRANCH_LTT(worker_id, depth);
BITMAP_intersection(members, prune_members, OrFr_members(LOCAL_top_or_fr));
if (members) {
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) &&
BRANCH_LTT(i, depth) > ltt &&
EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp(), REMOTE_pruning_scope(i))) {
@ -939,7 +939,7 @@
ltt = BRANCH_LTT(worker_id, depth);
BITMAP_intersection(members, prune_members, OrFr_members(leftmost_or_fr));
if (members) {
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) &&
BRANCH_LTT(i, depth) > ltt &&
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i)))
@ -954,7 +954,7 @@
ltt = BRANCH_LTT(worker_id, depth);
BITMAP_intersection(members, prune_members, OrFr_members(leftmost_or_fr));
if (members) {
for (i = 0; i < Yap_number_workers; i++) {
for (i = 0; i < GLOBAL_number_workers; i++) {
if (BITMAP_member(members, i) &&
BRANCH_LTT(i, depth) > ltt &&
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i))) {
@ -1213,7 +1213,7 @@
}
#endif /* YAPOR */
#ifdef DEBUG_OPTYAP
if (Yap_parallel_execution_mode) {
if (GLOBAL_parallel_execution_mode) {
choiceptr aux_cp;
OPTYAP_ERROR_CHECKING(completion, YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()));
aux_cp = chain_cp;
@ -1284,7 +1284,7 @@
}
#endif /* YAPOR */
#ifdef DEBUG_OPTYAP
if (Yap_parallel_execution_mode) {
if (GLOBAL_parallel_execution_mode) {
choiceptr aux_cp;
OPTYAP_ERROR_CHECKING(completion, YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()));
aux_cp = chain_cp;
@ -1381,7 +1381,7 @@
if (SCH_top_shared_cp(B)) {
#ifdef TIMESTAMP_CHECK
timestamp = ++Yap_timestamp;
timestamp = ++GLOBAL_timestamp;
#endif /* TIMESTAMP_CHECK */
entry_owners = OrFr_owners(LOCAL_top_or_fr);
}
@ -1409,7 +1409,7 @@
UNLOCK(DepFr_lock(dep_fr));
#ifdef DEBUG_OPTYAP
if (Yap_parallel_execution_mode) {
if (GLOBAL_parallel_execution_mode) {
choiceptr aux_cp;
OPTYAP_ERROR_CHECKING(completion, Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack());
aux_cp = DepFr_cons_cp(dep_fr);
@ -1434,7 +1434,7 @@
}
#endif /* YAPOR */
#ifdef DEBUG_OPTYAP
if (Yap_parallel_execution_mode) {
if (GLOBAL_parallel_execution_mode) {
choiceptr aux_cp;
OPTYAP_ERROR_CHECKING(completion, YOUNGER_CP(Get_LOCAL_top_cp(), Get_LOCAL_top_cp_on_stack()));
aux_cp = DepFr_cons_cp(dep_fr);

View File

@ -111,10 +111,10 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
#define MakeTableVarTerm(INDEX) ((INDEX) << NumberOfLowTagBits)
#define VarIndexOfTableTerm(TERM) (((unsigned int) (TERM)) >> NumberOfLowTagBits)
#define VarIndexOfTerm(TERM) \
((((CELL) (TERM)) - Yap_table_var_enumerator(0)) / sizeof(CELL))
((((CELL) (TERM)) - GLOBAL_table_var_enumerator(0)) / sizeof(CELL))
#define IsTableVarTerm(TERM) \
((CELL) (TERM)) >= Yap_table_var_enumerator(0) && \
((CELL) (TERM)) <= Yap_table_var_enumerator(MAX_TABLE_VARS - 1)
((CELL) (TERM)) >= GLOBAL_table_var_enumerator(0) && \
((CELL) (TERM)) <= GLOBAL_table_var_enumerator(MAX_TABLE_VARS - 1)
#ifdef TRIE_COMPACT_PAIRS
#define PairTermMark NULL
#define CompactPairInit AbsPair((Term *) 0)
@ -154,8 +154,8 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
#define IS_GLOBAL_TRIE_HASH(NODE) (TrNode_entry(NODE) == GLOBAL_TRIE_HASH_MARK)
#define HASH_TABLE_LOCK(NODE) ((((unsigned long int) (NODE)) >> 5) & (TABLE_LOCK_BUCKETS - 1))
#define LOCK_TABLE(NODE) LOCK(Yap_table_lock(HASH_TABLE_LOCK(NODE)))
#define UNLOCK_TABLE(NODE) UNLOCK(Yap_table_lock(HASH_TABLE_LOCK(NODE)))
#define LOCK_TABLE(NODE) LOCK(GLOBAL_table_lock(HASH_TABLE_LOCK(NODE)))
#define UNLOCK_TABLE(NODE) UNLOCK(GLOBAL_table_lock(HASH_TABLE_LOCK(NODE)))
#define STACK_PUSH_UP(ITEM, STACK) *--(STACK) = (CELL)(ITEM)
#define STACK_POP_UP(STACK) *--(STACK)
@ -290,8 +290,8 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
SetMode_GlobalTrie(TabEnt_mode(TAB_ENT)); \
TabEnt_subgoal_trie(TAB_ENT) = sg_node; \
TabEnt_hash_chain(TAB_ENT) = NULL; \
TabEnt_next(TAB_ENT) = Yap_root_tab_ent; \
Yap_root_tab_ent = TAB_ENT; \
TabEnt_next(TAB_ENT) = GLOBAL_root_tab_ent; \
GLOBAL_root_tab_ent = TAB_ENT; \
}
#define new_subgoal_frame(SG_FR, CODE) \
@ -394,27 +394,27 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
#ifdef LIMIT_TABLING
#define insert_into_global_sg_fr_list(SG_FR) \
SgFr_previous(SG_FR) = Yap_last_sg_fr; \
SgFr_previous(SG_FR) = GLOBAL_last_sg_fr; \
SgFr_next(SG_FR) = NULL; \
if (Yap_first_sg_fr == NULL) \
Yap_first_sg_fr = SG_FR; \
if (GLOBAL_first_sg_fr == NULL) \
GLOBAL_first_sg_fr = SG_FR; \
else \
SgFr_next(Yap_last_sg_fr) = SG_FR; \
Yap_last_sg_fr = SG_FR
SgFr_next(GLOBAL_last_sg_fr) = SG_FR; \
GLOBAL_last_sg_fr = SG_FR
#define remove_from_global_sg_fr_list(SG_FR) \
if (SgFr_previous(SG_FR)) { \
if ((SgFr_next(SgFr_previous(SG_FR)) = SgFr_next(SG_FR)) != NULL) \
SgFr_previous(SgFr_next(SG_FR)) = SgFr_previous(SG_FR); \
else \
Yap_last_sg_fr = SgFr_previous(SG_FR); \
GLOBAL_last_sg_fr = SgFr_previous(SG_FR); \
} else { \
if ((Yap_first_sg_fr = SgFr_next(SG_FR)) != NULL) \
if ((GLOBAL_first_sg_fr = SgFr_next(SG_FR)) != NULL) \
SgFr_previous(SgFr_next(SG_FR)) = NULL; \
else \
Yap_last_sg_fr = NULL; \
GLOBAL_last_sg_fr = NULL; \
} \
if (Yap_check_sg_fr == SG_FR) \
Yap_check_sg_fr = SgFr_previous(SG_FR)
if (GLOBAL_check_sg_fr == SG_FR) \
GLOBAL_check_sg_fr = SgFr_previous(SG_FR)
#else
#define insert_into_global_sg_fr_list(SG_FR)
#define remove_from_global_sg_fr_list(SG_FR)
@ -653,7 +653,7 @@ static inline void abolish_incomplete_subgoals(choiceptr prune_cp) {
if (EQUAL_OR_YOUNGER_CP(DepFr_cons_cp(LOCAL_top_dep_fr), prune_cp)) {
#ifdef YAPOR
if (Yap_parallel_execution_mode)
if (GLOBAL_parallel_execution_mode)
pruning_over_tabling_data_structures();
#endif /* YAPOR */
do {
@ -667,7 +667,7 @@ static inline void abolish_incomplete_subgoals(choiceptr prune_cp) {
while (LOCAL_top_sg_fr && EQUAL_OR_YOUNGER_CP(SgFr_gen_cp(LOCAL_top_sg_fr), prune_cp)) {
sg_fr_ptr sg_fr;
#ifdef YAPOR
if (Yap_parallel_execution_mode)
if (GLOBAL_parallel_execution_mode)
pruning_over_tabling_data_structures();
#endif /* YAPOR */
sg_fr = LOCAL_top_sg_fr;

View File

@ -468,7 +468,7 @@ static void free_global_trie_branch(gt_node_ptr current_node) {
if (num_nodes == 0) {
FREE_HASH_BUCKETS(Hash_buckets(hash));
FREE_GLOBAL_TRIE_HASH(hash);
if (parent_node != Yap_root_gt) {
if (parent_node != GLOBAL_root_gt) {
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
if (mode == TRAVERSE_MODE_NORMAL) {
if (IsApplTerm(t)) {
@ -506,7 +506,7 @@ static void free_global_trie_branch(gt_node_ptr current_node) {
} else if (TrNode_next(current_node) == NULL) {
CHECK_DECREMENT_GLOBAL_TRIE_FOR_SUBTERMS_REFERENCE(t, mode);
FREE_GLOBAL_TRIE_NODE(current_node);
if (parent_node != Yap_root_gt) {
if (parent_node != GLOBAL_root_gt) {
#ifdef GLOBAL_TRIE_FOR_SUBTERMS
if (mode == TRAVERSE_MODE_NORMAL) {
if (IsApplTerm(t)) {
@ -804,7 +804,7 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str, int str_in
static void traverse_global_trie_for_term(gt_node_ptr current_node, char *str, int *str_index, int *arity, int *mode, int type) {
if (TrNode_parent(current_node) != Yap_root_gt)
if (TrNode_parent(current_node) != GLOBAL_root_gt)
traverse_global_trie_for_term(TrNode_parent(current_node), str, str_index, arity, mode, type);
traverse_trie_node(TrNode_entry(current_node), str, str_index, arity, mode, type);
return;
@ -1378,11 +1378,11 @@ void show_global_trie(int show_mode) {
} else { /* SHOW_MODE_STRUCTURE */
fprintf(Yap_stdout, "Global trie structure\n");
}
if (TrNode_child(Yap_root_gt)) {
if (TrNode_child(GLOBAL_root_gt)) {
char *str = (char *) malloc(sizeof(char) * SHOW_TABLE_STR_ARRAY_SIZE);
int *arity = (int *) malloc(sizeof(int) * SHOW_TABLE_ARITY_ARRAY_SIZE);
arity[0] = 0;
traverse_global_trie(TrNode_child(Yap_root_gt), str, 0, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
traverse_global_trie(TrNode_child(GLOBAL_root_gt), str, 0, arity, TRAVERSE_MODE_NORMAL, TRAVERSE_POSITION_FIRST);
free(str);
free(arity);
} else

View File

@ -831,7 +831,7 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
************************************************************************/
CACHE_REGS
#ifdef MODE_GLOBAL_TRIE_LOOP
gt_node_ptr current_node = Yap_root_gt;
gt_node_ptr current_node = GLOBAL_root_gt;
#endif /* MODE_GLOBAL_TRIE_LOOP */
int subs_arity = *subs_arity_ptr;
CELL *stack_vars = *stack_vars_ptr;
@ -856,7 +856,7 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
if (subs_arity == MAX_TABLE_VARS)
Yap_Error(INTERNAL_ERROR, TermNil, "subgoal_search_loop: MAX_TABLE_VARS exceeded");
STACK_PUSH_UP(t, stack_vars);
*((CELL *)t) = Yap_table_var_enumerator(subs_arity);
*((CELL *)t) = GLOBAL_table_var_enumerator(subs_arity);
t = MakeTableVarTerm(subs_arity);
subs_arity = subs_arity + 1;
SUBGOAL_CHECK_INSERT_ENTRY(tab_ent, current_node, t);
@ -901,7 +901,7 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
STACK_PUSH_UP(t, stack_terms);
}
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
} else if (current_node != Yap_root_gt) {
} else if (current_node != GLOBAL_root_gt) {
gt_node_ptr entry_node = subgoal_search_global_trie_terms_loop(t, &subs_arity, &stack_vars, stack_terms);
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
@ -918,13 +918,13 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
STACK_PUSH_UP(Deref(aux_pair[0]), stack_terms);
}
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
} else if (current_node != Yap_root_gt) {
} else if (current_node != GLOBAL_root_gt) {
gt_node_ptr entry_node = subgoal_search_global_trie_terms_loop(t, &subs_arity, &stack_vars, stack_terms);
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
#else /* ! TRIE_COMPACT_PAIRS */
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
if (current_node != Yap_root_gt) {
if (current_node != GLOBAL_root_gt) {
gt_node_ptr entry_node = subgoal_search_global_trie_terms_loop(t, &subs_arity, &stack_vars, stack_terms);
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
} else
@ -1035,7 +1035,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
************************************************************************/
CACHE_REGS
#ifdef MODE_GLOBAL_TRIE_LOOP
gt_node_ptr current_node = Yap_root_gt;
gt_node_ptr current_node = GLOBAL_root_gt;
#endif /* MODE_GLOBAL_TRIE_LOOP */
int vars_arity = *vars_arity_ptr;
#if ! defined(MODE_GLOBAL_TRIE_LOOP) || ! defined(GLOBAL_TRIE_FOR_SUBTERMS)
@ -1066,7 +1066,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
if (vars_arity == MAX_TABLE_VARS)
Yap_Error(INTERNAL_ERROR, TermNil, "answer_search_loop: MAX_TABLE_VARS exceeded");
stack_vars_base[vars_arity] = t;
*((CELL *)t) = Yap_table_var_enumerator(vars_arity);
*((CELL *)t) = GLOBAL_table_var_enumerator(vars_arity);
t = MakeTableVarTerm(vars_arity);
ANSWER_CHECK_INSERT_ENTRY(sg_fr, current_node, t, _trie_retry_var + in_pair);
vars_arity = vars_arity + 1;
@ -1118,7 +1118,7 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
STACK_PUSH_UP(t, stack_terms);
}
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
} else if (current_node != Yap_root_gt) {
} else if (current_node != GLOBAL_root_gt) {
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
@ -1137,13 +1137,13 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
STACK_PUSH_UP(Deref(aux_pair[0]), stack_terms);
}
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
} else if (current_node != Yap_root_gt) {
} else if (current_node != GLOBAL_root_gt) {
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
#endif /* MODE_GLOBAL_TRIE_LOOP && GLOBAL_TRIE_FOR_SUBTERMS */
#else /* ! TRIE_COMPACT_PAIRS */
#if defined(MODE_GLOBAL_TRIE_LOOP) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
if (current_node != Yap_root_gt) {
if (current_node != GLOBAL_root_gt) {
gt_node_ptr entry_node = answer_search_global_trie_terms_loop(t, &vars_arity, stack_terms);
current_node = global_trie_check_insert_gt_entry(current_node, (Term) entry_node);
} else

View File

@ -1988,22 +1988,22 @@ PL_initialise(int myargc, char **myargv)
init_args.SchedulerLoop = 10;
init_args.DelayedReleaseLoad = 3;
Yap_PL_Argc = myargc;
Yap_PL_Argv = myargv;
Yap_InitialisedFromPL = TRUE;
GLOBAL_PL_Argc = myargc;
GLOBAL_PL_Argv = myargv;
GLOBAL_InitialisedFromPL = TRUE;
return YAP_Init(&init_args) != YAP_BOOT_ERROR;
}
X_API int
PL_is_initialised(int *argcp, char ***argvp)
{
if (Yap_InitialisedFromPL) {
if (GLOBAL_InitialisedFromPL) {
if (argcp)
*argcp = Yap_PL_Argc;
*argcp = GLOBAL_PL_Argc;
if (argvp)
*argvp = Yap_PL_Argv;
*argvp = GLOBAL_PL_Argv;
}
return Yap_InitialisedFromPL;
return GLOBAL_InitialisedFromPL;
}
X_API module_t

View File

@ -19,44 +19,43 @@
START_GLOBAL_DATA
// initialization: tell whether the system has been initialised and by whom.
int initialised Yap_Initialised =FALSE
int initialised_from_pl Yap_InitialisedFromPL =FALSE
int pl_argc Yap_PL_Argc =0
char **pl_argv Yap_PL_Argv =NULL
int initialised GLOBAL_Initialised =FALSE
int initialised_from_pl GLOBAL_InitialisedFromPL =FALSE
int pl_argc GLOBAL_PL_Argc =0
char **pl_argv GLOBAL_PL_Argv =NULL
// halt hooks
struct halt_hook *yap_halt_hook Yap_HaltHooks =NULL
struct halt_hook *yap_halt_hook GLOBAL_HaltHooks =NULL
// stack overflow expansion/gc control
int allow_local_expansion Yap_AllowLocalExpansion =TRUE
int allow_global_expansion Yap_AllowGlobalExpansion =TRUE
int allow_trail_expansion Yap_AllowTrailExpansion =TRUE
UInt size_of_overflow Yap_SizeOfOverflow =0
int allow_local_expansion GLOBAL_AllowLocalExpansion =TRUE
int allow_global_expansion GLOBAL_AllowGlobalExpansion =TRUE
int allow_trail_expansion GLOBAL_AllowTrailExpansion =TRUE
UInt size_of_overflow GLOBAL_SizeOfOverflow =0
// amount of space recovered in all garbage collections
UInt agc_last_call Yap_AGcLastCall =0
// amount of space recovered in all garbage collections
UInt agc_threshold Yap_AGcThreshold =10000
Agc_hook agc_hook Yap_AGCHook =NULL
UInt agc_threshold GLOBAL_AGcThreshold =10000
Agc_hook agc_hook GLOBAL_AGCHook =NULL
/* multi-thread support */
#if THREADS
/* number of threads and processes in system */
UInt n_of_threads Yap_NOfThreads =1
UInt n_of_threads GLOBAL_NOfThreads =1
/* number of threads created since start */
UInt n_of_threads_created Yap_NOfThreadsCreated =1
UInt n_of_threads_created GLOBAL_NOfThreadsCreated =1
/* total run time for dead threads */
UInt threads_total_time Yap_ThreadsTotalTime =0L
UInt threads_total_time GLOBAL_ThreadsTotalTime =0L
#endif
// multi-thread/ORP support
#if defined(YAPOR) || defined(THREADS)
// protect long critical regions
lockvar bgl Yap_BGL MkLock
lockvar bgl GLOBAL_BGL MkLock
#endif
// Threads Array
#ifdef THREADS
lockvar thread_handles_lock Yap_ThreadHandlesLock MkLock
lockvar thread_handles_lock GLOBAL_ThreadHandlesLock MkLock
#endif
#if defined(YAPOR) || defined(TABLING)