From 29dc250a660121da674bc0b2633faffcabee6f6b Mon Sep 17 00:00:00 2001 From: Ubuntu32 Date: Tue, 1 Nov 2011 17:25:59 -0700 Subject: [PATCH 1/5] fix big int indexing --- C/computils.c | 2 ++ H/findclause.h | 3 ++- H/headclause.h | 3 ++- misc/buildops | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/C/computils.c b/C/computils.c index 71f1784eb..4d90d9890 100644 --- a/C/computils.c +++ b/C/computils.c @@ -428,6 +428,8 @@ write_functor(Functor f) Yap_DebugPlWrite(MkAtomTerm(AtomDBREF)); } else if (f == FunctorLongInt) { Yap_DebugPlWrite(MkAtomTerm(AtomLONGINT)); + } else if (f == FunctorBigInt) { + Yap_DebugPlWrite(MkAtomTerm(AtomLONGINT)); } else if (f == FunctorDouble) { Yap_DebugPlWrite(MkAtomTerm(AtomDOUBLE)); } diff --git a/H/findclause.h b/H/findclause.h index 4a5c4199a..3ed05df81 100644 --- a/H/findclause.h +++ b/H/findclause.h @@ -671,7 +671,8 @@ break; case _get_bigint: if (is_regcopy(myregs, nofregs, cl->u.xN.x)) { - clause->Tag = cl->u.xN.b; + clause->Tag = AbsAppl((CELL *)FunctorBigInt); + clause->u.t_ptr = (CELL)NULL; return; } cl = NEXTOP(cl,xN); diff --git a/H/headclause.h b/H/headclause.h index a24f4df35..efdec61d6 100644 --- a/H/headclause.h +++ b/H/headclause.h @@ -562,7 +562,8 @@ break; case _get_bigint: if (iarg == cl->u.xN.x) { - clause->Tag = cl->u.xN.b; + clause->Tag = AbsAppl((CELL *)FunctorBigInt); + clause->u.t_ptr = (CELL)NULL; return; } cl = NEXTOP(cl,xN); diff --git a/misc/buildops b/misc/buildops index 41343394b..39dc05a96 100644 --- a/misc/buildops +++ b/misc/buildops @@ -877,7 +877,7 @@ opinfo("gl_void_vary",[bind("y","AbsPair(NULL)",workpc=currentop),new("y")]). opinfo("get_struct",[bind("x","AbsAppl((CELL *)cl->u.xfa.f)",workpc=nextop)]). opinfo("get_float",[bind("x","AbsAppl((CELL *)FunctorDouble)",t_ptr="d")]). opinfo("get_longint",[bind("x","AbsAppl((CELL *)FunctorLongInt)",t_ptr="i")]). -opinfo("get_bigint",[bind("x","b",[])]). +opinfo("get_bigint",[bind("x","AbsAppl((CELL *)FunctorBigInt)",t_ptr=[])]). opinfo("copy_idb_term",[logical]). opinfo("unify_idb_term",[logical]). opinfo("put_atom",[new("x")]). From d33829205e3adc71926d780ae8afe1275b03dd9e Mon Sep 17 00:00:00 2001 From: Ricardo Rocha Date: Wed, 7 Dec 2011 13:53:20 +0000 Subject: [PATCH 2/5] support for local pages with threads --- OPTYap/opt.init.c | 81 +++-- OPTYap/opt.macros.h | 121 +++++--- OPTYap/opt.preds.c | 691 +++++++++++++++---------------------------- OPTYap/opt.structs.h | 266 ++++++++++------- OPTYap/tab.structs.h | 6 +- OPTYap/tab.tries.c | 8 + OPTYap/tab.tries.i | 2 + pl/tabling.yap | 4 + pl/yapor.yap | 4 + 9 files changed, 559 insertions(+), 624 deletions(-) diff --git a/OPTYap/opt.init.c b/OPTYap/opt.init.c index 65eceea8d..5b41f2c22 100644 --- a/OPTYap/opt.init.c +++ b/OPTYap/opt.init.c @@ -63,36 +63,39 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop int i; /* global data related to memory management */ -#ifdef LIMIT_TABLING - if (max_table_size) - GLOBAL_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) * SHMMAX / Yap_page_size; - else - GLOBAL_max_pages = -1; -#endif /* LIMIT_TABLING */ - INIT_PAGES(GLOBAL_pages_void, void *); + INIT_PAGES(GLOBAL_pages_void, void *); +#ifdef TABLING + INIT_PAGES(GLOBAL_pages_tab_ent, struct table_entry); +#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) + INIT_PAGES(GLOBAL_pages_sg_ent, struct subgoal_entry); +#endif +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING) + INIT_PAGES(GLOBAL_pages_sg_fr, struct subgoal_frame); + INIT_PAGES(GLOBAL_pages_dep_fr, struct dependency_frame); +#endif +#if !defined(THREADS_NO_SHARING) + INIT_PAGES(GLOBAL_pages_sg_node, struct subgoal_trie_node); + INIT_PAGES(GLOBAL_pages_sg_hash, struct subgoal_trie_hash); +#endif +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) + INIT_PAGES(GLOBAL_pages_ans_node, struct answer_trie_node); + INIT_PAGES(GLOBAL_pages_ans_hash, struct answer_trie_hash); +#endif + INIT_PAGES(GLOBAL_pages_gt_node, struct global_trie_node); + INIT_PAGES(GLOBAL_pages_gt_hash, struct global_trie_hash); +#endif /* TABLING */ #ifdef YAPOR INIT_PAGES(GLOBAL_pages_or_fr, struct or_frame); INIT_PAGES(GLOBAL_pages_qg_sol_fr, struct query_goal_solution_frame); INIT_PAGES(GLOBAL_pages_qg_ans_fr, struct query_goal_answer_frame); #endif /* YAPOR */ +#if defined(YAPOR) && defined(TABLING) + INIT_PAGES(GLOBAL_pages_susp_fr, struct suspension_frame); +#endif /* YAPOR && TABLING */ #ifdef TABLING_INNER_CUTS INIT_PAGES(GLOBAL_pages_tg_sol_fr, struct table_subgoal_solution_frame); INIT_PAGES(GLOBAL_pages_tg_ans_fr, struct table_subgoal_answer_frame); #endif /* TABLING_INNER_CUTS */ -#ifdef TABLING - INIT_PAGES(GLOBAL_pages_tab_ent, struct table_entry); - INIT_PAGES(GLOBAL_pages_sg_fr, struct subgoal_frame); - INIT_PAGES(GLOBAL_pages_dep_fr, struct dependency_frame); - INIT_PAGES(GLOBAL_pages_sg_node, struct subgoal_trie_node); - INIT_PAGES(GLOBAL_pages_ans_node, struct answer_trie_node); - INIT_PAGES(GLOBAL_pages_gt_node, struct global_trie_node); - INIT_PAGES(GLOBAL_pages_sg_hash, struct subgoal_trie_hash); - INIT_PAGES(GLOBAL_pages_ans_hash, struct answer_trie_hash); - INIT_PAGES(GLOBAL_pages_gt_hash, struct global_trie_hash); -#endif /* TABLING */ -#if defined(YAPOR) && defined(TABLING) - INIT_PAGES(GLOBAL_pages_susp_fr, struct suspension_frame); -#endif /* YAPOR && TABLING */ #ifdef YAPOR /* global static data */ @@ -136,6 +139,10 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL); GLOBAL_root_tab_ent = NULL; #ifdef LIMIT_TABLING + if (max_table_size) + GLOBAL_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) * SHMMAX / Yap_page_size; + else + GLOBAL_max_pages = -1; GLOBAL_first_sg_fr = NULL; GLOBAL_last_sg_fr = NULL; GLOBAL_check_sg_fr = NULL; @@ -158,8 +165,37 @@ void Yap_init_global_optyap_data(int max_table_size, int n_workers, int sch_loop void Yap_init_local_optyap_data(int wid) { -#ifdef YAPOR CACHE_REGS + +#if defined(TABLING) && (defined(YAPOR) || defined(THREADS)) + /* local data related to memory management */ +#if defined(YAPOR) + REMOTE_next_free_ans_node(wid) = NULL; +#elif defined(THREADS) + INIT_PAGES(REMOTE_pages_void(wid), void *); + INIT_PAGES(REMOTE_pages_sg_fr(wid), struct subgoal_frame); + INIT_PAGES(REMOTE_pages_dep_fr(wid), struct dependency_frame); +#if defined(THREADS_NO_SHARING) + INIT_PAGES(REMOTE_pages_sg_node(wid), struct subgoal_trie_node); + INIT_PAGES(REMOTE_pages_sg_hash(wid), struct subgoal_trie_hash); +#elif defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) + REMOTE_next_free_sg_node(wid) = NULL; + REMOTE_next_free_sg_hash(wid) = NULL; +#endif +#if defined(THREADS_NO_SHARING) || defined(THREADS_SUBGOAL_SHARING) + INIT_PAGES(REMOTE_pages_ans_node(wid), struct answer_trie_node); + INIT_PAGES(REMOTE_pages_ans_hash(wid), struct answer_trie_hash); +#elif defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) + REMOTE_next_free_ans_node(wid) = NULL; + REMOTE_next_free_ans_hash(wid) = NULL; +#endif +#if defined(THREADS_FULL_SHARING) + INIT_PAGES(REMOTE_pages_ans_ref_node(wid), struct answer_ref_node); +#endif +#endif /* YAPOR - THREADS */ +#endif /* TABLING && (YAPOR || THREADS) */ + +#ifdef YAPOR /* local data related to or-parallelism */ Set_REMOTE_top_cp(wid, (choiceptr) LOCAL_LocalBase); REMOTE_top_or_fr(wid) = GLOBAL_root_or_fr; @@ -175,7 +211,6 @@ void Yap_init_local_optyap_data(int wid) { #ifdef TABLING /* local data related to tabling */ - REMOTE_next_free_ans_node(wid) = NULL; REMOTE_top_sg_fr(wid) = NULL; #ifdef YAPOR REMOTE_top_dep_fr(wid) = GLOBAL_root_dep_fr; diff --git a/OPTYap/opt.macros.h b/OPTYap/opt.macros.h index 1bd8df770..09a6a9f51 100644 --- a/OPTYap/opt.macros.h +++ b/OPTYap/opt.macros.h @@ -280,55 +280,104 @@ extern int Yap_page_size; } #endif /******************************************************************************/ -#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, struct or_frame, GLOBAL_pages_or_fr, GLOBAL_pages_void) -#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, struct or_frame, GLOBAL_pages_or_fr, GLOBAL_pages_void) - -#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, struct query_goal_solution_frame, GLOBAL_pages_qg_sol_fr, GLOBAL_pages_void) -#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, struct query_goal_solution_frame, GLOBAL_pages_qg_sol_fr, GLOBAL_pages_void) - -#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, struct query_goal_answer_frame, GLOBAL_pages_qg_ans_fr, GLOBAL_pages_void) -#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, struct query_goal_answer_frame, GLOBAL_pages_qg_ans_fr, GLOBAL_pages_void) - -#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, struct table_subgoal_solution_frame, GLOBAL_pages_tg_sol_fr, GLOBAL_pages_void) -#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, struct table_subgoal_solution_frame, GLOBAL_pages_tg_sol_fr, GLOBAL_pages_void) - -#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, struct table_subgoal_answer_frame, GLOBAL_pages_tg_ans_fr, GLOBAL_pages_void) -#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, struct table_subgoal_answer_frame, GLOBAL_pages_tg_ans_fr, GLOBAL_pages_void) #define ALLOC_TABLE_ENTRY(STR) ALLOC_STRUCT(STR, struct table_entry, GLOBAL_pages_tab_ent, GLOBAL_pages_void) -#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, struct table_entry, GLOBAL_pages_tab_ent, GLOBAL_pages_void) +#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, struct table_entry, GLOBAL_pages_tab_ent, GLOBAL_pages_void) +#define ALLOC_SUBGOAL_ENTRY(STR) ALLOC_STRUCT(STR, struct subgoal_entry, GLOBAL_pages_sg_ent, GLOBAL_pages_void) +#define FREE_SUBGOAL_ENTRY(STR) FREE_STRUCT(STR, struct subgoal_entry, GLOBAL_pages_sg_ent, GLOBAL_pages_void) + +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING) #define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, struct subgoal_frame, GLOBAL_pages_sg_fr, GLOBAL_pages_void) -#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, struct subgoal_frame, GLOBAL_pages_sg_fr, GLOBAL_pages_void) +#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, struct subgoal_frame, GLOBAL_pages_sg_fr, GLOBAL_pages_void) +#else +#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, struct subgoal_frame, LOCAL_pages_sg_fr, LOCAL_pages_void) +#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, struct subgoal_frame, LOCAL_pages_sg_fr, LOCAL_pages_void) +#endif +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING) #define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, struct dependency_frame, GLOBAL_pages_dep_fr, GLOBAL_pages_void) -#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, struct dependency_frame, GLOBAL_pages_dep_fr, GLOBAL_pages_void) +#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, struct dependency_frame, GLOBAL_pages_dep_fr, GLOBAL_pages_void) +#else +#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, struct dependency_frame, LOCAL_pages_dep_fr, LOCAL_pages_void) +#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, struct dependency_frame, LOCAL_pages_dep_fr, LOCAL_pages_void) +#endif -#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, struct suspension_frame, GLOBAL_pages_susp_fr, GLOBAL_pages_void) -#define FREE_SUSPENSION_FRAME(STR) FREE_BLOCK(SuspFr_global_start(STR)); \ - FREE_STRUCT(STR, struct suspension_frame, GLOBAL_pages_susp_fr, GLOBAL_pages_void) +#if !defined(THREADS_NO_SHARING) +#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) +#define ALLOC_SUBGOAL_TRIE_NODE(STR) LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_next_free_sg_node, struct subgoal_trie_node, GLOBAL_pages_sg_node, GLOBAL_pages_void) +#else +#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct subgoal_trie_node, GLOBAL_pages_sg_node, GLOBAL_pages_void) +#endif +#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct subgoal_trie_node, GLOBAL_pages_sg_node, GLOBAL_pages_void) +#else +#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct subgoal_trie_node, LOCAL_pages_sg_node, LOCAL_pages_void) +#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct subgoal_trie_node, LOCAL_pages_sg_node, LOCAL_pages_void) +#endif + +#if !defined(THREADS_NO_SHARING) +#if defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) +#define ALLOC_SUBGOAL_TRIE_HASH(STR) LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_next_free_sg_hash, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, GLOBAL_pages_void) +#else +#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, GLOBAL_pages_void) +#endif +#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, GLOBAL_pages_void) +#else +#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct subgoal_trie_hash, LOCAL_pages_sg_hash, LOCAL_pages_void) +#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct subgoal_trie_hash, LOCAL_pages_sg_hash, LOCAL_pages_void) +#endif + +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) +#if defined(YAPOR) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) +#define ALLOC_ANSWER_TRIE_NODE(STR) LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_next_free_ans_node, struct answer_trie_node, GLOBAL_pages_ans_node, GLOBAL_pages_void) +#else +#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct answer_trie_node, GLOBAL_pages_ans_node, GLOBAL_pages_void) +#endif +#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, struct answer_trie_node, GLOBAL_pages_ans_node, GLOBAL_pages_void) +#else +#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct answer_trie_node, LOCAL_pages_ans_node, LOCAL_pages_void) +#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, struct answer_trie_node, LOCAL_pages_ans_node, LOCAL_pages_void) +#endif + +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) +#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) +#define ALLOC_ANSWER_TRIE_HASH(STR) LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_next_free_ans_hash, struct answer_trie_hash, GLOBAL_pages_ans_hash, GLOBAL_pages_void) +#else +#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct answer_trie_hash, GLOBAL_pages_ans_hash, GLOBAL_pages_void) +#endif +#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, struct answer_trie_hash, GLOBAL_pages_ans_hash, GLOBAL_pages_void) +#else +#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct answer_trie_hash, LOCAL_pages_ans_hash, LOCAL_pages_void) +#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, struct answer_trie_hash, LOCAL_pages_ans_hash, LOCAL_pages_void) +#endif + +#define ALLOC_ANSWER_REF_NODE(STR) ALLOC_STRUCT(STR, struct answer_ref_node, LOCAL_pages_ans_ref_node, LOCAL_pages_void) +#define FREE_ANSWER_REF_NODE(STR) FREE_STRUCT(STR, struct answer_ref_node, LOCAL_pages_ans_ref_node, LOCAL_pages_void) #define ALLOC_GLOBAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct global_trie_node, GLOBAL_pages_gt_node, GLOBAL_pages_void) -#define FREE_GLOBAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct global_trie_node, GLOBAL_pages_gt_node, GLOBAL_pages_void) - -#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct subgoal_trie_node, GLOBAL_pages_sg_node, GLOBAL_pages_void) -#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct subgoal_trie_node, GLOBAL_pages_sg_node, GLOBAL_pages_void) - -#ifdef YAPOR -#define ALLOC_ANSWER_TRIE_NODE(STR) LOCAL_NEXT_ALLOC_STRUCT(STR, LOCAL_next_free_ans_node, struct answer_trie_node, GLOBAL_pages_ans_node, GLOBAL_pages_void) -#else /* TABLING */ -#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, struct answer_trie_node, GLOBAL_pages_ans_node, GLOBAL_pages_void) -#endif /* YAPOR - TABLING */ -#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, struct answer_trie_node, GLOBAL_pages_ans_node, GLOBAL_pages_void) +#define FREE_GLOBAL_TRIE_NODE(STR) FREE_STRUCT(STR, struct global_trie_node, GLOBAL_pages_gt_node, GLOBAL_pages_void) #define ALLOC_GLOBAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct global_trie_hash, GLOBAL_pages_gt_hash, GLOBAL_pages_void) -#define FREE_GLOBAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct global_trie_hash, GLOBAL_pages_gt_hash, GLOBAL_pages_void) +#define FREE_GLOBAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct global_trie_hash, GLOBAL_pages_gt_hash, GLOBAL_pages_void) -#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, GLOBAL_pages_void) -#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, GLOBAL_pages_void) +#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, struct or_frame, GLOBAL_pages_or_fr, GLOBAL_pages_void) +#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, struct or_frame, GLOBAL_pages_or_fr, GLOBAL_pages_void) -#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, struct answer_trie_hash, GLOBAL_pages_ans_hash, GLOBAL_pages_void) -#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, struct answer_trie_hash, GLOBAL_pages_ans_hash, GLOBAL_pages_void) +#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, struct query_goal_solution_frame, GLOBAL_pages_qg_sol_fr, GLOBAL_pages_void) +#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, struct query_goal_solution_frame, GLOBAL_pages_qg_sol_fr, GLOBAL_pages_void) + +#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, struct query_goal_answer_frame, GLOBAL_pages_qg_ans_fr, GLOBAL_pages_void) +#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, struct query_goal_answer_frame, GLOBAL_pages_qg_ans_fr, GLOBAL_pages_void) + +#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, struct suspension_frame, GLOBAL_pages_susp_fr, GLOBAL_pages_void) +#define FREE_SUSPENSION_FRAME(STR) FREE_BLOCK(SuspFr_global_start(STR)); \ + FREE_STRUCT(STR, struct suspension_frame, GLOBAL_pages_susp_fr, GLOBAL_pages_void) + +#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, struct table_subgoal_solution_frame, GLOBAL_pages_tg_sol_fr, GLOBAL_pages_void) +#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, struct table_subgoal_solution_frame, GLOBAL_pages_tg_sol_fr, GLOBAL_pages_void) + +#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, struct table_subgoal_answer_frame, GLOBAL_pages_tg_ans_fr, GLOBAL_pages_void) +#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, struct table_subgoal_answer_frame, GLOBAL_pages_tg_ans_fr, GLOBAL_pages_void) diff --git a/OPTYap/opt.preds.c b/OPTYap/opt.preds.c index 581ae4bc7..a9f1aad7a 100644 --- a/OPTYap/opt.preds.c +++ b/OPTYap/opt.preds.c @@ -78,8 +78,8 @@ static inline long show_statistics_table_entries(IOSTREAM *out); static inline long show_statistics_subgoal_frames(IOSTREAM *out); static inline long show_statistics_dependency_frames(IOSTREAM *out); static inline long show_statistics_subgoal_trie_nodes(IOSTREAM *out); -static inline long show_statistics_answer_trie_nodes(IOSTREAM *out); static inline long show_statistics_subgoal_trie_hashes(IOSTREAM *out); +static inline long show_statistics_answer_trie_nodes(IOSTREAM *out); static inline long show_statistics_answer_trie_hashes(IOSTREAM *out); static inline long show_statistics_global_trie_nodes(IOSTREAM *out); static inline long show_statistics_global_trie_hashes(IOSTREAM *out); @@ -109,6 +109,83 @@ static int length_answer; static qg_ans_fr_ptr actual_answer; #endif /* YAPOR */ +struct page_statistics { +#ifdef USE_PAGES_MALLOC + long pages_allocated; /* same as struct pages (opt.structs.h) */ +#endif /* USE_PAGES_MALLOC */ + long structs_in_use; /* same as struct pages (opt.structs.h) */ +}; + +#ifdef USE_PAGES_MALLOC +#ifdef DEBUG_TABLING +#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE, STR_PAGES) \ + { pg_hd_ptr pg_hd; \ + STR_TYPE *aux_ptr; \ + long cont = 0; \ + pg_hd = Pg_free_pg(STR_PAGES); \ + while (pg_hd) { \ + aux_ptr = PgHd_free_str(pg_hd); \ + while (aux_ptr) { \ + cont++; \ + aux_ptr = aux_ptr->next; \ + } \ + pg_hd = PgHd_next(pg_hd); \ + } \ + if(Pg_str_free(STR_PAGES) != cont)printf("ERRRO!!!!!!!!\n");\ + TABLING_ERROR_CHECKING(CHECK_PAGE_FREE_STRUCTS, Pg_str_free(STR_PAGES) != cont); \ + } +#else +#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE,STR_PAGES) +#endif /* DEBUG_TABLING */ +#define INIT_PAGE_STATS(STATS) \ + Pg_pg_alloc(STATS) = 0; \ + Pg_str_in_use(STATS) = 0 +#define INCREMENT_PAGE_STATS(STATS,PAGE) \ + Pg_pg_alloc(STATS) += Pg_pg_alloc(PAGE); \ + Pg_str_in_use(STATS) += Pg_str_in_use(PAGE) +#define SHOW_PAGE_STATS_MSG(STR_NAME) " " STR_NAME " %10ld bytes (%ld pages and %ld structs in use)\n" +#define SHOW_PAGE_STATS_ARGS(STATS,STR_TYPE) Pg_str_in_use(STATS) * sizeof(STR_TYPE), Pg_pg_alloc(STATS), Pg_str_in_use(STATS) +#else /* !USE_PAGES_MALLOC */ +#define INIT_PAGE_STATS(STATS) \ + Pg_str_in_use(STATS) = 0 +#define INCREMENT_PAGE_STATS(STATS,PAGE) \ + Pg_str_in_use(STATS) += Pg_str_in_use(PAGE) +#define CHECK_PAGE_FREE_STRUCTS(STR_TYPE,STR_PAGES) +#define SHOW_PAGE_STATS_MSG(STR_NAME) " " STR_NAME " %10ld bytes (%ld structs in use)\n" +#define SHOW_PAGE_STATS_ARGS(STATS,STR_TYPE) Pg_str_in_use(STATS) * sizeof(STR_TYPE), Pg_str_in_use(STATS) +#endif + +#define GET_GLOBAL_PAGE_STATS(STATS,STR_PAGES) \ + INIT_PAGE_STATS(STATS); \ + CHECK_PAGE_FREE_STRUCTS(STR_TYPE,STR_PAGES); \ + INCREMENT_PAGE_STATS(STATS,STR_PAGES) +#define GET_REMOTE_PAGE_STATS(STATS,STR_PAGES) \ + INIT_PAGE_STATS(STATS); \ + LOCK(GLOBAL_ThreadHandlesLock); \ + { int wid; \ + for (wid = 0; wid < MAX_THREADS; wid++) { \ + if (!Yap_local[wid]) \ + break; \ + if (REMOTE_ThreadHandle(wid).in_use) { \ + CHECK_PAGE_FREE_STRUCTS(STR_TYPE,STR_PAGES); \ + INCREMENT_PAGE_STATS(STATS,STR_PAGES(wid)); \ + } \ + } \ + } \ + UNLOCK(GLOBAL_ThreadHandlesLock) +#define SHOW_GLOBAL_PAGE_STATS(OUT_STREAM,STR_TYPE,STR_PAGES,STR_NAME) \ + { struct page_statistics stats; \ + GET_GLOBAL_PAGE_STATS(stats,STR_PAGES); \ + Sfprintf(OUT_STREAM,SHOW_PAGE_STATS_MSG(STR_NAME),SHOW_PAGE_STATS_ARGS(stats,STR_TYPE)); \ + return Pg_str_in_use(stats) * sizeof(STR_TYPE); \ + } +#define SHOW_REMOTE_PAGE_STATS(OUT_STREAM,STR_TYPE,STR_PAGES,STR_NAME) \ + { struct page_statistics stats; \ + GET_REMOTE_PAGE_STATS(stats,STR_PAGES); \ + Sfprintf(OUT_STREAM,SHOW_PAGE_STATS_MSG(STR_NAME),SHOW_PAGE_STATS_ARGS(stats,STR_TYPE)); \ + return Pg_str_in_use(stats) * sizeof(STR_TYPE); \ + } + /******************************* @@ -792,110 +869,141 @@ static Int p_show_statistics_opt( USES_REGS1 ) { static Int p_get_optyap_statistics( USES_REGS1 ) { + struct page_statistics stats; + Int value, bytes = 0, structs = -1; Term tbytes, tstructs; - Int value, bytes = -1, structs = -1; value = IntOfTerm(Deref(ARG1)); - if (value == 0) { /* total_memory */ - bytes = 0; #ifdef TABLING - bytes += Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry); - bytes += Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame); - bytes += Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame); - bytes += Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node); - bytes += Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node); - bytes += Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash); - bytes += Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash); - bytes += Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node); - bytes += Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash); + if (value == 0 || value == 1) { /* table_entries */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_tab_ent); + bytes += Pg_str_in_use(stats) * sizeof(struct table_entry); + if (value != 0) structs = Pg_str_in_use(stats); + } +#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) + if (value == 0 || value == 16) { /* subgoal_entries */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_sg_entry); + bytes += Pg_str_in_use(stats) * sizeof(struct subgoal_entry); + if (value != 0) structs = Pg_str_in_use(stats); + } +#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */ + if (value == 0 || value == 2) { /* subgoal_frames */ +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING) + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_sg_fr); +#else + GET_REMOTE_PAGE_STATS(stats, REMOTE_pages_sg_fr); +#endif + bytes += Pg_str_in_use(stats) * sizeof(struct subgoal_frame); + if (value != 0) structs = Pg_str_in_use(stats); + } + if (value == 0 || value == 3) { /* dependency_frames */ +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING) + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_dep_fr); +#else + GET_REMOTE_PAGE_STATS(stats, REMOTE_pages_dep_fr); +#endif + bytes += Pg_str_in_use(stats) * sizeof(struct dependency_frame); + if (value != 0) structs = Pg_str_in_use(stats); + } + if (value == 0 || value == 6) { /* subgoal_trie_nodes */ +#if !defined(THREADS_NO_SHARING) + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_sg_node); +#else + GET_REMOTE_PAGE_STATS(stats, REMOTE_pages_sg_node); +#endif + bytes += Pg_str_in_use(stats) * sizeof(struct subgoal_trie_node); + if (value != 0) structs = Pg_str_in_use(stats); + } + if (value == 0 || value == 8) { /* subgoal_trie_hashes */ +#if !defined(THREADS_NO_SHARING) + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_sg_hash); +#else + GET_REMOTE_PAGE_STATS(stats, REMOTE_pages_sg_hash); +#endif + bytes += Pg_str_in_use(stats) * sizeof(struct subgoal_trie_hash); + if (value != 0) structs = Pg_str_in_use(stats); + } + if (value == 0 || value == 7) { /* answer_trie_nodes */ +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_ans_node); +#else + GET_REMOTE_PAGE_STATS(stats, REMOTE_pages_ans_node); +#endif + bytes += Pg_str_in_use(stats) * sizeof(struct answer_trie_node); + if (value != 0) structs = Pg_str_in_use(stats); + } + if (value == 0 || value == 9) { /* answer_trie_hashes */ +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_ans_hash); +#else + GET_REMOTE_PAGE_STATS(stats, REMOTE_pages_ans_hash); +#endif + bytes += Pg_str_in_use(stats) * sizeof(struct answer_trie_hash); + if (value != 0) structs = Pg_str_in_use(stats); + } +#if defined(THREADS_FULL_SHARING) + if (value == 0 || value == 17) { /* answer_ref_nodes */ + GET_REMOTE_PAGE_STATS(stats, REMOTE_pages_ans_ref_node); + bytes += Pg_str_in_use(stats) * sizeof(struct answer_ref_node); + if (value != 0) structs = Pg_str_in_use(stats); + } +#endif /* THREADS_FULL_SHARING */ + if (value == 0 || value == 10) { /* global_trie_nodes */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_gt_node); + bytes += Pg_str_in_use(stats) * sizeof(struct global_trie_node); + if (value != 0) structs = Pg_str_in_use(stats); + } + if (value == 0 || value == 11) { /* global_trie_hashes */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_gt_hash); + bytes += Pg_str_in_use(stats) * sizeof(struct global_trie_hash); + if (value != 0) structs = Pg_str_in_use(stats); + } #endif /* TABLING */ #ifdef YAPOR - bytes += Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame); - bytes += Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame); - bytes += Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame); + if (value == 0 || value == 4) { /* or_frames */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_or_fr); + bytes += Pg_str_in_use(stats) * sizeof(struct or_frame); + if (value != 0) structs = Pg_str_in_use(stats); + } + if (value == 0 || value == 12) { /* query_goal_solution_frames */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_qg_sol_fr); + bytes += Pg_str_in_use(stats) * sizeof(struct query_goal_solution_frame); + if (value != 0) structs = Pg_str_in_use(stats); + } + if (value == 0 || value == 13) { /* query_goal_answer_frames */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_qg_ans_fr); + bytes += Pg_str_in_use(stats) * sizeof(struct query_goal_answer_frame); + if (value != 0) structs = Pg_str_in_use(stats); + } #endif /* YAPOR */ #if defined(YAPOR) && defined(TABLING) - bytes += Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame); + if (value == 0 || value == 5) { /* suspension_frames */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_susp_fr); + bytes += Pg_str_in_use(stats) * sizeof(struct suspension_frame); + if (value != 0) structs = Pg_str_in_use(stats); + } #ifdef TABLING_INNER_CUTS - bytes += Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame); - bytes += Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame); + if (value == 0 || value == 14) { /* table_subgoal_solution_frames */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_tg_sol_fr); + bytes += Pg_str_in_use(stats) * sizeof(struct table_subgoal_solution_frame); + if (value != 0) structs = Pg_str_in_use(stats); + } + if (value == 0 || value == 15) { /* table_subgoal_answer_frames */ + GET_GLOBAL_PAGE_STATS(stats, GLOBAL_pages_tg_ans_fr); + bytes += Pg_str_in_use(stats) * sizeof(struct table_subgoal_answer_frame); + if (value != 0) structs = Pg_str_in_use(stats); + } #endif /* TABLING_INNER_CUTS */ #endif /* YAPOR && TABLING */ + + if (value == 0) { /* total_memory */ #ifdef USE_PAGES_MALLOC structs = Pg_pg_alloc(GLOBAL_pages_void) * Yap_page_size; #else structs = bytes; #endif /* USE_PAGES_MALLOC */ } -#ifdef TABLING - if (value == 1) { /* table_entries */ - bytes = Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry); - structs = Pg_str_in_use(GLOBAL_pages_tab_ent); - } - if (value == 2) { /* subgoal_frames */ - bytes = Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame); - structs = Pg_str_in_use(GLOBAL_pages_sg_fr); - } - if (value == 3) { /* dependency_frames */ - bytes = Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame); - structs = Pg_str_in_use(GLOBAL_pages_dep_fr); - } - if (value == 6) { /* subgoal_trie_nodes */ - bytes = Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node); - structs = Pg_str_in_use(GLOBAL_pages_sg_node); - } - if (value == 7) { /* answer_trie_nodes */ - bytes = Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node); - structs = Pg_str_in_use(GLOBAL_pages_ans_node); - } - if (value == 8) { /* subgoal_trie_hashes */ - bytes = Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash); - structs = Pg_str_in_use(GLOBAL_pages_sg_hash); - } - if (value == 9) { /* answer_trie_hashes */ - bytes = Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash); - structs = Pg_str_in_use(GLOBAL_pages_ans_hash); - } - if (value == 10) { /* global_trie_nodes */ - bytes = Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node); - structs = Pg_str_in_use(GLOBAL_pages_gt_node); - } - if (value == 11) { /* global_trie_hashes */ - bytes = Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash); - structs = Pg_str_in_use(GLOBAL_pages_gt_hash); - } -#endif /* TABLING */ -#ifdef YAPOR - if (value == 4) { /* or_frames */ - bytes = Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame); - structs = Pg_str_in_use(GLOBAL_pages_or_fr ); - } - if (value == 12) { /* query_goal_solution_frames */ - bytes = Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame); - structs = Pg_str_in_use(GLOBAL_pages_qg_sol_fr ); - } - if (value == 13) { /* query_goal_answer_frames */ - bytes = Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame); - structs = Pg_str_in_use(GLOBAL_pages_qg_ans_fr); - } -#endif /* YAPOR */ -#if defined(YAPOR) && defined(TABLING) - if (value == 5) { /* suspension_frames */ - bytes = Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame); - structs = Pg_str_in_use(GLOBAL_pages_susp_fr); - } -#ifdef TABLING_INNER_CUTS - if (value == 14) { /* table_subgoal_solution_frames */ - bytes = Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame); - structs = Pg_str_in_use(GLOBAL_pages_tg_sol_fr); - } - if (value == 15) { /* table_subgoal_answer_frames */ - bytes = Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame); - structs = Pg_str_in_use(GLOBAL_pages_tg_ans_fr); - } -#endif /* TABLING_INNER_CUTS */ -#endif /* YAPOR && TABLING */ - if (bytes == -1) + if (structs == -1) return (FALSE); tbytes = Deref(ARG2); tstructs = Deref(ARG3); @@ -1013,429 +1121,94 @@ static inline void answer_to_stdout(char *answer) { #ifdef TABLING static inline long show_statistics_table_entries(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_TABLING - pg_hd_ptr pg_hd; - tab_ent_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_tab_ent); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = TabEnt_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - TABLING_ERROR_CHECKING(statistics_table_entries, Pg_str_free(GLOBAL_pages_tab_ent) != cont); -#endif /* DEBUG_TABLING */ - Sfprintf(out, " Table entries: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry), Pg_pg_alloc(GLOBAL_pages_tab_ent), Pg_str_in_use(GLOBAL_pages_tab_ent)); -#else - Sfprintf(out, " Table entries: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry), Pg_str_in_use(GLOBAL_pages_tab_ent)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry); + SHOW_GLOBAL_PAGE_STATS(out, struct table_entry, GLOBAL_pages_tab_ent, "Table entries: "); } - static inline long show_statistics_subgoal_frames(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_TABLING - pg_hd_ptr pg_hd; - sg_fr_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_sg_fr); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = SgFr_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - TABLING_ERROR_CHECKING(statistics_subgoal_frames, Pg_str_free(GLOBAL_pages_sg_fr) != cont); -#endif /* DEBUG_TABLING */ - Sfprintf(out, " Subgoal frames: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame), Pg_pg_alloc(GLOBAL_pages_sg_fr), Pg_str_in_use(GLOBAL_pages_sg_fr)); +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING) + SHOW_GLOBAL_PAGE_STATS(out, struct subgoal_frame, GLOBAL_pages_sg_fr, "Subgoal frames: "); #else - Sfprintf(out, " Subgoal frames: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame), Pg_str_in_use(GLOBAL_pages_sg_fr)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame); + SHOW_REMOTE_PAGE_STATS(out, struct subgoal_frame, REMOTE_pages_sg_fr, "Subgoal frames: "); +#endif } - static inline long show_statistics_dependency_frames(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_TABLING - pg_hd_ptr pg_hd; - dep_fr_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_dep_fr); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = DepFr_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - TABLING_ERROR_CHECKING(statistics_dependency_frames, Pg_str_free(GLOBAL_pages_dep_fr) != cont); -#endif /* DEBUG_TABLING */ - Sfprintf(out, " Dependency frames: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame), Pg_pg_alloc(GLOBAL_pages_dep_fr), Pg_str_in_use(GLOBAL_pages_dep_fr)); +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING) + SHOW_GLOBAL_PAGE_STATS(out, struct dependency_frame, GLOBAL_pages_dep_fr, "Dependency frames: "); #else - Sfprintf(out, " Dependency frames: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame), Pg_str_in_use(GLOBAL_pages_dep_fr)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame); + SHOW_REMOTE_PAGE_STATS(out, struct dependency_frame, REMOTE_pages_dep_fr, "Dependency frames: "); +#endif } - static inline long show_statistics_subgoal_trie_nodes(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_TABLING - pg_hd_ptr pg_hd; - sg_node_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_sg_node); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = TrNode_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - TABLING_ERROR_CHECKING(statistics_subgoal_trie_nodes, Pg_str_free(GLOBAL_pages_sg_node) != cont); -#endif /* DEBUG_TABLING */ - Sfprintf(out, " Subgoal trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node), Pg_pg_alloc(GLOBAL_pages_sg_node), Pg_str_in_use(GLOBAL_pages_sg_node)); +#if !defined(THREADS_NO_SHARING) + SHOW_GLOBAL_PAGE_STATS(out, struct subgoal_trie_node, GLOBAL_pages_sg_node, "Subgoal trie nodes: "); #else - Sfprintf(out, " Subgoal trie nodes: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node), Pg_str_in_use(GLOBAL_pages_sg_node)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node); + SHOW_REMOTE_PAGE_STATS(out, struct subgoal_trie_node, REMOTE_pages_sg_node, "Subgoal trie nodes: "); +#endif } - -static inline long show_statistics_answer_trie_nodes(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_TABLING - pg_hd_ptr pg_hd; - ans_node_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_ans_node); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = TrNode_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - TABLING_ERROR_CHECKING(statistics_answer_trie_nodes, Pg_str_free(GLOBAL_pages_ans_node) != cont); -#endif /* DEBUG_TABLING */ - Sfprintf(out, " Answer trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node), Pg_pg_alloc(GLOBAL_pages_ans_node), Pg_str_in_use(GLOBAL_pages_ans_node)); -#else - Sfprintf(out, " Answer trie nodes: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node), Pg_str_in_use(GLOBAL_pages_ans_node)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node); -} - - static inline long show_statistics_subgoal_trie_hashes(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_TABLING - pg_hd_ptr pg_hd; - sg_hash_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_sg_hash); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = Hash_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - TABLING_ERROR_CHECKING(statistics_subgoal_trie_hashes, Pg_str_free(GLOBAL_pages_sg_hash) != cont); -#endif /* DEBUG_TABLING */ - Sfprintf(out, " Subgoal trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash), Pg_pg_alloc(GLOBAL_pages_sg_hash), Pg_str_in_use(GLOBAL_pages_sg_hash)); +#if !defined(THREADS_NO_SHARING) + SHOW_GLOBAL_PAGE_STATS(out, struct subgoal_trie_hash, GLOBAL_pages_sg_hash, "Subgoal trie hashes: "); #else - Sfprintf(out, " Subgoal trie hashes: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash), Pg_str_in_use(GLOBAL_pages_sg_hash)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash); + SHOW_REMOTE_PAGE_STATS(out, struct subgoal_trie_hash, REMOTE_pages_sg_hash, "Subgoal trie hashes: "); +#endif } +static inline long show_statistics_answer_trie_nodes(IOSTREAM *out) { +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) + SHOW_GLOBAL_PAGE_STATS(out, struct answer_trie_node, GLOBAL_pages_ans_node, "Answer trie nodes: "); +#else + SHOW_REMOTE_PAGE_STATS(out, struct answer_trie_node, REMOTE_pages_ans_node, "Answer trie nodes: "); +#endif +} static inline long show_statistics_answer_trie_hashes(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_TABLING - pg_hd_ptr pg_hd; - ans_hash_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_ans_hash); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = Hash_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - TABLING_ERROR_CHECKING(statistics_answer_trie_hashes, Pg_str_free(GLOBAL_pages_ans_hash) != cont); -#endif /* DEBUG_TABLING */ - Sfprintf(out, " Answer trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash), Pg_pg_alloc(GLOBAL_pages_ans_hash), Pg_str_in_use(GLOBAL_pages_ans_hash)); +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) + SHOW_GLOBAL_PAGE_STATS(out, struct answer_trie_hash, GLOBAL_pages_ans_hash, "Answer trie hashes: "); #else - Sfprintf(out, " Answer trie hashes: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash), Pg_str_in_use(GLOBAL_pages_ans_hash)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash); + SHOW_REMOTE_PAGE_STATS(out, struct answer_trie_hash, REMOTE_pages_ans_hash, "Answer trie hashes: "); +#endif } - static inline long show_statistics_global_trie_nodes(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_TABLING - pg_hd_ptr pg_hd; - gt_node_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_gt_node); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = TrNode_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - TABLING_ERROR_CHECKING(statistics_global_trie_nodes, Pg_str_free(GLOBAL_pages_gt_node) != cont); -#endif /* DEBUG_TABLING */ - Sfprintf(out, " Global trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node), Pg_pg_alloc(GLOBAL_pages_gt_node), Pg_str_in_use(GLOBAL_pages_gt_node)); -#else - Sfprintf(out, " Global trie nodes: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node), Pg_str_in_use(GLOBAL_pages_gt_node)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node); + SHOW_GLOBAL_PAGE_STATS(out, struct global_trie_node, GLOBAL_pages_gt_node, "Global trie nodes: "); } - static inline long show_statistics_global_trie_hashes(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_TABLING - /* suport not yet implemented :( - pg_hd_ptr pg_hd; - gt_hash_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_gt_hash); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = Hash_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - TABLING_ERROR_CHECKING(statistics_global_trie_hashes, Pg_str_free(GLOBAL_pages_gt_hash) != cont); - */ -#endif /* DEBUG_TABLING */ - Sfprintf(out, " Global trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash), Pg_pg_alloc(GLOBAL_pages_gt_hash), Pg_str_in_use(GLOBAL_pages_gt_hash)); -#else - Sfprintf(out, " Global trie hashes: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash), Pg_str_in_use(GLOBAL_pages_gt_hash)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash); + SHOW_GLOBAL_PAGE_STATS(out, struct global_trie_hash, GLOBAL_pages_gt_hash, "Global trie hashes: "); } #endif /* TABLING */ #ifdef YAPOR static inline long show_statistics_or_frames(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_YAPOR - pg_hd_ptr pg_hd; - or_fr_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_or_fr ); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = OrFr_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - YAPOR_ERROR_CHECKING(statistics_or_frames, Pg_str_free(GLOBAL_pages_or_fr ) != cont); -#endif /* DEBUG_YAPOR */ - Sfprintf(out, " Or-frames: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame), Pg_pg_alloc(GLOBAL_pages_or_fr ), Pg_str_in_use(GLOBAL_pages_or_fr )); -#else - Sfprintf(out, " Or-frames: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame), Pg_str_in_use(GLOBAL_pages_or_fr )); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame); + SHOW_GLOBAL_PAGE_STATS(out, struct or_frame, GLOBAL_pages_or_fr, "Or-frames: "); } - static inline long show_statistics_query_goal_solution_frames(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_YAPOR - pg_hd_ptr pg_hd; - qg_sol_fr_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_qg_sol_fr ); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = SolFr_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - YAPOR_ERROR_CHECKING(statistics_query_goal_solution_frames, Pg_str_free(GLOBAL_pages_qg_sol_fr ) != cont); -#endif /* DEBUG_YAPOR */ - Sfprintf(out, " Query goal solution frames: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame), Pg_pg_alloc(GLOBAL_pages_qg_sol_fr ), Pg_str_in_use(GLOBAL_pages_qg_sol_fr )); -#else - Sfprintf(out, " Query goal solution frames: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame), Pg_str_in_use(GLOBAL_pages_qg_sol_fr )); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame); + SHOW_GLOBAL_PAGE_STATS(out, struct query_goal_solution_frame, GLOBAL_pages_qg_sol_fr, "Query goal solution frames: "); } - static inline long show_statistics_query_goal_answer_frames(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_YAPOR - pg_hd_ptr pg_hd; - qg_ans_fr_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_qg_ans_fr); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = AnsFr_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - YAPOR_ERROR_CHECKING(statistics_query_goal_answer_frames, Pg_str_free(GLOBAL_pages_qg_ans_fr) != cont); -#endif /* DEBUG_YAPOR */ - Sfprintf(out, " Query goal answer frames: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_pg_alloc(GLOBAL_pages_qg_ans_fr), Pg_str_in_use(GLOBAL_pages_qg_ans_fr)); -#else - Sfprintf(out, " Query goal answer frames: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_str_in_use(GLOBAL_pages_qg_ans_fr)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame); + SHOW_GLOBAL_PAGE_STATS(out, struct query_goal_answer_frame, GLOBAL_pages_qg_ans_fr, "Query goal answer frames: "); } #endif /* YAPOR */ #if defined(YAPOR) && defined(TABLING) static inline long show_statistics_suspension_frames(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_OPTYAP - pg_hd_ptr pg_hd; - susp_fr_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_susp_fr); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = SuspFr_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - OPTYAP_ERROR_CHECKING(statistics_suspension_frames, Pg_str_free(GLOBAL_pages_susp_fr) != cont); -#endif /* DEBUG_OPTYAP */ - Sfprintf(out, " Suspension frames: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame), Pg_pg_alloc(GLOBAL_pages_susp_fr), Pg_str_in_use(GLOBAL_pages_susp_fr)); -#else - Sfprintf(out, " Suspension frames: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame), Pg_str_in_use(GLOBAL_pages_susp_fr)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame); + SHOW_GLOBAL_PAGE_STATS(out, struct suspension_frame, GLOBAL_pages_susp_fr, "Suspension frames: "); } - #ifdef TABLING_INNER_CUTS static inline long show_statistics_table_subgoal_solution_frames(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_OPTYAP - pg_hd_ptr pg_hd; - tg_sol_fr_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_tg_sol_fr); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = SolFr_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - OPTYAP_ERROR_CHECKING(statistics_table_subgoal_solution_frames, Pg_str_free(GLOBAL_pages_tg_sol_fr) != cont); -#endif /* DEBUG_OPTYAP */ - Sfprintf(out, " Table subgoal solution frames: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame), Pg_pg_alloc(GLOBAL_pages_tg_sol_fr), Pg_str_in_use(GLOBAL_pages_tg_sol_fr)); -#else - Sfprintf(out, " Table subgoal solution frames: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame), Pg_str_in_use(GLOBAL_pages_tg_sol_fr)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame); + SHOW_GLOBAL_PAGE_STATS(out, struct table_subgoal_solution_frame, GLOBAL_pages_tg_sol_fr, "Table subgoal solution frames:"); } - static inline long show_statistics_table_subgoal_answer_frames(IOSTREAM *out) { -#ifdef USE_PAGES_MALLOC -#ifdef DEBUG_OPTYAP - pg_hd_ptr pg_hd; - tg_ans_fr_ptr aux_ptr; - long cont = 0; - - pg_hd = Pg_free_pg(GLOBAL_pages_tg_ans_fr); - while (pg_hd) { - aux_ptr = PgHd_free_str(pg_hd); - while (aux_ptr) { - cont++; - aux_ptr = AnsFr_next(aux_ptr); - } - pg_hd = PgHd_next(pg_hd); - } - OPTYAP_ERROR_CHECKING(statistics_table_subgoal_answer_frames, Pg_str_free(GLOBAL_pages_tg_ans_fr) != cont); -#endif /* DEBUG_OPTYAP */ - Sfprintf(out, " Table subgoal answer frames: %10ld bytes (%ld pages and %ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame), Pg_pg_alloc(GLOBAL_pages_tg_ans_fr), Pg_str_in_use(GLOBAL_pages_tg_ans_fr)); -#else - Sfprintf(out, " Table subgoal answer frames: %10ld bytes (%ld structs in use)\n", - Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame), Pg_str_in_use(GLOBAL_pages_tg_ans_fr)); -#endif /* USE_PAGES_MALLOC */ - return Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame); + SHOW_GLOBAL_PAGE_STATS(out, struct table_subgoal_answer_frame, GLOBAL_pages_tg_ans_fr, "Table subgoal answer frames: "); } #endif /* TABLING_INNER_CUTS */ #endif /* YAPOR && TABLING */ diff --git a/OPTYap/opt.structs.h b/OPTYap/opt.structs.h index 00afdfc1f..d8cff5dd0 100644 --- a/OPTYap/opt.structs.h +++ b/OPTYap/opt.structs.h @@ -53,6 +53,50 @@ cptr_to_offset_with_null(choiceptr node) +/********************************************************** +** Structs ma_h_inner_struct and ma_hash_entry ** +**********************************************************/ + +#if (defined(TABLING) || !defined(YAPOR_COW)) && defined(MULTI_ASSIGNMENT_VARIABLES) +#define MAVARS_HASH_SIZE 512 + +typedef struct ma_h_entry { + CELL* addr; + struct ma_h_entry *next; +} ma_h_inner_struct; + +typedef struct { + UInt timestmp; + struct ma_h_entry val; +} ma_hash_entry; +#endif /* (TABLING || !YAPOR_COW) && MULTI_ASSIGNMENT_VARIABLES */ + + + +/*************************************** +** threads_dependency_frame ** +***************************************/ + +#ifdef THREADS_CONSUMER_SHARING +struct threads_dependency_frame { + lockvar lock; + enum { + working, + idle, + completing + } state; + int terminator; + int next; +}; +#endif /* THREADS_CONSUMER_SHARING */ + +#define ThDepFr_lock(X) ((X).lock) +#define ThDepFr_state(X) ((X).state) +#define ThDepFr_terminator(X) ((X).terminator) +#define ThDepFr_next(X) ((X).next) + + + /********************************* ** Struct page_header ** *********************************/ @@ -64,12 +108,12 @@ typedef struct page_header { struct page_header *previous; struct page_header *next; } *pg_hd_ptr; +#endif /* USE_PAGES_MALLOC */ #define PgHd_str_in_use(X) ((X)->structs_in_use) #define PgHd_free_str(X) ((X)->first_free_struct) #define PgHd_previous(X) ((X)->previous) #define PgHd_next(X) ((X)->next) -#endif /* USE_PAGES_MALLOC */ @@ -103,40 +147,75 @@ struct pages { **********************************/ struct global_pages { -#ifdef LIMIT_TABLING - int max_pages; -#endif /* LIMIT_TABLING */ struct pages void_pages; +#ifdef TABLING + struct pages table_entry_pages; +#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) + struct pages subgoal_entry_pages; +#endif +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) && !defined(THREADS_FULL_SHARING) && !defined(THREADS_CONSUMER_SHARING) + struct pages subgoal_frame_pages; + struct pages dependency_frame_pages; +#endif +#if !defined(THREADS_NO_SHARING) + struct pages subgoal_trie_node_pages; + struct pages subgoal_trie_hash_pages; +#endif +#if !defined(THREADS_NO_SHARING) && !defined(THREADS_SUBGOAL_SHARING) + struct pages answer_trie_node_pages; + struct pages answer_trie_hash_pages; +#endif + struct pages global_trie_node_pages; + struct pages global_trie_hash_pages; +#endif /* TABLING */ #ifdef YAPOR struct pages or_frame_pages; struct pages query_goal_solution_frame_pages; struct pages query_goal_answer_frame_pages; #endif /* YAPOR */ +#if defined(YAPOR) && defined(TABLING) + struct pages suspension_frame_pages; +#endif /* YAPOR && TABLING */ #ifdef TABLING_INNER_CUTS struct pages table_subgoal_solution_frame_pages; struct pages table_subgoal_answer_frame_pages; #endif /* TABLING_INNER_CUTS */ -#ifdef TABLING - struct pages table_entry_pages; +}; + + + +/********************************* +** Struct local_pages ** +*********************************/ + +#if defined(TABLING) && (defined(YAPOR) || defined(THREADS)) +struct local_pages { +#if defined(YAPOR) + struct answer_trie_node *next_free_answer_trie_node; +#elif defined(THREADS) + struct pages void_pages; struct pages subgoal_frame_pages; struct pages dependency_frame_pages; +#if defined(THREADS_NO_SHARING) struct pages subgoal_trie_node_pages; - struct pages answer_trie_node_pages; - struct pages global_trie_node_pages; struct pages subgoal_trie_hash_pages; +#elif defined(THREADS_SUBGOAL_SHARING) || defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) + struct subgoal_trie_node *next_free_subgoal_trie_node; + struct subgoal_trie_hash *next_free_subgoal_trie_hash; +#endif +#if defined(THREADS_NO_SHARING) || defined(THREADS_SUBGOAL_SHARING) + struct pages answer_trie_node_pages; struct pages answer_trie_hash_pages; - struct pages global_trie_hash_pages; -#endif /* TABLING */ -#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) - struct pages subgoal_entry_pages; -#endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */ -#ifdef THREADS_FULL_SHARING +#elif defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING) + struct answer_trie_node *next_free_answer_trie_node; + struct answer_trie_hash *next_free_answer_trie_hash; +#endif +#if defined(THREADS_FULL_SHARING) struct pages answer_ref_node_pages; -#endif /* THREADS_FULL_SHARING */ -#if defined(YAPOR) && defined(TABLING) - struct pages suspension_frame_pages; -#endif /* YAPOR && TABLING */ +#endif +#endif /* YAPOR - THREADS */ }; +#endif /* TABLING && (YAPOR || THREADS) */ @@ -164,27 +243,31 @@ struct global_optyap_locks { -/*************************************** -** threads_dependency_frame ** -***************************************/ +/****************************************** +** Struct local_optyap_signals ** +******************************************/ -#ifdef THREADS_CONSUMER_SHARING -struct threads_dependency_frame { +#ifdef YAPOR +struct local_optyap_signals { +#if defined(YAPOR_COPY) || defined(YAPOR_THREADS) lockvar lock; - enum { - working, - idle, - completing - } state; - int terminator; - int next; + volatile enum { + Q_idle = 0, + trail = 1, + global = 2, + local = 3, + P_idle = 4 + } P_fase, Q_fase; +#endif /* YAPOR_COPY || YAPOR_THREADS */ + volatile enum { + no_sharing = 0, + sharing = 1, + nodes_shared = 2, + copy_done = 3, + worker_ready = 4 + } reply_signal; }; -#endif /* THREADS_CONSUMER_SHARING */ - -#define ThDepFr_lock(X) ((X).lock) -#define ThDepFr_state(X) ((X).state) -#define ThDepFr_terminator(X) ((X).terminator) -#define ThDepFr_next(X) ((X).next) +#endif /* YAPOR */ @@ -235,6 +318,7 @@ struct global_optyap_data { struct global_trie_node *root_global_trie; struct table_entry *root_table_entry; #ifdef LIMIT_TABLING + int max_pages; struct subgoal_frame *first_subgoal_frame; struct subgoal_frame *last_subgoal_frame; struct subgoal_frame *check_subgoal_frame; @@ -255,25 +339,23 @@ struct global_optyap_data { #endif /* TABLING */ }; -#define GLOBAL_max_pages (GLOBAL_optyap_data.pages.max_pages) #define GLOBAL_pages_void (GLOBAL_optyap_data.pages.void_pages) -#define GLOBAL_pages_or_fr (GLOBAL_optyap_data.pages.or_frame_pages) -#define GLOBAL_pages_qg_sol_fr (GLOBAL_optyap_data.pages.query_goal_solution_frame_pages) -#define GLOBAL_pages_qg_ans_fr (GLOBAL_optyap_data.pages.query_goal_answer_frame_pages) -#define GLOBAL_pages_tg_sol_fr (GLOBAL_optyap_data.pages.table_subgoal_solution_frame_pages) -#define GLOBAL_pages_tg_ans_fr (GLOBAL_optyap_data.pages.table_subgoal_answer_frame_pages) #define GLOBAL_pages_tab_ent (GLOBAL_optyap_data.pages.table_entry_pages) +#define GLOBAL_pages_sg_ent (GLOBAL_optyap_data.pages.subgoal_entry_pages) #define GLOBAL_pages_sg_fr (GLOBAL_optyap_data.pages.subgoal_frame_pages) #define GLOBAL_pages_dep_fr (GLOBAL_optyap_data.pages.dependency_frame_pages) #define GLOBAL_pages_sg_node (GLOBAL_optyap_data.pages.subgoal_trie_node_pages) -#define GLOBAL_pages_ans_node (GLOBAL_optyap_data.pages.answer_trie_node_pages) -#define GLOBAL_pages_gt_node (GLOBAL_optyap_data.pages.global_trie_node_pages) #define GLOBAL_pages_sg_hash (GLOBAL_optyap_data.pages.subgoal_trie_hash_pages) +#define GLOBAL_pages_ans_node (GLOBAL_optyap_data.pages.answer_trie_node_pages) #define GLOBAL_pages_ans_hash (GLOBAL_optyap_data.pages.answer_trie_hash_pages) +#define GLOBAL_pages_gt_node (GLOBAL_optyap_data.pages.global_trie_node_pages) #define GLOBAL_pages_gt_hash (GLOBAL_optyap_data.pages.global_trie_hash_pages) -#define GLOBAL_pages_sg_ent (GLOBAL_optyap_data.pages.subgoal_entry_pages) -#define GLOBAL_pages_ans_ref (GLOBAL_optyap_data.pages.answer_ref_node_pages) +#define GLOBAL_pages_or_fr (GLOBAL_optyap_data.pages.or_frame_pages) +#define GLOBAL_pages_qg_sol_fr (GLOBAL_optyap_data.pages.query_goal_solution_frame_pages) +#define GLOBAL_pages_qg_ans_fr (GLOBAL_optyap_data.pages.query_goal_answer_frame_pages) #define GLOBAL_pages_susp_fr (GLOBAL_optyap_data.pages.suspension_frame_pages) +#define GLOBAL_pages_tg_sol_fr (GLOBAL_optyap_data.pages.table_subgoal_solution_frame_pages) +#define GLOBAL_pages_tg_ans_fr (GLOBAL_optyap_data.pages.table_subgoal_answer_frame_pages) #define GLOBAL_scheduler_loop (GLOBAL_optyap_data.scheduler_loop) #define GLOBAL_delayed_release_load (GLOBAL_optyap_data.delayed_release_load) #define GLOBAL_number_workers (GLOBAL_optyap_data.number_workers) @@ -281,7 +363,7 @@ struct global_optyap_data { #define GLOBAL_master_worker (GLOBAL_optyap_data.master_worker) #define GLOBAL_execution_time (GLOBAL_optyap_data.execution_time) #ifdef YAPOR_THREADS -#define Get_GLOBAL_root_cp() offset_to_cptr(GLOBAL_optyap_data.root_choice_point_offset) +#define Get_GLOBAL_root_cp() offset_to_cptr(GLOBAL_optyap_data.root_choice_point_offset) #define Set_GLOBAL_root_cp(bptr) (GLOBAL_optyap_data.root_choice_point_offset = cptr_to_offset(bptr)) #else #define GLOBAL_root_cp (GLOBAL_optyap_data.root_choice_point) @@ -311,6 +393,7 @@ struct global_optyap_data { #define GLOBAL_parallel_mode (GLOBAL_optyap_data.parallel_mode) #define GLOBAL_root_gt (GLOBAL_optyap_data.root_global_trie) #define GLOBAL_root_tab_ent (GLOBAL_optyap_data.root_table_entry) +#define GLOBAL_max_pages (GLOBAL_optyap_data.max_pages) #define GLOBAL_first_sg_fr (GLOBAL_optyap_data.first_subgoal_frame) #define GLOBAL_last_sg_fr (GLOBAL_optyap_data.last_subgoal_frame) #define GLOBAL_check_sg_fr (GLOBAL_optyap_data.check_subgoal_frame) @@ -323,59 +406,16 @@ struct global_optyap_data { -/****************************************** -** Struct local_optyap_signals ** -******************************************/ - -#ifdef YAPOR -struct local_optyap_signals{ -#if defined(YAPOR_COPY) || defined(YAPOR_THREADS) - lockvar lock; - volatile enum { - Q_idle = 0, - trail = 1, - global = 2, - local = 3, - P_idle = 4 - } P_fase, Q_fase; -#endif /* YAPOR_COPY || YAPOR_THREADS */ - volatile enum { - no_sharing = 0, - sharing = 1, - nodes_shared = 2, - copy_done = 3, - worker_ready = 4 - } reply_signal; -}; -#endif /* YAPOR */ - - - -/********************************************************** -** Structs ma_h_inner_struct and ma_hash_entry ** -**********************************************************/ - -#if (defined(TABLING) || !defined(YAPOR_COW)) && defined(MULTI_ASSIGNMENT_VARIABLES) -#define MAVARS_HASH_SIZE 512 - -typedef struct ma_h_entry { - CELL* addr; - struct ma_h_entry *next; -} ma_h_inner_struct; - -typedef struct { - UInt timestmp; - struct ma_h_entry val; -} ma_hash_entry; -#endif /* (TABLING || !YAPOR_COW) && MULTI_ASSIGNMENT_VARIABLES */ - - - /*************************************** ** Struct local_optyap_data ** ***************************************/ struct local_optyap_data { +#if defined(TABLING) && (defined(YAPOR) || defined(THREADS)) + /* local data related to memory management */ + struct local_pages pages; +#endif /* TABLING && (YAPOR || THREADS) */ + #ifdef YAPOR lockvar lock; /* local data related to or-parallelism */ @@ -384,13 +424,13 @@ struct local_optyap_data { Int top_choice_point_offset; #else choiceptr top_choice_point; -#endif +#endif /* YAPOR_THREADS */ struct or_frame *top_or_frame; #ifdef YAPOR_THREADS Int prune_request_offset; #else choiceptr prune_request; -#endif +#endif /* YAPOR_THREADS */ volatile int share_request; struct local_optyap_signals share_signals; volatile struct { @@ -401,7 +441,6 @@ struct local_optyap_data { #ifdef TABLING /* local data related to tabling */ - struct answer_trie_node *next_free_answer_trie_node; struct subgoal_frame *top_subgoal_frame; struct dependency_frame *top_dependency_frame; #ifdef TABLING_INNER_CUTS @@ -412,7 +451,7 @@ struct local_optyap_data { Int top_choice_point_on_stack_offset; #else choiceptr top_choice_point_on_stack; -#endif +#endif /* YAPOR_THREADS */ struct or_frame *top_or_frame_with_suspensions; #endif /* YAPOR */ #endif /* TABLING */ @@ -424,6 +463,18 @@ struct local_optyap_data { #endif /* (TABLING || !YAPOR_COW) && MULTI_ASSIGNMENT_VARIABLES */ }; +#define LOCAL_pages_void (LOCAL_optyap_data.pages.void_pages) +#define LOCAL_pages_sg_fr (LOCAL_optyap_data.pages.subgoal_frame_pages) +#define LOCAL_pages_dep_fr (LOCAL_optyap_data.pages.dependency_frame_pages) +#define LOCAL_pages_sg_node (LOCAL_optyap_data.pages.subgoal_trie_node_pages) +#define LOCAL_pages_sg_hash (LOCAL_optyap_data.pages.subgoal_trie_hash_pages) +#define LOCAL_pages_ans_node (LOCAL_optyap_data.pages.answer_trie_node_pages) +#define LOCAL_pages_ans_hash (LOCAL_optyap_data.pages.answer_trie_hash_pages) +#define LOCAL_pages_ans_ref_node (LOCAL_optyap_data.pages.answer_ref_node_pages) +#define LOCAL_next_free_sg_node (LOCAL_optyap_data.pages.next_free_subgoal_trie_node) +#define LOCAL_next_free_sg_hash (LOCAL_optyap_data.pages.next_free_subgoal_trie_hash) +#define LOCAL_next_free_ans_node (LOCAL_optyap_data.pages.next_free_answer_trie_node) +#define LOCAL_next_free_ans_hash (LOCAL_optyap_data.pages.next_free_answer_trie_hash) #define LOCAL_lock (LOCAL_optyap_data.lock) #define LOCAL_load (LOCAL_optyap_data.load) #ifdef YAPOR_THREADS @@ -454,7 +505,6 @@ struct local_optyap_data { #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) @@ -470,8 +520,19 @@ struct local_optyap_data { #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_pages_void(wid) (REMOTE(wid)->optyap_data_.pages.void_pages) +#define REMOTE_pages_sg_fr(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_frame_pages) +#define REMOTE_pages_dep_fr(wid) (REMOTE(wid)->optyap_data_.pages.dependency_frame_pages) +#define REMOTE_pages_sg_node(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_trie_node_pages) +#define REMOTE_pages_sg_hash(wid) (REMOTE(wid)->optyap_data_.pages.subgoal_trie_hash_pages) +#define REMOTE_pages_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_node_pages) +#define REMOTE_pages_ans_hash(wid) (REMOTE(wid)->optyap_data_.pages.answer_trie_hash_pages) +#define REMOTE_pages_ans_ref_node(wid) (REMOTE(wid)->optyap_data_.pages.answer_ref_node_pages) +#define REMOTE_next_free_sg_node(wid) (REMOTE(wid)->optyap_data_.pages.next_free_subgoal_trie_node) +#define REMOTE_next_free_sg_hash(wid) (REMOTE(wid)->optyap_data_.pages.next_free_subgoal_trie_hash) +#define REMOTE_next_free_ans_node(wid) (REMOTE(wid)->optyap_data_.pages.next_free_answer_trie_node) +#define REMOTE_next_free_ans_hash(wid) (REMOTE(wid)->optyap_data_.pages.next_free_answer_trie_hash) #define REMOTE_lock(wid) (REMOTE(wid)->optyap_data_.lock) #define REMOTE_load(wid) (REMOTE(wid)->optyap_data_.load) #ifdef YAPOR_THREADS @@ -501,7 +562,6 @@ struct local_optyap_data { #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) diff --git a/OPTYap/tab.structs.h b/OPTYap/tab.structs.h index 101ba9631..fa4338e9b 100644 --- a/OPTYap/tab.structs.h +++ b/OPTYap/tab.structs.h @@ -30,12 +30,12 @@ typedef struct table_entry { short execution_mode; /* combines yap_flags with pred_flags */ #ifdef MODE_DIRECTED_TABLING int* mode_directed_array; -#endif /*MODE_DIRECTED_TABLING*/ +#endif /* MODE_DIRECTED_TABLING */ #ifdef THREADS_NO_SHARING struct subgoal_trie_node *subgoal_trie[THREADS_FIRST_LEVEL_BUCKETS]; #else struct subgoal_trie_node *subgoal_trie; -#endif /*THREADS_NO_SHARING */ +#endif /* THREADS_NO_SHARING */ struct subgoal_trie_hash *hash_chain; struct table_entry *next; } *tab_ent_ptr; @@ -52,7 +52,7 @@ typedef struct table_entry { //#define TabEnt_subgoal_trie(X,I) ((X)->subgoal_trie[I]) #else #define TabEnt_subgoal_trie(X) ((X)->subgoal_trie) -#endif /*THREADS_NO_SHARING */ +#endif /* THREADS_NO_SHARING */ #define TabEnt_hash_chain(X) ((X)->hash_chain) #define TabEnt_next(X) ((X)->next) diff --git a/OPTYap/tab.tries.c b/OPTYap/tab.tries.c index 1c8a798a1..bec2c648e 100644 --- a/OPTYap/tab.tries.c +++ b/OPTYap/tab.tries.c @@ -1246,6 +1246,8 @@ void update_answer_trie(sg_fr_ptr sg_fr) { void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) { + CACHE_REGS + if (! IS_SUBGOAL_LEAF_NODE(current_node)) { int child_mode; if (mode == TRAVERSE_MODE_NORMAL) { @@ -1315,6 +1317,8 @@ void free_subgoal_trie(sg_node_ptr current_node, int mode, int position) { void free_answer_trie(ans_node_ptr current_node, int mode, int position) { + CACHE_REGS + #ifdef TABLING_INNER_CUTS if (! IS_ANSWER_LEAF_NODE(current_node) && TrNode_child(current_node)) { #else @@ -1363,6 +1367,8 @@ void free_answer_trie(ans_node_ptr current_node, int mode, int position) { void free_subgoal_hash_chain(sg_hash_ptr hash) { + CACHE_REGS + while (hash) { sg_node_ptr chain_node, *bucket, *last_bucket; sg_hash_ptr next_hash; @@ -1391,6 +1397,8 @@ void free_subgoal_hash_chain(sg_hash_ptr hash) { void free_answer_hash_chain(ans_hash_ptr hash) { + CACHE_REGS + while (hash) { ans_node_ptr chain_node, *bucket, *last_bucket; ans_hash_ptr next_hash; diff --git a/OPTYap/tab.tries.i b/OPTYap/tab.tries.i index 90d864f2c..180819ce7 100644 --- a/OPTYap/tab.tries.i +++ b/OPTYap/tab.tries.i @@ -64,6 +64,7 @@ static inline sg_node_ptr subgoal_trie_check_insert_gt_entry(tab_ent_ptr tab_ent #else static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr tab_ent, sg_node_ptr parent_node, Term t) { #endif /* MODE_GLOBAL_TRIE_ENTRY */ + CACHE_REGS sg_node_ptr child_node; LOCK_SUBGOAL_NODE(parent_node); @@ -358,6 +359,7 @@ static inline ans_node_ptr answer_trie_check_insert_gt_entry(sg_fr_ptr sg_fr, an #else static inline ans_node_ptr answer_trie_check_insert_entry(sg_fr_ptr sg_fr, ans_node_ptr parent_node, Term t, int instr) { #endif /* MODE_GLOBAL_TRIE_ENTRY */ + CACHE_REGS ans_node_ptr child_node; TABLING_ERROR_CHECKING(answer_trie_check_insert_(gt)_entry, IS_ANSWER_LEAF_NODE(parent_node)); diff --git a/pl/tabling.yap b/pl/tabling.yap index 0c9cbf488..af2749a2e 100644 --- a/pl/tabling.yap +++ b/pl/tabling.yap @@ -83,6 +83,10 @@ tabling_statistics(global_trie_nodes,[BytesInUse,StructsInUse]) :- '$c_get_optyap_statistics'(10,BytesInUse,StructsInUse). tabling_statistics(global_trie_hashes,[BytesInUse,StructsInUse]) :- '$c_get_optyap_statistics'(11,BytesInUse,StructsInUse). +tabling_statistics(subgoal_entries,[BytesInUse,StructsInUse]) :- + '$c_get_optyap_statistics'(16,BytesInUse,StructsInUse). +tabling_statistics(answer_ref_nodes,[BytesInUse,StructsInUse]) :- + '$c_get_optyap_statistics'(17,BytesInUse,StructsInUse). diff --git a/pl/yapor.yap b/pl/yapor.yap index cba67fcbc..1620bb6c4 100644 --- a/pl/yapor.yap +++ b/pl/yapor.yap @@ -86,6 +86,10 @@ opt_statistics(table_subgoal_solution_frames,[BytesInUse,StructsInUse]) :- '$c_get_optyap_statistics'(14,BytesInUse,StructsInUse). opt_statistics(table_subgoal_answer_frames,[BytesInUse,StructsInUse]) :- '$c_get_optyap_statistics'(15,BytesInUse,StructsInUse). +opt_statistics(subgoal_entries,[BytesInUse,StructsInUse]) :- + '$c_get_optyap_statistics'(16,BytesInUse,StructsInUse). +opt_statistics(answer_ref_nodes,[BytesInUse,StructsInUse]) :- + '$c_get_optyap_statistics'(17,BytesInUse,StructsInUse). From c74cc23940be39b137366cd916b81b6f9eec888d Mon Sep 17 00:00:00 2001 From: Ubuntu32 Date: Wed, 7 Dec 2011 08:36:10 -0800 Subject: [PATCH 3/5] ifix bad prototype. --- C/alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C/alloc.c b/C/alloc.c index d6336ce10..3b4e434f7 100644 --- a/C/alloc.c +++ b/C/alloc.c @@ -410,7 +410,7 @@ Yap_KillStacks(int wid) } #else void -Yap_KillStacks(void) +Yap_KillStacks(int wid) { if (LOCAL_GlobalBase) { free(LOCAL_GlobalBase); From 65c7b4250afa9e993493f4164c80787ce53b7498 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Wed, 7 Dec 2011 08:39:56 -0800 Subject: [PATCH 4/5] iensure we have LD. --- os/pl-error.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/os/pl-error.c b/os/pl-error.c index 43ede40b2..f0ec697e1 100644 --- a/os/pl-error.c +++ b/os/pl-error.c @@ -42,7 +42,8 @@ PL_get_atom_ex__LD(term_t t, atom_t *a ARG_LD) int PL_get_atom_ex(term_t t, atom_t *a) -{ if ( PL_get_atom(t, a) ) +{ GET_LD + if ( PL_get_atom(t, a) ) succeed; return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_atom, t); From dcbf8b0522db23f93270cec5096128712fbc7c89 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Wed, 7 Dec 2011 09:04:46 -0800 Subject: [PATCH 5/5] fix configure to handle or-parallelism correctly and to remove random from clib. --- configure | 6 +++--- configure.in | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index a2ca2141e..e2ddf1495 100755 --- a/configure +++ b/configure @@ -4955,7 +4955,7 @@ else #define MAX_WORKERS $yap_cv_max_workers _ACEOF - if test "$orparallelism" = copy + if test "$orparallelism" = copy -o "$orparallelism" = yes then use_malloc="no" fi @@ -9693,8 +9693,8 @@ CHR_TARGETS=chr_support."$SO" if test "$ENABLE_CLIB" = ""; then -CLIB_TARGETS="random.$SO socket.$SO cgi.$SO memfile.$SO files.$SO mime.$SO $CRYPT_TARGETS" -CLIB_PLTARGETS="random.pl socket.pl cgi.pl memfile.pl filesex.pl mime.pl $CRYPT_TARGETS" +CLIB_TARGETS="socket.$SO cgi.$SO memfile.$SO files.$SO mime.$SO $CRYPT_TARGETS" +CLIB_PLTARGETS="socket.pl cgi.pl memfile.pl filesex.pl mime.pl $CRYPT_TARGETS" if test "$ac_cv_func_setitimer" = "yes"; then CLIB_TARGETS="$CLIB_TARGETS time.$SO" diff --git a/configure.in b/configure.in index 211e35f7b..853f7ea4f 100755 --- a/configure.in +++ b/configure.in @@ -469,7 +469,7 @@ then AC_DEFINE(MAX_WORKERS,1) else AC_DEFINE_UNQUOTED(MAX_WORKERS,$yap_cv_max_workers) - if test "$orparallelism" = copy + if test "$orparallelism" = copy -o "$orparallelism" = yes then use_malloc="no" fi @@ -2073,8 +2073,8 @@ AC_SUBST(CHR_TARGETS) dnl clib if test "$ENABLE_CLIB" = ""; then -CLIB_TARGETS="random.$SO socket.$SO cgi.$SO memfile.$SO files.$SO mime.$SO $CRYPT_TARGETS" -CLIB_PLTARGETS="random.pl socket.pl cgi.pl memfile.pl filesex.pl mime.pl $CRYPT_TARGETS" +CLIB_TARGETS="socket.$SO cgi.$SO memfile.$SO files.$SO mime.$SO $CRYPT_TARGETS" +CLIB_PLTARGETS="socket.pl cgi.pl memfile.pl filesex.pl mime.pl $CRYPT_TARGETS" if test "$ac_cv_func_setitimer" = "yes"; then CLIB_TARGETS="$CLIB_TARGETS time.$SO"