support for the common global trie (version GT-T: global trie for terms)

This commit is contained in:
Ricardo Rocha
2009-09-27 02:31:31 +01:00
parent 218bc2e423
commit 7d841065e9
11 changed files with 2091 additions and 1381 deletions

View File

@@ -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));