fix YapOr threads.
This commit is contained in:
@@ -91,8 +91,8 @@
|
||||
/************************************************************
|
||||
** memory mapping scheme (mandatory, define one) **
|
||||
************************************************************/
|
||||
//#define MMAP_MEMORY_MAPPING_SCHEME 1
|
||||
#define SHM_MEMORY_MAPPING_SCHEME 1
|
||||
#define MMAP_MEMORY_MAPPING_SCHEME 1
|
||||
/*#define SHM_MEMORY_MAPPING_SCHEME 1*/
|
||||
|
||||
/*************************************************
|
||||
** enable error checking ? (optional) **
|
||||
|
@@ -233,9 +233,9 @@ void make_root_frames(void) {
|
||||
void init_workers(void) {
|
||||
CACHE_REGS
|
||||
int proc;
|
||||
#ifdef THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
return;
|
||||
#endif
|
||||
#endif /* YAPOR_THREADS */
|
||||
#ifdef YAPOR_COW
|
||||
if (Yap_number_workers> 1) {
|
||||
int son;
|
||||
|
@@ -16,7 +16,7 @@
|
||||
**************************************/
|
||||
|
||||
#include "Yap.h"
|
||||
#if defined(YAPOR) && !defined(THREADS)
|
||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@@ -72,7 +72,7 @@ void Yap_init_optyap_memory(long TrailAuxArea, long HeapArea, long GlobalLocalAr
|
||||
#endif /* MMAP_MEMORY_MAPPING_SCHEME */
|
||||
#else /* YAPOR_COPY || YAPOR_SBA */
|
||||
long TotalArea;
|
||||
#endif /* YAPOR_MODEL */
|
||||
#endif
|
||||
long ExtraArea;
|
||||
|
||||
HeapArea = ADJUST_SIZE_TO_PAGE(HeapArea);
|
||||
@@ -97,7 +97,7 @@ void Yap_init_optyap_memory(long TrailAuxArea, long HeapArea, long GlobalLocalAr
|
||||
/* the others need n stacks */
|
||||
Yap_worker_area_size = ADJUST_SIZE_TO_PAGE(GlobalLocalArea + TrailAuxArea);
|
||||
TotalArea = ExtraArea + HeapArea + Yap_worker_area_size * n_workers;
|
||||
#endif /* YAPOR_MODEL */
|
||||
#endif
|
||||
|
||||
#ifdef MMAP_MEMORY_MAPPING_SCHEME
|
||||
/* map total area in a single go */
|
||||
@@ -116,7 +116,7 @@ void Yap_init_optyap_memory(long TrailAuxArea, long HeapArea, long GlobalLocalAr
|
||||
for (i = 0; i < n_workers; i++)
|
||||
shm_map_memory(i, Yap_worker_area_size, Yap_GlobalBase + Yap_worker_area_size * i);
|
||||
}
|
||||
#endif /* YAPOR_MODEL */
|
||||
#endif
|
||||
#endif /* MEMORY_MAPPING_SCHEME */
|
||||
|
||||
#ifdef YAPOR_COW
|
||||
@@ -220,7 +220,7 @@ void Yap_unmap_optyap_memory (void) {
|
||||
itos(Yap_master_worker, &MapFile[9]);
|
||||
#else /* YAPOR_COPY || YAPOR_SBA */
|
||||
itos(Yap_worker_pid(0), &MapFile[9]);
|
||||
#endif /* YAPOR_MODEL */
|
||||
#endif
|
||||
if (remove(MapFile) == 0)
|
||||
INFORMATION_MESSAGE("Removing mapfile \"%s\"", MapFile);
|
||||
else
|
||||
@@ -230,7 +230,7 @@ void Yap_unmap_optyap_memory (void) {
|
||||
i = 0;
|
||||
#else /* YAPOR_COPY || YAPOR_SBA */
|
||||
for (i = 0; i < Yap_number_workers + 1; i++)
|
||||
#endif /* YAPOR_COW */
|
||||
#endif
|
||||
{
|
||||
if (shmctl(shm_mapid[i], IPC_RMID, 0) == 0)
|
||||
INFORMATION_MESSAGE("Removing shared memory segment %d", shm_mapid[i]);
|
||||
@@ -271,5 +271,4 @@ void shm_map_memory(int id, int size, void *shmaddr) {
|
||||
return;
|
||||
}
|
||||
#endif /* MMAP_MEMORY_MAPPING_SCHEME */
|
||||
|
||||
#endif /* YAPOR && !THREADS */
|
||||
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */
|
||||
|
@@ -501,7 +501,7 @@ static Int p_show_statistics_global_trie( USES_REGS1 ) {
|
||||
*********************************/
|
||||
|
||||
static Int p_yapor_threads( USES_REGS1 ) {
|
||||
#if defined(YAPOR) && defined(THREADS)
|
||||
#ifdef YAPOR_THREADS
|
||||
return Yap_unify(MkIntegerTerm(Yap_number_workers),ARG1);
|
||||
#else
|
||||
return FALSE;
|
||||
|
@@ -18,7 +18,7 @@
|
||||
typedef double realtime;
|
||||
typedef unsigned long bitmap;
|
||||
|
||||
#ifdef THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
/* Threads may not assume addresses are the same at different workers */
|
||||
static inline choiceptr
|
||||
offset_to_cptr(Int node)
|
||||
@@ -49,7 +49,7 @@ cptr_to_offset_with_null(choiceptr node)
|
||||
if (node == NULL) return 0L;
|
||||
return (Int)((CELL *)node-LCL0);
|
||||
}
|
||||
#endif /* THREADS */
|
||||
#endif /* YAPOR_THREADS */
|
||||
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ struct global_optyap_data{
|
||||
char performance_mode; /* PERFORMANCE_OFF / PERFORMANCE_ON / PERFORMANCE_IN_EXECUTION */
|
||||
|
||||
/* global data related to or-parallelism */
|
||||
#if THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
Int root_choice_point_offset;
|
||||
#else
|
||||
choiceptr root_choice_point;
|
||||
@@ -218,7 +218,7 @@ struct global_optyap_data{
|
||||
#ifdef TABLE_LOCK_AT_WRITE_LEVEL
|
||||
lockvar table_lock[TABLE_LOCK_BUCKETS];
|
||||
#endif /* TABLE_LOCK_AT_WRITE_LEVEL */
|
||||
#ifdef TIMESTAMP_CHECK
|
||||
#ifdef TIMESTAMP_CHECKThreads
|
||||
long timestamp;
|
||||
#endif /* TIMESTAMP_CHECK */
|
||||
#endif /* TABLING */
|
||||
@@ -250,7 +250,7 @@ struct global_optyap_data{
|
||||
#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)
|
||||
#if THREADS
|
||||
#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))
|
||||
#else
|
||||
@@ -299,7 +299,7 @@ struct global_optyap_data{
|
||||
|
||||
#ifdef YAPOR
|
||||
struct local_signals{
|
||||
#if defined(YAPOR_COPY) || defined(THREADS)
|
||||
#if defined(YAPOR_COPY) || defined(YAPOR_THREADS)
|
||||
lockvar lock;
|
||||
volatile enum {
|
||||
Q_idle = 0,
|
||||
@@ -308,7 +308,7 @@ struct local_signals{
|
||||
local = 3,
|
||||
P_idle = 4
|
||||
} P_fase, Q_fase;
|
||||
#endif /* YAPOR_COPY || THREADS */
|
||||
#endif /* YAPOR_COPY || YAPOR_THREADS */
|
||||
volatile enum {
|
||||
no_sharing = 0,
|
||||
sharing = 1,
|
||||
@@ -346,19 +346,17 @@ typedef struct {
|
||||
********************************/
|
||||
|
||||
struct local_data{
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
lockvar lock;
|
||||
#endif
|
||||
#ifdef YAPOR
|
||||
lockvar lock;
|
||||
/* local data related to or-parallelism */
|
||||
volatile int load;
|
||||
#if THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
Int top_choice_point_offset;
|
||||
#else
|
||||
choiceptr top_choice_point;
|
||||
#endif
|
||||
struct or_frame *top_or_frame;
|
||||
#if THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
Int prune_request_offset;
|
||||
#else
|
||||
choiceptr prune_request;
|
||||
@@ -380,7 +378,7 @@ struct local_data{
|
||||
choiceptr bottom_pruning_scope;
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
#ifdef YAPOR
|
||||
#ifdef THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
Int top_choice_point_on_stack_offset;
|
||||
#else
|
||||
choiceptr top_choice_point_on_stack;
|
||||
@@ -398,7 +396,7 @@ struct local_data{
|
||||
|
||||
#define LOCAL_lock (LOCAL->lock)
|
||||
#define LOCAL_load (LOCAL->load)
|
||||
#if THREADS
|
||||
#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))
|
||||
#else
|
||||
@@ -407,7 +405,7 @@ struct local_data{
|
||||
#define Set_LOCAL_top_cp(cpt) (LOCAL->top_choice_point = cpt)
|
||||
#endif
|
||||
#define LOCAL_top_or_fr (LOCAL->top_or_frame)
|
||||
#if THREADS
|
||||
#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))
|
||||
#else
|
||||
@@ -430,7 +428,7 @@ struct local_data{
|
||||
#define LOCAL_top_sg_fr (LOCAL->top_subgoal_frame)
|
||||
#define LOCAL_top_dep_fr (LOCAL->top_dependency_frame)
|
||||
#define LOCAL_pruning_scope (LOCAL->bottom_pruning_scope)
|
||||
#if THREADS
|
||||
#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))
|
||||
#else
|
||||
@@ -443,11 +441,10 @@ struct local_data{
|
||||
#define LOCAL_ma_h_top (LOCAL->ma_h_top)
|
||||
#define LOCAL_ma_hash_table (LOCAL->ma_hash_table)
|
||||
|
||||
|
||||
#define REMOTE_lock(worker) (REMOTE[worker].lock)
|
||||
|
||||
|
||||
#define REMOTE_load(worker) (REMOTE[worker].load)
|
||||
#if THREADS
|
||||
#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))
|
||||
#else
|
||||
@@ -455,7 +452,7 @@ struct local_data{
|
||||
#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)
|
||||
#if THREADS
|
||||
#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))
|
||||
#else
|
||||
@@ -478,7 +475,7 @@ struct local_data{
|
||||
#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)
|
||||
#if THREADS
|
||||
#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))
|
||||
#else
|
||||
|
@@ -137,7 +137,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
|
||||
SCHEDULER_GET_WORK(); \
|
||||
}
|
||||
|
||||
#if defined(YAPOR_COPY) || defined(YAPOR_SBA) || defined(THREADS)
|
||||
#if defined(YAPOR_COPY) || defined(YAPOR_SBA) || defined(YAPOR_THREADS)
|
||||
#define SCH_check_share_request() \
|
||||
if (SCH_any_share_request) { \
|
||||
ASP = YENV; \
|
||||
@@ -151,7 +151,7 @@ STD_PROTO(static inline qg_sol_fr_ptr CUT_prune_solution_frames, (qg_sol_fr_ptr,
|
||||
if (! p_share_work()) \
|
||||
goto shared_fail; \
|
||||
}
|
||||
#endif /* YAPOR_COPY || YAPOR_SBA || YAPOR_COW */
|
||||
#endif /* YAPOR_COPY || YAPOR_SBA || YAPOR_COW || YAPOR_THREADS */
|
||||
|
||||
#define SCH_check_requests() \
|
||||
SCH_check_prune_request(); \
|
||||
|
@@ -19,7 +19,7 @@ typedef struct or_frame {
|
||||
lockvar lock;
|
||||
yamop *alternative;
|
||||
volatile bitmap members;
|
||||
#ifdef THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
Int node_offset;
|
||||
#else
|
||||
choiceptr node;
|
||||
@@ -27,7 +27,7 @@ typedef struct or_frame {
|
||||
struct or_frame *nearest_livenode;
|
||||
/* cut support */
|
||||
int depth;
|
||||
#ifdef THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
Int pending_prune_cp_offset;
|
||||
#else
|
||||
choiceptr pending_prune_cp;
|
||||
@@ -51,7 +51,7 @@ typedef struct or_frame {
|
||||
#define OrFr_lock(X) ((X)->lock)
|
||||
#define OrFr_alternative(X) ((X)->alternative)
|
||||
#define OrFr_members(X) ((X)->members)
|
||||
#ifdef THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
#define GetOrFr_node(X) offset_to_cptr((X)->node_offset)
|
||||
#define SetOrFr_node(X,V) ((X)->node_offset = cptr_to_offset(V))
|
||||
#else
|
||||
@@ -61,7 +61,7 @@ typedef struct or_frame {
|
||||
#endif
|
||||
#define OrFr_nearest_livenode(X) ((X)->nearest_livenode)
|
||||
#define OrFr_depth(X) ((X)->depth)
|
||||
#ifdef THREADS
|
||||
#ifdef YAPOR_THREADS
|
||||
#define Get_OrFr_pend_prune_cp(X) offset_to_cptr_with_null((X)->pending_prune_cp_offset)
|
||||
#define Set_OrFr_pend_prune_cp(X,V) ((X)->pending_prune_cp_offset = cptr_to_offset_with_null(V))
|
||||
#else
|
||||
|
@@ -16,7 +16,7 @@
|
||||
** ------------------ */
|
||||
|
||||
#include "Yap.h"
|
||||
#if defined(THREADS) && defined(YAPOR)
|
||||
#ifdef YAPOR_THREADS
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
@@ -539,4 +539,4 @@ void share_private_nodes(int worker_q) {
|
||||
REMOTE_load(worker_q) = LOCAL_load = 0;
|
||||
return;
|
||||
}
|
||||
#endif /* YAPOR_COPY */
|
||||
#endif /* YAPOR_THREADS */
|
||||
|
@@ -164,10 +164,10 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int);
|
||||
#define STACK_NOT_EMPTY(STACK, STACK_BASE) (STACK) != (STACK_BASE)
|
||||
#define AUX_STACK_CHECK_EXPAND(STACK, STACK_LIMIT) if ((STACK_LIMIT) >= (STACK)) EXPAND_AUX_STACK(STACK)
|
||||
#define STACK_CHECK_EXPAND(STACK, STACK_LIMIT) if ((STACK_LIMIT) >= (STACK)+4096) EXPAND_STACK(STACK)
|
||||
#if defined(YAPOR) && !defined(THREADS)
|
||||
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
||||
#define EXPAND_AUX_STACK(STACK) Yap_Error(INTERNAL_ERROR, TermNil, "stack full (AUX_STACK_CHECK_EXPAND)");
|
||||
#define EXPAND_STACK(STACK) Yap_Error(INTERNAL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)");
|
||||
#else
|
||||
#else /* YAPOR_THREADS */
|
||||
#define EXPAND_AUX_STACK(STACK) STACK = expand_auxiliary_stack(STACK)
|
||||
#define EXPAND_STACK(STACK) Yap_Error(INTERNAL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)");
|
||||
#endif /* YAPOR */
|
||||
|
Reference in New Issue
Block a user