fix configure file. change memory management in YapOr.

This commit is contained in:
Joao 2011-04-28 09:48:42 +01:00
parent 3ebfafc36b
commit d4825159ee
17 changed files with 156 additions and 174 deletions

View File

@ -29,8 +29,8 @@
#include <string.h>
#endif
#if YAPOR_THREADS
#include <opt.mavar.h>
#endif
#include "opt.mavar.h"
#endif /* YAPOR_THREADS */
#if !HAVE_STRNCAT
#define strncat(s0,s1,sz) strcat(s0,s1)
@ -269,7 +269,7 @@ RestoreTrail(int worker_p USES_REGS)
if (aux_tr < TR){
Yap_Error(SYSTEM_ERROR, TermNil, "oops");
}
Yap_NEW_MAHASH((ma_h_inner_struct *)H);
Yap_NEW_MAHASH((ma_h_inner_struct *)H PASS_REGS);
while (TR != aux_tr) {
CELL aux_cell = TrailTerm(--aux_tr);
if (IsVarTerm(aux_cell)) {
@ -295,7 +295,7 @@ RestoreTrail(int worker_p USES_REGS)
CELL *cell_ptr = RepAppl(aux_cell);
if (((CELL *)aux_cell < Get_LOCAL_top_cp()->cp_h ||
EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp(), (choiceptr)aux_cell)) &&
!Yap_lookup_ma_var(cell_ptr)) {
!Yap_lookup_ma_var(cell_ptr PASS_REGS)) {
/* first time we found the variable, let's put the new value */
#ifdef TABLING
*cell_ptr = TrailVal(aux_tr);

View File

@ -1247,7 +1247,7 @@ struct global_data Yap_Global;
struct worker_local *Yap_WLocal[MAX_THREADS];
#elif defined(YAPOR)
struct worker_local *Yap_WLocal;
#else
#else /* !THREADS && !YAPOR */
struct worker_local Yap_WLocal;
#endif

View File

@ -138,7 +138,7 @@ typedef struct regstore_t
int sba_size_;
#endif /* YAPOR_SBA */
#endif /* YAPOR || THREADS */
#if (defined(YAPOR) || defined(TABLING))
#if defined(YAPOR) || defined(TABLING)
struct local_data *LOCAL_;
#endif
#if PUSH_REGS

View File

@ -188,17 +188,15 @@ extern struct global_data Yap_Global;
#define Yap_global (&Yap_Global)
#endif
#if defined(YAPOR) || defined(THREADS)
#if defined(THREADS)
extern struct worker_local *Yap_WLocal[MAX_THREADS];
#define WL (Yap_WLocal[worker_id])
#define FOREIGN(wid) (Yap_WLocal[(wid)])
#else
#elif defined(YAPOR)
extern struct worker_local *Yap_WLocal;
#define WL (Yap_WLocal+worker_id)
#define FOREIGN(wid) (Yap_WLocal+wid)
#endif
#else
#else /* !THREADS && !YAPOR */
extern struct worker_local Yap_WLocal;
#define WL (&Yap_WLocal)
#define FOREIGN(wid) (&Yap_WLocal)

View File

@ -133,10 +133,6 @@
#define PL_local_data_p WL->Yap_ld_
#define execution WL->_execution
#if (defined(YAPOR) || defined(TABLING)) && defined(THREADS)
#define WORKER WL->worker
#endif
#ifdef THREADS
#define ThreadHandle WL->thread_handle
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)

View File

@ -135,10 +135,6 @@ typedef struct worker_local {
struct PL_local_data *Yap_ld_;
struct open_query_struct* _execution;
#if (defined(YAPOR) || defined(TABLING)) && defined(THREADS)
struct worker worker;
#endif
#ifdef THREADS
struct thandle thread_handle;
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)

View File

@ -133,10 +133,6 @@ static void InitWorker(int wid) {
FOREIGN(wid)->Yap_ld_ = Yap_InitThreadIO(wid);
FOREIGN(wid)->_execution = NULL;
#if (defined(YAPOR) || defined(TABLING)) && defined(THREADS)
#endif
#ifdef THREADS
InitThreadHandle(wid);
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)

View File

@ -133,10 +133,6 @@ static void RestoreWorker(int wid USES_REGS) {
#if (defined(YAPOR) || defined(TABLING)) && defined(THREADS)
#endif
#ifdef THREADS
#define FOREIGN_ThreadHandle(wid) (Yap_WLocal[(wid)]->thread_handle)

View File

@ -17,13 +17,11 @@
** General Configuration Parameters **
************************************************************************/
/**********************************************************
** memory alloc scheme (mandatory, define one) **
**********************************************************/
/****************************************************************
** use shared pages memory alloc scheme ? (optional) **
****************************************************************/
#define YAP_MEMORY_ALLOC_SCHEME 1
/* #define MALLOC_MEMORY_ALLOC_SCHEME 1 */
/* #define OPTYAP_PAGES_MEMORY_ALLOC_SCHEME 1 */
/* #define USE_PAGES_MALLOC 1 */
@ -93,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) **
@ -153,23 +151,9 @@
** Parameter Checks **
************************************************************************/
#if !defined(OPTYAP_PAGES_MEMORY_ALLOC_SCHEME) && !defined(MALLOC_MEMORY_ALLOC_SCHEME) && !defined(YAP_MEMORY_ALLOC_SCHEME)
#error Define a memory alloc scheme
#endif /* !OPTYAP_PAGES_MEMORY_ALLOC_SCHEME && !MALLOC_MEMORY_ALLOC_SCHEME && !YAP_MEMORY_ALLOC_SCHEME */
#if (defined(OPTYAP_PAGES_MEMORY_ALLOC_SCHEME) && (defined(MALLOC_MEMORY_ALLOC_SCHEME) || defined(YAP_MEMORY_ALLOC_SCHEME))) || (defined(MALLOC_MEMORY_ALLOC_SCHEME) && defined(YAP_MEMORY_ALLOC_SCHEME))
#error Do not define multiple memory alloc schemes
#endif /* (OPTYAP_PAGES_MEMORY_ALLOC_SCHEME && (MALLOC_MEMORY_ALLOC_SCHEME || YAP_MEMORY_ALLOC_SCHEME)) || (MALLOC_MEMORY_ALLOC_SCHEME && YAP_MEMORY_ALLOC_SCHEME) */
#ifdef USE_SYSTEM_MALLOC
#define MALLOC_MEMORY_ALLOC_SCHEME 1
#undef YAP_MEMORY_ALLOC_SCHEME
#undef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#endif /* USE_SYSTEM_MALLOC */
#if defined(YAPOR) && defined(MALLOC_MEMORY_ALLOC_SCHEME)
#error YAPOR is incompatible with MALLOC_MEMORY_ALLOC_SCHEME
#endif /* YAPOR && MALLOC_MEMORY_ALLOC_SCHEME */
#ifndef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifndef USE_PAGES_MALLOC
#undef LIMIT_TABLING
#endif /* !OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* !USE_PAGES_MALLOC */
#ifdef YAPOR
#ifdef i386 /* For i386 machines we use shared memory segments */

View File

@ -40,7 +40,7 @@
** Macros **
*********************/
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#define STRUCTS_PER_PAGE(STR_TYPE) ((Yap_page_size - STRUCT_SIZE(struct page_header)) / STRUCT_SIZE(STR_TYPE))
#define INIT_PAGES(PG, STR_TYPE) \
@ -51,7 +51,7 @@
Pg_free_pg(PG) = NULL
#else
#define INIT_PAGES(PG, STR_TYPE) Pg_str_in_use(PG) = 0
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */

View File

@ -17,9 +17,9 @@
extern int Yap_page_size;
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#include <sys/shm.h>
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
#define SHMMAX 0x2000000 /* 32 Mbytes: works fine with linux */
/* #define SHMMAX 0x400000 - 4 Mbytes: shmget limit for Mac (?) */
@ -45,9 +45,9 @@ extern int Yap_page_size;
#define UPDATE_STATS(STAT, VALUE) STAT += VALUE
#ifdef MALLOC_MEMORY_ALLOC_SCHEME
#ifdef USE_SYSTEM_MALLOC
/*************************************************************************************************
** MALLOC_MEMORY_ALLOC_SCHEME **
** USE_SYSTEM_MALLOC **
*************************************************************************************************/
#define ALLOC_BLOCK(STR, SIZE, STR_TYPE) \
if ((STR = (STR_TYPE *) malloc(SIZE)) == NULL) \
@ -56,7 +56,7 @@ extern int Yap_page_size;
free(STR)
#else
/*************************************************************************************************
** ! MALLOC_MEMORY_ALLOC_SCHEME **
** ! USE_SYSTEM_MALLOC **
*************************************************************************************************/
#define ALLOC_BLOCK(STR, SIZE, STR_TYPE) \
{ char *block_ptr; \
@ -79,22 +79,49 @@ extern int Yap_page_size;
#endif /*****************************************************************************************/
#if defined(MALLOC_MEMORY_ALLOC_SCHEME) || defined(YAP_MEMORY_ALLOC_SCHEME)
#ifdef USE_PAGES_MALLOC
/*************************************************************************************************
** MALLOC_MEMORY_ALLOC_SCHEME || YAP_MEMORY_ALLOC_SCHEME **
** USE_PAGES_MALLOC **
*************************************************************************************************/
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \
UPDATE_STATS(Pg_str_in_use(STR_PAGES), 1); \
ALLOC_BLOCK(STR, sizeof(STR_TYPE), STR_TYPE)
#define ALLOC_NEXT_FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \
ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE)
#define FREE_PAGE(PG_HD) \
LOCK(Pg_lock(Yap_pages_void)); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), -1); \
PgHd_next(PG_HD) = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PG_HD; \
UNLOCK(Pg_lock(Yap_pages_void))
#define FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \
UPDATE_STATS(Pg_str_in_use(STR_PAGES), -1); \
FREE_BLOCK(STR)
#elif OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
{ pg_hd_ptr pg_hd; \
pg_hd = PAGE_HEADER(STR); \
LOCK(Pg_lock(STR_PAGES)); \
UPDATE_STATS(Pg_str_in_use(STR_PAGES), -1); \
if (--PgHd_str_in_use(pg_hd) == 0) { \
UPDATE_STATS(Pg_pg_alloc(STR_PAGES), -1); \
if (PgHd_previous(pg_hd)) { \
if ((PgHd_next(PgHd_previous(pg_hd)) = PgHd_next(pg_hd)) != NULL) \
PgHd_previous(PgHd_next(pg_hd)) = PgHd_previous(pg_hd); \
} else { \
if ((Pg_free_pg(STR_PAGES) = PgHd_next(pg_hd)) != NULL) \
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
} \
UNLOCK(Pg_lock(STR_PAGES)); \
FREE_PAGE(pg_hd); \
} else { \
if ((STRUCT_NEXT(STR) = (STR_TYPE *) PgHd_free_str(pg_hd)) == NULL) { \
PgHd_previous(pg_hd) = NULL; \
if ((PgHd_next(pg_hd) = Pg_free_pg(STR_PAGES)) != NULL) \
PgHd_previous(PgHd_next(pg_hd)) = pg_hd; \
Pg_free_pg(STR_PAGES) = pg_hd; \
} \
PgHd_free_str(pg_hd) = (void *) STR; \
UNLOCK(Pg_lock(STR_PAGES)); \
} \
}
#ifdef LIMIT_TABLING
/*************************************************************************************************
** OPTYAP_PAGES_MEMORY_ALLOC_SCHEME && LIMIT_TABLING **
** USE_PAGES_MALLOC && LIMIT_TABLING **
*************************************************************************************************/
#define INIT_PAGE(PG_HD, STR_PAGES, STR_TYPE) \
{ int i; \
@ -233,7 +260,7 @@ extern int Yap_page_size;
LOCAL_next_free_ans_node = STRUCT_NEXT(STR)
#else
/*************************************************************************************************
** OPTYAP_PAGES_MEMORY_ALLOC_SCHEME && !LIMIT_TABLING **
** USE_PAGES_MALLOC && ! LIMIT_TABLING **
*************************************************************************************************/
#define ALLOC_PAGE(PG_HD) \
LOCK(Pg_lock(Yap_pages_void)); \
@ -328,45 +355,22 @@ extern int Yap_page_size;
} \
LOCAL_next_free_ans_node = STRUCT_NEXT(STR)
#endif /* LIMIT_TABLING */
#else /* ! USE_PAGES_MALLOC */
/*************************************************************************************************
** OPTYAP_PAGES_MEMORY_ALLOC_SCHEME **
** ! USE_PAGES_MALLOC **
*************************************************************************************************/
#define FREE_PAGE(PG_HD) \
LOCK(Pg_lock(Yap_pages_void)); \
UPDATE_STATS(Pg_str_in_use(Yap_pages_void), -1); \
PgHd_next(PG_HD) = Pg_free_pg(Yap_pages_void); \
Pg_free_pg(Yap_pages_void) = PG_HD; \
UNLOCK(Pg_lock(Yap_pages_void))
#define ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE) \
UPDATE_STATS(Pg_str_in_use(STR_PAGES), 1); \
ALLOC_BLOCK(STR, sizeof(STR_TYPE), STR_TYPE)
#define ALLOC_NEXT_FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \
ALLOC_STRUCT(STR, STR_PAGES, STR_TYPE)
#define FREE_STRUCT(STR, STR_PAGES, STR_TYPE) \
{ pg_hd_ptr pg_hd; \
pg_hd = PAGE_HEADER(STR); \
LOCK(Pg_lock(STR_PAGES)); \
UPDATE_STATS(Pg_str_in_use(STR_PAGES), -1); \
if (--PgHd_str_in_use(pg_hd) == 0) { \
UPDATE_STATS(Pg_pg_alloc(STR_PAGES), -1); \
if (PgHd_previous(pg_hd)) { \
if ((PgHd_next(PgHd_previous(pg_hd)) = PgHd_next(pg_hd)) != NULL) \
PgHd_previous(PgHd_next(pg_hd)) = PgHd_previous(pg_hd); \
} else { \
if ((Pg_free_pg(STR_PAGES) = PgHd_next(pg_hd)) != NULL) \
PgHd_previous(PgHd_next(pg_hd)) = NULL; \
} \
UNLOCK(Pg_lock(STR_PAGES)); \
FREE_PAGE(pg_hd); \
} else { \
if ((STRUCT_NEXT(STR) = (STR_TYPE *) PgHd_free_str(pg_hd)) == NULL) { \
PgHd_previous(pg_hd) = NULL; \
if ((PgHd_next(pg_hd) = Pg_free_pg(STR_PAGES)) != NULL) \
PgHd_previous(PgHd_next(pg_hd)) = pg_hd; \
Pg_free_pg(STR_PAGES) = pg_hd; \
} \
PgHd_free_str(pg_hd) = (void *) STR; \
UNLOCK(Pg_lock(STR_PAGES)); \
} \
}
UPDATE_STATS(Pg_str_in_use(STR_PAGES), -1); \
FREE_BLOCK(STR)
#endif /*****************************************************************************************/
#define ALLOC_HASH_BUCKETS(BUCKET_PTR, NUM_BUCKETS) \
{ int i; void **bucket_ptr; \
ALLOC_BLOCK(bucket_ptr, NUM_BUCKETS * sizeof(void *), void *); \

View File

@ -21,13 +21,13 @@
#define OPT_MAVAR_STATIC inline static
#endif /* !OPT_MAVAR_STATIC */
OPT_MAVAR_STATIC unsigned int Yap_MAVAR_HASH(CELL *addr);
OPT_MAVAR_STATIC struct ma_h_entry * Yap_ALLOC_NEW_MASPACE(void);
OPT_MAVAR_STATIC int Yap_lookup_ma_var(CELL *addr);
OPT_MAVAR_STATIC UInt Yap_NEW_MAHASH(ma_h_inner_struct *top);
OPT_MAVAR_STATIC unsigned int Yap_MAVAR_HASH(CELL *addr USES_REGS);
OPT_MAVAR_STATIC struct ma_h_entry * Yap_ALLOC_NEW_MASPACE(USES_REGS1);
OPT_MAVAR_STATIC int Yap_lookup_ma_var(CELL *addr USES_REGS);
OPT_MAVAR_STATIC UInt Yap_NEW_MAHASH(ma_h_inner_struct *top USES_REGS);
OPT_MAVAR_STATIC unsigned int
Yap_MAVAR_HASH(CELL *addr) {
Yap_MAVAR_HASH(CELL *addr USES_REGS) {
#if SIZEOF_INT_P==8
return((((unsigned int)((CELL)(addr)))>>3)%MAVARS_HASH_SIZE);
#else
@ -36,7 +36,7 @@ Yap_MAVAR_HASH(CELL *addr) {
}
OPT_MAVAR_STATIC struct ma_h_entry *
Yap_ALLOC_NEW_MASPACE(void)
Yap_ALLOC_NEW_MASPACE(USES_REGS1)
{
ma_h_inner_struct *new = LOCAL_ma_h_top;
LOCAL_ma_h_top++;
@ -44,8 +44,8 @@ Yap_ALLOC_NEW_MASPACE(void)
}
OPT_MAVAR_STATIC int
Yap_lookup_ma_var(CELL *addr) {
unsigned int i = Yap_MAVAR_HASH(addr);
Yap_lookup_ma_var(CELL *addr USES_REGS) {
unsigned int i = Yap_MAVAR_HASH(addr PASS_REGS);
struct ma_h_entry *nptr, *optr;
if (LOCAL_ma_hash_table[i].timestmp != LOCAL_ma_timestamp) {
@ -65,14 +65,14 @@ Yap_lookup_ma_var(CELL *addr) {
optr = nptr;
nptr = nptr->next;
}
nptr = Yap_ALLOC_NEW_MASPACE();
nptr = Yap_ALLOC_NEW_MASPACE(PASS_REGS1);
nptr->addr = addr;
nptr->next = optr;
return FALSE;
}
OPT_MAVAR_STATIC UInt
Yap_NEW_MAHASH(ma_h_inner_struct *top) {
Yap_NEW_MAHASH(ma_h_inner_struct *top USES_REGS) {
UInt time = ++LOCAL_ma_timestamp;
if (time == 0) {
unsigned int i;

View File

@ -477,14 +477,14 @@ static Int p_show_statistics_tabling( USES_REGS1 ) {
aux_bytes += show_statistics_global_trie_hashes();
fprintf(Yap_stdout, " Memory in use (III): %10ld bytes\n\n", aux_bytes);
total_bytes += aux_bytes;
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
total_bytes, Pg_str_in_use(Yap_pages_void));
fprintf(Yap_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
Pg_pg_alloc(Yap_pages_void) * Yap_page_size, Pg_pg_alloc(Yap_pages_void));
#else
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return (TRUE);
}
@ -713,14 +713,14 @@ static Int p_show_statistics_or( USES_REGS1 ) {
aux_bytes += show_statistics_query_goal_answer_frames();
fprintf(Yap_stdout, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
total_bytes += aux_bytes;
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
total_bytes, Pg_str_in_use(Yap_pages_void));
fprintf(Yap_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
Pg_pg_alloc(Yap_pages_void) * Yap_page_size, Pg_pg_alloc(Yap_pages_void));
#else
fprintf(Yap_stdout, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return (TRUE);
}
@ -769,14 +769,14 @@ static Int p_show_statistics_opt( USES_REGS1 ) {
#endif /* TABLING_INNER_CUTS */
fprintf(Yap_stdout, " Memory in use (IV): %10ld bytes\n\n", aux_bytes);
total_bytes += aux_bytes;
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
fprintf(Yap_stdout, "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
total_bytes, Pg_str_in_use(Yap_pages_void));
fprintf(Yap_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
Pg_pg_alloc(Yap_pages_void) * Yap_page_size, Pg_pg_alloc(Yap_pages_void));
#else
fprintf(Yap_stdout, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return (TRUE);
}
@ -813,11 +813,11 @@ static Int p_get_optyap_statistics( USES_REGS1 ) {
bytes += Pg_str_in_use(Yap_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
#endif /* TABLING_INNER_CUTS */
#endif /* YAPOR && TABLING */
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
structs = Pg_pg_alloc(Yap_pages_void) * Yap_page_size;
#else
structs = bytes;
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
}
#ifdef TABLING
if (value == 1) { /* table_entries */
@ -1025,7 +1025,7 @@ static inline void answer_to_stdout(char *answer) {
#ifdef TABLING
static inline long show_statistics_table_entries(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_TABLING
pg_hd_ptr pg_hd;
tab_ent_ptr aux_ptr;
@ -1047,13 +1047,13 @@ static inline long show_statistics_table_entries(void) {
#else
fprintf(Yap_stdout, " Table entries: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_tab_ent) * sizeof(struct table_entry), Pg_str_in_use(Yap_pages_tab_ent));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_tab_ent) * sizeof(struct table_entry);
}
static inline long show_statistics_subgoal_frames(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_TABLING
pg_hd_ptr pg_hd;
sg_fr_ptr aux_ptr;
@ -1075,13 +1075,13 @@ static inline long show_statistics_subgoal_frames(void) {
#else
fprintf(Yap_stdout, " Subgoal frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_sg_fr) * sizeof(struct subgoal_frame), Pg_str_in_use(Yap_pages_sg_fr));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_sg_fr) * sizeof(struct subgoal_frame);
}
static inline long show_statistics_dependency_frames(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_TABLING
pg_hd_ptr pg_hd;
dep_fr_ptr aux_ptr;
@ -1103,13 +1103,13 @@ static inline long show_statistics_dependency_frames(void) {
#else
fprintf(Yap_stdout, " Dependency frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_dep_fr) * sizeof(struct dependency_frame), Pg_str_in_use(Yap_pages_dep_fr));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_dep_fr) * sizeof(struct dependency_frame);
}
static inline long show_statistics_subgoal_trie_nodes(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_TABLING
pg_hd_ptr pg_hd;
sg_node_ptr aux_ptr;
@ -1131,13 +1131,13 @@ static inline long show_statistics_subgoal_trie_nodes(void) {
#else
fprintf(Yap_stdout, " Subgoal trie nodes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_sg_node) * sizeof(struct subgoal_trie_node), Pg_str_in_use(Yap_pages_sg_node));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_sg_node) * sizeof(struct subgoal_trie_node);
}
static inline long show_statistics_answer_trie_nodes(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_TABLING
pg_hd_ptr pg_hd;
ans_node_ptr aux_ptr;
@ -1159,13 +1159,13 @@ static inline long show_statistics_answer_trie_nodes(void) {
#else
fprintf(Yap_stdout, " Answer trie nodes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_ans_node) * sizeof(struct answer_trie_node), Pg_str_in_use(Yap_pages_ans_node));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_ans_node) * sizeof(struct answer_trie_node);
}
static inline long show_statistics_subgoal_trie_hashes(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_TABLING
pg_hd_ptr pg_hd;
sg_hash_ptr aux_ptr;
@ -1187,13 +1187,13 @@ static inline long show_statistics_subgoal_trie_hashes(void) {
#else
fprintf(Yap_stdout, " Subgoal trie hashes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_sg_hash) * sizeof(struct subgoal_trie_hash), Pg_str_in_use(Yap_pages_sg_hash));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_sg_hash) * sizeof(struct subgoal_trie_hash);
}
static inline long show_statistics_answer_trie_hashes(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_TABLING
pg_hd_ptr pg_hd;
ans_hash_ptr aux_ptr;
@ -1215,13 +1215,13 @@ static inline long show_statistics_answer_trie_hashes(void) {
#else
fprintf(Yap_stdout, " Answer trie hashes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_ans_hash) * sizeof(struct answer_trie_hash), Pg_str_in_use(Yap_pages_ans_hash));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_ans_hash) * sizeof(struct answer_trie_hash);
}
static inline long show_statistics_global_trie_nodes(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_TABLING
pg_hd_ptr pg_hd;
gt_node_ptr aux_ptr;
@ -1243,13 +1243,13 @@ static inline long show_statistics_global_trie_nodes(void) {
#else
fprintf(Yap_stdout, " Global trie nodes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_gt_node) * sizeof(struct global_trie_node), Pg_str_in_use(Yap_pages_gt_node));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_gt_node) * sizeof(struct global_trie_node);
}
static inline long show_statistics_global_trie_hashes(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_TABLING
pg_hd_ptr pg_hd;
gt_hash_ptr aux_ptr;
@ -1271,7 +1271,7 @@ static inline long show_statistics_global_trie_hashes(void) {
#else
fprintf(Yap_stdout, " Global trie hashes: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_gt_hash) * sizeof(struct global_trie_hash), Pg_str_in_use(Yap_pages_gt_hash));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_gt_hash) * sizeof(struct global_trie_hash);
}
#endif /* TABLING */
@ -1279,7 +1279,7 @@ static inline long show_statistics_global_trie_hashes(void) {
#ifdef YAPOR
static inline long show_statistics_or_frames(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_YAPOR
pg_hd_ptr pg_hd;
or_fr_ptr aux_ptr;
@ -1301,13 +1301,13 @@ static inline long show_statistics_or_frames(void) {
#else
fprintf(Yap_stdout, " Or-frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_or_fr ) * sizeof(struct or_frame), Pg_str_in_use(Yap_pages_or_fr ));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_or_fr ) * sizeof(struct or_frame);
}
static inline long show_statistics_query_goal_solution_frames(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_YAPOR
pg_hd_ptr pg_hd;
qg_sol_fr_ptr aux_ptr;
@ -1329,13 +1329,13 @@ static inline long show_statistics_query_goal_solution_frames(void) {
#else
fprintf(Yap_stdout, " Query goal solution frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame), Pg_str_in_use(Yap_pages_qg_sol_fr ));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame);
}
static inline long show_statistics_query_goal_answer_frames(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_YAPOR
pg_hd_ptr pg_hd;
qg_ans_fr_ptr aux_ptr;
@ -1353,11 +1353,11 @@ static inline long show_statistics_query_goal_answer_frames(void) {
YAPOR_ERROR_CHECKING(statistics_query_goal_answer_frames, Pg_str_free(Yap_pages_qg_ans_fr) != cont);
#endif /* DEBUG_YAPOR */
fprintf(Yap_stdout, " Query goal answer frames: %10ld bytes (%ld pages and %ld structs in use)\n",
Pg_str_in_use(Yap_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_pg_alloc(Yap_pages_qg_ans__fr), Pg_str_in_use(Yap_pages_qg_ans_fr));
Pg_str_in_use(Yap_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_pg_alloc(Yap_pages_qg_ans_fr), Pg_str_in_use(Yap_pages_qg_ans_fr));
#else
fprintf(Yap_stdout, " Query goal answer frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_str_in_use(Yap_pages_qg_ans_fr));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
}
#endif /* YAPOR */
@ -1365,7 +1365,7 @@ static inline long show_statistics_query_goal_answer_frames(void) {
#if defined(YAPOR) && defined(TABLING)
static inline long show_statistics_suspension_frames(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_OPTYAP
pg_hd_ptr pg_hd;
susp_fr_ptr aux_ptr;
@ -1387,14 +1387,14 @@ static inline long show_statistics_suspension_frames(void) {
#else
fprintf(Yap_stdout, " Suspension frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_susp_fr) * sizeof(struct suspension_frame), Pg_str_in_use(Yap_pages_susp_fr));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_susp_fr) * sizeof(struct suspension_frame);
}
#ifdef TABLING_INNER_CUTS
static inline long show_statistics_table_subgoal_solution_frames(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_OPTYAP
pg_hd_ptr pg_hd;
tg_sol_fr_ptr aux_ptr;
@ -1416,13 +1416,13 @@ static inline long show_statistics_table_subgoal_solution_frames(void) {
#else
fprintf(Yap_stdout, " Table subgoal solution frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame), Pg_str_in_use(Yap_pages_tg_sol_fr));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame);
}
static inline long show_statistics_table_subgoal_answer_frames(void) {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef DEBUG_OPTYAP
pg_hd_ptr pg_hd;
tg_ans_fr_ptr aux_ptr;
@ -1444,7 +1444,7 @@ static inline long show_statistics_table_subgoal_answer_frames(void) {
#else
fprintf(Yap_stdout, " Table subgoal answer frames: %10ld bytes (%ld structs in use)\n",
Pg_str_in_use(Yap_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame), Pg_str_in_use(Yap_pages_tg_ans_fr));
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
return Pg_str_in_use(Yap_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
}
#endif /* TABLING_INNER_CUTS */

View File

@ -76,14 +76,14 @@ typedef struct page_header {
***************************/
struct pages {
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
#ifdef YAPOR
lockvar lock;
#endif /* YAPOR */
int structs_per_page;
struct page_header *first_free_page;
volatile long pages_allocated;
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
volatile long structs_in_use;
};

View File

@ -125,9 +125,9 @@ typedef struct global_trie_hash {
int number_of_buckets;
struct global_trie_node **buckets;
int number_of_nodes;
#ifdef OPTYAP_PAGES_MEMORY_ALLOC_SCHEME
#ifdef USE_PAGES_MALLOC
struct global_trie_hash *next;
#endif /* OPTYAP_PAGES_MEMORY_ALLOC_SCHEME */
#endif /* USE_PAGES_MALLOC */
} *gt_hash_ptr;
#define Hash_mark(X) ((X)->mark)

44
configure vendored
View File

@ -3691,24 +3691,40 @@ done
# Check whether --enable-tabling was given.
if test "${enable_tabling+set}" = set; then :
enableval=$enable_tabling; tabling="$enableval"
enableval=$enable_tabling; tabling="$enableval"
{
if test "${enable_or_parallelism+set}" = set; then :
enableval=$enable_or_parallelism; orparallelism="$enableval"
case "$orparallelism" in
yes|copy)
;;
*)
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "tabling only works with YapOr copy"; }
;;
esac
fi
}
else
tabling=no
tabling=no
fi
# Check whether --enable-or-parallelism was given.
if test "${enable_or_parallelism+set}" = set; then :
enableval=$enable_or_parallelism; orparallelism="$enableval"
case "$orparallelism" in
yes|copy|sba|cow|threads)
;;
*)
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "--enable-or-parallelism=$orparallelism invalid option"; }
;;
esac
enableval=$enable_or_parallelism; orparallelism="$enableval"
case "$orparallelism" in
yes|copy|sba|cow)
;;
threads)
enable_threads=yes
;;
*)
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "--enable-or-parallelism=$orparallelism invalid option"; }
;;
esac
else
orparallelism=no
fi
@ -7528,7 +7544,7 @@ else
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_COW=1"
;;
threads)
YAP_EXTRAS="$YAP_EXTRAS -DYAPOR_THREADS=1"
YAP_EXTRAS="$YAP_EXTRAS -DTHREADS=1 -DYAPOR_THREADS=1"
;;
esac
fi

View File

@ -148,10 +148,6 @@ struct PL_local_data *Yap_ld_ PL_local_data_p =Yap_InitThreadIO(wid)
struct open_query_struct* _execution execution =NULL
// Ricardo's stuff
#if MULTIPLE_STACKS
struct worker worker WORKER void
#endif
#ifdef THREADS
struct thandle thread_handle ThreadHandle InitThreadHandle(wid)