support for the common global trie (version GT-T: global trie for terms)
This commit is contained in:
parent
218bc2e423
commit
7d841065e9
@ -13,9 +13,9 @@
|
||||
** General Configuration Parameters **
|
||||
** ----------------------------------------------------------------- */
|
||||
|
||||
/* ------------------------------------------ **
|
||||
** memory alloc scheme (define one) **
|
||||
** ------------------------------------------ */
|
||||
/* ----------------------------------------------------- **
|
||||
** memory alloc scheme (mandatory, define one) **
|
||||
** ----------------------------------------------------- */
|
||||
#define YAP_MEMORY_ALLOC_SCHEME 1
|
||||
/* #define SHM_MEMORY_ALLOC_SCHEME 1 */
|
||||
/* #define MALLOC_MEMORY_ALLOC_SCHEME 1 */
|
||||
@ -33,9 +33,9 @@
|
||||
** ----------------------- */
|
||||
#define MAX_TABLE_VARS 1000
|
||||
|
||||
/* ------------------------------------------ **
|
||||
** trail freeze scheme (define one) **
|
||||
** ------------------------------------------ */
|
||||
/* ----------------------------------------------------- **
|
||||
** trail freeze scheme (mandatory, define one) **
|
||||
** ----------------------------------------------------- */
|
||||
#define BFZ_TRAIL_SCHEME 1
|
||||
/* #define BBREG_TRAIL_SCHEME 1 */
|
||||
|
||||
@ -44,29 +44,36 @@
|
||||
** ----------------------------------------------- */
|
||||
#define TABLING_EARLY_COMPLETION 1
|
||||
|
||||
/* ------------------------------------------------ **
|
||||
** support trie compact pairs? (optional) **
|
||||
** ------------------------------------------------ */
|
||||
/* ------------------------------------------------- **
|
||||
** support trie compact pairs ? (optional) **
|
||||
** ------------------------------------------------- */
|
||||
#define TRIE_COMPACT_PAIRS 1
|
||||
|
||||
/* --------------------------------------------------- **
|
||||
** support deterministic tabling? (optional) **
|
||||
** --------------------------------------------------- */
|
||||
/* ------------------------------------------------------ **
|
||||
** support global trie ? (optional, define one) **
|
||||
** ------------------------------------------------------ */
|
||||
/* #define GLOBAL_TRIE_FOR_CALLS_ANSWERS 1 */
|
||||
/* #define GLOBAL_TRIE_FOR_TERMS 1 */
|
||||
/* #define GLOBAL_TRIE_FOR_SUBTERMS 1 */
|
||||
|
||||
/* ---------------------------------------------------- **
|
||||
** support deterministic tabling ? (optional) **
|
||||
** ---------------------------------------------------- */
|
||||
/* #define DETERMINISTIC_TABLING 1 */
|
||||
|
||||
/* ------------------------------------------------ **
|
||||
** limit the table space size? (optional) **
|
||||
** ------------------------------------------------ */
|
||||
/* ------------------------------------------------- **
|
||||
** limit the table space size ? (optional) **
|
||||
** ------------------------------------------------- */
|
||||
/* #define LIMIT_TABLING 1 */
|
||||
|
||||
/* ------------------------------------------------ **
|
||||
** support incomplete tabling? (optional) **
|
||||
** ------------------------------------------------ */
|
||||
/* ------------------------------------------------- **
|
||||
** support incomplete tabling ? (optional) **
|
||||
** ------------------------------------------------- */
|
||||
/* #define INCOMPLETE_TABLING 1 */
|
||||
|
||||
/* ---------------------------------------- -- **
|
||||
** enable error checking? (optional) **
|
||||
** ------------------------------------------- */
|
||||
/* ----------------------------------------- -- **
|
||||
** enable error checking ? (optional) **
|
||||
** -------------------------------------------- */
|
||||
/* #define TABLING_ERRORS 1 */
|
||||
|
||||
|
||||
@ -84,15 +91,15 @@
|
||||
#define MAX_BRANCH_DEPTH 1000
|
||||
#define MAX_BEST_TIMES 21
|
||||
|
||||
/* -------------------------------------------- **
|
||||
** memory mapping scheme (define one) **
|
||||
** -------------------------------------------- */
|
||||
/* ------------------------------------------------------- **
|
||||
** memory mapping scheme (mandatory, define one) **
|
||||
** ------------------------------------------------------- */
|
||||
#define MMAP_MEMORY_MAPPING_SCHEME 1
|
||||
/* #define SHM_MEMORY_MAPPING_SCHEME 1 */
|
||||
|
||||
/* ---------------------------------------- -- **
|
||||
** enable error checking? (optional) **
|
||||
** ------------------------------------------- */
|
||||
/* -------------------------------------------- **
|
||||
** enable error checking ? (optional) **
|
||||
** -------------------------------------------- */
|
||||
/* #define YAPOR_ERRORS 1 */
|
||||
|
||||
|
||||
@ -109,40 +116,38 @@
|
||||
#define TABLE_LOCK_BUCKETS 512
|
||||
#define TG_ANSWER_SLOTS 20
|
||||
|
||||
/* ------------------------------------------- **
|
||||
** tries locking scheme (define one) **
|
||||
** ------------------------------------------- **
|
||||
** The TABLE_LOCK_AT_ENTRY_LEVEL scheme locks **
|
||||
** the access to the table space in the entry **
|
||||
** data structure. It restricts the number of **
|
||||
** lock operations needed to go through the **
|
||||
** table data structures. **
|
||||
** **
|
||||
** The TABLE_LOCK_AT_NODE_LEVEL scheme locks **
|
||||
** each data structure before accessing it. It **
|
||||
** decreases concurrrency for workers **
|
||||
** accessing commom parts of the table space. **
|
||||
** **
|
||||
** The TABLE_LOCK_AT_WRITE_LEVEL scheme is an **
|
||||
** hibrid scheme, it only locks a table data **
|
||||
** structure when it is going to update it. **
|
||||
** You can use ALLOC_BEFORE_CHECK with this **
|
||||
** scheme to allocate a node before checking **
|
||||
** if it will be necessary. **
|
||||
** ------------------------------------------- */
|
||||
/* ------------------------------------------------------ **
|
||||
** tries locking scheme (mandatory, define one) **
|
||||
** ------------------------------------------------------ **
|
||||
** The TABLE_LOCK_AT_ENTRY_LEVEL scheme locks the access **
|
||||
** to the table space in the entry data structure. It **
|
||||
** restricts the number of lock operations needed to go **
|
||||
** through the table data structures. **
|
||||
** **
|
||||
** The TABLE_LOCK_AT_NODE_LEVEL scheme locks each data **
|
||||
** structure before accessing it. It decreases **
|
||||
** concurrrency for workers accessing commom parts of the **
|
||||
** table space. **
|
||||
** **
|
||||
** The TABLE_LOCK_AT_WRITE_LEVEL scheme is an hibrid **
|
||||
** scheme, it only locks a table data structure when it **
|
||||
** is going to update it. You can use ALLOC_BEFORE_CHECK **
|
||||
** with this scheme to allocate a node before checking **
|
||||
** if it will be necessary. **
|
||||
** ------------------------------------------------------ */
|
||||
/* #define TABLE_LOCK_AT_ENTRY_LEVEL 1 */
|
||||
/* #define TABLE_LOCK_AT_NODE_LEVEL 1 */
|
||||
#define TABLE_LOCK_AT_WRITE_LEVEL 1
|
||||
/* #define ALLOC_BEFORE_CHECK 1 */
|
||||
|
||||
/* ---------------------------------------- **
|
||||
** support inner cuts? (optional) **
|
||||
** ---------------------------------------- */
|
||||
/* ----------------------------------------- **
|
||||
** support inner cuts ? (optional) **
|
||||
** ----------------------------------------- */
|
||||
#define TABLING_INNER_CUTS 1
|
||||
|
||||
/* --------------------------------------------------- **
|
||||
** use timestamps for suspension? (optional) **
|
||||
** --------------------------------------------------- */
|
||||
/* ---------------------------------------------------- **
|
||||
** use timestamps for suspension ? (optional) **
|
||||
** ---------------------------------------------------- */
|
||||
#define TIMESTAMP_CHECK 1
|
||||
|
||||
|
||||
@ -189,6 +194,17 @@
|
||||
#if defined(BFZ_TRAIL_SCHEME) && defined(BBREG_TRAIL_SCHEME)
|
||||
#error Do not define multiple trail schemes
|
||||
#endif /* BFZ_TRAIL_SCHEME && BBREG_TRAIL_SCHEME */
|
||||
#if defined(GLOBAL_TRIE_FOR_CALLS_ANSWERS)
|
||||
#if defined(GLOBAL_TRIE_FOR_TERMS) || defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
#error Do not define multiple global trie schemes
|
||||
#endif /* GLOBAL_TRIE_FOR_TERMS || GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#endif /* GLOBAL_TRIE_FOR_CALLS_ANSWERS */
|
||||
#if defined(GLOBAL_TRIE_FOR_TERMS) && defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
#error Do not define multiple global trie schemes
|
||||
#endif /* GLOBAL_TRIE_FOR_TERMS && GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#if defined(GLOBAL_TRIE_FOR_CALLS_ANSWERS) || defined(GLOBAL_TRIE_FOR_TERMS) || defined(GLOBAL_TRIE_FOR_SUBTERMS)
|
||||
#define GLOBAL_TRIE
|
||||
#endif /* GLOBAL_TRIE_FOR_CALLS_ANSWERS || GLOBAL_TRIE_FOR_TERMS || GLOBAL_TRIE_FOR_SUBTERMS */
|
||||
#endif /* TABLING */
|
||||
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
@ -225,8 +241,11 @@
|
||||
#ifndef TABLING
|
||||
#undef BFZ_TRAIL_SCHEME
|
||||
#undef BBREG_TRAIL_SCHEME
|
||||
#undef TRIE_COMPACT_PAIRS
|
||||
#undef TABLING_EARLY_COMPLETION
|
||||
#undef TRIE_COMPACT_PAIRS
|
||||
#undef GLOBAL_TRIE_FOR_CALLS_ANSWERS
|
||||
#undef GLOBAL_TRIE_FOR_TERMS
|
||||
#undef GLOBAL_TRIE_FOR_SUBTERMS
|
||||
#undef DETERMINISTIC_TABLING
|
||||
#undef LIMIT_TABLING
|
||||
#undef INCOMPLETE_TABLING
|
||||
|
@ -46,6 +46,7 @@ ma_h_inner_struct *Yap_ma_h_top;
|
||||
** Local macros **
|
||||
** ---------------------- */
|
||||
|
||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||
#define STRUCTS_PER_PAGE(STR_TYPE) ((Yap_page_size - STRUCT_SIZE(struct page_header)) / STRUCT_SIZE(STR_TYPE))
|
||||
|
||||
#define INIT_PAGES(PG, STR_TYPE) \
|
||||
@ -54,6 +55,9 @@ ma_h_inner_struct *Yap_ma_h_top;
|
||||
Pg_str_in_use(PG) = 0; \
|
||||
Pg_str_per_pg(PG) = STRUCTS_PER_PAGE(STR_TYPE); \
|
||||
Pg_free_pg(PG) = NULL
|
||||
#else
|
||||
#define INIT_PAGES(PG, STR_TYPE) Pg_str_in_use(PG) = 0
|
||||
#endif /* SHM_MEMORY_ALLOC_SCHEME */
|
||||
|
||||
|
||||
|
||||
@ -82,12 +86,16 @@ void Yap_init_global(int max_table_size, int n_workers, int sch_loop, int delay_
|
||||
INIT_PAGES(GLOBAL_PAGES_tg_ans_fr, struct table_subgoal_answer_frame);
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
#ifdef TABLING
|
||||
#ifdef GLOBAL_TRIE
|
||||
INIT_PAGES(GLOBAL_PAGES_gt_node, struct global_trie_node);
|
||||
INIT_PAGES(GLOBAL_PAGES_gt_hash, struct global_trie_hash);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
INIT_PAGES(GLOBAL_PAGES_tab_ent, struct table_entry);
|
||||
INIT_PAGES(GLOBAL_PAGES_sg_fr, struct subgoal_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_sg_hash, struct subgoal_hash);
|
||||
INIT_PAGES(GLOBAL_PAGES_ans_hash, struct answer_hash);
|
||||
INIT_PAGES(GLOBAL_PAGES_sg_hash, struct subgoal_trie_hash);
|
||||
INIT_PAGES(GLOBAL_PAGES_ans_hash, struct answer_trie_hash);
|
||||
INIT_PAGES(GLOBAL_PAGES_dep_fr, struct dependency_frame);
|
||||
#endif /* TABLING */
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
@ -141,6 +149,9 @@ void Yap_init_global(int max_table_size, int n_workers, int sch_loop, int delay_
|
||||
#ifdef TABLING
|
||||
/* global data related to tabling */
|
||||
GLOBAL_root_tab_ent = NULL;
|
||||
#ifdef GLOBAL_TRIE
|
||||
new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#ifdef LIMIT_TABLING
|
||||
GLOBAL_first_sg_fr = NULL;
|
||||
GLOBAL_last_sg_fr = NULL;
|
||||
|
@ -48,8 +48,6 @@ extern int Yap_page_size;
|
||||
#define PAGE_HEADER(STR) (pg_hd_ptr)((unsigned long int)STR - (unsigned long int)STR % Yap_page_size)
|
||||
#define STRUCT_NEXT(STR) ((STR)->next)
|
||||
|
||||
|
||||
|
||||
#define UPDATE_STATS(STAT, VALUE) STAT += VALUE
|
||||
|
||||
#ifdef MALLOC_MEMORY_ALLOC_SCHEME /* ---------------------------------------------------------------- */
|
||||
@ -148,7 +146,7 @@ extern int Yap_page_size;
|
||||
if (SgFr_first_answer(sg_fr) && \
|
||||
SgFr_first_answer(sg_fr) != SgFr_answer_trie(sg_fr)) { \
|
||||
SgFr_state(sg_fr) = ready; \
|
||||
free_answer_hash_chain(SgFr_hash_chain(sg_fr)); \
|
||||
free_answer_trie_hash_chain(SgFr_hash_chain(sg_fr)); \
|
||||
SgFr_hash_chain(sg_fr) = NULL; \
|
||||
SgFr_first_answer(sg_fr) = NULL; \
|
||||
SgFr_last_answer(sg_fr) = NULL; \
|
||||
@ -384,51 +382,55 @@ extern int Yap_page_size;
|
||||
}
|
||||
#define FREE_HASH_BUCKETS(BUCKET_PTR) FREE_BLOCK(BUCKET_PTR)
|
||||
|
||||
#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_or_fr, struct or_frame)
|
||||
#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_or_fr, struct or_frame)
|
||||
|
||||
#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_qg_sol_fr, struct query_goal_solution_frame)
|
||||
#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_qg_sol_fr, struct query_goal_solution_frame)
|
||||
|
||||
#define ALLOC_OR_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_or_fr, struct or_frame)
|
||||
#define FREE_OR_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_or_fr, struct or_frame)
|
||||
#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_qg_ans_fr, struct query_goal_answer_frame)
|
||||
#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_qg_ans_fr, struct query_goal_answer_frame)
|
||||
|
||||
#define ALLOC_QG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_qg_sol_fr, struct query_goal_solution_frame)
|
||||
#define FREE_QG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_qg_sol_fr, struct query_goal_solution_frame)
|
||||
#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_tg_sol_fr, struct table_subgoal_solution_frame)
|
||||
#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_tg_sol_fr, struct table_subgoal_solution_frame)
|
||||
|
||||
#define ALLOC_QG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_qg_ans_fr, struct query_goal_answer_frame)
|
||||
#define FREE_QG_ANSWER_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_qg_ans_fr, struct query_goal_answer_frame)
|
||||
#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_tg_ans_fr, struct table_subgoal_answer_frame)
|
||||
#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_tg_ans_fr, struct table_subgoal_answer_frame)
|
||||
|
||||
#define ALLOC_TG_SOLUTION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_tg_sol_fr, struct table_subgoal_solution_frame)
|
||||
#define FREE_TG_SOLUTION_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_tg_sol_fr, struct table_subgoal_solution_frame)
|
||||
#define ALLOC_TABLE_ENTRY(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_tab_ent, struct table_entry)
|
||||
#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, GLOBAL_PAGES_tab_ent, struct table_entry)
|
||||
|
||||
#define ALLOC_TG_ANSWER_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_tg_ans_fr, struct table_subgoal_answer_frame)
|
||||
#define FREE_TG_ANSWER_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_tg_ans_fr, struct table_subgoal_answer_frame)
|
||||
#define ALLOC_GLOBAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_gt_node, struct global_trie_node)
|
||||
#define FREE_GLOBAL_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_PAGES_gt_node, struct global_trie_node)
|
||||
|
||||
#define ALLOC_TABLE_ENTRY(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_tab_ent, struct table_entry)
|
||||
#define FREE_TABLE_ENTRY(STR) FREE_STRUCT(STR, GLOBAL_PAGES_tab_ent, struct table_entry)
|
||||
#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_sg_node, struct subgoal_trie_node)
|
||||
#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_PAGES_sg_node, struct subgoal_trie_node)
|
||||
|
||||
#define ALLOC_SUBGOAL_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_sg_node, struct subgoal_trie_node)
|
||||
#define FREE_SUBGOAL_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_PAGES_sg_node, struct subgoal_trie_node)
|
||||
|
||||
#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_sg_fr, struct subgoal_frame)
|
||||
#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_sg_fr, struct subgoal_frame)
|
||||
#define ALLOC_SUBGOAL_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_sg_fr, struct subgoal_frame)
|
||||
#define FREE_SUBGOAL_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_sg_fr, struct subgoal_frame)
|
||||
|
||||
#ifdef YAPOR
|
||||
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_NEXT_FREE_STRUCT(STR, GLOBAL_PAGES_ans_node, struct answer_trie_node)
|
||||
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_NEXT_FREE_STRUCT(STR, GLOBAL_PAGES_ans_node, struct answer_trie_node)
|
||||
#else /* TABLING */
|
||||
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_ans_node, struct answer_trie_node)
|
||||
#define ALLOC_ANSWER_TRIE_NODE(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_ans_node, struct answer_trie_node)
|
||||
#endif /* YAPOR - TABLING */
|
||||
#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_PAGES_ans_node, struct answer_trie_node)
|
||||
#define FREE_ANSWER_TRIE_NODE(STR) FREE_STRUCT(STR, GLOBAL_PAGES_ans_node, struct answer_trie_node)
|
||||
|
||||
#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_dep_fr, struct dependency_frame)
|
||||
#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_dep_fr, struct dependency_frame)
|
||||
#define ALLOC_DEPENDENCY_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_dep_fr, struct dependency_frame)
|
||||
#define FREE_DEPENDENCY_FRAME(STR) FREE_STRUCT(STR, GLOBAL_PAGES_dep_fr, struct dependency_frame)
|
||||
|
||||
#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_susp_fr, struct suspension_frame)
|
||||
#define FREE_SUSPENSION_FRAME(STR) FREE_BLOCK(SuspFr_global_start(STR)); \
|
||||
FREE_STRUCT(STR, GLOBAL_PAGES_susp_fr, struct suspension_frame)
|
||||
#define ALLOC_SUSPENSION_FRAME(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_susp_fr, struct suspension_frame)
|
||||
#define FREE_SUSPENSION_FRAME(STR) FREE_BLOCK(SuspFr_global_start(STR)); \
|
||||
FREE_STRUCT(STR, GLOBAL_PAGES_susp_fr, struct suspension_frame)
|
||||
|
||||
#define ALLOC_SUBGOAL_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_sg_hash, struct subgoal_hash)
|
||||
#define FREE_SUBGOAL_HASH(STR) FREE_STRUCT(STR, GLOBAL_PAGES_sg_hash, struct subgoal_hash)
|
||||
#define ALLOC_GLOBAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_gt_hash, struct global_trie_hash)
|
||||
#define FREE_GLOBAL_TRIE_HASH(STR) FREE_STRUCT(STR, GLOBAL_PAGES_gt_hash, struct global_trie_hash)
|
||||
|
||||
#define ALLOC_ANSWER_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_ans_hash, struct answer_hash)
|
||||
#define FREE_ANSWER_HASH(STR) FREE_STRUCT(STR, GLOBAL_PAGES_ans_hash, struct answer_hash)
|
||||
#define ALLOC_SUBGOAL_TRIE_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_sg_hash, struct subgoal_trie_hash)
|
||||
#define FREE_SUBGOAL_TRIE_HASH(STR) FREE_STRUCT(STR, GLOBAL_PAGES_sg_hash, struct subgoal_trie_hash)
|
||||
|
||||
#define ALLOC_ANSWER_TRIE_HASH(STR) ALLOC_STRUCT(STR, GLOBAL_PAGES_ans_hash, struct answer_trie_hash)
|
||||
#define FREE_ANSWER_TRIE_HASH(STR) FREE_STRUCT(STR, GLOBAL_PAGES_ans_hash, struct answer_trie_hash)
|
||||
|
||||
|
||||
|
||||
|
@ -72,6 +72,9 @@ static Int p_abolish_all_tables(void);
|
||||
static Int p_show_tabled_predicates(void);
|
||||
static Int p_show_table(void);
|
||||
static Int p_show_all_tables(void);
|
||||
#ifdef GLOBAL_TRIE
|
||||
static Int p_show_global_trie(void);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
static Int p_table_statistics(void);
|
||||
static Int p_tabling_statistics(void);
|
||||
#endif /* TABLING */
|
||||
@ -100,9 +103,13 @@ static void shm_table_entries(long *pages_in_use, long *bytes_in_use);
|
||||
static void shm_subgoal_frames(long *pages_in_use, long *bytes_in_use);
|
||||
static void shm_subgoal_trie_nodes(long *pages_in_use, long *bytes_in_use);
|
||||
static void shm_answer_trie_nodes(long *pages_in_use, long *bytes_in_use);
|
||||
static void shm_subgoal_hashes(long *pages_in_use, long *bytes_in_use);
|
||||
static void shm_answer_hashes(long *pages_in_use, long *bytes_in_use);
|
||||
static void shm_subgoal_trie_hashes(long *pages_in_use, long *bytes_in_use);
|
||||
static void shm_answer_trie_hashes(long *pages_in_use, long *bytes_in_use);
|
||||
static void shm_dependency_frames(long *pages_in_use, long *bytes_in_use);
|
||||
#ifdef GLOBAL_TRIE
|
||||
static void shm_global_trie_nodes(long *pages_in_use, long *bytes_in_use);
|
||||
static void shm_global_trie_hashes(long *pages_in_use, long *bytes_in_use);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#endif /* TABLING */
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
static void shm_suspension_frames(long *pages_in_use, long *bytes_in_use);
|
||||
@ -137,6 +144,9 @@ void Yap_init_optyap_preds(void) {
|
||||
Yap_InitCPred("show_tabled_predicates", 0, p_show_tabled_predicates, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$c_show_table", 2, p_show_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("show_all_tables", 0, p_show_all_tables, SafePredFlag|SyncPredFlag);
|
||||
#ifdef GLOBAL_TRIE
|
||||
Yap_InitCPred("show_global_trie", 0, p_show_global_trie, SafePredFlag|SyncPredFlag);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
Yap_InitCPred("$c_table_statistics", 2, p_table_statistics, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("tabling_statistics", 0, p_tabling_statistics, SafePredFlag|SyncPredFlag);
|
||||
#endif /* TABLING */
|
||||
@ -499,27 +509,23 @@ Int p_or_statistics(void) {
|
||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||
long pages_in_use = 0, bytes_in_use = 0;
|
||||
|
||||
fprintf(Yap_stdout, "\n");
|
||||
shm_or_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_query_goal_solution_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_query_goal_answer_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_pages(pages_in_use, bytes_in_use);
|
||||
fprintf(Yap_stdout, "\n");
|
||||
#else
|
||||
long bytes_in_use = 0;
|
||||
|
||||
fprintf(Yap_stdout, "\n");
|
||||
fprintf(Yap_stdout, "%s or frames: %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Or-frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_or_fr) == 1 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_or_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_or_fr) * sizeof(struct or_frame);
|
||||
fprintf(Yap_stdout, "%s query goal solution frames: %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Query goal solution frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_qg_sol_fr) == 0 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_qg_sol_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_qg_sol_fr) * sizeof(struct query_goal_solution_frame);
|
||||
fprintf(Yap_stdout, "%s query goal answer frames: %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Query goal answer frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_qg_ans_fr) == 0 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_qg_ans_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
|
||||
fprintf(Yap_stdout, "\n total memory in use: %10ld bytes\n", bytes_in_use);
|
||||
fprintf(Yap_stdout, "\n");
|
||||
fprintf(Yap_stdout, " Total memory in use: %10ld bytes\n", bytes_in_use);
|
||||
#endif /* MEMORY_ALLOC_SCHEME */
|
||||
return (TRUE);
|
||||
}
|
||||
@ -559,7 +565,6 @@ Int p_table(void) {
|
||||
Atom at;
|
||||
int arity;
|
||||
tab_ent_ptr tab_ent;
|
||||
sg_node_ptr sg_node;
|
||||
|
||||
mod = Deref(ARG1);
|
||||
t = Deref(ARG2);
|
||||
@ -578,8 +583,7 @@ Int p_table(void) {
|
||||
if (pe->cs.p_code.FirstClause)
|
||||
return (FALSE); /* predicate already compiled */
|
||||
pe->PredFlags |= TabledPredFlag;
|
||||
new_subgoal_trie_node(sg_node, 0, NULL, NULL, NULL);
|
||||
new_table_entry(tab_ent, pe, at, arity, sg_node);
|
||||
new_table_entry(tab_ent, pe, at, arity);
|
||||
if (IsMode_Local(yap_flags[TABLING_MODE_FLAG]))
|
||||
SetMode_Local(TabEnt_mode(tab_ent));
|
||||
if (IsMode_LoadAnswers(yap_flags[TABLING_MODE_FLAG]))
|
||||
@ -680,11 +684,15 @@ Int p_abolish_table(void) {
|
||||
return (FALSE);
|
||||
hash = TabEnt_hash_chain(tab_ent);
|
||||
TabEnt_hash_chain(tab_ent) = NULL;
|
||||
free_subgoal_hash_chain(hash);
|
||||
free_subgoal_trie_hash_chain(hash);
|
||||
sg_node = TrNode_child(TabEnt_subgoal_trie(tab_ent));
|
||||
if (sg_node) {
|
||||
TrNode_child(TabEnt_subgoal_trie(tab_ent)) = NULL;
|
||||
#ifdef GLOBAL_TRIE
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), TRAVERSE_POSITION_FIRST);
|
||||
#else
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), 0, TRAVERSE_POSITION_FIRST);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
@ -700,11 +708,15 @@ Int p_abolish_all_tables(void) {
|
||||
while(tab_ent) {
|
||||
hash = TabEnt_hash_chain(tab_ent);
|
||||
TabEnt_hash_chain(tab_ent) = NULL;
|
||||
free_subgoal_hash_chain(hash);
|
||||
free_subgoal_trie_hash_chain(hash);
|
||||
sg_node = TrNode_child(TabEnt_subgoal_trie(tab_ent));
|
||||
if (sg_node) {
|
||||
TrNode_child(TabEnt_subgoal_trie(tab_ent)) = NULL;
|
||||
#ifdef GLOBAL_TRIE
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), TRAVERSE_POSITION_FIRST);
|
||||
#else
|
||||
free_subgoal_trie_branch(sg_node, TabEnt_arity(tab_ent), 0, TRAVERSE_POSITION_FIRST);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
}
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
@ -742,8 +754,7 @@ Int p_show_table(void) {
|
||||
tab_ent = RepPredProp(PredPropByFunc(FunctorOfTerm(t), mod))->TableOfPred;
|
||||
else
|
||||
return (FALSE);
|
||||
fprintf(Yap_stdout, "Table structure for predicate '%s/%d'\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
||||
traverse_table(tab_ent, TRUE);
|
||||
show_table(tab_ent, SHOW_MODE_STRUCTURE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -754,14 +765,22 @@ Int p_show_all_tables(void) {
|
||||
|
||||
tab_ent = GLOBAL_root_tab_ent;
|
||||
while(tab_ent) {
|
||||
fprintf(Yap_stdout, "Table structure for predicate '%s/%d'\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
||||
traverse_table(tab_ent, TRUE);
|
||||
show_table(tab_ent, SHOW_MODE_STRUCTURE);
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
#ifdef GLOBAL_TRIE
|
||||
static
|
||||
Int p_show_global_trie(void) {
|
||||
show_global_trie();
|
||||
return (TRUE);
|
||||
}
|
||||
#endif /* GLOBAL_TRIE */
|
||||
|
||||
|
||||
static
|
||||
Int p_table_statistics(void) {
|
||||
Term mod, t;
|
||||
@ -775,9 +794,7 @@ Int p_table_statistics(void) {
|
||||
tab_ent = RepPredProp(PredPropByFunc(FunctorOfTerm(t), mod))->TableOfPred;
|
||||
else
|
||||
return (FALSE);
|
||||
fprintf(Yap_stdout, "Table statistics for predicate '%s/%d'", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
||||
traverse_table(tab_ent, FALSE);
|
||||
table_stats();
|
||||
show_table(tab_ent, SHOW_MODE_STATISTICS);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -787,37 +804,47 @@ Int p_tabling_statistics(void) {
|
||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||
long pages_in_use = 0, bytes_in_use = 0;
|
||||
|
||||
fprintf(Yap_stdout, "\n");
|
||||
shm_table_entries(&pages_in_use, &bytes_in_use);
|
||||
shm_subgoal_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_subgoal_trie_nodes(&pages_in_use, &bytes_in_use);
|
||||
shm_answer_trie_nodes(&pages_in_use, &bytes_in_use);
|
||||
shm_subgoal_hashes(&pages_in_use, &bytes_in_use);
|
||||
shm_answer_hashes(&pages_in_use, &bytes_in_use);
|
||||
#ifdef GLOBAL_TRIE
|
||||
shm_global_trie_nodes(&pages_in_use, &bytes_in_use);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
shm_subgoal_trie_hashes(&pages_in_use, &bytes_in_use);
|
||||
shm_answer_trie_hashes(&pages_in_use, &bytes_in_use);
|
||||
#ifdef GLOBAL_TRIE
|
||||
shm_global_trie_hashes(&pages_in_use, &bytes_in_use);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
shm_dependency_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_pages(pages_in_use, bytes_in_use);
|
||||
fprintf(Yap_stdout, "\n");
|
||||
#else
|
||||
long bytes_in_use = 0;
|
||||
|
||||
fprintf(Yap_stdout, "\n");
|
||||
fprintf(Yap_stdout, " table entries: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_tab_ent));
|
||||
fprintf(Yap_stdout, " Table entries: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_tab_ent));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_tab_ent) * sizeof(struct table_entry);
|
||||
fprintf(Yap_stdout, " subgoal frames: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_fr));
|
||||
fprintf(Yap_stdout, " Subgoal frames: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_fr) * sizeof(struct subgoal_frame);
|
||||
fprintf(Yap_stdout, " subgoal trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_node));
|
||||
fprintf(Yap_stdout, " Subgoal trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_node));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_node) * sizeof(struct subgoal_trie_node);
|
||||
fprintf(Yap_stdout, " answer trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_node));
|
||||
fprintf(Yap_stdout, " Answer trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_node));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_node) * sizeof(struct answer_trie_node);
|
||||
fprintf(Yap_stdout, " subgoal hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_hash) * sizeof(struct subgoal_hash);
|
||||
fprintf(Yap_stdout, " answer hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_hash);
|
||||
fprintf(Yap_stdout, "%s dependency frames: %10ld structs in use\n",
|
||||
#ifdef GLOBAL_TRIE
|
||||
fprintf(Yap_stderr, " Global trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_gt_node));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_gt_node) * sizeof(struct global_trie_node);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
fprintf(Yap_stdout, " Subgoal trie hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_hash) * sizeof(struct subgoal_trie_hash);
|
||||
fprintf(Yap_stdout, " Answer trie hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_trie_hash);
|
||||
#ifdef GLOBAL_TRIE
|
||||
fprintf(Yap_stderr, " Global trie hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_gt_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_gt_hash) * sizeof(struct global_trie_hash);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
fprintf(Yap_stdout, "%s Dependency frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_dep_fr) == 1 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_dep_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_dep_fr) * sizeof(struct dependency_frame);
|
||||
fprintf(Yap_stdout, "\n total memory in use: %10ld bytes\n", bytes_in_use);
|
||||
fprintf(Yap_stdout, "\n");
|
||||
fprintf(Yap_stdout, " Total memory in use: %10ld bytes\n", bytes_in_use);
|
||||
#endif /* MEMORY_ALLOC_SCHEME */
|
||||
return (TRUE);
|
||||
}
|
||||
@ -830,7 +857,6 @@ int p_opt_statistics(void) {
|
||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||
long pages_in_use = 0, bytes_in_use = 0;
|
||||
|
||||
fprintf(Yap_stdout, "\n");
|
||||
shm_or_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_query_goal_solution_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_query_goal_answer_frames(&pages_in_use, &bytes_in_use);
|
||||
@ -842,53 +868,64 @@ int p_opt_statistics(void) {
|
||||
shm_subgoal_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_subgoal_trie_nodes(&pages_in_use, &bytes_in_use);
|
||||
shm_answer_trie_nodes(&pages_in_use, &bytes_in_use);
|
||||
shm_subgoal_hashes(&pages_in_use, &bytes_in_use);
|
||||
shm_answer_hashes(&pages_in_use, &bytes_in_use);
|
||||
#ifdef GLOBAL_TRIE
|
||||
shm_global_trie_nodes(&pages_in_use, &bytes_in_use);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
shm_subgoal_trie_hashes(&pages_in_use, &bytes_in_use);
|
||||
shm_answer_trie_hashes(&pages_in_use, &bytes_in_use);
|
||||
#ifdef GLOBAL_TRIE
|
||||
shm_global_trie_hashes(&pages_in_use, &bytes_in_use);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
shm_dependency_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_show_suspension_frames(&pages_in_use, &bytes_in_use);
|
||||
shm_pages(pages_in_use, bytes_in_use);
|
||||
fprintf(Yap_stdout, "\n");
|
||||
#else
|
||||
long bytes_in_use = 0;
|
||||
|
||||
fprintf(Yap_stdout, "\n");
|
||||
fprintf(Yap_stdout, "%s or frames: %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Or-frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_or_fr) == 1 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_or_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_or_fr) * sizeof(struct or_frame);
|
||||
fprintf(Yap_stdout, "%s query goal solution frames: %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Query goal solution frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_qg_sol_fr) == 1 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_qg_sol_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_qg_sol_fr) * sizeof(struct query_goal_solution_frame);
|
||||
fprintf(Yap_stdout, "%s query goal answer frames: %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Query goal answer frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_qg_ans_fr) == 1 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_qg_ans_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
fprintf(Yap_stdout, "%s table subgoal solution frames: %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Table subgoal solution frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_tg_sol_fr) == 0 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_tg_sol_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame);
|
||||
fprintf(Yap_stdout, "%s table subgoal answer frames: %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Table subgoal answer frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_tg_ans_fr) == 0 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_tg_ans_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
fprintf(Yap_stdout, " table entries: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_tab_ent));
|
||||
fprintf(Yap_stdout, " Table entries: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_tab_ent));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_tab_ent) * sizeof(struct table_entry);
|
||||
fprintf(Yap_stdout, " subgoal frames: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_fr));
|
||||
fprintf(Yap_stdout, " Subgoal frames: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_fr) * sizeof(struct subgoal_frame);
|
||||
fprintf(Yap_stdout, " subgoal trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_node));
|
||||
fprintf(Yap_stdout, " Subgoal trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_node));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_node) * sizeof(struct subgoal_trie_node);
|
||||
fprintf(Yap_stdout, " answer trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_node));
|
||||
fprintf(Yap_stdout, " Answer trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_node));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_node) * sizeof(struct answer_trie_node);
|
||||
fprintf(Yap_stdout, " subgoal hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_hash) * sizeof(struct subgoal_hash);
|
||||
fprintf(Yap_stdout, " answer hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_hash);
|
||||
fprintf(Yap_stdout, "%s dependency frames: %10ld structs in use\n",
|
||||
#ifdef GLOBAL_TRIE
|
||||
fprintf(Yap_stderr, " Global trie nodes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_gt_node));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_gt_node) * sizeof(struct global_trie_node);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
fprintf(Yap_stdout, " Subgoal trie hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_sg_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_hash) * sizeof(struct subgoal_trie_hash);
|
||||
fprintf(Yap_stdout, " Answer trie hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_trie_hash);
|
||||
#ifdef GLOBAL_TRIE
|
||||
fprintf(Yap_stderr, " Global trie hashes: %10ld structs in use\n", Pg_str_in_use(GLOBAL_PAGES_gt_hash));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_gt_hash) * sizeof(struct global_trie_hash);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
fprintf(Yap_stdout, "%s Dependency frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_dep_fr) == 1 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_dep_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_dep_fr) * sizeof(struct dependency_frame);
|
||||
fprintf(Yap_stdout, "%s suspension frames: %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Suspension frames: %10ld structs in use\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_susp_fr) == 0 ? " ": "*", Pg_str_in_use(GLOBAL_PAGES_susp_fr));
|
||||
bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_susp_fr) * sizeof(struct suspension_frame);
|
||||
fprintf(Yap_stdout, "\n total memory in use: %10ld bytes\n", bytes_in_use);
|
||||
fprintf(Yap_stdout, "\n");
|
||||
fprintf(Yap_stdout, " Total memory in use: %10ld bytes\n", bytes_in_use);
|
||||
#endif /* MEMORY_ALLOC_SCHEME */
|
||||
return (TRUE);
|
||||
}
|
||||
@ -932,11 +969,11 @@ void shm_pages(long pages_in_use, long bytes_in_use) {
|
||||
cont++;
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "\n%s total memory in use: %8ld pages %10ld bytes\n",
|
||||
fprintf(Yap_stdout, "%s Total memory in use: %8ld pages %10ld bytes\n",
|
||||
Pg_str_in_use(GLOBAL_PAGES_void) == pages_in_use &&
|
||||
Pg_pg_alloc(GLOBAL_PAGES_void) - pages_in_use == cont ? " ": "*",
|
||||
Pg_str_in_use(GLOBAL_PAGES_void), bytes_in_use);
|
||||
fprintf(Yap_stdout, " total memory: %8ld pages %10ld bytes\n",
|
||||
fprintf(Yap_stdout, " Total memory allocated: %8ld pages %10ld bytes\n",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_void), Pg_pg_alloc(GLOBAL_PAGES_void) * Yap_page_size);
|
||||
return;
|
||||
}
|
||||
@ -958,7 +995,7 @@ void shm_or_frames(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s or frames: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Or-frames: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_or_fr) == cont &&
|
||||
Pg_str_in_use(GLOBAL_PAGES_or_fr) == 1 ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_or_fr), Pg_str_in_use(GLOBAL_PAGES_or_fr));
|
||||
@ -983,7 +1020,7 @@ void shm_query_goal_solution_frames(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s query goal solution frames: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Query goal solution frames: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_qg_sol_fr) == cont &&
|
||||
Pg_str_in_use(GLOBAL_PAGES_qg_sol_fr) == 0 ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_qg_sol_fr), Pg_str_in_use(GLOBAL_PAGES_qg_sol_fr));
|
||||
@ -1008,7 +1045,7 @@ void shm_query_goal_answer_frames(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s query goal answer frames: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Query goal answer frames: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_qg_ans_fr) == cont &&
|
||||
Pg_str_in_use(GLOBAL_PAGES_qg_ans_fr) == 0 ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_qg_ans_fr), Pg_str_in_use(GLOBAL_PAGES_qg_ans_fr));
|
||||
@ -1035,7 +1072,7 @@ void shm_table_subgoal_solution_frames(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s table subgoal solution frames: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Table subgoal solution frames: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_tg_sol_fr) == cont &&
|
||||
Pg_str_in_use(GLOBAL_PAGES_tg_sol_fr) == 0 ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_tg_sol_fr), Pg_str_in_use(GLOBAL_PAGES_tg_sol_fr));
|
||||
@ -1060,7 +1097,7 @@ void shm_table_subgoal_answer_frames(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s table subgoal answer frames: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Table subgoal answer frames: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_tg_ans_fr) == cont &&
|
||||
Pg_str_in_use(GLOBAL_PAGES_tg_ans_fr) == 0 ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_tg_ans_fr), Pg_str_in_use(GLOBAL_PAGES_tg_ans_fr));
|
||||
@ -1092,7 +1129,7 @@ void shm_table_entries(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s table entries: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Table entries: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_tab_ent) + Pg_str_in_use(GLOBAL_PAGES_tab_ent) == cont ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_tab_ent), Pg_str_in_use(GLOBAL_PAGES_tab_ent));
|
||||
*pages_in_use += Pg_pg_alloc(GLOBAL_PAGES_tab_ent);
|
||||
@ -1123,7 +1160,7 @@ void shm_subgoal_frames(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s subgoal frames: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Subgoal frames: %8ld pages %10ld structs in use\n",
|
||||
#ifdef LIMIT_TABLING
|
||||
Pg_str_in_use(GLOBAL_PAGES_sg_fr) +
|
||||
#endif /* LIMIT_TABLING */
|
||||
@ -1150,7 +1187,7 @@ void shm_subgoal_trie_nodes(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s subgoal trie nodes: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Subgoal trie nodes: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_sg_node) == cont ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_sg_node), Pg_str_in_use(GLOBAL_PAGES_sg_node));
|
||||
*pages_in_use += Pg_pg_alloc(GLOBAL_PAGES_sg_node);
|
||||
@ -1174,7 +1211,7 @@ void shm_answer_trie_nodes(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s answer trie nodes: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Answer trie nodes: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_ans_node) == cont ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_ans_node), Pg_str_in_use(GLOBAL_PAGES_ans_node));
|
||||
*pages_in_use += Pg_pg_alloc(GLOBAL_PAGES_ans_node);
|
||||
@ -1184,7 +1221,7 @@ void shm_answer_trie_nodes(long *pages_in_use, long *bytes_in_use) {
|
||||
|
||||
|
||||
static
|
||||
void shm_subgoal_hashes(long *pages_in_use, long *bytes_in_use) {
|
||||
void shm_subgoal_trie_hashes(long *pages_in_use, long *bytes_in_use) {
|
||||
long cont = 0;
|
||||
pg_hd_ptr pg_hd;
|
||||
sg_hash_ptr aux_ptr;
|
||||
@ -1198,17 +1235,17 @@ void shm_subgoal_hashes(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s subgoal hashes: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Subgoal trie hashes: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_sg_hash) == cont ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_sg_hash), Pg_str_in_use(GLOBAL_PAGES_sg_hash));
|
||||
*pages_in_use += Pg_pg_alloc(GLOBAL_PAGES_sg_hash);
|
||||
*bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_hash) * sizeof(struct subgoal_hash);
|
||||
*bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_sg_hash) * sizeof(struct subgoal_trie_hash);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void shm_answer_hashes(long *pages_in_use, long *bytes_in_use) {
|
||||
void shm_answer_trie_hashes(long *pages_in_use, long *bytes_in_use) {
|
||||
long cont = 0;
|
||||
pg_hd_ptr pg_hd;
|
||||
ans_hash_ptr aux_ptr;
|
||||
@ -1222,11 +1259,11 @@ void shm_answer_hashes(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s answer hashes: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Answer trie hashes: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_ans_hash) == cont ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_ans_hash), Pg_str_in_use(GLOBAL_PAGES_ans_hash));
|
||||
*pages_in_use += Pg_pg_alloc(GLOBAL_PAGES_ans_hash);
|
||||
*bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_hash);
|
||||
*bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_ans_hash) * sizeof(struct answer_trie_hash);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1246,7 +1283,7 @@ void shm_dependency_frames(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s dependency frames: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Dependency frames: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_dep_fr) == cont &&
|
||||
Pg_str_in_use(GLOBAL_PAGES_dep_fr) == 1 ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_dep_fr), Pg_str_in_use(GLOBAL_PAGES_dep_fr));
|
||||
@ -1254,6 +1291,56 @@ void shm_dependency_frames(long *pages_in_use, long *bytes_in_use) {
|
||||
*bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_dep_fr) * sizeof(struct dependency_frame);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef GLOBAL_TRIE
|
||||
static
|
||||
void shm_global_trie_nodes(long *pages_in_use, long *bytes_in_use) {
|
||||
long cont = 0;
|
||||
pg_hd_ptr pg_hd;
|
||||
gt_node_ptr aux_ptr;
|
||||
|
||||
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);
|
||||
}
|
||||
fprintf(Yap_stderr, "%s Global trie nodes: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_gt_node) == cont ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_gt_node), Pg_str_in_use(GLOBAL_PAGES_gt_node));
|
||||
*pages_in_use += Pg_pg_alloc(GLOBAL_PAGES_gt_node);
|
||||
*bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_gt_node) * sizeof(struct global_trie_node);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void shm_global_trie_hashes(long *pages_in_use, long *bytes_in_use) {
|
||||
long cont = 0;
|
||||
pg_hd_ptr pg_hd;
|
||||
gt_hash_ptr aux_ptr;
|
||||
|
||||
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);
|
||||
}
|
||||
fprintf(Yap_stderr, "%s Global trie hashes: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_gt_hash) == cont ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_gt_hash), Pg_str_in_use(GLOBAL_PAGES_gt_hash));
|
||||
*pages_in_use += Pg_pg_alloc(GLOBAL_PAGES_gt_hash);
|
||||
*bytes_in_use += Pg_str_in_use(GLOBAL_PAGES_gt_hash) * sizeof(struct global_trie_hash);
|
||||
return;
|
||||
}
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
@ -1273,7 +1360,7 @@ void shm_suspension_frames(long *pages_in_use, long *bytes_in_use) {
|
||||
}
|
||||
pg_hd = PgHd_next(pg_hd);
|
||||
}
|
||||
fprintf(Yap_stdout, "%s suspension frames: %8ld pages %10ld structs in use\n",
|
||||
fprintf(Yap_stdout, "%s Suspension frames: %8ld pages %10ld structs in use\n",
|
||||
Pg_str_free(GLOBAL_PAGES_susp_fr) == cont &&
|
||||
Pg_str_in_use(GLOBAL_PAGES_susp_fr) == 0 ? " ": "*",
|
||||
Pg_pg_alloc(GLOBAL_PAGES_susp_fr), Pg_str_in_use(GLOBAL_PAGES_susp_fr));
|
||||
|
@ -65,13 +65,22 @@ void finish_yapor(void);
|
||||
#ifdef TABLING
|
||||
sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr);
|
||||
ans_node_ptr answer_search(sg_fr_ptr sg_fr, CELL *subs_ptr);
|
||||
void load_answer_trie(ans_node_ptr ans_node, CELL *subs_ptr);
|
||||
void load_answer(ans_node_ptr ans_node, CELL *subs_ptr);
|
||||
#ifdef GLOBAL_TRIE
|
||||
CELL *load_substitution_variable(gt_node_ptr current_node, CELL *aux_stack_ptr);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
void private_completion(sg_fr_ptr sg_fr);
|
||||
#ifdef GLOBAL_TRIE
|
||||
void free_subgoal_trie_branch(sg_node_ptr node, int nodes_left, int position);
|
||||
#else
|
||||
void free_subgoal_trie_branch(sg_node_ptr node, int nodes_left, int nodes_extra, int position);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
void free_answer_trie_branch(ans_node_ptr node, int position);
|
||||
void update_answer_trie(sg_fr_ptr sg_fr);
|
||||
void traverse_table(tab_ent_ptr tab_ent, int show_table);
|
||||
void table_stats(void);
|
||||
void show_table(tab_ent_ptr tab_ent, int show_mode);
|
||||
#ifdef GLOBAL_TRIE
|
||||
void show_global_trie(void);
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
@ -41,20 +41,22 @@ typedef struct page_header {
|
||||
** ---------------------- */
|
||||
|
||||
struct pages {
|
||||
#ifdef SHM_MEMORY_ALLOC_SCHEME
|
||||
#ifdef YAPOR
|
||||
lockvar lock;
|
||||
#endif /* YAPOR */
|
||||
volatile long pages_allocated;
|
||||
volatile long structs_in_use;
|
||||
int structs_per_page;
|
||||
struct page_header *first_free_page;
|
||||
volatile long pages_allocated;
|
||||
#endif /* SHM_MEMORY_ALLOC_SCHEME */
|
||||
volatile long structs_in_use;
|
||||
};
|
||||
|
||||
#define Pg_lock(X) ((X).lock)
|
||||
#define Pg_pg_alloc(X) ((X).pages_allocated)
|
||||
#define Pg_str_in_use(X) ((X).structs_in_use)
|
||||
#define Pg_str_per_pg(X) ((X).structs_per_page)
|
||||
#define Pg_free_pg(X) ((X).first_free_page)
|
||||
#define Pg_pg_alloc(X) ((X).pages_allocated)
|
||||
#define Pg_str_in_use(X) ((X).structs_in_use)
|
||||
#define Pg_str_free(X) (Pg_pg_alloc(X) * Pg_str_per_pg(X) - Pg_str_in_use(X))
|
||||
|
||||
|
||||
@ -78,12 +80,16 @@ struct global_pages {
|
||||
struct pages table_subgoal_answer_frame_pages;
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
#ifdef TABLING
|
||||
#ifdef GLOBAL_TRIE
|
||||
struct pages global_trie_node_pages;
|
||||
struct pages global_trie_hash_pages;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
struct pages table_entry_pages;
|
||||
struct pages subgoal_frame_pages;
|
||||
struct pages subgoal_trie_node_pages;
|
||||
struct pages answer_trie_node_pages;
|
||||
struct pages subgoal_hash_pages;
|
||||
struct pages answer_hash_pages;
|
||||
struct pages subgoal_trie_hash_pages;
|
||||
struct pages answer_trie_hash_pages;
|
||||
struct pages dependency_frame_pages;
|
||||
#endif /* TABLING */
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
@ -166,6 +172,9 @@ struct global_data{
|
||||
#ifdef TABLING
|
||||
/* global data related to tabling */
|
||||
struct table_entry *root_table_entry;
|
||||
#ifdef GLOBAL_TRIE
|
||||
struct global_trie_node *root_global_trie;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#ifdef LIMIT_TABLING
|
||||
struct subgoal_frame *first_subgoal_frame;
|
||||
struct subgoal_frame *last_subgoal_frame;
|
||||
@ -189,12 +198,14 @@ struct global_data{
|
||||
#define GLOBAL_PAGES_qg_ans_fr (GLOBAL.pages.query_goal_answer_frame_pages)
|
||||
#define GLOBAL_PAGES_tg_sol_fr (GLOBAL.pages.table_subgoal_solution_frame_pages)
|
||||
#define GLOBAL_PAGES_tg_ans_fr (GLOBAL.pages.table_subgoal_answer_frame_pages)
|
||||
#define GLOBAL_PAGES_gt_node (GLOBAL.pages.global_trie_node_pages)
|
||||
#define GLOBAL_PAGES_gt_hash (GLOBAL.pages.global_trie_hash_pages)
|
||||
#define GLOBAL_PAGES_tab_ent (GLOBAL.pages.table_entry_pages)
|
||||
#define GLOBAL_PAGES_sg_fr (GLOBAL.pages.subgoal_frame_pages)
|
||||
#define GLOBAL_PAGES_sg_node (GLOBAL.pages.subgoal_trie_node_pages)
|
||||
#define GLOBAL_PAGES_ans_node (GLOBAL.pages.answer_trie_node_pages)
|
||||
#define GLOBAL_PAGES_sg_hash (GLOBAL.pages.subgoal_hash_pages)
|
||||
#define GLOBAL_PAGES_ans_hash (GLOBAL.pages.answer_hash_pages)
|
||||
#define GLOBAL_PAGES_sg_hash (GLOBAL.pages.subgoal_trie_hash_pages)
|
||||
#define GLOBAL_PAGES_ans_hash (GLOBAL.pages.answer_trie_hash_pages)
|
||||
#define GLOBAL_PAGES_dep_fr (GLOBAL.pages.dependency_frame_pages)
|
||||
#define GLOBAL_PAGES_susp_fr (GLOBAL.pages.suspension_frame_pages)
|
||||
#define SCHEDULER_LOOP (GLOBAL.scheduler_loop)
|
||||
@ -231,6 +242,7 @@ struct global_data{
|
||||
#define PARALLEL_EXECUTION_MODE (GLOBAL.parallel_execution_mode)
|
||||
#define GLOBAL_answers (GLOBAL.answers)
|
||||
#define GLOBAL_root_tab_ent (GLOBAL.root_table_entry)
|
||||
#define GLOBAL_root_gt (GLOBAL.root_global_trie)
|
||||
#define GLOBAL_first_sg_fr (GLOBAL.first_subgoal_frame)
|
||||
#define GLOBAL_last_sg_fr (GLOBAL.last_subgoal_frame)
|
||||
#define GLOBAL_check_sg_fr (GLOBAL.check_subgoal_frame)
|
||||
|
@ -210,7 +210,7 @@
|
||||
} else { \
|
||||
subs_ptr = (CELL *) (CONS_CP(B) + 1); \
|
||||
} \
|
||||
load_answer_trie(ANSWER, subs_ptr); \
|
||||
load_answer(ANSWER, subs_ptr); \
|
||||
/* procceed */ \
|
||||
YENV = ENV; \
|
||||
GONext(); \
|
||||
@ -317,7 +317,7 @@
|
||||
}
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
load_answer_trie(ans_node, subs_ptr);
|
||||
load_answer(ans_node, subs_ptr);
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
ENDPBOp();
|
||||
@ -347,7 +347,7 @@
|
||||
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
load_answer_trie(ans_node, subs_ptr);
|
||||
load_answer(ans_node, subs_ptr);
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
} else {
|
||||
@ -420,7 +420,7 @@
|
||||
store_generator_node(tab_ent, sg_fr, PREG->u.Otapl.s, TRY_ANSWER);
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
load_answer_trie(ans_node, subs_ptr);
|
||||
load_answer(ans_node, subs_ptr);
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
#endif /* INCOMPLETE_TABLING */
|
||||
@ -479,7 +479,7 @@
|
||||
}
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
load_answer_trie(ans_node, YENV);
|
||||
load_answer(ans_node, YENV);
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
} else {
|
||||
@ -490,7 +490,9 @@
|
||||
PREG = (yamop *) TrNode_child(SgFr_answer_trie(sg_fr));
|
||||
PREFETCH_OP(PREG);
|
||||
*--YENV = 0; /* vars_arity */
|
||||
#ifndef GLOBAL_TRIE
|
||||
*--YENV = 0; /* heap_arity */
|
||||
#endif /* GLOBAL_TRIE */
|
||||
GONext();
|
||||
}
|
||||
}
|
||||
@ -529,7 +531,7 @@
|
||||
store_generator_node(tab_ent, sg_fr, PREG->u.Otapl.s, TRY_ANSWER);
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
load_answer_trie(ans_node, subs_ptr);
|
||||
load_answer(ans_node, subs_ptr);
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
#endif /* INCOMPLETE_TABLING */
|
||||
@ -588,7 +590,7 @@
|
||||
}
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
load_answer_trie(ans_node, YENV);
|
||||
load_answer(ans_node, YENV);
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
} else {
|
||||
@ -599,7 +601,9 @@
|
||||
PREG = (yamop *) TrNode_child(SgFr_answer_trie(sg_fr));
|
||||
PREFETCH_OP(PREG);
|
||||
*--YENV = 0; /* vars_arity */
|
||||
#ifndef GLOBAL_TRIE
|
||||
*--YENV = 0; /* heap_arity */
|
||||
#endif /* GLOBAL_TRIE */
|
||||
GONext();
|
||||
}
|
||||
}
|
||||
@ -638,7 +642,7 @@
|
||||
store_generator_node(tab_ent, sg_fr, PREG->u.Otapl.s, TRY_ANSWER);
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
load_answer_trie(ans_node, subs_ptr);
|
||||
load_answer(ans_node, subs_ptr);
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
#endif /* INCOMPLETE_TABLING */
|
||||
@ -697,7 +701,7 @@
|
||||
}
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
load_answer_trie(ans_node, YENV);
|
||||
load_answer(ans_node, YENV);
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
} else {
|
||||
@ -708,7 +712,9 @@
|
||||
PREG = (yamop *) TrNode_child(SgFr_answer_trie(sg_fr));
|
||||
PREFETCH_OP(PREG);
|
||||
*--YENV = 0; /* vars_arity */
|
||||
#ifndef GLOBAL_TRIE
|
||||
*--YENV = 0; /* heap_arity */
|
||||
#endif /* GLOBAL_TRIE */
|
||||
GONext();
|
||||
}
|
||||
}
|
||||
@ -1685,7 +1691,7 @@
|
||||
}
|
||||
PREG = (yamop *) CPREG;
|
||||
PREFETCH_OP(PREG);
|
||||
load_answer_trie(ans_node, YENV);
|
||||
load_answer(ans_node, YENV);
|
||||
YENV = ENV;
|
||||
GONext();
|
||||
} else {
|
||||
@ -1697,7 +1703,9 @@
|
||||
PREG = (yamop *) TrNode_child(SgFr_answer_trie(sg_fr));
|
||||
PREFETCH_OP(PREG);
|
||||
*--YENV = 0; /* vars_arity */
|
||||
*--YENV = 0; /* heap_arity */
|
||||
#ifndef GLOBAL_TRIE
|
||||
*--YENV = 0; /* heap_arity */
|
||||
#endif /* GLOBAL_TRIE */
|
||||
GONext();
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ STD_PROTO(static inline void unbind_variables, (tr_fr_ptr, tr_fr_ptr));
|
||||
STD_PROTO(static inline void rebind_variables, (tr_fr_ptr, tr_fr_ptr));
|
||||
STD_PROTO(static inline void restore_bindings, (tr_fr_ptr, tr_fr_ptr));
|
||||
STD_PROTO(static inline void abolish_incomplete_subgoals, (choiceptr));
|
||||
STD_PROTO(static inline void free_subgoal_hash_chain, (sg_hash_ptr));
|
||||
STD_PROTO(static inline void free_answer_hash_chain, (ans_hash_ptr));
|
||||
STD_PROTO(static inline void free_subgoal_trie_hash_chain, (sg_hash_ptr));
|
||||
STD_PROTO(static inline void free_answer_trie_hash_chain, (ans_hash_ptr));
|
||||
STD_PROTO(static inline choiceptr freeze_current_cp, (void));
|
||||
STD_PROTO(static inline void resume_frozen_cp, (choiceptr));
|
||||
|
||||
@ -61,6 +61,10 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
** Defines **
|
||||
** ----------------- */
|
||||
|
||||
#define SHOW_MODE_STRUCTURE 0
|
||||
#define SHOW_MODE_STATISTICS 1
|
||||
#define TRAVERSE_TYPE_SUBGOAL 0
|
||||
#define TRAVERSE_TYPE_ANSWER 1
|
||||
#define TRAVERSE_MODE_NORMAL 0
|
||||
#define TRAVERSE_MODE_FLOAT 1
|
||||
#define TRAVERSE_MODE_FLOAT2 2
|
||||
@ -91,9 +95,6 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
#define IS_BATCHED_GEN_CP(CP) (GEN_CP(CP)->cp_dep_fr == NULL)
|
||||
#endif /* DETERMINISTIC_TABLING */
|
||||
|
||||
#define TAG_AS_ANSWER_LEAF_NODE(NODE) TrNode_parent(NODE) = (ans_node_ptr)((unsigned long int)TrNode_parent(NODE) | 0x1)
|
||||
#define UNTAG_ANSWER_LEAF_NODE(NODE) ((ans_node_ptr)((unsigned long int)NODE & ~(0x1)))
|
||||
#define IS_ANSWER_LEAF_NODE(NODE) ((unsigned long int)TrNode_parent(NODE) & 0x1)
|
||||
|
||||
#define STACK_NOT_EMPTY(STACK, STACK_BASE) STACK != STACK_BASE
|
||||
#define STACK_PUSH_UP(ITEM, STACK) *--STACK = (CELL)(ITEM)
|
||||
@ -101,8 +102,8 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
#define STACK_PUSH_DOWN(ITEM, STACK) *STACK++ = (CELL)(ITEM)
|
||||
#define STACK_POP_UP(STACK) *--STACK
|
||||
#ifdef YAPOR
|
||||
#define STACK_CHECK_EXPAND(STACK, STACK_LIMIT, STACK_BASE) \
|
||||
if (STACK_LIMIT >= STACK) { \
|
||||
#define STACK_CHECK_EXPAND(STACK, STACK_LIMIT, STACK_BASE) \
|
||||
if (STACK_LIMIT >= STACK) { \
|
||||
Yap_Error(INTERNAL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)")
|
||||
#else
|
||||
#define STACK_CHECK_EXPAND(STACK, STACK_LIMIT, STACK_BASE) \
|
||||
@ -126,10 +127,30 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
#endif /* YAPOR */
|
||||
|
||||
|
||||
#ifdef GLOBAL_TRIE
|
||||
#define INCREMENT_GLOBAL_TRIE_REFS(NODE) \
|
||||
{ register gt_node_ptr gt_node = NODE; \
|
||||
TrNode_child(gt_node) = (gt_node_ptr) ((unsigned long int) TrNode_child(gt_node) + 1); \
|
||||
}
|
||||
#define DECREMENT_GLOBAL_TRIE_REFS(NODE) \
|
||||
{ register gt_node_ptr gt_node = NODE; \
|
||||
TrNode_child(gt_node) = (gt_node_ptr) ((unsigned long int) TrNode_child(gt_node) - 1); \
|
||||
if (TrNode_child(gt_node) == 0) \
|
||||
free_global_trie_branch(gt_node); \
|
||||
}
|
||||
#else
|
||||
#define INCREMENT_GLOBAL_TRIE_REFS(NODE)
|
||||
#define DECREMENT_GLOBAL_TRIE_REFS(NODE)
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#define TAG_AS_ANSWER_LEAF_NODE(NODE) TrNode_parent(NODE) = (ans_node_ptr)((unsigned long int) TrNode_parent(NODE) | 0x1)
|
||||
#define UNTAG_ANSWER_LEAF_NODE(NODE) ((ans_node_ptr)((unsigned long int) NODE & ~(0x1)))
|
||||
#define IS_ANSWER_LEAF_NODE(NODE) ((unsigned long int) TrNode_parent(NODE) & 0x1)
|
||||
|
||||
|
||||
/* LowTagBits is 3 for 32 bit-machines and 7 for 64 bit-machines */
|
||||
#define NumberOfLowTagBits (LowTagBits == 3 ? 2 : 3)
|
||||
#define MakeTableVarTerm(INDEX) (INDEX << NumberOfLowTagBits)
|
||||
#define VarIndexOfTableTerm(TERM) (TERM >> NumberOfLowTagBits)
|
||||
#define VarIndexOfTableTerm(TERM) (((unsigned int) TERM) >> NumberOfLowTagBits)
|
||||
#define VarIndexOfTerm(TERM) \
|
||||
((((CELL) TERM) - GLOBAL_table_var_enumerator(0)) / sizeof(CELL))
|
||||
#define IsTableVarTerm(TERM) \
|
||||
@ -142,7 +163,8 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
#define CompactPairEndList AbsPair((Term *) (2*(LowTagBits + 1)))
|
||||
#endif /* TRIE_COMPACT_PAIRS */
|
||||
|
||||
#define HASH_TABLE_LOCK(NODE) ((((unsigned long int)NODE) >> 5) & (TABLE_LOCK_BUCKETS - 1))
|
||||
|
||||
#define HASH_TABLE_LOCK(NODE) ((((unsigned long int) NODE) >> 5) & (TABLE_LOCK_BUCKETS - 1))
|
||||
#define LOCK_TABLE(NODE) LOCK(GLOBAL_table_lock(HASH_TABLE_LOCK(NODE)))
|
||||
#define UNLOCK_TABLE(NODE) UNLOCK(GLOBAL_table_lock(HASH_TABLE_LOCK(NODE)))
|
||||
|
||||
@ -264,11 +286,11 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
|
||||
#define new_subgoal_frame(SG_FR, CODE) \
|
||||
{ register ans_node_ptr ans_node; \
|
||||
new_root_answer_trie_node(ans_node); \
|
||||
ALLOC_SUBGOAL_FRAME(SG_FR); \
|
||||
INIT_LOCK(SgFr_lock(SG_FR)); \
|
||||
SgFr_code(SG_FR) = CODE; \
|
||||
SgFr_state(SG_FR) = ready; \
|
||||
new_answer_trie_node(ans_node, 0, 0, NULL, NULL, NULL); \
|
||||
SgFr_hash_chain(SG_FR) = NULL; \
|
||||
SgFr_answer_trie(SG_FR) = ans_node; \
|
||||
SgFr_first_answer(SG_FR) = NULL; \
|
||||
@ -292,66 +314,102 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
|
||||
DepFr_leader_cp(DEP_FR) = NORM_CP(LEADER_CP); \
|
||||
DepFr_cons_cp(DEP_FR) = NORM_CP(CONS_CP); \
|
||||
/* start with TrNode_child(DepFr_last_answer(DEP_FR)) pointing to SgFr_first_answer(SG_FR) */ \
|
||||
DepFr_last_answer(DEP_FR) = (ans_node_ptr)((unsigned long int)(SG_FR) + \
|
||||
(unsigned long int)(&SgFr_first_answer((sg_fr_ptr)DEP_FR)) - \
|
||||
(unsigned long int)(&TrNode_child((ans_node_ptr)DEP_FR))); \
|
||||
DepFr_last_answer(DEP_FR) = (ans_node_ptr) ((unsigned long int) (SG_FR) + \
|
||||
(unsigned long int) (&SgFr_first_answer((sg_fr_ptr)DEP_FR)) - \
|
||||
(unsigned long int) (&TrNode_child((ans_node_ptr)DEP_FR))); \
|
||||
DepFr_next(DEP_FR) = NEXT
|
||||
|
||||
|
||||
#define new_table_entry(TAB_ENT, PRED_ENTRY, ATOM, ARITY, SUBGOAL_TRIE) \
|
||||
ALLOC_TABLE_ENTRY(TAB_ENT); \
|
||||
TabEnt_init_lock_field(TAB_ENT); \
|
||||
TabEnt_pe(TAB_ENT) = PRED_ENTRY; \
|
||||
TabEnt_atom(TAB_ENT) = ATOM; \
|
||||
TabEnt_arity(TAB_ENT) = ARITY; \
|
||||
TabEnt_mode(TAB_ENT) = 0; \
|
||||
TabEnt_subgoal_trie(TAB_ENT) = SUBGOAL_TRIE; \
|
||||
TabEnt_hash_chain(TAB_ENT) = NULL; \
|
||||
TabEnt_next(TAB_ENT) = GLOBAL_root_tab_ent; \
|
||||
GLOBAL_root_tab_ent = TAB_ENT
|
||||
#define new_table_entry(TAB_ENT, PRED_ENTRY, ATOM, ARITY) \
|
||||
{ register sg_node_ptr sg_node; \
|
||||
new_root_subgoal_trie_node(sg_node); \
|
||||
ALLOC_TABLE_ENTRY(TAB_ENT); \
|
||||
TabEnt_init_lock_field(TAB_ENT); \
|
||||
TabEnt_pe(TAB_ENT) = PRED_ENTRY; \
|
||||
TabEnt_atom(TAB_ENT) = ATOM; \
|
||||
TabEnt_arity(TAB_ENT) = ARITY; \
|
||||
TabEnt_mode(TAB_ENT) = 0; \
|
||||
TabEnt_subgoal_trie(TAB_ENT) = sg_node; \
|
||||
TabEnt_hash_chain(TAB_ENT) = NULL; \
|
||||
TabEnt_next(TAB_ENT) = GLOBAL_root_tab_ent; \
|
||||
GLOBAL_root_tab_ent = TAB_ENT; \
|
||||
}
|
||||
|
||||
|
||||
#define new_subgoal_trie_node(NODE, ENTRY, CHILD, PARENT, NEXT) \
|
||||
ALLOC_SUBGOAL_TRIE_NODE(NODE); \
|
||||
TrNode_entry(NODE) = ENTRY; \
|
||||
TrNode_init_lock_field(NODE); \
|
||||
TrNode_child(NODE) = CHILD; \
|
||||
TrNode_parent(NODE) = PARENT; \
|
||||
#define new_global_trie_node(NODE, ENTRY, CHILD, PARENT, NEXT) \
|
||||
ALLOC_GLOBAL_TRIE_NODE(NODE); \
|
||||
TrNode_entry(NODE) = ENTRY; \
|
||||
TrNode_child(NODE) = CHILD; \
|
||||
TrNode_parent(NODE) = PARENT; \
|
||||
TrNode_next(NODE) = NEXT
|
||||
|
||||
#define new_root_subgoal_trie_node(NODE) \
|
||||
ALLOC_SUBGOAL_TRIE_NODE(NODE); \
|
||||
init_subgoal_trie_node(NODE, 0, NULL, NULL, NULL)
|
||||
#define new_subgoal_trie_node(NODE, ENTRY, CHILD, PARENT, NEXT) \
|
||||
INCREMENT_GLOBAL_TRIE_REFS(ENTRY); \
|
||||
ALLOC_SUBGOAL_TRIE_NODE(NODE); \
|
||||
init_subgoal_trie_node(NODE, ENTRY, CHILD, PARENT, NEXT)
|
||||
#define init_subgoal_trie_node(NODE, ENTRY, CHILD, PARENT, NEXT) \
|
||||
TrNode_entry(NODE) = ENTRY; \
|
||||
TrNode_init_lock_field(NODE); \
|
||||
TrNode_child(NODE) = CHILD; \
|
||||
TrNode_parent(NODE) = PARENT; \
|
||||
TrNode_next(NODE) = NEXT
|
||||
|
||||
|
||||
#define new_root_answer_trie_node(NODE) \
|
||||
ALLOC_ANSWER_TRIE_NODE(NODE); \
|
||||
init_answer_trie_node(NODE, 0, 0, NULL, NULL, NULL)
|
||||
#define new_answer_trie_node(NODE, INSTR, ENTRY, CHILD, PARENT, NEXT) \
|
||||
INCREMENT_GLOBAL_TRIE_REFS(ENTRY); \
|
||||
ALLOC_ANSWER_TRIE_NODE(NODE); \
|
||||
init_answer_trie_node(NODE, INSTR, ENTRY, CHILD, PARENT, NEXT)
|
||||
#define init_answer_trie_node(NODE, INSTR, ENTRY, CHILD, PARENT, NEXT) \
|
||||
TrNode_instr(NODE) = INSTR; \
|
||||
TrNode_entry(NODE) = ENTRY; \
|
||||
TrNode_init_lock_field(NODE); \
|
||||
TrNode_child(NODE) = CHILD; \
|
||||
TrNode_parent(NODE) = PARENT; \
|
||||
TrNode_next(NODE) = NEXT
|
||||
|
||||
|
||||
#define new_answer_trie_node(NODE, INSTR, ENTRY, CHILD, PARENT, NEXT) \
|
||||
ALLOC_ANSWER_TRIE_NODE(NODE); \
|
||||
TrNode_instr(NODE) = INSTR; \
|
||||
TrNode_entry(NODE) = ENTRY; \
|
||||
TrNode_init_lock_field(NODE); \
|
||||
TrNode_child(NODE) = CHILD; \
|
||||
TrNode_parent(NODE) = PARENT; \
|
||||
TrNode_next(NODE) = NEXT
|
||||
#define MAX_NODES_PER_TRIE_LEVEL 8
|
||||
#define MAX_NODES_PER_BUCKET (MAX_NODES_PER_TRIE_LEVEL / 2)
|
||||
#define BASE_HASH_BUCKETS 64
|
||||
#define HASH_ENTRY(ENTRY, SEED) ((((unsigned long int) ENTRY) >> NumberOfLowTagBits) & (SEED))
|
||||
#ifdef GLOBAL_TRIE
|
||||
#define GLOBAL_TRIE_HASH_MARK ((Term) MakeTableVarTerm(MAX_TABLE_VARS))
|
||||
#define IS_GLOBAL_TRIE_HASH(NODE) (TrNode_entry(NODE) == GLOBAL_TRIE_HASH_MARK)
|
||||
#define SUBGOAL_TRIE_HASH_MARK (NULL)
|
||||
#else
|
||||
#define SUBGOAL_TRIE_HASH_MARK ((Term) MakeTableVarTerm(MAX_TABLE_VARS))
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#define IS_SUBGOAL_TRIE_HASH(NODE) (TrNode_entry(NODE) == SUBGOAL_TRIE_HASH_MARK)
|
||||
#define ANSWER_TRIE_HASH_MARK 0
|
||||
#define IS_ANSWER_TRIE_HASH(NODE) (TrNode_instr(NODE) == ANSWER_TRIE_HASH_MARK)
|
||||
|
||||
|
||||
#define MAX_NODES_PER_TRIE_LEVEL 8
|
||||
#define MAX_NODES_PER_BUCKET (MAX_NODES_PER_TRIE_LEVEL / 2)
|
||||
#define BASE_HASH_BUCKETS 64
|
||||
#define SUBGOAL_HASH_MARK ((Term) MakeTableVarTerm(MAX_TABLE_VARS))
|
||||
#define ANSWER_HASH_MARK 0
|
||||
#define IS_SUBGOAL_HASH(NODE) (TrNode_entry(NODE) == SUBGOAL_HASH_MARK)
|
||||
#define IS_ANSWER_HASH(NODE) (TrNode_instr(NODE) == ANSWER_HASH_MARK)
|
||||
#define HASH_TERM(TERM, SEED) (((TERM) >> NumberOfLowTagBits) & (SEED))
|
||||
#define new_global_trie_hash(HASH, NUM_NODES) \
|
||||
ALLOC_GLOBAL_TRIE_HASH(HASH); \
|
||||
Hash_mark(HASH) = GLOBAL_TRIE_HASH_MARK; \
|
||||
Hash_num_buckets(HASH) = BASE_HASH_BUCKETS; \
|
||||
ALLOC_HASH_BUCKETS(Hash_buckets(HASH), BASE_HASH_BUCKETS); \
|
||||
Hash_num_nodes(HASH) = NUM_NODES
|
||||
|
||||
|
||||
#define new_subgoal_hash(HASH, NUM_NODES, TAB_ENT) \
|
||||
ALLOC_SUBGOAL_HASH(HASH); \
|
||||
Hash_mark(HASH) = SUBGOAL_HASH_MARK; \
|
||||
#define new_subgoal_trie_hash(HASH, NUM_NODES, TAB_ENT) \
|
||||
ALLOC_SUBGOAL_TRIE_HASH(HASH); \
|
||||
Hash_mark(HASH) = SUBGOAL_TRIE_HASH_MARK; \
|
||||
Hash_num_buckets(HASH) = BASE_HASH_BUCKETS; \
|
||||
ALLOC_HASH_BUCKETS(Hash_buckets(HASH), BASE_HASH_BUCKETS); \
|
||||
Hash_num_nodes(HASH) = NUM_NODES; \
|
||||
SgHash_init_next_field(HASH, TAB_ENT)
|
||||
|
||||
|
||||
#define new_answer_hash(HASH, NUM_NODES, SG_FR) \
|
||||
ALLOC_ANSWER_HASH(HASH); \
|
||||
Hash_mark(HASH) = ANSWER_HASH_MARK; \
|
||||
#define new_answer_trie_hash(HASH, NUM_NODES, SG_FR) \
|
||||
ALLOC_ANSWER_TRIE_HASH(HASH); \
|
||||
Hash_mark(HASH) = ANSWER_TRIE_HASH_MARK; \
|
||||
Hash_num_buckets(HASH) = BASE_HASH_BUCKETS; \
|
||||
ALLOC_HASH_BUCKETS(Hash_buckets(HASH), BASE_HASH_BUCKETS); \
|
||||
Hash_num_nodes(HASH) = NUM_NODES; \
|
||||
@ -621,7 +679,7 @@ void abolish_incomplete_subgoals(choiceptr prune_cp) {
|
||||
#else
|
||||
ans_node_ptr node;
|
||||
SgFr_state(sg_fr) = ready;
|
||||
free_answer_hash_chain(SgFr_hash_chain(sg_fr));
|
||||
free_answer_trie_hash_chain(SgFr_hash_chain(sg_fr));
|
||||
SgFr_hash_chain(sg_fr) = NULL;
|
||||
SgFr_first_answer(sg_fr) = NULL;
|
||||
SgFr_last_answer(sg_fr) = NULL;
|
||||
@ -641,7 +699,7 @@ void abolish_incomplete_subgoals(choiceptr prune_cp) {
|
||||
|
||||
|
||||
static inline
|
||||
void free_subgoal_hash_chain(sg_hash_ptr hash) {
|
||||
void free_subgoal_trie_hash_chain(sg_hash_ptr hash) {
|
||||
while (hash) {
|
||||
sg_node_ptr chain_node, *bucket, *last_bucket;
|
||||
sg_hash_ptr next_hash;
|
||||
@ -662,7 +720,7 @@ void free_subgoal_hash_chain(sg_hash_ptr hash) {
|
||||
}
|
||||
next_hash = Hash_next(hash);
|
||||
FREE_HASH_BUCKETS(Hash_buckets(hash));
|
||||
FREE_SUBGOAL_HASH(hash);
|
||||
FREE_SUBGOAL_TRIE_HASH(hash);
|
||||
hash = next_hash;
|
||||
}
|
||||
return;
|
||||
@ -670,7 +728,7 @@ void free_subgoal_hash_chain(sg_hash_ptr hash) {
|
||||
|
||||
|
||||
static inline
|
||||
void free_answer_hash_chain(ans_hash_ptr hash) {
|
||||
void free_answer_trie_hash_chain(ans_hash_ptr hash) {
|
||||
while (hash) {
|
||||
ans_node_ptr chain_node, *bucket, *last_bucket;
|
||||
ans_hash_ptr next_hash;
|
||||
@ -691,7 +749,7 @@ void free_answer_hash_chain(ans_hash_ptr hash) {
|
||||
}
|
||||
next_hash = Hash_next(hash);
|
||||
FREE_HASH_BUCKETS(Hash_buckets(hash));
|
||||
FREE_ANSWER_HASH(hash);
|
||||
FREE_ANSWER_TRIE_HASH(hash);
|
||||
hash = next_hash;
|
||||
}
|
||||
return;
|
||||
|
@ -62,7 +62,7 @@ typedef struct table_entry {
|
||||
int pred_arity;
|
||||
int mode_flags;
|
||||
struct subgoal_trie_node *subgoal_trie;
|
||||
struct subgoal_hash *hash_chain;
|
||||
struct subgoal_trie_hash *hash_chain;
|
||||
struct table_entry *next;
|
||||
} *tab_ent_ptr;
|
||||
|
||||
@ -77,12 +77,25 @@ typedef struct table_entry {
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------- **
|
||||
** Structs subgoal_trie_node and answer_trie_node **
|
||||
** -------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- **
|
||||
** Structs global_trie_node, subgoal_trie_node and answer_trie_node **
|
||||
** -------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef GLOBAL_TRIE
|
||||
typedef struct global_trie_node {
|
||||
Term entry;
|
||||
struct global_trie_node *parent;
|
||||
struct global_trie_node *child;
|
||||
struct global_trie_node *next;
|
||||
} *gt_node_ptr;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
|
||||
typedef struct subgoal_trie_node {
|
||||
#ifdef GLOBAL_TRIE
|
||||
struct global_trie_node *entry;
|
||||
#else
|
||||
Term entry;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#ifdef TABLE_LOCK_AT_NODE_LEVEL
|
||||
lockvar lock;
|
||||
#endif /* TABLE_LOCK_AT_NODE_LEVEL */
|
||||
@ -96,7 +109,11 @@ typedef struct answer_trie_node {
|
||||
#ifdef YAPOR
|
||||
int or_arg; /* u.Otapl.or_arg */
|
||||
#endif /* YAPOR */
|
||||
#ifdef GLOBAL_TRIE
|
||||
struct global_trie_node *entry;
|
||||
#else
|
||||
Term entry;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
#ifdef TABLE_LOCK_AT_NODE_LEVEL
|
||||
lockvar lock;
|
||||
#endif /* TABLE_LOCK_AT_NODE_LEVEL */
|
||||
@ -116,28 +133,43 @@ typedef struct answer_trie_node {
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------- **
|
||||
** Structs subgoal_hash and answer_hash **
|
||||
** ---------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- **
|
||||
** Structs global_trie_hash, subgoal_trie_hash and answer_trie_hash **
|
||||
** -------------------------------------------------------------------------- */
|
||||
|
||||
typedef struct subgoal_hash {
|
||||
#ifdef GLOBAL_TRIE
|
||||
typedef struct global_trie_hash {
|
||||
/* the first field is used for compatibility **
|
||||
** with the global_trie_node data structure */
|
||||
Term mark;
|
||||
int number_of_buckets;
|
||||
struct global_trie_node **buckets;
|
||||
int number_of_nodes;
|
||||
} *gt_hash_ptr;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
|
||||
typedef struct subgoal_trie_hash {
|
||||
/* the first field is used for compatibility **
|
||||
** with the subgoal_trie_node data structure */
|
||||
#ifdef GLOBAL_TRIE
|
||||
struct global_trie_node *mark;
|
||||
#else
|
||||
Term mark;
|
||||
#endif /* GLOBAL_TRIE */
|
||||
int number_of_buckets;
|
||||
struct subgoal_trie_node **buckets;
|
||||
int number_of_nodes;
|
||||
struct subgoal_hash *next;
|
||||
struct subgoal_trie_hash *next;
|
||||
} *sg_hash_ptr;
|
||||
|
||||
typedef struct answer_hash {
|
||||
typedef struct answer_trie_hash {
|
||||
/* the first field is used for compatibility **
|
||||
** with the answer_trie_node data structure */
|
||||
OPCODE mark;
|
||||
int number_of_buckets;
|
||||
struct answer_trie_node **buckets;
|
||||
int number_of_nodes;
|
||||
struct answer_hash *next;
|
||||
struct answer_trie_hash *next;
|
||||
} *ans_hash_ptr;
|
||||
|
||||
#define Hash_mark(X) ((X)->mark)
|
||||
@ -171,7 +203,7 @@ typedef struct subgoal_frame {
|
||||
compiled_in_use = 6 /* LIMIT_TABLING */
|
||||
} state_flag; /* do not change order !!! */
|
||||
choiceptr generator_choice_point;
|
||||
struct answer_hash *hash_chain;
|
||||
struct answer_trie_hash *hash_chain;
|
||||
struct answer_trie_node *answer_trie;
|
||||
struct answer_trie_node *first_answer;
|
||||
struct answer_trie_node *last_answer;
|
||||
@ -212,7 +244,7 @@ typedef struct subgoal_frame {
|
||||
SgFr_arity the arity of the subgoal.
|
||||
SgFr_state: a flag that indicates the subgoal state.
|
||||
SgFr_gen_cp: a pointer to the correspondent generator choice point.
|
||||
SgFr_hash_chain: a pointer to the first answer_hash struct for the subgoal in hand.
|
||||
SgFr_hash_chain: a pointer to the first answer_trie_hash struct for the subgoal in hand.
|
||||
SgFr_answer_trie: a pointer to the top answer trie node.
|
||||
It is used to check for/insert new answers.
|
||||
SgFr_first_answer: a pointer to the bottom answer trie node of the first available answer.
|
||||
|
1387
OPTYap/tab.tries.c
1387
OPTYap/tab.tries.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user