struct local_optyap_data is now part of struct worker_local (generated from the file LOCALS)

This commit is contained in:
Ricardo Rocha 2011-05-09 19:36:51 +01:00
parent 72a83eec62
commit a532b6cff3
31 changed files with 490 additions and 533 deletions

View File

@ -336,11 +336,7 @@ struct various_codes *Yap_heap_regs;
static void
InitHeap(void)
{
CACHE_REGS
Yap_heap_regs = (struct various_codes *)calloc(1, sizeof(struct various_codes));
#if defined(YAPOR) || defined(TABLING)
LOCAL = REMOTE; /* point to the first area */
#endif /* YAPOR || TABLING */
}
void
@ -1479,10 +1475,6 @@ InitHeap(void *heap_addr)
#endif
FreeBlocks = NIL;
#if defined(YAPOR) || defined(TABLING)
LOCAL = REMOTE; /* point to the first area */
#endif /* YAPOR || TABLING */
}
void

View File

@ -2823,27 +2823,21 @@ YAP_Init(YAP_init_args *yap_init)
}
yap_flags[FAST_BOOT_FLAG] = yap_init->FastBoot;
#if defined(YAPOR) || defined(TABLING)
#ifdef TABLING
/* make sure we initialise this field */
Yap_root_dep_fr = NULL;
#endif
make_root_frames();
#ifdef YAPOR
init_workers();
#endif /* YAPOR */
Yap_init_local();
Yap_init_root_frames();
#endif /* YAPOR || TABLING */
#ifdef YAPOR
init_yapor_workers();
if (worker_id != 0) {
#if YAPOR_SBA||YAPOR_COPY
#if defined(YAPOR_COPY) || defined(YAPOR_SBA)
/*
In the SBA we cannot just happily inherit registers
from the other workers
*/
Yap_InitYaamRegs();
#endif /* YAPOR_SBA */
#ifndef THREADS
#endif /* YAPOR_COPY || YAPOR_SBA */
#ifndef YAPOR_THREADS
Yap_InitPreAllocCodeSpace();
#endif
#endif /* YAPOR_THREADS */
/* slaves, waiting for work */
CurrentModule = USER_MODULE;
P = GETWORK_FIRST_TIME;
@ -2851,7 +2845,6 @@ YAP_Init(YAP_init_args *yap_init)
Yap_Error(INTERNAL_ERROR, TermNil, "abstract machine unexpected exit (YAP_Init)");
}
#endif /* YAPOR */
#endif /* YAPOR || TABLING */
RECOVER_MACHINE_REGS();
}
/* make sure we do this after restore */

View File

@ -1610,7 +1610,7 @@ Yap_InitYaamRegs(void)
int myworker_id = worker_id;
pthread_setspecific(Yap_yaamregs_key, (const void *)FOREIGN_ThreadHandle(myworker_id).default_yaam_regs);
FOREIGN_ThreadHandle(myworker_id).current_yaam_regs = FOREIGN_ThreadHandle(myworker_id).default_yaam_regs;
worker_id = myworker_id;
worker_id = myworker_id; /* ricroc: for what I understand, this shouldn't be necessary */
#else
Yap_regp = &Yap_standard_regs;
#endif

View File

