My first attempt to synchronize OPTYap with CVS
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@916 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
e2e49aecd1
commit
80be9121af
@ -395,7 +395,7 @@ Int Yap_unify(Term t0, Term t1)
|
||||
pt[0] = TrailVal(TR);
|
||||
#else
|
||||
pt[0] = TrailTerm(TR);
|
||||
#endif
|
||||
#endif /* FROZEN_STACKS */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ static void receive_signals(int s);
|
||||
** Local macros **
|
||||
** ---------------------- */
|
||||
|
||||
#define STRUCTS_PER_PAGE(STR_TYPE) ((PageSize - STRUCT_SIZE(struct page_header)) / STRUCT_SIZE(STR_TYPE))
|
||||
#define STRUCTS_PER_PAGE(STR_TYPE) ((Yap_page_size - STRUCT_SIZE(struct page_header)) / STRUCT_SIZE(STR_TYPE))
|
||||
|
||||
#ifdef STATISTICS
|
||||
#define INIT_PAGE_STATISTICS(PG) \
|
||||
@ -165,7 +165,7 @@ void init_global(int n_workers, int sch_loop, int delay_load) {
|
||||
void init_local(void) {
|
||||
#ifdef YAPOR
|
||||
/* local data related to or-parallelism */
|
||||
LOCAL = REMOTE+worker_id;
|
||||
LOCAL = REMOTE + worker_id;
|
||||
LOCAL_top_cp = B_BASE;
|
||||
LOCAL_top_or_fr = GLOBAL_root_or_fr;
|
||||
LOCAL_load = 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
** Memory management **
|
||||
** --------------------------- */
|
||||
|
||||
extern int PageSize;
|
||||
extern int Yap_page_size;
|
||||
|
||||
#define H_BASE ((CELL *) Yap_GlobalBase)
|
||||
#define B_BASE ((choiceptr) Yap_LocalBase)
|
||||
@ -20,9 +20,9 @@ extern int PageSize;
|
||||
#endif /* SIZEOF_INT_P */
|
||||
|
||||
#define ADJUST_SIZE(SIZE) ((SIZE + ALIGN) & ALIGNMASK)
|
||||
#define ADJUST_SIZE_TO_PAGE(SIZE) ((SIZE) - (SIZE) % PageSize + PageSize)
|
||||
#define ADJUST_SIZE_TO_PAGE(SIZE) ((SIZE) - (SIZE) % Yap_page_size + Yap_page_size)
|
||||
#define STRUCT_SIZE(STR_TYPE) ADJUST_SIZE(sizeof(STR_TYPE))
|
||||
#define PAGE_HEADER(STR) (pg_hd_ptr)((unsigned int)STR - (unsigned int)STR % PageSize)
|
||||
#define PAGE_HEADER(STR) (pg_hd_ptr)((unsigned int)STR - (unsigned int)STR % Yap_page_size)
|
||||
#define STRUCT_NEXT(STR) ((STR)->next)
|
||||
|
||||
|
||||
@ -52,20 +52,13 @@ extern int PageSize;
|
||||
#define FREE_HASH_BUCKETS(BUCKET_PTR) FREE_BLOCK(BUCKET_PTR)
|
||||
|
||||
#ifdef USE_HEAP
|
||||
|
||||
#define alloc_memory_block(SIZE) (void *)Yap_AllocCodeSpace(SIZE)
|
||||
#define free_memory_block(BLK) Yap_FreeCodeSpace((ADDR)BLK)
|
||||
#define reset_alloc_block_area()
|
||||
|
||||
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) STR = (STR_TYPE *)Yap_AllocCodeSpace(sizeof(STR_TYPE))
|
||||
|
||||
#define ALLOC_NEXT_FREE_STRUCT(STR, STR_PAGES, STR_TYPE) STR = (STR_TYPE *)Yap_AllocCodeSpace(sizeof(STR_TYPE))
|
||||
|
||||
#define FREE_STRUCT(STR, STR_PAGES, STR_TYPE) Yap_FreeCodeSpace((ADDR)(STR))
|
||||
|
||||
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \
|
||||
STR = (STR_TYPE *)Yap_AllocCodeSpace(sizeof(STR_TYPE))
|
||||
#define ALLOC_NEXT_FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \
|
||||
STR = (STR_TYPE *)Yap_AllocCodeSpace(sizeof(STR_TYPE))
|
||||
#define FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \
|
||||
Yap_FreeCodeSpace((ADDR)(STR))
|
||||
#else
|
||||
|
||||
|
||||
#define ALLOC_PAGE(PG_HD) \
|
||||
LOCK(Pg_lock(GLOBAL_PAGES_void)); \
|
||||
UPDATE_STATS(Pg_requests(GLOBAL_PAGES_void), 1); \
|
||||
@ -75,7 +68,7 @@ extern int PageSize;
|
||||
abort_optyap("no more free alloc space (ALLOC_PAGE)"); \
|
||||
UPDATE_STATS(Pg_str_alloc(GLOBAL_PAGES_void), 1); \
|
||||
PG_HD = (pg_hd_ptr)TopAllocArea; \
|
||||
TopAllocArea += PageSize; \
|
||||
TopAllocArea += Yap_page_size \
|
||||
} else { \
|
||||
PG_HD = Pg_free_pg(GLOBAL_PAGES_void); \
|
||||
Pg_free_pg(GLOBAL_PAGES_void) = PgHd_next(PG_HD); \
|
||||
@ -90,8 +83,6 @@ extern int PageSize;
|
||||
Pg_free_pg(GLOBAL_PAGES_void) = PG_HD; \
|
||||
UNLOCK(Pg_lock(GLOBAL_PAGES_void))
|
||||
|
||||
|
||||
|
||||
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \
|
||||
{ pg_hd_ptr pg_hd; \
|
||||
LOCK(Pg_lock(STR_PAGES)); \
|
||||
@ -102,7 +93,8 @@ extern int PageSize;
|
||||
PgHd_str_in_use(pg_hd)++; \
|
||||
STR = (STR_TYPE *) PgHd_free_str(pg_hd); \
|
||||
if ((PgHd_free_str(pg_hd) = (void *) STRUCT_NEXT(STR)) == NULL) \
|
||||
Pg_free_pg(STR_PAGES) = PgHd_next(pg_hd); \
|
||||
if ((Pg_free_pg(STR_PAGES) = PgHd_next(pg_hd)) != NULL) \
|
||||
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
|
||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
||||
} else { \
|
||||
int i; \
|
||||
@ -192,8 +184,7 @@ extern int PageSize;
|
||||
UNLOCK(Pg_lock(STR_PAGES)); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif /* TEST*/
|
||||
#endif /* USE_HEAP */
|
||||
|
||||
|
||||
#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_or_fr, struct or_frame)
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
/*
|
||||
Set of routines to allow restoring updatable variables when we go *up*
|
||||
@ -91,4 +90,4 @@ NEW_MAHASH(ma_h_inner_struct *top) {
|
||||
return(time);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
|
@ -27,7 +27,7 @@
|
||||
** -------------------------------------- */
|
||||
|
||||
#include "Yap.h"
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
#ifdef YAPOR
|
||||
#include "Yatom.h"
|
||||
#include "Heap.h"
|
||||
#include "alloc.h"
|
||||
@ -42,86 +42,67 @@
|
||||
#include <sys/shm.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#define KBYTES 1024
|
||||
#define HEAP_BLOCKS 1
|
||||
#define OPT_BLOCKS 5
|
||||
#define OPT_BLOCK_SIZE ADJUST_SIZE_TO_PAGE(10000 * KBYTES)
|
||||
#define KBYTES 1024
|
||||
|
||||
int PageSize;
|
||||
#ifdef MMAP_MEMORY_MAPPING_SCHEME
|
||||
int fd_mapfile;
|
||||
#else /* SHM_MEMORY_MAPPING_SCHEME */
|
||||
int shm_mapid[MAX_WORKERS + HEAP_BLOCKS + OPT_BLOCKS];
|
||||
int shm_mapid[MAX_WORKERS + 1];
|
||||
#endif /* MEMORY_MAPPING_SCHEME */
|
||||
|
||||
|
||||
|
||||
/* --------------------------- **
|
||||
** Global functions **
|
||||
** --------------------------- */
|
||||
|
||||
long global_data_size(void) {
|
||||
return ADJUST_SIZE(sizeof(struct global_data));
|
||||
}
|
||||
|
||||
|
||||
long local_data_size(void) {
|
||||
return ADJUST_SIZE(sizeof(struct local_data));
|
||||
}
|
||||
|
||||
|
||||
#ifdef SHM_MEMORY_MAPPING_SCHEME
|
||||
void shm_map_memory(int id, int size, void *shmaddr) {
|
||||
#define SHMMAX 0x2000000 /* as in <asm/shmparam.h> */
|
||||
if (size > SHMMAX)
|
||||
abort_optyap("maximum size for a shm segment exceeded in function shm_map_memory");
|
||||
if ((shm_mapid[id] = shmget(IPC_PRIVATE, size, SHM_R|SHM_W)) == -1)
|
||||
abort_optyap("shmget error in function shm_map_memory %s", strerror(errno));
|
||||
abort_optyap("shmget error in function shm_map_memory: %s", strerror(errno));
|
||||
if (shmat(shm_mapid[id], shmaddr, 0) == (void *) -1)
|
||||
abort_optyap("shmat error in function shm_map_memory %s", strerror(errno));
|
||||
abort_optyap("shmat error in function shm_map_memory: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
#else /* MMAP_MEMORY_MAPPING_SCHEME */
|
||||
static void
|
||||
open_mapfile(long TotalArea) {
|
||||
char mapfile[20];
|
||||
strcpy(mapfile,"/tmp/mapfile");
|
||||
itos(getpid(), &mapfile[12]);
|
||||
if ((fd_mapfile = open(mapfile, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
|
||||
abort_optyap("open error in function open_mapfile %s", strerror(errno));
|
||||
abort_optyap("open error in function open_mapfile: %s", strerror(errno));
|
||||
if (lseek(fd_mapfile, TotalArea, SEEK_SET) < 0)
|
||||
abort_optyap("lseek error in function map_memory: %s", strerror(errno));
|
||||
abort_optyap("lseek error in function open_mapfile: %s", strerror(errno));
|
||||
if (write(fd_mapfile, "", 1) < 0)
|
||||
abort_optyap("write error in function map_memory: %s", strerror(errno));
|
||||
abort_optyap("write error in function open_mapfile: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
close_mapfile(void) {
|
||||
if (close(fd_mapfile) < 0)
|
||||
abort_optyap("close error in function open_mapfile %s", strerror(errno));
|
||||
abort_optyap("close error in function close_mapfile: %s", strerror(errno));
|
||||
}
|
||||
#endif /* MMAP_MEMORY_MAPPING_SCHEME */
|
||||
|
||||
|
||||
void map_memory(long HeapArea, long GlobalLocalArea, long TrailAuxArea, int n_workers) {
|
||||
#ifndef ACOW
|
||||
#ifdef YAPOR
|
||||
int i;
|
||||
#endif /* YAPOR */
|
||||
long WorkerArea;
|
||||
long TotalArea;
|
||||
#else
|
||||
#if MMAP_MEMORY_MAPPING_SCHEME
|
||||
long TotalArea;
|
||||
#endif
|
||||
#endif
|
||||
void *mmap_addr = (void *)MMAP_ADDR;
|
||||
#ifdef ACOW
|
||||
int private_fd_mapfile;
|
||||
#endif /* ACOW */
|
||||
#if MMAP_MEMORY_MAPPING_SCHEME
|
||||
long TotalArea;
|
||||
#endif /* MMAP_MEMORY_MAPPING_SCHEME */
|
||||
#else /* ENV_COPY || SBA */
|
||||
int i;
|
||||
long WorkerArea;
|
||||
long TotalArea;
|
||||
#endif /* YAPOR_MODEL */
|
||||
|
||||
/* Initial Allocation */
|
||||
/* model indepndent */
|
||||
PageSize = sysconf(_SC_PAGESIZE);
|
||||
/* initial allocation - model independent */
|
||||
HeapArea = ADJUST_SIZE_TO_PAGE(HeapArea * KBYTES);
|
||||
GlobalLocalArea = ADJUST_SIZE(GlobalLocalArea * KBYTES);
|
||||
TrailAuxArea = ADJUST_SIZE(TrailAuxArea * KBYTES);
|
||||
@ -129,41 +110,37 @@ void map_memory(long HeapArea, long GlobalLocalArea, long TrailAuxArea, int n_wo
|
||||
/* we'll need this later */
|
||||
Yap_GlobalBase = mmap_addr + HeapArea;
|
||||
|
||||
/* model dependent */
|
||||
/* shared memory allocation */
|
||||
/* shared memory allocation - model dependent */
|
||||
#ifdef ACOW
|
||||
/* acow just needs one stack */
|
||||
#ifdef MMAP_MEMORY_MAPPING_SCHEME
|
||||
/* I need this for MMAP to know what it must allocate */
|
||||
TotalArea = HeapArea;
|
||||
#endif
|
||||
#else
|
||||
#endif /* MMAP_MEMORY_MAPPING_SCHEME */
|
||||
#else /* ENV_COPY || SBA */
|
||||
/* the others need n stacks */
|
||||
WorkerArea = ADJUST_SIZE_TO_PAGE(GlobalLocalArea + TrailAuxArea);
|
||||
TotalArea = HeapArea + WorkerArea * n_workers;
|
||||
#endif /* ACOW */
|
||||
#endif /* YAPOR_MODEL */
|
||||
|
||||
/* step 2: mmap heap area */
|
||||
/* mmap heap area */
|
||||
#ifdef MMAP_MEMORY_MAPPING_SCHEME
|
||||
/* map total area in a single go */
|
||||
open_mapfile(TotalArea);
|
||||
if ((mmap_addr = mmap((void *) MMAP_ADDR, (size_t) TotalArea, PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED|MAP_FIXED, fd_mapfile, 0)) == (void *) -1)
|
||||
abort_optyap("mmap error in function map_memory: %s", strerror(errno));
|
||||
#endif /* MEMORY_MAPPING_SCHEME */
|
||||
|
||||
#else /* SHM_MEMORY_MAPPING_SCHEME */
|
||||
/* Most systems are limited regarding what we can allocate */
|
||||
#ifdef SHM_MEMORY_MAPPING_SCHEME
|
||||
#ifdef ACOW
|
||||
/* single shared segment in ACOW */
|
||||
shm_map_memory(0, HeapArea, mmap_addr);
|
||||
#else
|
||||
/* place as segment n otherwise (0..n-1 reserved for stacks */
|
||||
#else /* ENV_COPY || SBA */
|
||||
/* place as segment n otherwise (0..n-1 reserved for worker areas */
|
||||
shm_map_memory(n_workers, HeapArea, mmap_addr);
|
||||
#endif
|
||||
#endif
|
||||
#endif /* YAPOR_MODEL */
|
||||
#endif /* MEMORY_MAPPING_SCHEME */
|
||||
|
||||
#ifdef YAPOR
|
||||
#ifdef ACOW
|
||||
/* just allocate local space for stacks */
|
||||
if ((private_fd_mapfile = open("/dev/zero", O_RDWR)) < 0)
|
||||
@ -172,7 +149,7 @@ void map_memory(long HeapArea, long GlobalLocalArea, long TrailAuxArea, int n_wo
|
||||
MAP_PRIVATE|MAP_FIXED, private_fd_mapfile, 0) == (void *) -1)
|
||||
abort_optyap("mmap error in function map_memory: %s", strerror(errno));
|
||||
close(private_fd_mapfile);
|
||||
#else /* ENV_COPY or SBA */
|
||||
#else /* ENV_COPY || SBA */
|
||||
for (i = 0; i < n_workers; i++) {
|
||||
/* initialize worker vars */
|
||||
worker_area(i) = Yap_GlobalBase + i * WorkerArea;
|
||||
@ -182,14 +159,7 @@ void map_memory(long HeapArea, long GlobalLocalArea, long TrailAuxArea, int n_wo
|
||||
shm_map_memory(i, WorkerArea, worker_area(i));
|
||||
#endif /* SHM_MEMORY_MAPPING_SCHEME */
|
||||
}
|
||||
#endif /* ACOW */
|
||||
#else /* TABLING */
|
||||
#ifdef SHM_MEMORY_MAPPING_SCHEME
|
||||
/* mapping worker area */
|
||||
shm_map_memory(0, WorkerArea, mmap_addr + HeapArea);
|
||||
#endif /* SHM_MEMORY_MAPPING_SCHEME */
|
||||
#endif /* YAPOR */
|
||||
|
||||
#endif /* YAPOR_MODEL */
|
||||
|
||||
#ifdef SBA
|
||||
/* alloc space for the sparse binding array */
|
||||
@ -226,8 +196,6 @@ void unmap_memory (void) {
|
||||
#else /* MMAP_MEMORY_MAPPING_SCHEME */
|
||||
char MapFile[20];
|
||||
#endif /* MEMORY_MAPPING_SCHEME */
|
||||
|
||||
#ifdef YAPOR
|
||||
{
|
||||
int proc;
|
||||
for (proc = 0; proc < number_workers; proc++) {
|
||||
@ -247,18 +215,13 @@ void unmap_memory (void) {
|
||||
}
|
||||
#endif /* ACOW */
|
||||
}
|
||||
#endif /* YAPOR */
|
||||
|
||||
#ifdef SHM_MEMORY_MAPPING_SCHEME
|
||||
#ifdef YAPOR
|
||||
#ifdef ACOW
|
||||
i = 0;
|
||||
#else
|
||||
for (i = 0; i < number_workers + 1; i++)
|
||||
#endif
|
||||
#else /* TABLING */
|
||||
for (i = 0; i < 1 + 2; i++)
|
||||
#endif /* YAPOR */
|
||||
#endif /* ACOW */
|
||||
{
|
||||
if (shmctl(shm_mapid[i], IPC_RMID, 0) == 0)
|
||||
INFORMATION_MESSAGE("Removing shared memory segment %d", shm_mapid[i]);
|
||||
@ -266,15 +229,11 @@ void unmap_memory (void) {
|
||||
}
|
||||
#else /* MMAP_MEMORY_MAPPING_SCHEME */
|
||||
strcpy(MapFile,"/tmp/mapfile");
|
||||
#ifdef YAPOR
|
||||
#ifdef ACOW
|
||||
itos(GLOBAL_master_worker, &MapFile[12]);
|
||||
#else /* ENV_COPY || SBA */
|
||||
itos(worker_pid(0), &MapFile[12]);
|
||||
#endif
|
||||
#else /* TABLING */
|
||||
itos(getpid(), &MapFile[12]);
|
||||
#endif /* YAPOR */
|
||||
if (remove(MapFile) == 0)
|
||||
INFORMATION_MESSAGE("Removing mapfile \"%s\"", MapFile);
|
||||
else INFORMATION_MESSAGE("Can't remove mapfile \"%s\"", MapFile);
|
||||
@ -283,7 +242,6 @@ void unmap_memory (void) {
|
||||
}
|
||||
|
||||
|
||||
#ifdef YAPOR
|
||||
void remap_memory(void) {
|
||||
#ifdef ACOW
|
||||
/* do nothing */
|
||||
@ -334,44 +292,3 @@ void remap_memory(void) {
|
||||
#endif /* ENV_COPY */
|
||||
}
|
||||
#endif /* YAPOR */
|
||||
|
||||
|
||||
#ifdef DEAD_CODE
|
||||
|
||||
This code is pretty much dead, the idea is to allocate large memory
|
||||
blocks from the Heap.
|
||||
|
||||
void *alloc_memory_block(int size) {
|
||||
void *block;
|
||||
LOCK(Pg_lock(GLOBAL_PAGES_void));
|
||||
#if USE_HEAP_FOR_ALLOC_MEMORY_BLOCKS
|
||||
block = (void *) AllocCodeSpace(size);
|
||||
#else
|
||||
if (size > TopAllocBlockArea - TopAllocArea)
|
||||
abort_optyap("no more free alloc space (alloc_memory_block)");
|
||||
TopAllocBlockArea -= size;
|
||||
block = TopAllocBlockArea;
|
||||
#endif /* USE_HEAP_FOR_ALLOC_MEMORY_BLOCKS */
|
||||
UNLOCK(Pg_lock(GLOBAL_PAGES_void));
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
void free_memory_block(void *block) {
|
||||
#if USE_HEAP_FOR_ALLOC_MEMORY_BLOCKS
|
||||
LOCK(Pg_lock(GLOBAL_PAGES_void));
|
||||
Yap_FreeCodeSpace((char *) block);
|
||||
UNLOCK(Pg_lock(GLOBAL_PAGES_void));
|
||||
#endif /* USE_HEAP_FOR_ALLOC_MEMORY_BLOCKS */
|
||||
}
|
||||
|
||||
|
||||
void reset_alloc_block_area(void) {
|
||||
#if USE_HEAP_FOR_ALLOC_MEMORY_BLOCKS
|
||||
TopAllocBlockArea = BaseAllocArea+OPT_CHUNK_SIZE;
|
||||
#endif /* USE_HEAP_FOR_ALLOC_MEMORY_BLOCKS */
|
||||
}
|
||||
|
||||
#endif /* USE_HEAP */
|
||||
|
||||
#endif /* YAPOR || TABLING */
|
||||
|
@ -6,6 +6,7 @@
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "Yatom.h"
|
||||
#include "yapio.h"
|
||||
#if HAVE_UNISTD_H
|
||||
@ -21,10 +22,8 @@
|
||||
** Global variables are defined here **
|
||||
** ------------------------------------------- */
|
||||
|
||||
struct global_data *GLOBAL;
|
||||
struct local_data *LOCAL;
|
||||
#ifdef YAPOR
|
||||
struct local_data *REMOTE[MAX_WORKERS];
|
||||
struct worker WORKER;
|
||||
#endif /* YAPOR */
|
||||
|
||||
@ -48,7 +47,7 @@ void abort_optyap(const char *msg, ...) {
|
||||
|
||||
#ifdef YAPOR
|
||||
unmap_memory();
|
||||
#endif
|
||||
#endif /* YAPOR */
|
||||
exit (1);
|
||||
}
|
||||
|
||||
@ -77,16 +76,7 @@ void information_message(const char *mesg,...) {
|
||||
fprintf(stderr, " ]\n");
|
||||
return;
|
||||
}
|
||||
/* ------------------------- **
|
||||
** Local functions **
|
||||
** ------------------------- */
|
||||
|
||||
int tabling_putchar(int sno, int ch) {
|
||||
return(putc(ch, stderr));
|
||||
}
|
||||
#endif /* TABLING_DEBUG */
|
||||
|
||||
#ifdef YAPOR
|
||||
|
||||
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
||||
void error_message(const char *mesg, ...) {
|
||||
|
@ -35,12 +35,12 @@ static qg_ans_fr_ptr actual_answer;
|
||||
** Local functions declaration **
|
||||
** ------------------------------------- */
|
||||
|
||||
static int p_default_sequential(void);
|
||||
#ifdef YAPOR
|
||||
static realtime current_time(void);
|
||||
static int yapor_on(void);
|
||||
static int start_yapor(void);
|
||||
static int p_sequential(void);
|
||||
static int p_default_sequential(void);
|
||||
static int p_execution_mode(void);
|
||||
static int p_performance(void);
|
||||
static int p_parallel_new_answer(void);
|
||||
@ -69,27 +69,27 @@ static int p_debug_prolog(void);
|
||||
** -------------------------- */
|
||||
|
||||
void Yap_init_optyap_preds(void) {
|
||||
Yap_InitCPred("$default_sequential", 1, p_default_sequential, SafePredFlag);
|
||||
#ifdef YAPOR
|
||||
Yap_InitCPred("$yapor_on", 0, yapor_on, SafePredFlag);
|
||||
Yap_InitCPred("$start_yapor", 0, start_yapor, SafePredFlag);
|
||||
Yap_InitCPred("$sequential", 1, p_sequential, SafePredFlag);
|
||||
Yap_InitCPred("execution_mode", 1, p_execution_mode, SafePredFlag);
|
||||
Yap_InitCPred("performance", 1, p_performance, SafePredFlag);
|
||||
Yap_InitCPred("$parallel_new_answer", 1, p_parallel_new_answer, SafePredFlag);
|
||||
Yap_InitCPred("$parallel_yes_answer", 0, p_parallel_yes_answer, SafePredFlag);
|
||||
Yap_InitCPred("$yapor_on", 0, yapor_on, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$start_yapor", 0, start_yapor, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$sequential", 1, p_sequential, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$default_sequential", 1, p_default_sequential, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("execution_mode", 1, p_execution_mode, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("performance", 1, p_performance, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$parallel_new_answer", 1, p_parallel_new_answer, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$parallel_yes_answer", 0, p_parallel_yes_answer, SafePredFlag|SyncPredFlag);
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
Yap_InitCPred("$do_table", 2, p_table, SafePredFlag);
|
||||
Yap_InitCPred("$do_abolish_trie", 2, p_abolish_trie, SafePredFlag);
|
||||
Yap_InitCPred("$show_trie", 3, p_show_trie, SafePredFlag);
|
||||
Yap_InitCPred("$resume_trie", 2, p_resume_trie, SafePredFlag);
|
||||
Yap_InitCPred("$do_table", 2, p_table, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$do_abolish_trie", 2, p_abolish_trie, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$show_trie", 3, p_show_trie, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$resume_trie", 2, p_resume_trie, SafePredFlag|SyncPredFlag);
|
||||
#endif /* TABLING */
|
||||
#ifdef STATISTICS
|
||||
Yap_InitCPred("show_frames", 0, p_show_frames, SafePredFlag);
|
||||
Yap_InitCPred("show_frames", 0, p_show_frames, SafePredFlag|SyncPredFlag);
|
||||
#endif /* STATISTICS */
|
||||
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
||||
Yap_InitCPred("debug_prolog", 1, p_debug_prolog, SafePredFlag);
|
||||
Yap_InitCPred("debug_prolog", 1, p_debug_prolog, SafePredFlag|SyncPredFlag);
|
||||
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
||||
}
|
||||
|
||||
@ -108,39 +108,6 @@ void finish_yapor(void) {
|
||||
** Local functions **
|
||||
** ------------------------- */
|
||||
|
||||
static
|
||||
int p_default_sequential(void) {
|
||||
#ifdef YAPOR
|
||||
Term t;
|
||||
t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
Term ta;
|
||||
if (SEQUENTIAL_IS_DEFAULT)
|
||||
ta = MkAtomTerm(Yap_LookupAtom("on"));
|
||||
else
|
||||
ta = MkAtomTerm(Yap_LookupAtom("off"));
|
||||
Bind((CELL *)t, ta);
|
||||
return(TRUE);
|
||||
}
|
||||
if (IsAtomTerm(t)) {
|
||||
char *s;
|
||||
s = RepAtom(AtomOfTerm(t))->StrOfAE;
|
||||
if (strcmp(s, "on") == 0) {
|
||||
SEQUENTIAL_IS_DEFAULT = TRUE;
|
||||
return(TRUE);
|
||||
}
|
||||
if (strcmp(s,"off") == 0) {
|
||||
SEQUENTIAL_IS_DEFAULT = FALSE;
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
return(FALSE);
|
||||
#else
|
||||
return(TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef YAPOR
|
||||
static
|
||||
realtime current_time(void) {
|
||||
@ -182,32 +149,26 @@ int start_yapor(void) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
static
|
||||
int p_sequential(void) {
|
||||
Term t, tmod;
|
||||
Atom at;
|
||||
int arity;
|
||||
PredEntry *pe;
|
||||
SMALLUNSGN mod;
|
||||
PredEntry *pe;
|
||||
|
||||
t = Deref(ARG1);
|
||||
tmod = Deref(ARG2);
|
||||
if (IsVarTerm(tmod) || !IsAtomTerm(tmod)) {
|
||||
return(FALSE);
|
||||
} else {
|
||||
mod = Yap_LookupModule(tmod);
|
||||
}
|
||||
mod = Yap_LookupModule(tmod);
|
||||
t = Deref(ARG1);
|
||||
if (IsAtomTerm(t)) {
|
||||
at = AtomOfTerm(t);
|
||||
arity = 0;
|
||||
Atom at = AtomOfTerm(t);
|
||||
pe = RepPredProp(PredPropByAtom(at, mod));
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor func = FunctorOfTerm(t);
|
||||
at = NameOfFunctor(func);
|
||||
arity = ArityOfFunctor(func);
|
||||
pe = RepPredProp(PredPropByFunc(func, mod));
|
||||
} else {
|
||||
abort_optyap("unknown term in function p_sequential");
|
||||
return(FALSE);
|
||||
}
|
||||
pe->PredFlags |= SequentialPredFlag;
|
||||
@ -215,6 +176,35 @@ int p_sequential(void) {
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int p_default_sequential(void) {
|
||||
Term t;
|
||||
t = Deref(ARG1);
|
||||
if (IsVarTerm(t)) {
|
||||
Term ta;
|
||||
if (SEQUENTIAL_IS_DEFAULT)
|
||||
ta = MkAtomTerm(Yap_LookupAtom("on"));
|
||||
else
|
||||
ta = MkAtomTerm(Yap_LookupAtom("off"));
|
||||
Bind((CELL *)t, ta);
|
||||
return(TRUE);
|
||||
}
|
||||
if (IsAtomTerm(t)) {
|
||||
char *s;
|
||||
s = RepAtom(AtomOfTerm(t))->StrOfAE;
|
||||
if (strcmp(s, "on") == 0) {
|
||||
SEQUENTIAL_IS_DEFAULT = TRUE;
|
||||
return(TRUE);
|
||||
}
|
||||
if (strcmp(s,"off") == 0) {
|
||||
SEQUENTIAL_IS_DEFAULT = FALSE;
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int p_execution_mode(void) {
|
||||
Term t;
|
||||
@ -457,33 +447,32 @@ void answer_to_stdout(char *answer) {
|
||||
#ifdef TABLING
|
||||
static
|
||||
int p_table(void) {
|
||||
Term t, t2;
|
||||
Term t, tmod;
|
||||
SMALLUNSGN mod;
|
||||
PredEntry *pe;
|
||||
tab_ent_ptr te;
|
||||
sg_node_ptr sg_node;
|
||||
SMALLUNSGN mod;
|
||||
|
||||
t = Deref(ARG1);
|
||||
t2 = Deref(ARG2);
|
||||
if (IsVarTerm(t2) || !IsAtomTerm(t2)) {
|
||||
tmod = Deref(ARG2);
|
||||
if (IsVarTerm(tmod) || !IsAtomTerm(tmod)) {
|
||||
return (FALSE);
|
||||
} else {
|
||||
mod = Yap_LookupModule(t2);
|
||||
mod = Yap_LookupModule(tmod);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
if (IsAtomTerm(t)) {
|
||||
Atom at = AtomOfTerm(t);
|
||||
pe = RepPredProp(PredPropByAtom(at, mod));
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor func = FunctorOfTerm(t);
|
||||
pe = RepPredProp(PredPropByFunc(func, mod));
|
||||
} else
|
||||
} else {
|
||||
return (FALSE);
|
||||
|
||||
}
|
||||
pe->PredFlags |= TabledPredFlag;
|
||||
new_subgoal_trie_node(sg_node, 0, NULL, NULL, NULL);
|
||||
new_table_entry(te, sg_node);
|
||||
pe->TableOfPred = te;
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -497,13 +486,13 @@ int p_abolish_trie(void) {
|
||||
sg_node_ptr sg_node;
|
||||
UInt arity;
|
||||
|
||||
t = Deref(ARG1);
|
||||
tmod = Deref(ARG2);
|
||||
if (IsVarTerm(tmod) || !IsAtomTerm(tmod)) {
|
||||
return (FALSE);
|
||||
} else {
|
||||
mod = Yap_LookupModule(tmod);
|
||||
}
|
||||
t = Deref(ARG1);
|
||||
if (IsAtomTerm(t)) {
|
||||
Atom at = AtomOfTerm(t);
|
||||
tab_ent = RepPredProp(PredPropByAtom(at, mod))->TableOfPred;
|
||||
@ -512,9 +501,9 @@ int p_abolish_trie(void) {
|
||||
Functor func = FunctorOfTerm(t);
|
||||
tab_ent = RepPredProp(PredPropByFunc(func, mod))->TableOfPred;
|
||||
arity = ArityOfFunctor(func);
|
||||
} else
|
||||
} else {
|
||||
return (FALSE);
|
||||
|
||||
}
|
||||
hash = TabEnt_hash_chain(tab_ent);
|
||||
TabEnt_hash_chain(tab_ent) = NULL;
|
||||
free_subgoal_hash_chain(hash);
|
||||
@ -523,7 +512,6 @@ int p_abolish_trie(void) {
|
||||
TrNode_child(TabEnt_subgoal_trie(tab_ent)) = NULL;
|
||||
free_subgoal_trie_branch(sg_node, arity);
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -531,30 +519,30 @@ int p_abolish_trie(void) {
|
||||
static
|
||||
int p_show_trie(void) {
|
||||
Term t1, t2, tmod;
|
||||
PredEntry *pe;
|
||||
SMALLUNSGN mod;
|
||||
PredEntry *pe;
|
||||
Atom at;
|
||||
UInt arity;
|
||||
|
||||
t1 = Deref(ARG1);
|
||||
tmod = Deref(ARG2);
|
||||
if (IsVarTerm(tmod) || !IsAtomTerm(tmod)) {
|
||||
return (FALSE);
|
||||
} else {
|
||||
mod = Yap_LookupModule(tmod);
|
||||
}
|
||||
t1 = Deref(ARG1);
|
||||
if (IsAtomTerm(t1)) {
|
||||
at = AtomOfTerm(t1);
|
||||
arity = 0;
|
||||
pe = RepPredProp(PredPropByAtom(at, mod));
|
||||
arity = 0;
|
||||
} else if (IsApplTerm(t1)) {
|
||||
Functor func = FunctorOfTerm(t1);
|
||||
at = NameOfFunctor(func);
|
||||
arity = ArityOfFunctor(func);
|
||||
pe = RepPredProp(PredPropByFunc(func, mod));
|
||||
} else
|
||||
arity = ArityOfFunctor(func);
|
||||
} else {
|
||||
return (FALSE);
|
||||
|
||||
}
|
||||
t2 = Deref(ARG3);
|
||||
if (IsVarTerm(t2)) {
|
||||
Term ta = MkAtomTerm(Yap_LookupAtom("stdout"));
|
||||
@ -567,39 +555,40 @@ int p_show_trie(void) {
|
||||
abort_optyap("fopen error in function p_show_trie");
|
||||
traverse_trie(file, TrNode_child(TabEnt_subgoal_trie(pe->TableOfPred)), arity, at, TRUE);
|
||||
fclose(file);
|
||||
} else
|
||||
} else {
|
||||
return(FALSE);
|
||||
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int p_resume_trie(void) {
|
||||
Term t1;
|
||||
Term t, tmod;
|
||||
SMALLUNSGN mod;
|
||||
PredEntry *pe;
|
||||
Atom at;
|
||||
int arity;
|
||||
PredEntry *pe;
|
||||
Term tmod = Deref(ARG2);
|
||||
SMALLUNSGN mod;
|
||||
|
||||
if (IsVarTerm(tmod) || !IsAtomTerm(tmod)) {
|
||||
tmod = Deref(ARG2);
|
||||
if (IsVarTerm(tmod) || !IsAtomTerm(tmod)) {
|
||||
return (FALSE);
|
||||
} else {
|
||||
mod = Yap_LookupModule(tmod);
|
||||
}
|
||||
t1 = Deref(ARG1);
|
||||
if (IsAtomTerm(t1)) {
|
||||
at = AtomOfTerm(t1);
|
||||
arity = 0;
|
||||
t = Deref(ARG1);
|
||||
if (IsAtomTerm(t)) {
|
||||
at = AtomOfTerm(t);
|
||||
pe = RepPredProp(PredPropByAtom(at, mod));
|
||||
} else if (IsApplTerm(t1)) {
|
||||
Functor func = FunctorOfTerm(t1);
|
||||
arity = 0;
|
||||
} else if (IsApplTerm(t)) {
|
||||
Functor func = FunctorOfTerm(t);
|
||||
at = NameOfFunctor(func);
|
||||
arity = ArityOfFunctor(func);
|
||||
pe = RepPredProp(PredPropByFunc(func, mod));
|
||||
} else
|
||||
arity = ArityOfFunctor(func);
|
||||
} else {
|
||||
return(FALSE);
|
||||
|
||||
}
|
||||
traverse_trie(stdout, TrNode_child(TabEnt_subgoal_trie(pe->TableOfPred)), arity, at, FALSE);
|
||||
return (TRUE);
|
||||
}
|
||||
@ -862,7 +851,7 @@ int p_show_frames(void) {
|
||||
}
|
||||
fprintf(stdout, " %s[%ld] Pages: In Use %ld - Free %ld (%ld Accesses)\n]\n\n",
|
||||
(Pg_str_alloc(GLOBAL_PAGES_void) - Pg_str_in_use(GLOBAL_PAGES_void) == cont &&
|
||||
TopAllocArea - BaseAllocArea == PageSize * Pg_str_alloc(GLOBAL_PAGES_void) &&
|
||||
TopAllocArea - BaseAllocArea == Yap_page_size * Pg_str_alloc(GLOBAL_PAGES_void) &&
|
||||
Pg_str_in_use(GLOBAL_PAGES_void) == pages) ? " ": "*",
|
||||
Pg_str_alloc(GLOBAL_PAGES_void),
|
||||
Pg_str_in_use(GLOBAL_PAGES_void), cont, Pg_requests(GLOBAL_PAGES_void));
|
||||
|
@ -6,17 +6,15 @@
|
||||
** opt.memory.c **
|
||||
** -------------- */
|
||||
|
||||
long global_data_size(void);
|
||||
long local_data_size(void);
|
||||
#ifdef YAPOR
|
||||
#ifdef SHM_MEMORY_MAPPING_SCHEME
|
||||
void shm_map_memory(int id, int size, void *shmaddr);
|
||||
#else /* MMAP_MEMORY_MAPPING_SCHEME */
|
||||
void open_mapfile(long);
|
||||
#endif /* MEMORY_MAPPING_SCHEME */
|
||||
void close_mapfile(void);
|
||||
#endif /* MEMORY_MAPPING_SCHEME */
|
||||
void map_memory(long HeapArea, long GlobalLocalArea, long TrailAuxArea, int n_workers);
|
||||
void unmap_memory(void);
|
||||
#ifdef YAPOR
|
||||
void remap_memory(void);
|
||||
#endif /* YAPOR */
|
||||
|
||||
@ -50,7 +48,6 @@ void init_signals(void);
|
||||
** opt.preds.c **
|
||||
** ------------- */
|
||||
|
||||
void init_optyap_preds(void);
|
||||
#ifdef YAPOR
|
||||
void finish_yapor(void);
|
||||
#endif /* YAPOR */
|
||||
@ -74,9 +71,6 @@ void private_completion(sg_fr_ptr sg_fr);
|
||||
void free_subgoal_trie_branch(sg_node_ptr node, int missing_nodes);
|
||||
void free_answer_trie(sg_fr_ptr sg_fr);
|
||||
void update_answer_trie(sg_fr_ptr sg_fr);
|
||||
void show_trie(FILE *stream, sg_node_ptr sg_node, int pred_arity, Atom pred_atom);
|
||||
int show_subgoal_trie(FILE *stream, sg_node_ptr sg_node, char *str, int str_index, int *arity);
|
||||
int show_answer_trie(FILE *stream, ans_node_ptr ans_node, char *str, int str_index, int *arity, int var_index);
|
||||
void traverse_trie(FILE *stream, sg_node_ptr sg_node, int pred_arity, Atom pred_atom, int show);
|
||||
#endif /* TABLING */
|
||||
|
||||
|
@ -4,7 +4,11 @@
|
||||
|
||||
typedef double realtime;
|
||||
typedef unsigned long bitmap;
|
||||
#define MAX_WORKERS (sizeof(bitmap) * 8 - 1)
|
||||
#ifdef YAPOR
|
||||
#define MAX_WORKERS (sizeof(bitmap) * 8)
|
||||
#else
|
||||
#define MAX_WORKERS 1
|
||||
#endif /* YAPOR */
|
||||
|
||||
|
||||
|
||||
|
@ -84,7 +84,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 = ready;
|
||||
PUT_IN_REQUESTABLE(worker_id);
|
||||
PUT_BUSY(worker_id);
|
||||
|
@ -92,6 +92,7 @@ void make_root_choice_point(void) {
|
||||
LOCAL_top_cp_on_stack = LOCAL_top_cp;
|
||||
adjust_freeze_registers();
|
||||
#endif /* TABLING */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -189,7 +190,6 @@ int q_share_work(int worker_p) {
|
||||
|
||||
/* unbind variables */
|
||||
aux_tr = LOCAL_top_cp->cp_tr;
|
||||
printf("%d: Starting variable unbinding %p---%p\n", worker_id, TR, aux_tr);
|
||||
#ifdef TABLING_ERRORS
|
||||
if (TR < aux_tr)
|
||||
TABLING_ERROR_MESSAGE("TR < aux_tr (q_share_work)");
|
||||
@ -217,9 +217,8 @@ int q_share_work(int worker_p) {
|
||||
} else if (IsApplTerm(aux_cell)) {
|
||||
CELL *aux_ptr = RepAppl(aux_cell);
|
||||
Term aux_val = TrailTerm(--aux_tr);
|
||||
|
||||
*aux_ptr = aux_val;
|
||||
#endif
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +321,6 @@ sync_with_p:
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
} else if (IsApplTerm(aux_cell)) {
|
||||
CELL *cell_ptr = RepAppl(aux_cell);
|
||||
|
||||
if (((CELL *)aux_cell < LOCAL_top_cp->cp_h ||
|
||||
EQUAL_OR_YOUNGER_CP(LOCAL_top_cp, (choiceptr)aux_cell)) &&
|
||||
!lookup_ma_var(cell_ptr)) {
|
||||
@ -335,7 +333,7 @@ sync_with_p:
|
||||
}
|
||||
/* skip the old value */
|
||||
aux_tr--;
|
||||
#endif
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,6 @@ void PUT_OUT_REQUESTABLE(int p) {
|
||||
return;
|
||||
}
|
||||
|
||||
extern int vsc_op;
|
||||
|
||||
static inline
|
||||
void SCH_update_local_or_tops(void) {
|
||||
|
@ -43,7 +43,6 @@ reset_trail(tr_fr_ptr tr_top, tr_fr_ptr trp)
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
} else {
|
||||
CELL *aux_ptr = RepAppl(aux_cell);
|
||||
|
||||
trp--;
|
||||
if (Unsigned((Int)(aux_ptr)-(Int)(H_FZ)) >
|
||||
Unsigned((Int)(B_FZ)-(Int)(H_FZ))) {
|
||||
@ -51,7 +50,7 @@ reset_trail(tr_fr_ptr tr_top, tr_fr_ptr trp)
|
||||
} else {
|
||||
*aux_ptr = TrailTerm(trp);
|
||||
}
|
||||
#endif
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,7 +184,6 @@ int q_share_work(int worker_p) {
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
} else if (IsApplTerm(aux_cell)) {
|
||||
CELL *cell_ptr = RepAppl(aux_cell);
|
||||
|
||||
if (!lookup_ma_var(cell_ptr)) {
|
||||
/* first time we found the variable, let's put the new value */
|
||||
CELL *ptr = STACK_TO_SBA(cell_ptr);
|
||||
@ -194,7 +192,7 @@ int q_share_work(int worker_p) {
|
||||
/* skip the old value */
|
||||
aux_tr--;
|
||||
}
|
||||
#endif
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
}
|
||||
|
||||
/* update registers and return */
|
||||
@ -296,7 +294,6 @@ void share_private_nodes(int worker_q) {
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
} else {
|
||||
CELL *cell_ptr = RepAppl(aux_cell);
|
||||
|
||||
/* first do as a for a standard cell */
|
||||
if ((cell_ptr < B->cp_h || cell_ptr > (CELL *)B) && !(cell_ptr < H_FZ || (choiceptr)cell_ptr > B_FZ)) {
|
||||
CELL *ptr = STACK_TO_SBA(cell_ptr);
|
||||
@ -308,7 +305,7 @@ void share_private_nodes(int worker_q) {
|
||||
}
|
||||
/* but we also need to skip the old value */
|
||||
tr_ptr--;
|
||||
#endif
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -328,5 +325,3 @@ void share_private_nodes(int worker_q) {
|
||||
}
|
||||
|
||||
#endif /* SBA */
|
||||
|
||||
|
||||
|
@ -213,7 +213,8 @@ int get_work(void) {
|
||||
}
|
||||
}
|
||||
if (LOCAL_top_cp == GLOBAL_root_cp) {
|
||||
PUT_IN_ROOT_NODE(worker_id);
|
||||
if (! BITMAP_member(GLOBAL_bm_root_cp_workers, worker_id))
|
||||
PUT_IN_ROOT_NODE(worker_id);
|
||||
if (BITMAP_same(GLOBAL_bm_idle_workers, GLOBAL_bm_root_cp_workers) &&
|
||||
BITMAP_same(GLOBAL_bm_idle_workers, GLOBAL_bm_present_workers)) {
|
||||
/* All workers are idle in root choicepoint. Execution
|
||||
|
@ -429,7 +429,7 @@
|
||||
CELL *aux_args;
|
||||
CELL *aux_subs;
|
||||
|
||||
sg_fr_ptr aux_sg_fr = LOCAL_top_sg_fr;
|
||||
aux_sg_fr = LOCAL_top_sg_fr;
|
||||
while (aux_sg_fr && aux_sg_fr != sg_fr)
|
||||
aux_sg_fr = SgFr_next(aux_sg_fr);
|
||||
if (aux_sg_fr == NULL)
|
||||
@ -927,7 +927,7 @@
|
||||
|
||||
|
||||
|
||||
BOp(table_completion, ld);
|
||||
BOp(table_completion, ld);
|
||||
#ifdef YAPOR
|
||||
if (SCH_top_shared_cp(B)) {
|
||||
SCH_new_alternative(PREG, GEN_CP_NULL_ALT);
|
||||
@ -1169,9 +1169,9 @@
|
||||
/* unconsumed answer */
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
if (ans_node == NULL) {
|
||||
ans_node = DepFr_last_ans(dep_fr) = SgFr_first_answer(DepFr_sg_fr(dep_fr));
|
||||
ans_node = DepFr_last_ans(LOCAL_top_dep_fr) = SgFr_first_answer(DepFr_sg_fr(LOCAL_top_dep_fr));
|
||||
} else {
|
||||
ans_node = DepFr_last_ans(dep_fr) = TrNode_child(ans_node);
|
||||
ans_node = DepFr_last_ans(LOCAL_top_dep_fr) = TrNode_child(ans_node);
|
||||
}
|
||||
UNLOCK(DepFr_lock(LOCAL_top_dep_fr));
|
||||
consume_answer_and_procceed(LOCAL_top_dep_fr, ans_node);
|
||||
@ -1225,10 +1225,10 @@
|
||||
goto fail;
|
||||
#else /* TABLING_LOCAL_SCHEDULING */
|
||||
/* subgoal completed */
|
||||
LOCK_SG_FRAME(sg_fr);
|
||||
LOCK(SgFr_lock(sg_fr));
|
||||
if (SgFr_state(sg_fr) == complete)
|
||||
update_answer_trie(sg_fr);
|
||||
UNLOCK_SG_FRAME(sg_fr);
|
||||
UNLOCK(SgFr_lock(sg_fr));
|
||||
if (SgFr_first_answer(sg_fr) == NULL) {
|
||||
/* no answers --> fail */
|
||||
B = B->cp_b;
|
||||
@ -1248,14 +1248,14 @@
|
||||
/* yes answer --> procceed */
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
Y = ENV;
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
} else {
|
||||
/* answers -> load first answer */
|
||||
PREG = (yamop *) TrNode_child(SgFr_answer_trie(sg_fr));
|
||||
PREFETCH_OP(PREG);
|
||||
*--Y = 0; /* vars_arity */
|
||||
*--Y = 0; /* heap_arity */
|
||||
*--YENV = 0; /* vars_arity */
|
||||
*--YENV = 0; /* heap_arity */
|
||||
GONext();
|
||||
}
|
||||
#endif /* TABLING_SCHEDULING */
|
||||
|
@ -33,10 +33,7 @@ STD_PROTO(static inline void CUT_validate_tg_answers, (tg_sol_fr_ptr));
|
||||
STD_PROTO(static inline void CUT_join_tg_solutions, (tg_sol_fr_ptr *, tg_sol_fr_ptr));
|
||||
STD_PROTO(static inline void CUT_join_solution_frame_tg_answers, (tg_sol_fr_ptr));
|
||||
STD_PROTO(static inline void CUT_join_solution_frames_tg_answers, (tg_sol_fr_ptr));
|
||||
/*printf*/
|
||||
STD_PROTO(static inline void CUT_free_tg_solution_frame, (tg_sol_fr_ptr));
|
||||
/*STD_PROTO(static inline int CUT_free_tg_solution_frame, (tg_sol_fr_ptr));*/
|
||||
/*printf*/
|
||||
STD_PROTO(static inline void CUT_free_tg_solution_frames, (tg_sol_fr_ptr));
|
||||
STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_ptr, int));
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
@ -89,7 +86,7 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
#else
|
||||
#define STACK_PUSH(ITEM, STACK, STACK_TOP, STACK_BASE) \
|
||||
*--(STACK) = (CELL)(ITEM); \
|
||||
if ((STACK) <= STACK_TOP+1024) { \
|
||||
if ((STACK) <= STACK_TOP + 1024) { \
|
||||
CELL *NEW_STACK; \
|
||||
UInt diff; \
|
||||
char *OldTrailTop = (char *)Yap_TrailTop; \
|
||||
@ -149,8 +146,7 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
#else
|
||||
#define find_dependency_node(SG_FR, LEADER_CP, DEP_ON_STACK) \
|
||||
LEADER_CP = SgFr_gen_cp(SG_FR); \
|
||||
DEP_ON_STACK = TRUE;
|
||||
|
||||
DEP_ON_STACK = TRUE
|
||||
#define find_leader_node(LEADER_CP, DEP_ON_STACK) \
|
||||
{ dep_fr_ptr chain_dep_fr = LOCAL_top_dep_fr; \
|
||||
while (YOUNGER_CP(DepFr_cons_cp(chain_dep_fr), LEADER_CP)) { \
|
||||
@ -171,7 +167,6 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
#define GEN_CP_NULL_ALT ANSWER_RESOLUTION
|
||||
#define GEN_CP_SG_FR(GCP) DepFr_sg_fr(GEN_CP(GCP)->gcp_dep_fr)
|
||||
#endif /* TABLING_SCHEDULING */
|
||||
#define SgFr_init_scheduling_fields(SG_FR, ARITY) SgFr_arity(SG_FR) = ARITY
|
||||
|
||||
|
||||
#ifdef YAPOR
|
||||
@ -202,7 +197,7 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
TabEnt_hash_chain(TAB_ENT) = HASH
|
||||
#define AnsHash_init_next_field(HASH, SG_FR) \
|
||||
Hash_next(HASH) = SgFr_hash_chain(SG_FR); \
|
||||
SgFr_hash_chain(SG_Fr) = HASH
|
||||
SgFr_hash_chain(SG_FR) = HASH
|
||||
#else
|
||||
#define TabEnt_init_lock_field(TAB_ENT)
|
||||
#define SgHash_init_next_field(HASH, TAB_ENT) \
|
||||
@ -255,7 +250,7 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
SgFr_last_answer(SG_FR) = NULL; \
|
||||
SgFr_hash_chain(SG_FR) = NULL; \
|
||||
SgFr_state(SG_FR) = resolving; \
|
||||
SgFr_init_scheduling_fields(SG_FR, ARITY); \
|
||||
SgFr_arity(SG_FR) = ARITY; \
|
||||
SgFr_next(SG_FR) = NEXT; \
|
||||
}
|
||||
|
||||
@ -348,8 +343,8 @@ void mark_as_completed(sg_fr_ptr sg_fr) {
|
||||
hash = SgFr_hash_chain(sg_fr);
|
||||
SgFr_hash_chain(sg_fr) = NULL;
|
||||
SgFr_state(sg_fr) = complete;
|
||||
UNLOCK(SgFr_lock(sg_fr));
|
||||
free_answer_hash_chain(hash);
|
||||
UNLOCK(SgFr_lock(sg_fr));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -383,9 +378,8 @@ void unbind_variables(tr_fr_ptr unbind_tr, tr_fr_ptr end_tr) {
|
||||
} else {
|
||||
Term aux_val = TrailTerm(--unbind_tr);
|
||||
CELL *aux_ptr = RepAppl(ref);
|
||||
|
||||
*aux_ptr = aux_val;
|
||||
#endif
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -421,18 +415,19 @@ void rebind_variables(tr_fr_ptr rebind_tr, tr_fr_ptr end_tr) {
|
||||
#ifdef MULTI_ASSIGNMENT_VARIABLES
|
||||
} else {
|
||||
CELL *cell_ptr = RepAppl(ref);
|
||||
|
||||
if (!lookup_ma_var(cell_ptr)) {
|
||||
/* first time we found the variable, let's put the new value */
|
||||
*cell_ptr = TrailVal(rebind_tr);
|
||||
}
|
||||
/* skip the old value */
|
||||
rebind_tr--;
|
||||
#endif
|
||||
#endif /* MULTI_ASSIGNMENT_VARIABLES */
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static inline
|
||||
void restore_bindings(tr_fr_ptr unbind_tr, tr_fr_ptr rebind_tr) {
|
||||
CELL ref;
|
||||
|
@ -112,7 +112,6 @@ typedef struct subgoal_frame {
|
||||
complete = 1,
|
||||
executable = 2
|
||||
} state_flag;
|
||||
/* vsc: needed by garbage collector to find where substitution frame for table_completion is */
|
||||
int subgoal_arity;
|
||||
struct subgoal_frame *next;
|
||||
} *sg_fr_ptr;
|
||||
|
@ -665,7 +665,7 @@ sg_node_ptr subgoal_search(tab_ent_ptr tab_ent, OPREG arity, CELL **Yaddr) {
|
||||
#else
|
||||
stack_terms_top = (CELL *)TR;
|
||||
stack_terms_base = stack_terms = (CELL *)Yap_TrailTop;
|
||||
#endif
|
||||
#endif /* YAPOR */
|
||||
current_sg_node = TabEnt_subgoal_trie(tab_ent);
|
||||
|
||||
for (i = 1; i <= arity; i++) {
|
||||
@ -730,12 +730,12 @@ ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr) {
|
||||
subs_arity = *subs_ptr;
|
||||
stack_vars = AuxSp;
|
||||
#ifdef YAPOR
|
||||
stack_terms_top = (CELL *)TrailTop;
|
||||
stack_terms_top = (CELL *)Yap_TrailTop;
|
||||
stack_terms_base = stack_terms = stack_vars - MAX_TABLE_VARS;
|
||||
#else
|
||||
stack_terms_top = (CELL *)TR;
|
||||
stack_terms_base = stack_terms = (CELL *)Yap_TrailTop;
|
||||
#endif
|
||||
#endif /* YAPOR */
|
||||
current_ans_node = SgFr_answer_trie(sg_fr);
|
||||
|
||||
for (i = subs_arity; i >= 1; i--) {
|
||||
@ -801,12 +801,12 @@ void load_answer_trie(ans_node_ptr ans_node, CELL *subs_ptr) {
|
||||
CELL *stack_vars, *stack_terms, *stack_refs, *stack_refs_base, *stack_top;
|
||||
ans_node_ptr aux_parent_node;
|
||||
#ifdef YAPOR
|
||||
stack_top = (CELL *)TrailTop;
|
||||
stack_top = (CELL *)Yap_TrailTop;
|
||||
stack_vars = stack_terms = AuxSp - MAX_TABLE_VARS;
|
||||
#else
|
||||
stack_top = (CELL *)TR;
|
||||
stack_vars = stack_terms = ((CELL *)Yap_TrailTop)-MAX_TABLE_VARS;
|
||||
#endif
|
||||
#endif /* YAPOR */
|
||||
|
||||
/* load the new answer from the answer trie to the stack_terms */
|
||||
aux_parent_node = UNTAG_ANSWER_LEAF_NODE(TrNode_parent(ans_node));
|
||||
|
Reference in New Issue
Block a user