@ -73,11 +73,12 @@ STATIC_PROTO(void InitStdPreds,(void));
STATIC_PROTO(void InitFlags, (void));
STATIC_PROTO(void InitCodes, (void));
STATIC_PROTO(void InitVersion, (void));
static void InitWorker(int wid);
STD_PROTO(void exit, (int));
static void InitWorker(int wid);
#ifdef YAPOR
void init_yapor_workers(void);
#endif /* YAPOR */
/************** YAP PROLOG GLOBAL VARIABLES *************************/
@ -1166,6 +1167,54 @@ InitInvisibleAtoms(void)
INIT_RWLOCK(Yap_heap_regs->invisiblechain.AERWLock);
}
#ifdef YAPOR
void init_yapor_workers(void) {
CACHE_REGS
int proc;
#ifdef YAPOR_THREADS
return;
#endif /* YAPOR_THREADS */
#ifdef YAPOR_COW
if (Yap_number_workers > 1) {
int son;
son = fork();
if (son == -1)
Yap_Error(FATAL_ERROR, TermNil, "fork error (init_yapor_workers)");
if (son > 0) {
/* I am the father, I must stay here and wait for my children to all die */
struct sigaction sigact;
Yap_master_worker = getpid();
sigact.sa_handler = SIG_DFL;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_RESTART;
sigaction(SIGINT, &sigact, NULL);
pause();
exit(0);
} else
Yap_worker_pid(0) = getpid();
}
#endif /* YAPOR_COW */
for (proc = 1; proc < Yap_number_workers; proc++) {
int son;
son = fork();
if (son == -1)
Yap_Error(FATAL_ERROR, TermNil, "fork error (init_yapor_workers)");
if (son == 0) {
/* new worker */
worker_id = proc;
Yap_remap_optyap_memory();
LOCAL = REMOTE(worker_id);
InitWorker(worker_id);
break;
} else
Yap_worker_pid(proc) = son;
}
}
#endif /* YAPOR */
#ifdef THREADS
static void
InitThreadHandle(int wid)
@ -1189,7 +1238,7 @@ Yap_InitThread(int new_id)
if (new_id) {
if (!(new_s = (struct worker_local *)calloc(sizeof(struct worker_local), 1)))
return FALSE;
Yap_WLocal[new_id] = new_s;
Yap_local[new_id] = new_s;
}
InitWorker(new_id);
return TRUE;
@ -1241,11 +1290,11 @@ struct global_data Yap_Global;
#endif
#if defined(THREADS)
struct worker_local *Yap_WLocal[MAX_THREADS];
struct worker_local *Yap_local[MAX_THREADS];
#elif defined(YAPOR)
struct worker_local *Yap_WLocal;
struct worker_local *Yap_local;
#else /* !THREADS && !YAPOR */
struct worker_local Yap_WLocal;
struct worker_local Yap_local;
#endif
static void
@ -1255,7 +1304,7 @@ InitCodes(void)
#if THREADS
int wid;
for (wid = 1; wid < MAX_THREADS; wid++) {
Yap_WLocal[wid] = NULL;
Yap_local[wid] = NULL;
}
#endif
#include "ihstruct.h"
@ -1304,7 +1353,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
/* initialise system stuff */
#if PUSH_REGS
#ifdef THREADS
if (!(Yap_WLocal[0] = (struct worker_local *)calloc(sizeof(struct worker_local), 1)))
if (!(Yap_local[0] = (struct worker_local *)calloc(sizeof(struct worker_local), 1)))
return;
pthread_key_create(&Yap_yaamregs_key, NULL);
pthread_setspecific(Yap_yaamregs_key, (const void *)&Yap_standard_regs);
@ -1319,8 +1368,7 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
#ifdef THREADS
Yap_regp = ((REGSTORE *)pthread_getspecific(Yap_yaamregs_key));
Yap_regp->worker_id_ = 0;
#endif
#endif /* THREADS */
/* Init signal handling and time */
/* also init memory page size, required by later functions */
Yap_InitSysbits ();
@ -1338,8 +1386,10 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
Atts = 2048*sizeof(CELL);
else
Atts = AdjustPageSize(Atts * K);
#ifdef YAPOR
#if defined(YAPOR) || defined(THREADS)
worker_id = 0;
#endif /* YAPOR || THREADS */
#ifdef YAPOR
if (n_workers > MAX_WORKERS)
Yap_Error(INTERNAL_ERROR, TermNil, "excessive number of workers");
#ifdef YAPOR_COPY
@ -1355,13 +1405,16 @@ Yap_InitWorkspace(UInt Heap, UInt Stack, UInt Trail, UInt Atts, UInt max_table_s
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
Yap_init_optyap_memory(Trail, Heap, Stack+Atts, n_workers);
#else
Yap_InitMemory (Trail, Heap, Stack+Atts);
Yap_InitMemory(Trail, Heap, Stack+Atts);
#endif
#if defined(YAPOR) || defined(TABLING)
Yap_init_optyap_data(max_table_size, n_workers, sch_loop, delay_load);
Yap_init_global_optyap_data(max_table_size, n_workers, sch_loop, delay_load);
#endif /* YAPOR || TABLING */
Yap_AttsSize = Atts;
#if defined(YAPOR) || defined(THREADS)
LOCAL = REMOTE(0); /* point to the first area */
#endif /* YAPOR || THREADS */
Yap_AttsSize = Atts;
Yap_InitTime ();
/* InitAbsmi must be done before InitCodes */
/* This must be done before initialising predicates */

View File

@ -53,13 +53,13 @@ allocate_new_tid(void)
int new_worker_id = 0;
LOCK(Yap_ThreadHandlesLock);
while(new_worker_id < MAX_THREADS &&
Yap_WLocal[new_worker_id] &&
Yap_local[new_worker_id] &&
(FOREIGN_ThreadHandle(new_worker_id).in_use == TRUE ||
FOREIGN_ThreadHandle(new_worker_id).zombie == TRUE) )
new_worker_id++;
if (new_worker_id >= MAX_THREADS) {
new_worker_id = -1;
} else if (!Yap_WLocal[new_worker_id]) {
} else if (!Yap_local[new_worker_id]) {
DEBUG_TLOCK_ACCESS(new_worker_id, 0);
if (!Yap_InitThread(new_worker_id)) {
return -1;
@ -182,16 +182,11 @@ setup_engine(int myworker_id, int init_thread)
pthread_setspecific(Yap_yaamregs_key, (void *)FOREIGN_ThreadHandle(myworker_id).default_yaam_regs);
}
worker_id = myworker_id;
LOCAL = REMOTE(worker_id);
Yap_InitExStacks(FOREIGN_ThreadHandle(myworker_id).tsize, FOREIGN_ThreadHandle(myworker_id).ssize);
CurrentModule = FOREIGN_ThreadHandle(myworker_id).cmod;
Yap_InitTime();
Yap_InitYaamRegs();
#ifdef YAPOR
Yap_init_local();
#endif
#ifdef TABLING
new_dependency_frame(REMOTE_top_dep_fr(myworker_id)), FALSE, NULL, NULL, NULL, NULL, NULL);
#endif
Yap_ReleasePreAllocCodeSpace(Yap_PreAllocCodeSpace());
/* I exist */
Yap_NOfThreadsCreated++;
@ -447,7 +442,7 @@ Yap_thread_attach_engine(int wid)
FOREIGN_ThreadHandle(wid).pthread_handle = pthread_self();
FOREIGN_ThreadHandle(wid).ref_count++;
pthread_setspecific(Yap_yaamregs_key, (const void *)FOREIGN_ThreadHandle(wid).default_yaam_regs);
worker_id = wid;
worker_id = wid; /* ricroc: for what I understand, this shouldn't be necessary */
DEBUG_TLOCK_ACCESS(9, wid);
pthread_mutex_unlock(&(FOREIGN_ThreadHandle(wid).tlock));
return TRUE;
@ -836,7 +831,7 @@ p_nof_threads( USES_REGS1 )
int i = 0, wid;
LOCK(Yap_ThreadHandlesLock);
for (wid = 0; wid < MAX_THREADS; wid++) {
if (!Yap_WLocal[wid]) break;
if (!Yap_local[wid]) break;
if (FOREIGN_ThreadHandle(wid).in_use)
i++;
}

View File

@ -746,26 +746,26 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
lastw = separator;
if (wglb->keep_terms) {
/* garbage collection may be called */
sl = Yap_InitSlot(t);
sl = Yap_InitSlot(t PASS_REGS);
}
writeTerm(HeadOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt);
restore_from_write(&nrwt, wglb);
if (wglb->keep_terms) {
/* garbage collection may be called */
t = Yap_GetFromSlot(sl);
Yap_RecoverSlots(1);
t = Yap_GetFromSlot(sl PASS_REGS);
Yap_RecoverSlots(1 PASS_REGS);
}
wrputs(",",wglb->writewch);
if (wglb->keep_terms) {
/* garbage collection may be called */
sl = Yap_InitSlot(t);
sl = Yap_InitSlot(t PASS_REGS);
}
writeTerm(TailOfTerm(t), 999, depth + 1, FALSE, wglb, &nrwt);
restore_from_write(&nrwt, wglb);
if (wglb->keep_terms) {
/* garbage collection may be called */
t = Yap_GetFromSlot(sl);
Yap_RecoverSlots(1);
t = Yap_GetFromSlot(sl PASS_REGS);
Yap_RecoverSlots(1 PASS_REGS);
}
wrputc(')', wglb->writewch);
lastw = separator;

View File

@ -126,9 +126,10 @@ typedef struct regstore_t
#endif /* YAPOR_SBA || TABLING */
struct pred_entry *PP_;
#if defined(YAPOR) || defined(THREADS)
unsigned int worker_id_;
struct worker_local *worker_local_;
/* recursive write-locks for PredEntry */
yamop **PREG_ADDR_;
unsigned int worker_id_;
#ifdef YAPOR_SBA
choiceptr BSEG_;
struct or_frame *frame_head_, *frame_tail_;
@ -138,9 +139,6 @@ typedef struct regstore_t
int sba_size_;
#endif /* YAPOR_SBA */
#endif /* YAPOR || THREADS */
#if defined(YAPOR) || defined(TABLING)
struct local_data *LOCAL_;
#endif
#if PUSH_REGS
/* On a X86 machine, the best solution is to keep the
X registers on a global variable, whose address is known between
@ -642,8 +640,9 @@ EXTERN inline void restore_B(void) {
#endif /* YAPOR_SBA || TABLING */
#define PP (Yap_REGS.PP_)
#if defined(YAPOR) || defined(THREADS)
#define worker_id (Yap_REGS.worker_id_)
#define PREG_ADDR (Yap_REGS.PREG_ADDR_)
#define worker_id (Yap_REGS.worker_id_)
#define LOCAL (Yap_REGS.worker_local_)
#define PREG_ADDR (Yap_REGS.PREG_ADDR_)
#ifdef YAPOR_SBA
#define BSEG Yap_REGS.BSEG_
#define binding_array Yap_REGS.binding_array_
@ -653,10 +652,9 @@ EXTERN inline void restore_B(void) {
#define frame_head Yap_REGS.frame_head_
#define frame_tail Yap_REGS.frame_tail_
#endif /* YAPOR_SBA */
#endif /* YAPOR */
#if defined(YAPOR) || defined(TABLING)
#define LOCAL Yap_REGS.LOCAL_
#endif
#else
#define LOCAL (&Yap_local)
#endif /* YAPOR || THREADS */
#define CurrentModule Yap_REGS.CurrentModule_
#define ARITH_EXCEPTION Yap_REGS.ARITH_EXCEPTION_
#define Yap_isint Yap_REGS.isint_

View File

@ -189,20 +189,19 @@ extern struct global_data Yap_Global;
#endif
#if defined(THREADS)
extern struct worker_local *Yap_WLocal[MAX_THREADS];
#define WL (Yap_WLocal[worker_id])
#define FOREIGN(wid) (Yap_WLocal[(wid)])
extern struct worker_local *Yap_local[MAX_THREADS];
#define FOREIGN(wid) (Yap_local[wid])
#define REMOTE(wid) (Yap_local[wid])
#elif defined(YAPOR)
extern struct worker_local *Yap_WLocal;
#define WL (Yap_WLocal+worker_id)
#define FOREIGN(wid) (Yap_WLocal+wid)
extern struct worker_local *Yap_local;
#define FOREIGN(wid) (Yap_local + wid)
#define REMOTE(wid) (Yap_local + wid)
#else /* !THREADS && !YAPOR */
extern struct worker_local Yap_WLocal;
#define WL (&Yap_WLocal)
#define FOREIGN(wid) (&Yap_WLocal)
extern struct worker_local Yap_local;
#define FOREIGN(wid) (&Yap_local)
#define REMOTE(wid) (&Yap_local)
#endif
#ifdef USE_SYSTEM_MALLOC
extern struct various_codes *Yap_heap_regs;
#else

View File

@ -21,6 +21,22 @@
#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 Yap_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 Yap_AGcLastCall Yap_global->agc_last_call
#define Yap_AGcThreshold Yap_global->agc_threshold
#define Yap_AGCHook Yap_global->agc_hook
#if THREADS
@ -36,29 +52,10 @@
#define Yap_BGL Yap_global->bgl
#endif
#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 Yap_AGcLastCall Yap_global->agc_last_call
#define Yap_AGcThreshold Yap_global->agc_threshold
#define Yap_AGCHook Yap_global->agc_hook
#ifdef THREADS
#define Yap_ThreadHandlesLock Yap_global->thread_handles_lock
#endif
#if defined(YAPOR) || defined(TABLING)
#define Yap_optyap_data Yap_global->optyap_data
#define REMOTE Yap_global->remote
#endif
#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 Yap_HaltHooks Yap_global->yap_halt_hook
#endif /* YAPOR || TABLING */

View File

@ -5,133 +5,130 @@
#define LOCAL_c_input_stream WL->c_input_stream
#define LOCAL_c_output_stream WL->c_output_stream
#define LOCAL_c_error_stream WL->c_error_stream
#define LOCAL_c_input_stream LOCAL->c_input_stream
#define LOCAL_c_output_stream LOCAL->c_output_stream
#define LOCAL_c_error_stream LOCAL->c_error_stream
#define LOCAL_OldASP WL->rinfo.old_ASP
#define LOCAL_OldLCL0 WL->rinfo.old_LCL0
#define LOCAL_OldTR WL->rinfo.old_TR
#define LOCAL_OldGlobalBase WL->rinfo.old_GlobalBase
#define LOCAL_OldH WL->rinfo.old_H
#define LOCAL_OldH0 WL->rinfo.old_H0
#define LOCAL_OldTrailBase WL->rinfo.old_TrailBase
#define LOCAL_OldTrailTop WL->rinfo.old_TrailTop
#define LOCAL_OldHeapBase WL->rinfo.old_HeapBase
#define LOCAL_OldHeapTop WL->rinfo.old_HeapTop
#define LOCAL_ClDiff WL->rinfo.cl_diff
#define LOCAL_GDiff WL->rinfo.g_diff
#define LOCAL_HDiff WL->rinfo.h_diff
#define LOCAL_GDiff0 WL->rinfo.g_diff0
#define LOCAL_GSplit WL->rinfo.g_split
#define LOCAL_LDiff WL->rinfo.l_diff
#define LOCAL_TrDiff WL->rinfo.tr_diff
#define LOCAL_XDiff WL->rinfo.x_diff
#define LOCAL_DelayDiff WL->rinfo.delay_diff
#define LOCAL_BaseDiff WL->rinfo.base_diff
#define LOCAL_ReductionsCounter WL->call_counters.reductions
#define LOCAL_PredEntriesCounter WL->call_counters.reductions_retries
#define LOCAL_RetriesCounter WL->call_counters.retries
#define LOCAL_ReductionsCounterOn WL->call_counters.reductions_on
#define LOCAL_PredEntriesCounterOn WL->call_counters.reductions_retries_on
#define LOCAL_RetriesCounterOn WL->call_counters.retries_on
#define LOCAL_InterruptsDisabled WL->interrupts_disabled
#define LOCAL_OldASP LOCAL->rinfo.old_ASP
#define LOCAL_OldLCL0 LOCAL->rinfo.old_LCL0
#define LOCAL_OldTR LOCAL->rinfo.old_TR
#define LOCAL_OldGlobalBase LOCAL->rinfo.old_GlobalBase
#define LOCAL_OldH LOCAL->rinfo.old_H
#define LOCAL_OldH0 LOCAL->rinfo.old_H0
#define LOCAL_OldTrailBase LOCAL->rinfo.old_TrailBase
#define LOCAL_OldTrailTop LOCAL->rinfo.old_TrailTop
#define LOCAL_OldHeapBase LOCAL->rinfo.old_HeapBase
#define LOCAL_OldHeapTop LOCAL->rinfo.old_HeapTop
#define LOCAL_ClDiff LOCAL->rinfo.cl_diff
#define LOCAL_GDiff LOCAL->rinfo.g_diff
#define LOCAL_HDiff LOCAL->rinfo.h_diff
#define LOCAL_GDiff0 LOCAL->rinfo.g_diff0
#define LOCAL_GSplit LOCAL->rinfo.g_split
#define LOCAL_LDiff LOCAL->rinfo.l_diff
#define LOCAL_TrDiff LOCAL->rinfo.tr_diff
#define LOCAL_XDiff LOCAL->rinfo.x_diff
#define LOCAL_DelayDiff LOCAL->rinfo.delay_diff
#define LOCAL_BaseDiff LOCAL->rinfo.base_diff
#define LOCAL_ReductionsCounter LOCAL->call_counters.reductions
#define LOCAL_PredEntriesCounter LOCAL->call_counters.reductions_retries
#define LOCAL_RetriesCounter LOCAL->call_counters.retries
#define LOCAL_ReductionsCounterOn LOCAL->call_counters.reductions_on
#define LOCAL_PredEntriesCounterOn LOCAL->call_counters.reductions_retries_on
#define LOCAL_RetriesCounterOn LOCAL->call_counters.retries_on
#define LOCAL_InterruptsDisabled LOCAL->interrupts_disabled
#define LOCAL_ConsultSp WL->consultsp
#define LOCAL_ConsultSp LOCAL->consultsp
#define LOCAL_ConsultCapacity WL->consultcapacity
#define LOCAL_ConsultCapacity LOCAL->consultcapacity
#define LOCAL_ConsultBase WL->consultbase
#define LOCAL_ConsultBase LOCAL->consultbase
#define LOCAL_ConsultLow WL->consultlow
#define LOCAL_ConsultLow LOCAL->consultlow
#define LOCAL_GlobalArena WL->global_arena
#define LOCAL_GlobalArenaOverflows WL->global_arena_overflows
#define LOCAL_ArenaOverflows WL->arena_overflows
#define LOCAL_DepthArenas WL->depth_arenas
#define LOCAL_ArithError WL->arith_error
#define LOCAL_LastAssertedPred WL->last_asserted_pred
#define LOCAL_DebugOn WL->debug_on
#define LOCAL_ScannerStack WL->scanner_stack
#define LOCAL_ScannerExtraBlocks WL->scanner_extra_blocks
#define LOCAL_BallTerm WL->ball_term
#define LOCAL_ActiveSignals WL->active_signals
#define LOCAL_IPredArity WL->i_pred_arity
#define LOCAL_ProfEnd WL->prof_end
#define LOCAL_UncaughtThrow WL->uncaught_throw
#define LOCAL_DoingUndefp WL->doing_undefp
#define LOCAL_StartLine WL->start_line
#define LOCAL_ScratchPad WL->scratchpad
#define LOCAL_GlobalArena LOCAL->global_arena
#define LOCAL_GlobalArenaOverflows LOCAL->global_arena_overflows
#define LOCAL_ArenaOverflows LOCAL->arena_overflows
#define LOCAL_DepthArenas LOCAL->depth_arenas
#define LOCAL_ArithError LOCAL->arith_error
#define LOCAL_LastAssertedPred LOCAL->last_asserted_pred
#define LOCAL_DebugOn LOCAL->debug_on
#define LOCAL_ScannerStack LOCAL->scanner_stack
#define LOCAL_ScannerExtraBlocks LOCAL->scanner_extra_blocks
#define LOCAL_BallTerm LOCAL->ball_term
#define LOCAL_ActiveSignals LOCAL->active_signals
#define LOCAL_IPredArity LOCAL->i_pred_arity
#define LOCAL_ProfEnd LOCAL->prof_end
#define LOCAL_UncaughtThrow LOCAL->uncaught_throw
#define LOCAL_DoingUndefp LOCAL->doing_undefp
#define LOCAL_StartLine LOCAL->start_line
#define LOCAL_ScratchPad LOCAL->scratchpad
#ifdef COROUTINING
#define LOCAL_WokenGoals WL->woken_goals
#define LOCAL_AttsMutableList WL->atts_mutable_list
#define LOCAL_WokenGoals LOCAL->woken_goals
#define LOCAL_AttsMutableList LOCAL->atts_mutable_list
#endif
#define LOCAL_GcGeneration WL->gc_generation
#define LOCAL_GcPhase WL->gc_phase
#define LOCAL_GcCurrentPhase WL->gc_current_phase
#define LOCAL_GcCalls WL->gc_calls
#define LOCAL_TotGcTime WL->tot_gc_time
#define LOCAL_TotGcRecovered WL->tot_gc_recovered
#define LOCAL_LastGcTime WL->last_gc_time
#define LOCAL_LastSSTime WL->last_ss_time
#define LOCAL_GcGeneration LOCAL->gc_generation
#define LOCAL_GcPhase LOCAL->gc_phase
#define LOCAL_GcCurrentPhase LOCAL->gc_current_phase
#define LOCAL_GcCalls LOCAL->gc_calls
#define LOCAL_TotGcTime LOCAL->tot_gc_time
#define LOCAL_TotGcRecovered LOCAL->tot_gc_recovered
#define LOCAL_LastGcTime LOCAL->last_gc_time
#define LOCAL_LastSSTime LOCAL->last_ss_time
#if LOW_LEVEL_TRACER
#define LOCAL_total_choicepoints WL->total_cps
#define LOCAL_total_choicepoints LOCAL->total_cps
#endif
#define LOCAL_consult_level WL->consult_level_
#define LOCAL_consult_level LOCAL->consult_level_
#if defined(YAPOR) || defined(THREADS)
#define LOCAL_SignalLock WL->signal_lock
#define LOCAL_SignalLock LOCAL->signal_lock
#endif
#define LOCAL_total_marked WL->tot_marked
#define LOCAL_total_oldies WL->tot_oldies
#define LOCAL_current_B WL->wl_current_B
#define LOCAL_prev_HB WL->wl_prev_HB
#define LOCAL_HGEN WL->hgen
#define LOCAL_iptop WL->ip_top
#define LOCAL_total_marked LOCAL->tot_marked
#define LOCAL_total_oldies LOCAL->tot_oldies
#define LOCAL_current_B LOCAL->wl_current_B
#define LOCAL_prev_HB LOCAL->wl_prev_HB
#define LOCAL_HGEN LOCAL->hgen
#define LOCAL_iptop LOCAL->ip_top
#if defined(GC_NO_TAGS)
#define LOCAL_bp WL->b_p
#define LOCAL_bp LOCAL->b_p
#endif
#if !defined(TABLING) && !defined(YAPOR_SBA) && (defined(YAPOR) || defined(THREADS))
#define LOCAL_sTR WL->wl_sTR
#define LOCAL_sTR0 WL->wl_sTR0
#define LOCAL_new_TR WL->new_tr
#else
#define LOCAL_sTR WL->wl_sTR
#define LOCAL_sTR0 WL->wl_sTR0
#define LOCAL_new_TR WL->new_tr
#endif /* !TABLING && !YAPOR_SBA && (YAPOR || THREADS) */
#define LOCAL_cont_top0 WL->conttop0
#define LOCAL_cont_top WL->conttop
#define LOCAL_discard_trail_entries WL->disc_trail_entries
#define LOCAL_gc_ma_hash_table WL->Gc_ma_hash_table
#define LOCAL_gc_ma_h_top WL->Gc_ma_h_top
#define LOCAL_gc_ma_h_list WL->Gc_ma_h_list
#define LOCAL_gc_timestamp WL->Gc_timestamp
#define LOCAL_db_vec WL->DB_vec
#define LOCAL_db_vec0 WL->DB_vec0
#define LOCAL_db_root WL->DB_root
#define LOCAL_db_nil WL->DB_nil
#define LOCAL_gc_restore WL->gc_restore
#define LOCAL_DynamicArrays WL->dynamic_arrays
#define LOCAL_StaticArrays WL->static_arrays
#define LOCAL_GlobalVariables WL->global_variables
#define LOCAL_AllowRestart WL->allow_restart
#define LOCAL_sTR LOCAL->wl_sTR
#define LOCAL_sTR0 LOCAL->wl_sTR0
#define LOCAL_new_TR LOCAL->new_tr
#define LOCAL_cont_top0 LOCAL->conttop0
#define LOCAL_cont_top LOCAL->conttop
#define LOCAL_discard_trail_entries LOCAL->disc_trail_entries
#define LOCAL_gc_ma_hash_table LOCAL->Gc_ma_hash_table
#define LOCAL_gc_ma_h_top LOCAL->Gc_ma_h_top
#define LOCAL_gc_ma_h_list LOCAL->Gc_ma_h_list
#define LOCAL_gc_timestamp LOCAL->Gc_timestamp
#define LOCAL_db_vec LOCAL->DB_vec
#define LOCAL_db_vec0 LOCAL->DB_vec0
#define LOCAL_db_root LOCAL->DB_root
#define LOCAL_db_nil LOCAL->DB_nil
#define LOCAL_gc_restore LOCAL->gc_restore
#define LOCAL_DynamicArrays LOCAL->dynamic_arrays
#define LOCAL_StaticArrays LOCAL->static_arrays
#define LOCAL_GlobalVariables LOCAL->global_variables
#define LOCAL_AllowRestart LOCAL->allow_restart
#define LOCAL_CMemFirstBlock WL->cmem_first_block
#define LOCAL_CMemFirstBlockSz WL->cmem_first_block_sz
#define LOCAL_CMemFirstBlock LOCAL->cmem_first_block
#define LOCAL_CMemFirstBlockSz LOCAL->cmem_first_block_sz
#define LOCAL_LabelFirstArray WL->label_first_array
#define LOCAL_LabelFirstArraySz WL->label_first_array_sz
#define LOCAL_LabelFirstArray LOCAL->label_first_array
#define LOCAL_LabelFirstArraySz LOCAL->label_first_array_sz
#define LOCAL_PL_local_data_p WL->Yap_ld_
#define LOCAL_execution WL->_execution
#define LOCAL_PL_local_data_p LOCAL->Yap_ld_
#define LOCAL_execution LOCAL->_execution
#ifdef THREADS
#define LOCAL_ThreadHandle WL->thread_handle
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_WLocal[worker_id]->thread_handle)
#define LOCAL_ThreadHandle LOCAL->thread_handle
#define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle)
#endif
#if defined(YAPOR) || defined(TABLING)
#define LOCAL_optyap_data LOCAL->optyap_data
#endif /* YAPOR || TABLING */

View File

@ -19,9 +19,25 @@
typedef struct global_data {
int initialised;
int initialised_from_pl;
int pl_argc;
char **pl_argv;
struct halt_hook *yap_halt_hook;
int allow_local_expansion;
int allow_global_expansion;
int allow_trail_expansion;
UInt size_of_overflow;
UInt agc_last_call;
UInt agc_threshold;
Agc_hook agc_hook;
#if THREADS
UInt n_of_threads;
@ -36,29 +52,10 @@ typedef struct global_data {
lockvar bgl;
#endif
int allow_local_expansion;
int allow_global_expansion;
int allow_trail_expansion;
UInt size_of_overflow;
UInt agc_last_call;
UInt agc_threshold;
Agc_hook agc_hook;
#ifdef THREADS
lockvar thread_handles_lock;
#endif
#if defined(YAPOR) || defined(TABLING)
struct global_optyap_data optyap_data;
struct local_data remote[MAX_WORKERS];
#endif
int initialised;
int initialised_from_pl;
int pl_argc;
char **pl_argv;
struct halt_hook *yap_halt_hook;
#endif /* YAPOR || TABLING */
} w_shared;

View File

@ -96,15 +96,9 @@ typedef struct worker_local {
#if defined(GC_NO_TAGS)
char* b_p;
#endif
#if !defined(TABLING) && !defined(YAPOR_SBA) && (defined(YAPOR) || defined(THREADS))
Term* wl_sTR;
Term* wl_sTR0;
Term* new_tr;
#else
struct trail_frame* wl_sTR;
struct trail_frame* wl_sTR0;
struct trail_frame* new_tr;
#endif /* !TABLING && !YAPOR_SBA && (YAPOR || THREADS) */
tr_fr_ptr wl_sTR;
tr_fr_ptr wl_sTR0;
tr_fr_ptr new_tr;
struct gc_mark_continuation* conttop0;
struct gc_mark_continuation* conttop;
int disc_trail_entries;
@ -132,8 +126,11 @@ typedef struct worker_local {
struct open_query_struct* _execution;
#ifdef THREADS
struct thandle thread_handle;
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_WLocal[worker_id]->thread_handle)
#define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle)
#endif
#if defined(YAPOR) || defined(TABLING)
struct local_optyap_data optyap_data;
#endif /* YAPOR || TABLING */
} w_local;

View File

@ -19,9 +19,25 @@
static void InitGlobal(void) {
Yap_Initialised = FALSE;
Yap_InitialisedFromPL = FALSE;
Yap_PL_Argc = 0;
Yap_PL_Argv = NULL;
Yap_HaltHooks = NULL;
Yap_AllowLocalExpansion = TRUE;
Yap_AllowGlobalExpansion = TRUE;
Yap_AllowTrailExpansion = TRUE;
Yap_SizeOfOverflow = 0;
Yap_AGcLastCall = 0;
Yap_AGcThreshold = 10000;
Yap_AGCHook = NULL;
#if THREADS
Yap_NOfThreads = 1;
@ -36,29 +52,10 @@ static void InitGlobal(void) {
INIT_LOCK(Yap_BGL);
#endif
Yap_AllowLocalExpansion = TRUE;
Yap_AllowGlobalExpansion = TRUE;
Yap_AllowTrailExpansion = TRUE;
Yap_SizeOfOverflow = 0;
Yap_AGcLastCall = 0;
Yap_AGcThreshold = 10000;
Yap_AGCHook = NULL;
#ifdef THREADS
INIT_LOCK(Yap_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(TABLING)
#endif
Yap_Initialised = FALSE;
Yap_InitialisedFromPL = FALSE;
Yap_PL_Argc = 0;
Yap_PL_Argv = NULL;
Yap_HaltHooks = NULL;
#endif /* YAPOR || TABLING */
}

View File

@ -94,15 +94,9 @@ static void InitWorker(int wid) {
#if defined(GC_NO_TAGS)
FOREIGN(wid)->b_p = NULL;
#endif
#if !defined(TABLING) && !defined(YAPOR_SBA) && (defined(YAPOR) || defined(THREADS))
FOREIGN(wid)->wl_sTR = NULL;
FOREIGN(wid)->wl_sTR0 = NULL;
FOREIGN(wid)->new_tr = NULL;
#else
FOREIGN(wid)->wl_sTR = NULL;
FOREIGN(wid)->wl_sTR0 = NULL;
FOREIGN(wid)->new_tr = NULL;
#endif /* !TABLING && !YAPOR_SBA && (YAPOR || THREADS) */
FOREIGN(wid)->conttop0 = NULL;
FOREIGN(wid)->conttop = NULL;
FOREIGN(wid)->disc_trail_entries = 0;
@ -130,8 +124,11 @@ static void InitWorker(int wid) {
FOREIGN(wid)->_execution = NULL;
#ifdef THREADS
InitThreadHandle(wid);
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_WLocal[worker_id]->thread_handle)
#define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle)
#endif
#if defined(YAPOR) || defined(TABLING)
Yap_init_local_optyap_data(wid);
#endif /* YAPOR || TABLING */
}

View File

@ -19,9 +19,25 @@
static void RestoreGlobal(void) {
#if THREADS
@ -36,29 +52,10 @@ static void RestoreGlobal(void) {
REINIT_LOCK(Yap_BGL);
#endif
#ifdef THREADS
REINIT_LOCK(Yap_ThreadHandlesLock);
#endif
#if defined(YAPOR) || defined(TABLING)
#endif
#endif /* YAPOR || TABLING */
}

View File

@ -94,15 +94,9 @@ static void RestoreWorker(int wid USES_REGS) {
#if defined(GC_NO_TAGS)
#endif
#if !defined(TABLING) && !defined(YAPOR_SBA) && (defined(YAPOR) || defined(THREADS))
#else
#endif /* !TABLING && !YAPOR_SBA && (YAPOR || THREADS) */
@ -130,8 +124,11 @@ static void RestoreWorker(int wid USES_REGS) {
#ifdef THREADS
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_WLocal[worker_id]->thread_handle)
#define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle)
#endif
#if defined(YAPOR) || defined(TABLING)
#endif /* YAPOR || TABLING */
}

View File

@ -45,18 +45,18 @@
static Int null_id = 0;
STATIC_PROTO(Int c_db_my_connect,(void));
STATIC_PROTO(Int c_db_my_disconnect,(void));
STATIC_PROTO(Int c_db_my_number_of_fields,(void));
STATIC_PROTO(Int c_db_my_get_attributes_types,(void));
STATIC_PROTO(Int c_db_my_query,(void));
STATIC_PROTO(Int c_db_my_table_write,(void));
STATIC_PROTO(Int c_db_my_row,(void));
STATIC_PROTO(Int c_db_my_row_cut,(void));
STATIC_PROTO(Int c_db_my_get_fields_properties,(void));
STATIC_PROTO(Int c_db_my_get_next_result_set,(void));
STATIC_PROTO(Int c_db_my_get_database,(void));
STATIC_PROTO(Int c_db_my_change_database,(void));
STATIC_PROTO(Int c_db_my_connect,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_disconnect,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_number_of_fields,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_get_attributes_types,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_query,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_table_write,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_row,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_row_cut,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_get_fields_properties,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_get_next_result_set,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_get_database,( USES_REGS1 ));
STATIC_PROTO(Int c_db_my_change_database,( USES_REGS1 ));
void Yap_InitMYDDAS_MySQLPreds(void)
{
@ -104,7 +104,7 @@ void Yap_InitBackMYDDAS_MySQLPreds(void)
}
static Int
c_db_my_connect(void) {
c_db_my_connect( USES_REGS1 ) {
Term arg_host = Deref(ARG1);
Term arg_user = Deref(ARG2);
Term arg_passwd = Deref(ARG3);
@ -163,7 +163,7 @@ c_db_my_connect(void) {
/* db_query: SQLQuery x ResultSet x Connection */
static Int
c_db_my_query(void) {
c_db_my_query( USES_REGS1 ) {
Term arg_sql_query = Deref(ARG1);
Term arg_result_set = Deref(ARG2);
Term arg_conn = Deref(ARG3);
@ -337,7 +337,7 @@ c_db_my_query(void) {
}
static Int
c_db_my_number_of_fields(void) {
c_db_my_number_of_fields( USES_REGS1 ) {
Term arg_relation = Deref(ARG1);
Term arg_conn = Deref(ARG2);
Term arg_fields = Deref(ARG3);
@ -381,7 +381,7 @@ c_db_my_number_of_fields(void) {
/* db_get_attributes_types: RelName x Connection -> TypesList */
static Int
c_db_my_get_attributes_types(void) {
c_db_my_get_attributes_types( USES_REGS1 ) {
Term arg_relation = Deref(ARG1);
Term arg_conn = Deref(ARG2);
Term arg_types_list = Deref(ARG3);
@ -442,7 +442,7 @@ c_db_my_get_attributes_types(void) {
/* db_disconnect */
static Int
c_db_my_disconnect(void) {
c_db_my_disconnect( USES_REGS1 ) {
Term arg_conn = Deref(ARG1);
MYSQL *conn = (MYSQL *) IntegerOfTerm(arg_conn);
@ -461,7 +461,7 @@ c_db_my_disconnect(void) {
/* db_table_write: Result Set */
static Int
c_db_my_table_write(void) {
c_db_my_table_write( USES_REGS1 ) {
Term arg_res_set = Deref(ARG1);
MYSQL_RES *res_set = (MYSQL_RES *) IntegerOfTerm(arg_res_set);
@ -473,7 +473,7 @@ c_db_my_table_write(void) {
}
static Int
c_db_my_row_cut(void) {
c_db_my_row_cut( USES_REGS1 ) {
MYSQL_RES *mysql_res=NULL;
mysql_res = (MYSQL_RES *) IntegerOfTerm(EXTRA_CBACK_CUT_ARG(Term,1));
@ -483,7 +483,7 @@ c_db_my_row_cut(void) {
/* db_row: ResultSet x Arity_ListOfArgs x ListOfArgs -> */
static Int
c_db_my_row(void) {
c_db_my_row( USES_REGS1 ) {
#ifdef MYDDAS_STATS
/* Measure time used by the */
/* c_db_my_row function */
@ -598,7 +598,7 @@ c_db_my_row(void) {
}
static Int
c_db_my_get_fields_properties(void) {
c_db_my_get_fields_properties( USES_REGS1 ) {
Term nome_relacao = Deref(ARG1);
Term arg_conn = Deref(ARG2);
Term fields_properties_list = Deref(ARG3);
@ -680,7 +680,7 @@ c_db_my_get_fields_properties(void) {
/* c_db_my_get_next_result_set: Connection * NextResSet */
static Int
c_db_my_get_next_result_set(void) {
c_db_my_get_next_result_set( USES_REGS1 ) {
Term arg_conn = Deref(ARG1);
Term arg_next_res_set = Deref(ARG2);
@ -695,7 +695,7 @@ c_db_my_get_next_result_set(void) {
}
static Int
c_db_my_get_database(void) {
c_db_my_get_database( USES_REGS1 ) {
Term arg_con = Deref(ARG1);
Term arg_database = Deref(ARG2);
@ -709,7 +709,7 @@ c_db_my_get_database(void) {
}
static Int
c_db_my_change_database(void) {
c_db_my_change_database( USES_REGS1 ) {
Term arg_con = Deref(ARG1);
Term arg_database = Deref(ARG2);

View File

@ -173,6 +173,8 @@ static Term get_point(char *func){
}
static Term get_linestring(char *func){
CACHE_REGS
Term *c_list;
Term list;
Functor functor;
@ -203,6 +205,8 @@ static Term get_linestring(char *func){
}
static Term get_polygon(char *func){
CACHE_REGS
uint32 r;
int i;
Functor functor;
@ -233,6 +237,8 @@ static Term get_polygon(char *func){
}
static Term get_geometry(uint32 type){
CACHE_REGS
switch(type) {
case WKBPOINT:
return get_point("point");

View File

@ -59,7 +59,7 @@
** Global functions **
*******************************/
void Yap_init_optyap_data(int max_table_size, int n_workers, int sch_loop, int delay_load) {
void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop, int delay_load) {
int i;
/* global data related to memory management */
@ -108,6 +108,7 @@ void Yap_init_optyap_data(int max_table_size, int n_workers, int sch_loop, int d
Yap_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);
@ -144,7 +145,7 @@ void Yap_init_optyap_data(int max_table_size, int n_workers, int sch_loop, int d
Yap_last_sg_fr = NULL;
Yap_check_sg_fr = NULL;
#endif /* LIMIT_TABLING */
Yap_root_dep_fr = NULL;
new_dependency_frame(Yap_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);
RESET_VARIABLE(pt);
@ -159,43 +160,41 @@ void Yap_init_optyap_data(int max_table_size, int n_workers, int sch_loop, int d
}
void Yap_init_local(void) {
void Yap_init_local_optyap_data(int wid) {
#ifdef YAPOR
CACHE_REGS
/* local data related to or-parallelism */
LOCAL = REMOTE + worker_id;
Set_LOCAL_top_cp((choiceptr) Yap_LocalBase);
LOCAL_top_or_fr = Yap_root_or_fr;
LOCAL_load = 0;
LOCAL_share_request = MAX_WORKERS;
LOCAL_reply_signal = worker_ready;
Set_REMOTE_top_cp(wid, (choiceptr) Yap_LocalBase);
REMOTE_top_or_fr(wid) = Yap_root_or_fr;
REMOTE_load(wid) = 0;
REMOTE_share_request(wid) = MAX_WORKERS;
REMOTE_reply_signal(wid) = worker_ready;
#ifdef YAPOR_COPY
INIT_LOCK(LOCAL_lock_signals);
INIT_LOCK(REMOTE_lock_signals(wid));
#endif /* YAPOR_COPY */
Set_LOCAL_prune_request(NULL);
Set_REMOTE_prune_request(wid, NULL);
#endif /* YAPOR */
INIT_LOCK(LOCAL_lock);
INIT_LOCK(REMOTE_lock(wid));
#ifdef TABLING
/* local data related to tabling */
LOCAL_next_free_ans_node = NULL;
LOCAL_top_sg_fr = NULL;
LOCAL_top_dep_fr = Yap_root_dep_fr;
REMOTE_next_free_ans_node(wid) = NULL;
REMOTE_top_sg_fr(wid) = NULL;
REMOTE_top_dep_fr(wid) = Yap_root_dep_fr;
#ifdef YAPOR
Set_LOCAL_top_cp_on_stack((choiceptr) Yap_LocalBase); /* ??? */
LOCAL_top_susp_or_fr = Yap_root_or_fr;
Set_REMOTE_top_cp_on_stack(wid, (choiceptr) Yap_LocalBase); /* ??? */
REMOTE_top_susp_or_fr(wid) = Yap_root_or_fr;
#endif /* YAPOR */
#endif /* TABLING */
return;
}
void make_root_frames(void) {
#ifdef YAPOR
void Yap_init_root_frames(void) {
CACHE_REGS
/* root or frame */
or_fr_ptr or_fr;
ALLOC_OR_FRAME(or_fr);
#ifdef YAPOR
/* root or frame */
or_fr_ptr or_fr = Yap_root_or_fr;
INIT_LOCK(OrFr_lock(or_fr));
OrFr_alternative(or_fr) = NULL;
BITMAP_copy(OrFr_members(or_fr), Yap_bm_present_workers);
@ -215,63 +214,14 @@ void make_root_frames(void) {
OrFr_nearest_suspnode(or_fr) = or_fr;
#endif /* TABLING */
OrFr_next(or_fr) = NULL;
Yap_root_or_fr = or_fr;
#endif /* YAPOR */
#ifdef TABLING
/* root dependency frame */
if (!Yap_root_dep_fr) {
new_dependency_frame(Yap_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, NULL);
#ifdef TABLING
DepFr_cons_cp(Yap_root_dep_fr) = B;
#endif /* TABLING */
}
DepFr_cons_cp(Yap_root_dep_fr) = B;
#endif /* TABLING */
}
#ifdef YAPOR
void init_workers(void) {
CACHE_REGS
int proc;
#ifdef YAPOR_THREADS
return;
#endif /* YAPOR_THREADS */
#ifdef YAPOR_COW
if (Yap_number_workers> 1) {
int son;
son = fork();
if (son == -1)
Yap_Error(FATAL_ERROR, TermNil, "fork error (init_workers)");
if (son > 0) {
/* I am the father, I must stay here and wait for my children to all die */
struct sigaction sigact;
Yap_master_worker = getpid();
sigact.sa_handler = SIG_DFL;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_RESTART;
sigaction(SIGINT, &sigact, NULL);
pause();
exit(0);
} else Yap_worker_pid(0) = getpid();
}
#endif /* YAPOR_COW */
for (proc = 1; proc < Yap_number_workers; proc++) {
int son;
son = fork();
if (son == -1)
Yap_Error(FATAL_ERROR, TermNil, "fork error (init_workers)");
if (son == 0) {
/* new worker */
worker_id = proc;
Yap_remap_optyap_memory();
break;
}
else Yap_worker_pid(proc) = son;
}
}
#endif /* YAPOR */
void itos(int i, char *s) {
int n,r,j;

View File

@ -81,7 +81,7 @@ void Yap_init_optyap_memory(long TrailAuxArea, long HeapArea, long GlobalLocalAr
/* initial allocation - model independent */
ExtraArea = ADJUST_SIZE_TO_PAGE(sizeof(struct global_data) + MAX_WORKERS * sizeof(struct worker_local));
Yap_WLocal = (struct worker_local *)(MMAP_ADDR - ExtraArea);
Yap_local = (struct worker_local *)(MMAP_ADDR - ExtraArea);
Yap_global = (struct global_data *)(MMAP_ADDR - sizeof(struct global_data));
Yap_HeapBase = (ADDR) MMAP_ADDR;
Yap_GlobalBase = (ADDR) (MMAP_ADDR + HeapArea);
@ -102,7 +102,7 @@ void Yap_init_optyap_memory(long TrailAuxArea, long HeapArea, long GlobalLocalAr
#ifdef MMAP_MEMORY_MAPPING_SCHEME
/* map total area in a single go */
open_mapfile(TotalArea);
if (mmap((void *) Yap_WLocal, (size_t) TotalArea, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd_mapfile, 0) == (void *) -1)
if (mmap((void *) Yap_local, (size_t) TotalArea, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd_mapfile, 0) == (void *) -1)
Yap_Error(FATAL_ERROR, TermNil, "mmap error (Yap_init_optyap_memory)");
#else /* SHM_MEMORY_MAPPING_SCHEME */
/* most systems are limited regarding what we can allocate */
@ -111,7 +111,7 @@ void Yap_init_optyap_memory(long TrailAuxArea, long HeapArea, long GlobalLocalAr
shm_map_memory(0, ExtraArea + HeapArea, (void *) MMAP_ADDR);
#else /* YAPOR_COPY || YAPOR_SBA */
/* place as segment n otherwise (0..n-1 reserved for worker areas */
shm_map_memory(n_workers, ExtraArea + HeapArea, (void *) Yap_WLocal);
shm_map_memory(n_workers, ExtraArea + HeapArea, (void *) Yap_local);
{ int i;
for (i = 0; i < n_workers; i++)
shm_map_memory(i, Yap_worker_area_size, Yap_GlobalBase + Yap_worker_area_size * i);
@ -167,7 +167,7 @@ void Yap_remap_optyap_memory(void) {
int i;
void *remap_addr = Yap_GlobalBase;
#ifdef MMAP_MEMORY_MAPPING_SCHEME
long remap_offset = (ADDR) remap_addr - (ADDR) Yap_WLocal;
long remap_offset = (ADDR) remap_addr - (ADDR) Yap_local;
if (munmap(remap_addr, (size_t)(Yap_worker_area_size * Yap_number_workers)) == -1)
Yap_Error(FATAL_ERROR, TermNil, "munmap error (Yap_remap_optyap_memory)");
for (i = 0; i < Yap_number_workers; i++)

View File

@ -484,6 +484,7 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
#else
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
#endif /* USE_PAGES_MALLOC */
fflush(Yap_stdout);
return (TRUE);
}

View File

@ -27,12 +27,9 @@ void Yap_remap_optyap_memory(void);
** opt.init.c **
*************************/
void Yap_init_optyap_data(int, int, int, int);
void Yap_init_local(void);
void make_root_frames(void);
#ifdef YAPOR
void init_workers(void);
#endif /* YAPOR */
void Yap_init_global_optyap_data(int, int, int, int);
void Yap_init_local_optyap_data(int);
void Yap_init_root_frames(void);
void itos(int, char *);

View File

@ -132,12 +132,12 @@ struct global_pages {
/**********************************
** Struct global_locks **
**********************************/
/*****************************************
** Struct global_optyap_locks **
*****************************************/
#ifdef YAPOR
struct global_locks {
struct global_optyap_locks {
lockvar bitmap_idle_workers;
lockvar bitmap_root_cp_workers;
lockvar bitmap_invisible_workers;
@ -160,7 +160,7 @@ struct global_locks {
* Struct global_optyap_data **
*********************************/
struct global_optyap_data{
struct global_optyap_data {
/* global data related to memory management */
struct global_pages pages;
@ -198,7 +198,7 @@ struct global_optyap_data{
#ifdef TABLING_INNER_CUTS
volatile bitmap pruning_workers;
#endif /* TABLING_INNER_CUTS */
struct global_locks locks;
struct global_optyap_locks locks;
volatile unsigned int branch[MAX_WORKERS][MAX_BRANCH_DEPTH];
volatile char parallel_execution_mode; /* TRUE / FALSE */
volatile int answers;
@ -251,7 +251,7 @@ struct global_optyap_data{
#define Yap_number_goals (Yap_optyap_data.number_of_executed_goals)
#define Yap_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 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))
#else
#define Yap_root_cp (Yap_optyap_data.root_choice_point)
@ -293,12 +293,12 @@ struct global_optyap_data{
/***********************************
** Struct local_signals **
***********************************/
/******************************************
** Struct local_optyap_signals **
******************************************/
#ifdef YAPOR
struct local_signals{
struct local_optyap_signals{
#if defined(YAPOR_COPY) || defined(YAPOR_THREADS)
lockvar lock;
volatile enum {
@ -341,11 +341,11 @@ typedef struct {
/********************************
** Struct local_data **
********************************/
/***************************************
** Struct local_optyap_data **
***************************************/
struct local_data{
struct local_optyap_data {
#ifdef YAPOR
lockvar lock;
/* local data related to or-parallelism */
@ -362,7 +362,7 @@ struct local_data{
choiceptr prune_request;
#endif
volatile int share_request;
struct local_signals share_signals;
struct local_optyap_signals share_signals;
volatile struct {
CELL start;
CELL end;
@ -394,95 +394,95 @@ struct local_data{
#endif /* (TABLING || !YAPOR_COW) && MULTI_ASSIGNMENT_VARIABLES */
};
#define LOCAL_lock (LOCAL->lock)
#define LOCAL_load (LOCAL->load)
#define LOCAL_lock (LOCAL_optyap_data.lock)
#define LOCAL_load (LOCAL_optyap_data.load)
#ifdef YAPOR_THREADS
#define Get_LOCAL_top_cp() offset_to_cptr(LOCAL->top_choice_point_offset)
#define Set_LOCAL_top_cp(cpt) (LOCAL->top_choice_point_offset = cptr_to_offset(cpt))
#define Get_LOCAL_top_cp() offset_to_cptr(LOCAL_optyap_data.top_choice_point_offset)
#define Set_LOCAL_top_cp(cpt) (LOCAL_optyap_data.top_choice_point_offset = cptr_to_offset(cpt))
#else
#define LOCAL_top_cp (LOCAL->top_choice_point)
#define Get_LOCAL_top_cp() (LOCAL->top_choice_point)
#define Set_LOCAL_top_cp(cpt) (LOCAL->top_choice_point = cpt)
#endif
#define LOCAL_top_or_fr (LOCAL->top_or_frame)
#define LOCAL_top_cp (LOCAL_optyap_data.top_choice_point)
#define Get_LOCAL_top_cp() (LOCAL_optyap_data.top_choice_point)
#define Set_LOCAL_top_cp(cpt) (LOCAL_optyap_data.top_choice_point = cpt)
#endif /* YAPOR_THREADS */
#define LOCAL_top_or_fr (LOCAL_optyap_data.top_or_frame)
#ifdef YAPOR_THREADS
#define Get_LOCAL_prune_request() offset_to_cptr_with_null(LOCAL->prune_request_offset)
#define Set_LOCAL_prune_request(cpt) (LOCAL->prune_request_offset = cptr_to_offset_with_null(cpt))
#define Get_LOCAL_prune_request() offset_to_cptr_with_null(LOCAL_optyap_data.prune_request_offset)
#define Set_LOCAL_prune_request(cpt) (LOCAL_optyap_data.prune_request_offset = cptr_to_offset_with_null(cpt))
#else
#define LOCAL_prune_request (LOCAL->prune_request)
#define Get_LOCAL_prune_request() (LOCAL->prune_request)
#define Set_LOCAL_prune_request(cpt) (LOCAL->prune_request = cpt)
#endif
#define LOCAL_share_request (LOCAL->share_request)
#define LOCAL_reply_signal (LOCAL->share_signals.reply_signal)
#define LOCAL_p_fase_signal (LOCAL->share_signals.P_fase)
#define LOCAL_q_fase_signal (LOCAL->share_signals.Q_fase)
#define LOCAL_lock_signals (LOCAL->share_signals.lock)
#define LOCAL_start_global_copy (LOCAL->global_copy.start)
#define LOCAL_end_global_copy (LOCAL->global_copy.end)
#define LOCAL_start_local_copy (LOCAL->local_copy.start)
#define LOCAL_end_local_copy (LOCAL->local_copy.end)
#define LOCAL_start_trail_copy (LOCAL->trail_copy.start)
#define LOCAL_end_trail_copy (LOCAL->trail_copy.end)
#define LOCAL_next_free_ans_node (LOCAL->next_free_answer_trie_node)
#define LOCAL_top_sg_fr (LOCAL->top_subgoal_frame)
#define LOCAL_top_dep_fr (LOCAL->top_dependency_frame)
#define LOCAL_pruning_scope (LOCAL->bottom_pruning_scope)
#define LOCAL_prune_request (LOCAL_optyap_data.prune_request)
#define Get_LOCAL_prune_request() (LOCAL_optyap_data.prune_request)
#define Set_LOCAL_prune_request(cpt) (LOCAL_optyap_data.prune_request = cpt)
#endif /* YAPOR_THREADS */
#define LOCAL_share_request (LOCAL_optyap_data.share_request)
#define LOCAL_reply_signal (LOCAL_optyap_data.share_signals.reply_signal)
#define LOCAL_p_fase_signal (LOCAL_optyap_data.share_signals.P_fase)
#define LOCAL_q_fase_signal (LOCAL_optyap_data.share_signals.Q_fase)
#define LOCAL_lock_signals (LOCAL_optyap_data.share_signals.lock)
#define LOCAL_start_global_copy (LOCAL_optyap_data.global_copy.start)
#define LOCAL_end_global_copy (LOCAL_optyap_data.global_copy.end)
#define LOCAL_start_local_copy (LOCAL_optyap_data.local_copy.start)
#define LOCAL_end_local_copy (LOCAL_optyap_data.local_copy.end)
#define LOCAL_start_trail_copy (LOCAL_optyap_data.trail_copy.start)
#define LOCAL_end_trail_copy (LOCAL_optyap_data.trail_copy.end)
#define LOCAL_next_free_ans_node (LOCAL_optyap_data.next_free_answer_trie_node)
#define LOCAL_top_sg_fr (LOCAL_optyap_data.top_subgoal_frame)
#define LOCAL_top_dep_fr (LOCAL_optyap_data.top_dependency_frame)
#define LOCAL_pruning_scope (LOCAL_optyap_data.bottom_pruning_scope)
#ifdef YAPOR_THREADS
#define Get_LOCAL_top_cp_on_stack() offset_to_cptr(LOCAL->top_choice_point_on_stack_offset)
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL->top_choice_point_on_stack_offset = cptr_to_offset(cpt))
#define Get_LOCAL_top_cp_on_stack() offset_to_cptr(LOCAL_optyap_data.top_choice_point_on_stack_offset)
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL_optyap_data.top_choice_point_on_stack_offset = cptr_to_offset(cpt))
#else
#define LOCAL_top_cp_on_stack (LOCAL->top_choice_point_on_stack)
#define Get_LOCAL_top_cp_on_stack() (LOCAL->top_choice_point_on_stack)
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL->top_choice_point_on_stack = cpt)
#endif
#define LOCAL_top_susp_or_fr (LOCAL->top_or_frame_with_suspensions)
#define LOCAL_ma_timestamp (LOCAL->ma_timestamp)
#define LOCAL_ma_h_top (LOCAL->ma_h_top)
#define LOCAL_ma_hash_table (LOCAL->ma_hash_table)
#define LOCAL_top_cp_on_stack (LOCAL_optyap_data.top_choice_point_on_stack)
#define Get_LOCAL_top_cp_on_stack() (LOCAL_optyap_data.top_choice_point_on_stack)
#define Set_LOCAL_top_cp_on_stack(cpt) (LOCAL_optyap_data.top_choice_point_on_stack = cpt)
#endif /* YAPOR_THREADS */
#define LOCAL_top_susp_or_fr (LOCAL_optyap_data.top_or_frame_with_suspensions)
#define LOCAL_ma_timestamp (LOCAL_optyap_data.ma_timestamp)
#define LOCAL_ma_h_top (LOCAL_optyap_data.ma_h_top)
#define LOCAL_ma_hash_table (LOCAL_optyap_data.ma_hash_table)
#define REMOTE_lock(worker) (REMOTE[worker].lock)
#define REMOTE_load(worker) (REMOTE[worker].load)
#define REMOTE_lock(wid) (REMOTE(wid)->optyap_data.lock)
#define REMOTE_load(wid) (REMOTE(wid)->optyap_data.load)
#ifdef YAPOR_THREADS
#define REMOTE_top_cp(worker) offset_to_cptr(REMOTE[worker].top_choice_point_offset)
#define Set_REMOTE_top_cp(worker, bptr) (REMOTE[worker].top_choice_point_offset = cptr_to_offset(bptr))
#define REMOTE_top_cp(wid) offset_to_cptr(REMOTE(wid)->optyap_data.top_choice_point_offset)
#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point_offset = cptr_to_offset(bptr))
#else
#define REMOTE_top_cp(worker) (REMOTE[worker].top_choice_point)
#define Set_REMOTE_top_cp(worker, bptr) (REMOTE[worker].top_choice_point = (bptr))
#endif
#define REMOTE_top_or_fr(worker) (REMOTE[worker].top_or_frame)
#define REMOTE_top_cp(wid) (REMOTE(wid)->optyap_data.top_choice_point)
#define Set_REMOTE_top_cp(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point = (bptr))
#endif /* YAPOR_THREADS */
#define REMOTE_top_or_fr(wid) (REMOTE(wid)->optyap_data.top_or_frame)
#ifdef YAPOR_THREADS
#define Get_REMOTE_prune_request(worker) offset_to_cptr_with_null(REMOTE[worker].prune_request_offset)
#define Set_REMOTE_prune_request(worker,cp) (REMOTE[worker].prune_request_offset = cptr_to_offset_with_null(cp))
#define Get_REMOTE_prune_request(wid) offset_to_cptr_with_null(REMOTE(wid)->optyap_data.prune_request_offset)
#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data.prune_request_offset = cptr_to_offset_with_null(cp))
#else
#define REMOTE_prune_request(worker) (REMOTE[worker].prune_request)
#define Get_REMOTE_prune_request(worker) (REMOTE[worker].prune_request)
#define Set_REMOTE_prune_request(worker,cp) (REMOTE[worker].prune_request = cp)
#endif
#define REMOTE_share_request(worker) (REMOTE[worker].share_request)
#define REMOTE_reply_signal(worker) (REMOTE[worker].share_signals.reply_signal)
#define REMOTE_p_fase_signal(worker) (REMOTE[worker].share_signals.P_fase)
#define REMOTE_q_fase_signal(worker) (REMOTE[worker].share_signals.Q_fase)
#define REMOTE_lock_signals(worker) (REMOTE[worker].share_signals.lock)
#define REMOTE_start_global_copy(worker) (REMOTE[worker].global_copy.start)
#define REMOTE_end_global_copy(worker) (REMOTE[worker].global_copy.end)
#define REMOTE_start_local_copy(worker) (REMOTE[worker].local_copy.start)
#define REMOTE_end_local_copy(worker) (REMOTE[worker].local_copy.end)
#define REMOTE_start_trail_copy(worker) (REMOTE[worker].trail_copy.start)
#define REMOTE_end_trail_copy(worker) (REMOTE[worker].trail_copy.end)
#define REMOTE_next_free_ans_node(worker) (REMOTE[worker].next_free_answer_trie_node)
#define REMOTE_top_sg_fr(worker) (REMOTE[worker].top_subgoal_frame)
#define REMOTE_top_dep_fr(worker) (REMOTE[worker].top_dependency_frame)
#define REMOTE_pruning_scope(worker) (REMOTE[worker].bottom_pruning_scope)
#define REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data.prune_request)
#define Get_REMOTE_prune_request(wid) (REMOTE(wid)->optyap_data.prune_request)
#define Set_REMOTE_prune_request(wid,cp) (REMOTE(wid)->optyap_data.prune_request = cp)
#endif /* YAPOR_THREADS */
#define REMOTE_share_request(wid) (REMOTE(wid)->optyap_data.share_request)
#define REMOTE_reply_signal(wid) (REMOTE(wid)->optyap_data.share_signals.reply_signal)
#define REMOTE_p_fase_signal(wid) (REMOTE(wid)->optyap_data.share_signals.P_fase)
#define REMOTE_q_fase_signal(wid) (REMOTE(wid)->optyap_data.share_signals.Q_fase)
#define REMOTE_lock_signals(wid) (REMOTE(wid)->optyap_data.share_signals.lock)
#define REMOTE_start_global_copy(wid) (REMOTE(wid)->optyap_data.global_copy.start)
#define REMOTE_end_global_copy(wid) (REMOTE(wid)->optyap_data.global_copy.end)
#define REMOTE_start_local_copy(wid) (REMOTE(wid)->optyap_data.local_copy.start)
#define REMOTE_end_local_copy(wid) (REMOTE(wid)->optyap_data.local_copy.end)
#define REMOTE_start_trail_copy(wid) (REMOTE(wid)->optyap_data.trail_copy.start)
#define REMOTE_end_trail_copy(wid) (REMOTE(wid)->optyap_data.trail_copy.end)
#define REMOTE_next_free_ans_node(wid) (REMOTE(wid)->optyap_data.next_free_answer_trie_node)
#define REMOTE_top_sg_fr(wid) (REMOTE(wid)->optyap_data.top_subgoal_frame)
#define REMOTE_top_dep_fr(wid) (REMOTE(wid)->optyap_data.top_dependency_frame)
#define REMOTE_pruning_scope(wid) (REMOTE(wid)->optyap_data.bottom_pruning_scope)
#ifdef YAPOR_THREADS
#define REMOTE_top_cp_on_stack(worker) offset_to_cptr(REMOTE[worker].top_choice_point_on_stack_offset)
#define Set_REMOTE_top_cp_on_stack(worker, bptr) (REMOTE[worker].top_choice_point_on_stack_offset = cptr_to_offset(bptr))
#define REMOTE_top_cp_on_stack(wid) offset_to_cptr(REMOTE(wid)->optyap_data.top_choice_point_on_stack_offset)
#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point_on_stack_offset = cptr_to_offset(bptr))
#else
#define REMOTE_top_cp_on_stack(worker) (REMOTE[worker].top_choice_point_on_stack)
#define Set_REMOTE_top_cp_on_stack(worker, bptr) (REMOTE[worker].top_choice_point_on_stack = (bptr))
#endif
#define REMOTE_top_susp_or_fr(worker) (REMOTE[worker].top_or_frame_with_suspensions)
#define REMOTE_top_cp_on_stack(wid) (REMOTE(wid)->optyap_data.top_choice_point_on_stack)
#define Set_REMOTE_top_cp_on_stack(wid, bptr) (REMOTE(wid)->optyap_data.top_choice_point_on_stack = (bptr))
#endif /* YAPOR_THREADS */
#define REMOTE_top_susp_or_fr(wid) (REMOTE(wid)->optyap_data.top_or_frame_with_suspensions)
#ifdef YAPOR

View File

@ -98,7 +98,7 @@ int p_share_work(void) {
share_private_nodes(worker_q);
if ((son = fork()) == 0) {
worker_id = worker_q; /* child becomes requesting worker */
LOCAL = REMOTE + worker_id;
LOCAL = REMOTE(worker_id);
LOCAL_reply_signal = worker_ready;
PUT_IN_REQUESTABLE(worker_id);
PUT_BUSY(worker_id);

View File

@ -645,6 +645,7 @@ static inline CELL *expand_auxiliary_stack(CELL *stack) {
static inline void abolish_incomplete_subgoals(choiceptr prune_cp) {
CACHE_REGS
#ifdef YAPOR
if (EQUAL_OR_YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), prune_cp))
pruning_over_tabling_data_structures();

View File

@ -1363,6 +1363,7 @@ void show_table(tab_ent_ptr tab_ent, int show_mode) {
fprintf(Yap_stdout, " Answer trie nodes: %ld\n", TrStat_ans_nodes);
fprintf(Yap_stdout, " Global trie references: %ld\n", TrStat_gt_refs);
}
fflush(Yap_stdout);
return;
}

View File

@ -2491,9 +2491,9 @@ PL_create_engine(const PL_thread_attr_t *attr)
yapt.tsize = attr->global_size;
yapt.alias = (YAP_Term)attr->alias;
yapt.cancel = attr->cancel;
return Yap_WLocal+YAP_ThreadCreateEngine(&yapt);
return Yap_local+YAP_ThreadCreateEngine(&yapt);
} else {
return Yap_WLocal+YAP_ThreadCreateEngine(NULL);
return Yap_local+YAP_ThreadCreateEngine(NULL);
}
#else
return NULL;
@ -2519,7 +2519,7 @@ PL_set_engine(PL_engine_t engine, PL_engine_t *old)
int cwid = PL_thread_self(), nwid;
if (cwid >= 0) {
if (old) *old = (PL_engine_t)(Yap_WLocal[cwid]);
if (old) *old = (PL_engine_t)(Yap_local[cwid]);
}
if (!engine) {
if (cwid < 0)
@ -2561,7 +2561,7 @@ PL_set_engine(PL_engine_t engine, PL_engine_t *old)
}
return PL_ENGINE_SET;
#else
if (old) *old = (PL_engine_t)&Yap_WLocal;
if (old) *old = (PL_engine_t)&Yap_local;
return FALSE;
#endif
}

View File

@ -14,13 +14,30 @@
// init code (optional)
// restore code (optional)
//
//
// Stuff that must be shared by all threads or workers
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
// halt hooks
struct halt_hook *yap_halt_hook Yap_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
// 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
/* multi-thread support */
#if THREADS
/* number of threads and processes in system */
@ -37,37 +54,14 @@ UInt threads_total_time Yap_ThreadsTotalTime =0L
lockvar bgl Yap_BGL MkLock
#endif
// 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
// 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
// Threads Array
#ifdef THREADS
lockvar thread_handles_lock Yap_ThreadHandlesLock MkLock
#endif
// Ricardo's stuff
#if defined(YAPOR) || defined(TABLING)
struct global_optyap_data optyap_data Yap_optyap_data void
struct local_data remote[MAX_WORKERS] REMOTE void
#endif
// 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
// halt hooks
struct halt_hook *yap_halt_hook Yap_HaltHooks =NULL
#endif /* YAPOR || TABLING */
END_GLOBAL_DATA

View File

@ -103,16 +103,9 @@ CELL** ip_top LOCAL_iptop =NULL
#if defined(GC_NO_TAGS)
char* b_p LOCAL_bp =NULL
#endif
#if !defined(TABLING) && !defined(YAPOR_SBA) && (defined(YAPOR) || defined(THREADS))
Term* wl_sTR LOCAL_sTR =NULL
Term* wl_sTR0 LOCAL_sTR0 =NULL
Term* new_tr LOCAL_new_TR =NULL
#else
struct trail_frame* wl_sTR LOCAL_sTR =NULL
struct trail_frame* wl_sTR0 LOCAL_sTR0 =NULL
struct trail_frame* new_tr LOCAL_new_TR =NULL
#endif /* !TABLING && !YAPOR_SBA && (YAPOR || THREADS) */
tr_fr_ptr wl_sTR LOCAL_sTR =NULL
tr_fr_ptr wl_sTR0 LOCAL_sTR0 =NULL
tr_fr_ptr new_tr LOCAL_new_TR =NULL
struct gc_mark_continuation* conttop0 LOCAL_cont_top0 =NULL
struct gc_mark_continuation* conttop LOCAL_cont_top =NULL
int disc_trail_entries LOCAL_discard_trail_entries =0
@ -146,10 +139,14 @@ struct open_query_struct* _execution LOCAL_execution =NULL
#ifdef THREADS
struct thandle thread_handle LOCAL_ThreadHandle InitThreadHandle(wid)
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_WLocal[worker_id]->thread_handle)
#define FOREIGN_ThreadHandle(wid) (Yap_local[(wid)]->thread_handle)
#define MY_ThreadHandle (Yap_local[worker_id]->thread_handle)
#endif
#if defined(YAPOR) || defined(TABLING)
struct local_optyap_data optyap_data LOCAL_optyap_data Yap_init_local_optyap_data(wid)
#endif /* YAPOR || TABLING */
// END WORKER LOCAL STUFF
END_WORKER_LOCAL

View File

@ -119,7 +119,7 @@ fetch_name(Global) :-
Global = "Yap_global->".
fetch_name(Global) :-
globals(worker), !,
Global = "WL->".
Global = "LOCAL->".
fetch_name(Global) :-
globals(worker_init), !,
Global = "FOREIGN(wid)->".
@ -264,6 +264,10 @@ gen_init(Inp,Init) :-
split(Inp," ",[_, _, _, Init0| _]),
append("Yap_Init",_,Init0), !,
append([" ",Init0,";"],Init).
gen_init(Inp,Init) :-
split(Inp," ",[_, _, _, Init0| _]),
append("Yap_init",_,Init0), !,
append([" ",Init0,";"],Init).
gen_init(Inp,Out) :-
split(Inp," ",[_, Field, MacroName, "MkAT", AtomName]), !,
cut_c_stuff(Field, RField),

View File

@ -4740,7 +4740,7 @@ struct PL_local_data *Yap_InitThreadIO(int wid)
#if THREADS
if (wid) {
/* copy from other worker */
memcpy(p, Yap_WLocal[worker_id]->Yap_ld_, sizeof(struct PL_local_data));
memcpy(p, Yap_local[worker_id]->Yap_ld_, sizeof(struct PL_local_data));
}
#endif
return p;