Merge branch 'master' of ssh://yap.git.sourceforge.net/gitroot/yap/yap-6.3
This commit is contained in:
commit
d22d03b2a2
@ -457,7 +457,7 @@ extern int Yap_page_size;
|
||||
************************************************************************/
|
||||
|
||||
#define INFORMATION_MESSAGE(MESSAGE,ARGS...) \
|
||||
fprintf(stderr, "[ " MESSAGE " ]\n", ##ARGS)
|
||||
Sfprintf(Serror, "[ " MESSAGE " ]\n", ##ARGS)
|
||||
|
||||
#ifdef YAPOR
|
||||
#define ERROR_MESSAGE(MESSAGE) \
|
||||
|
@ -17,13 +17,9 @@
|
||||
|
||||
#include "Yap.h"
|
||||
#if defined(YAPOR) || defined(TABLING)
|
||||
#include <stdio.h>
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "yapio.h"
|
||||
#include "SWI-Prolog.h"
|
||||
#ifdef YAPOR
|
||||
#if HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
@ -43,9 +39,11 @@ static Int p_table( USES_REGS1 );
|
||||
static Int p_tabling_mode( USES_REGS1 );
|
||||
static Int p_abolish_table( USES_REGS1 );
|
||||
static Int p_abolish_all_tables( USES_REGS1 );
|
||||
static Int p_abolish_all_local_tables( USES_REGS1 );
|
||||
static Int p_show_tabled_predicates( USES_REGS1 );
|
||||
static Int p_show_table( USES_REGS1 );
|
||||
static Int p_show_all_tables( USES_REGS1 );
|
||||
static Int p_show_all_local_tables( USES_REGS1 );
|
||||
static Int p_show_global_trie( USES_REGS1 );
|
||||
static Int p_show_statistics_table( USES_REGS1 );
|
||||
static Int p_show_statistics_tabling( USES_REGS1 );
|
||||
@ -76,26 +74,26 @@ static inline void answer_to_stdout(char *answer);
|
||||
#endif /* YAPOR */
|
||||
|
||||
#ifdef TABLING
|
||||
static inline long show_statistics_table_entries(void);
|
||||
static inline long show_statistics_subgoal_frames(void);
|
||||
static inline long show_statistics_dependency_frames(void);
|
||||
static inline long show_statistics_subgoal_trie_nodes(void);
|
||||
static inline long show_statistics_answer_trie_nodes(void);
|
||||
static inline long show_statistics_subgoal_trie_hashes(void);
|
||||
static inline long show_statistics_answer_trie_hashes(void);
|
||||
static inline long show_statistics_global_trie_nodes(void);
|
||||
static inline long show_statistics_global_trie_hashes(void);
|
||||
static inline long show_statistics_table_entries(IOSTREAM *out);
|
||||
static inline long show_statistics_subgoal_frames(IOSTREAM *out);
|
||||
static inline long show_statistics_dependency_frames(IOSTREAM *out);
|
||||
static inline long show_statistics_subgoal_trie_nodes(IOSTREAM *out);
|
||||
static inline long show_statistics_answer_trie_nodes(IOSTREAM *out);
|
||||
static inline long show_statistics_subgoal_trie_hashes(IOSTREAM *out);
|
||||
static inline long show_statistics_answer_trie_hashes(IOSTREAM *out);
|
||||
static inline long show_statistics_global_trie_nodes(IOSTREAM *out);
|
||||
static inline long show_statistics_global_trie_hashes(IOSTREAM *out);
|
||||
#endif /* TABLING */
|
||||
#ifdef YAPOR
|
||||
static inline long show_statistics_or_frames(void);
|
||||
static inline long show_statistics_query_goal_solution_frames(void);
|
||||
static inline long show_statistics_query_goal_answer_frames(void);
|
||||
static inline long show_statistics_or_frames(IOSTREAM *out);
|
||||
static inline long show_statistics_query_goal_solution_frames(IOSTREAM *out);
|
||||
static inline long show_statistics_query_goal_answer_frames(IOSTREAM *out);
|
||||
#endif /* YAPOR */
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
static inline long show_statistics_suspension_frames(void);
|
||||
static inline long show_statistics_suspension_frames(IOSTREAM *out);
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
static inline long show_statistics_table_subgoal_solution_frames(void);
|
||||
static inline long show_statistics_table_subgoal_answer_frames(void);
|
||||
static inline long show_statistics_table_subgoal_solution_frames(IOSTREAM *out);
|
||||
static inline long show_statistics_table_subgoal_answer_frames(IOSTREAM *out);
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
#endif /* YAPOR && TABLING */
|
||||
|
||||
@ -129,13 +127,15 @@ void Yap_init_optyap_preds(void) {
|
||||
Yap_InitCPred("$c_tabling_mode", 3, p_tabling_mode, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$c_abolish_table", 2, p_abolish_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("abolish_all_tables", 0, p_abolish_all_tables, SafePredFlag|SyncPredFlag);
|
||||
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);
|
||||
Yap_InitCPred("show_global_trie", 0, p_show_global_trie, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$c_table_statistics", 2, p_show_statistics_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("tabling_statistics", 0, p_show_statistics_tabling, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("global_trie_statistics", 0, p_show_statistics_global_trie, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("abolish_all_local_tables", 0, p_abolish_all_local_tables, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("show_tabled_predicates", 1, p_show_tabled_predicates, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$c_show_table", 3, p_show_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("show_all_tables", 1, p_show_all_tables, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("show_all_local_tables", 1, p_show_all_local_tables, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("show_global_trie", 1, p_show_global_trie, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$c_table_statistics", 3, p_show_statistics_table, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("tabling_statistics", 1, p_show_statistics_tabling, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("global_trie_statistics", 1, p_show_statistics_global_trie, SafePredFlag|SyncPredFlag);
|
||||
#endif /* TABLING */
|
||||
Yap_InitCPred("$c_yapor_threads", 1, p_yapor_threads, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
#ifdef YAPOR
|
||||
@ -147,10 +147,10 @@ void Yap_init_optyap_preds(void) {
|
||||
Yap_InitCPred("performance", 1, p_performance, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("$c_parallel_new_answer", 1, p_parallel_new_answer, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("$c_parallel_yes_answer", 0, p_parallel_yes_answer, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
Yap_InitCPred("or_statistics", 0, p_show_statistics_or, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("or_statistics", 1, p_show_statistics_or, SafePredFlag|SyncPredFlag);
|
||||
#endif /* YAPOR */
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
Yap_InitCPred("opt_statistics", 0, p_show_statistics_opt, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred("opt_statistics", 1, p_show_statistics_opt, SafePredFlag|SyncPredFlag);
|
||||
#endif /* YAPOR && TABLING */
|
||||
Yap_InitCPred("$c_get_optyap_statistics", 3, p_get_optyap_statistics, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||
}
|
||||
@ -384,16 +384,29 @@ static Int p_abolish_all_tables( USES_REGS1 ) {
|
||||
}
|
||||
|
||||
|
||||
static Int p_abolish_all_local_tables( USES_REGS1 ) {
|
||||
#ifdef THREADS
|
||||
|
||||
#else
|
||||
p_abolish_all_tables();
|
||||
#endif /* THREADS */
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_tabled_predicates( USES_REGS1 ) {
|
||||
IOSTREAM *out;
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
if ((out = YAP_TermToStream(Deref(ARG1))) == NULL)
|
||||
return (FALSE);
|
||||
tab_ent = GLOBAL_root_tab_ent;
|
||||
fprintf(GLOBAL_stdout, "Tabled predicates\n");
|
||||
Sfprintf(out, "Tabled predicates\n");
|
||||
if (tab_ent == NULL)
|
||||
fprintf(GLOBAL_stdout, " NONE\n");
|
||||
Sfprintf(out, " NONE\n");
|
||||
else
|
||||
while(tab_ent) {
|
||||
fprintf(GLOBAL_stdout, " %s/%d\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
||||
Sfprintf(out, " %s/%d\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
return (TRUE);
|
||||
@ -401,96 +414,124 @@ static Int p_show_tabled_predicates( USES_REGS1 ) {
|
||||
|
||||
|
||||
static Int p_show_table( USES_REGS1 ) {
|
||||
IOSTREAM *out;
|
||||
Term mod, t;
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
mod = Deref(ARG1);
|
||||
t = Deref(ARG2);
|
||||
if ((out = YAP_TermToStream(Deref(ARG1))) == NULL)
|
||||
return (FALSE);
|
||||
mod = Deref(ARG2);
|
||||
t = Deref(ARG3);
|
||||
if (IsAtomTerm(t))
|
||||
tab_ent = RepPredProp(PredPropByAtom(AtomOfTerm(t), mod))->TableOfPred;
|
||||
else if (IsApplTerm(t))
|
||||
tab_ent = RepPredProp(PredPropByFunc(FunctorOfTerm(t), mod))->TableOfPred;
|
||||
else
|
||||
return (FALSE);
|
||||
show_table(tab_ent, SHOW_MODE_STRUCTURE);
|
||||
show_table(tab_ent, SHOW_MODE_STRUCTURE, out);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_all_tables( USES_REGS1 ) {
|
||||
IOSTREAM *out;
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
if ((out = YAP_TermToStream(Deref(ARG1))) == NULL)
|
||||
return (FALSE);
|
||||
tab_ent = GLOBAL_root_tab_ent;
|
||||
while(tab_ent) {
|
||||
show_table(tab_ent, SHOW_MODE_STRUCTURE);
|
||||
show_table(tab_ent, SHOW_MODE_STRUCTURE, out);
|
||||
tab_ent = TabEnt_next(tab_ent);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_all_local_tables( USES_REGS1 ) {
|
||||
#ifdef THREADS
|
||||
|
||||
#else
|
||||
p_show_all_tables();
|
||||
#endif /* THREADS */
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_global_trie( USES_REGS1 ) {
|
||||
show_global_trie(SHOW_MODE_STRUCTURE);
|
||||
IOSTREAM *out;
|
||||
|
||||
if ((out = YAP_TermToStream(Deref(ARG1))) == NULL)
|
||||
return (FALSE);
|
||||
show_global_trie(SHOW_MODE_STRUCTURE, out);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_statistics_table( USES_REGS1 ) {
|
||||
IOSTREAM *out;
|
||||
Term mod, t;
|
||||
tab_ent_ptr tab_ent;
|
||||
|
||||
mod = Deref(ARG1);
|
||||
t = Deref(ARG2);
|
||||
if ((out = YAP_TermToStream(Deref(ARG1))) == NULL)
|
||||
return (FALSE);
|
||||
mod = Deref(ARG2);
|
||||
t = Deref(ARG3);
|
||||
if (IsAtomTerm(t))
|
||||
tab_ent = RepPredProp(PredPropByAtom(AtomOfTerm(t), mod))->TableOfPred;
|
||||
else if (IsApplTerm(t))
|
||||
tab_ent = RepPredProp(PredPropByFunc(FunctorOfTerm(t), mod))->TableOfPred;
|
||||
else
|
||||
return (FALSE);
|
||||
show_table(tab_ent, SHOW_MODE_STATISTICS);
|
||||
show_table(tab_ent, SHOW_MODE_STATISTICS, out);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static Int p_show_statistics_tabling( USES_REGS1 ) {
|
||||
IOSTREAM *out;
|
||||
long total_bytes = 0, aux_bytes;
|
||||
|
||||
if ((out = YAP_TermToStream(Deref(ARG1))) == NULL)
|
||||
return (FALSE);
|
||||
aux_bytes = 0;
|
||||
fprintf(GLOBAL_stdout, "Execution data structures\n");
|
||||
aux_bytes += show_statistics_table_entries();
|
||||
aux_bytes += show_statistics_subgoal_frames();
|
||||
aux_bytes += show_statistics_dependency_frames();
|
||||
fprintf(GLOBAL_stdout, " Memory in use (I): %10ld bytes\n\n", aux_bytes);
|
||||
Sfprintf(out, "Execution data structures\n");
|
||||
aux_bytes += show_statistics_table_entries(out);
|
||||
aux_bytes += show_statistics_subgoal_frames(out);
|
||||
aux_bytes += show_statistics_dependency_frames(out);
|
||||
Sfprintf(out, " Memory in use (I): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
aux_bytes = 0;
|
||||
fprintf(GLOBAL_stdout, "Local trie data structures\n");
|
||||
aux_bytes += show_statistics_subgoal_trie_nodes();
|
||||
aux_bytes += show_statistics_answer_trie_nodes();
|
||||
aux_bytes += show_statistics_subgoal_trie_hashes();
|
||||
aux_bytes += show_statistics_answer_trie_hashes();
|
||||
fprintf(GLOBAL_stdout, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
|
||||
Sfprintf(out, "Local trie data structures\n");
|
||||
aux_bytes += show_statistics_subgoal_trie_nodes(out);
|
||||
aux_bytes += show_statistics_answer_trie_nodes(out);
|
||||
aux_bytes += show_statistics_subgoal_trie_hashes(out);
|
||||
aux_bytes += show_statistics_answer_trie_hashes(out);
|
||||
Sfprintf(out, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
aux_bytes = 0;
|
||||
fprintf(GLOBAL_stdout, "Global trie data structures\n");
|
||||
aux_bytes += show_statistics_global_trie_nodes();
|
||||
aux_bytes += show_statistics_global_trie_hashes();
|
||||
fprintf(GLOBAL_stdout, " Memory in use (III): %10ld bytes\n\n", aux_bytes);
|
||||
Sfprintf(out, "Global trie data structures\n");
|
||||
aux_bytes += show_statistics_global_trie_nodes(out);
|
||||
aux_bytes += show_statistics_global_trie_hashes(out);
|
||||
Sfprintf(out, " Memory in use (III): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
fprintf(GLOBAL_stdout, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
||||
Sfprintf(out, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
||||
total_bytes, Pg_str_in_use(GLOBAL_pages_void));
|
||||
fprintf(GLOBAL_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||
Sfprintf(out, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||
Pg_pg_alloc(GLOBAL_pages_void) * Yap_page_size, Pg_pg_alloc(GLOBAL_pages_void));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
||||
Sfprintf(out, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
fflush(GLOBAL_stdout);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static Int p_show_statistics_global_trie( USES_REGS1 ) {
|
||||
show_global_trie(SHOW_MODE_STATISTICS);
|
||||
IOSTREAM *out;
|
||||
|
||||
if ((out = YAP_TermToStream(Deref(ARG1))) == NULL)
|
||||
return (FALSE);
|
||||
show_global_trie(SHOW_MODE_STATISTICS, out);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif /* TABLING */
|
||||
@ -640,32 +681,33 @@ static Int p_performance( USES_REGS1 ) {
|
||||
return(FALSE);
|
||||
|
||||
if (GLOBAL_number_goals) {
|
||||
fprintf(GLOBAL_stdout, "[\n Best execution times:\n");
|
||||
Sfprintf(Soutput, "[\n Best execution times:\n");
|
||||
for (i = 1; i <= GLOBAL_number_goals; i++) {
|
||||
fprintf(GLOBAL_stdout, " %d. time: %f seconds", i, GLOBAL_best_times(i));
|
||||
Sfprintf(Soutput, " %d. time: %f seconds", i, GLOBAL_best_times(i));
|
||||
if (one_worker_execution_time != 0)
|
||||
fprintf(GLOBAL_stdout, " --> speedup %f (%6.2f %% )\n",
|
||||
Sfprintf(Soutput, " --> speedup %f (%6.2f %% )\n",
|
||||
one_worker_execution_time / GLOBAL_best_times(i),
|
||||
one_worker_execution_time / GLOBAL_best_times(i) / GLOBAL_number_workers* 100 );
|
||||
else fprintf(GLOBAL_stdout, "\n");
|
||||
else Sfprintf(Soutput, "\n");
|
||||
}
|
||||
|
||||
fprintf(GLOBAL_stdout, " Average : %f seconds",
|
||||
Sfprintf(Soutput, " Average : %f seconds",
|
||||
GLOBAL_best_times(0) / GLOBAL_number_goals);
|
||||
if (one_worker_execution_time != 0)
|
||||
fprintf(GLOBAL_stdout, " --> speedup %f (%6.2f %% )",
|
||||
Sfprintf(Soutput, " --> speedup %f (%6.2f %% )",
|
||||
one_worker_execution_time * GLOBAL_number_goals / GLOBAL_best_times(0),
|
||||
one_worker_execution_time * GLOBAL_number_goals / GLOBAL_best_times(0) / GLOBAL_number_workers* 100 );
|
||||
|
||||
if (GLOBAL_number_goals >= 3) {
|
||||
fprintf(GLOBAL_stdout, "\n Average (best three): %f seconds",
|
||||
Sfprintf(Soutput, "\n Average (best three): %f seconds",
|
||||
(GLOBAL_best_times(1) + GLOBAL_best_times(2) + GLOBAL_best_times(3)) / 3);
|
||||
if (one_worker_execution_time != 0)
|
||||
fprintf(GLOBAL_stdout, " --> speedup %f (%6.2f %% ) ]\n\n",
|
||||
Sfprintf(Soutput, " --> speedup %f (%6.2f %% ) ]\n\n",
|
||||
one_worker_execution_time * 3 / (GLOBAL_best_times(1) + GLOBAL_best_times(2) + GLOBAL_best_times(3)),
|
||||
one_worker_execution_time * 3 / (GLOBAL_best_times(1) + GLOBAL_best_times(2) + GLOBAL_best_times(3)) / GLOBAL_number_workers* 100 );
|
||||
else fprintf(GLOBAL_stdout, "\n]\n\n");
|
||||
} else fprintf(GLOBAL_stdout, "\n]\n\n");
|
||||
else Sfprintf(Soutput, "\n]\n\n");
|
||||
} else Sfprintf(Soutput, "\n]\n\n");
|
||||
Sflush(Soutput);
|
||||
return (TRUE);
|
||||
}
|
||||
return (FALSE);
|
||||
@ -700,28 +742,30 @@ static Int p_parallel_yes_answer( USES_REGS1 ) {
|
||||
|
||||
|
||||
static Int p_show_statistics_or( USES_REGS1 ) {
|
||||
IOSTREAM *out;
|
||||
long total_bytes = 0, aux_bytes;
|
||||
|
||||
if ((out = YAP_TermToStream(Deref(ARG1))) == NULL)
|
||||
return (FALSE);
|
||||
aux_bytes = 0;
|
||||
fprintf(GLOBAL_stdout, "Execution data structures\n");
|
||||
aux_bytes += show_statistics_or_frames();
|
||||
fprintf(GLOBAL_stdout, " Memory in use (I): %10ld bytes\n\n", aux_bytes);
|
||||
Sfprintf(out, "Execution data structures\n");
|
||||
aux_bytes += show_statistics_or_frames(out);
|
||||
Sfprintf(out, " Memory in use (I): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
aux_bytes = 0;
|
||||
fprintf(GLOBAL_stdout, "Cut support data structures\n");
|
||||
aux_bytes += show_statistics_query_goal_solution_frames();
|
||||
aux_bytes += show_statistics_query_goal_answer_frames();
|
||||
fprintf(GLOBAL_stdout, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
|
||||
Sfprintf(out, "Cut support data structures\n");
|
||||
aux_bytes += show_statistics_query_goal_solution_frames(out);
|
||||
aux_bytes += show_statistics_query_goal_answer_frames(out);
|
||||
Sfprintf(out, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
fprintf(GLOBAL_stdout, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
||||
Sfprintf(out, "Total memory in use (I+II+III): %10ld bytes (%ld pages in use)\n",
|
||||
total_bytes, Pg_str_in_use(GLOBAL_pages_void));
|
||||
fprintf(GLOBAL_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||
Sfprintf(out, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||
Pg_pg_alloc(GLOBAL_pages_void) * Yap_page_size, Pg_pg_alloc(GLOBAL_pages_void));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
||||
Sfprintf(out, "Total memory in use (I+II+III): %10ld bytes\n", total_bytes);
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
#endif /* YAPOR */
|
||||
@ -734,50 +778,52 @@ static Int p_show_statistics_or( USES_REGS1 ) {
|
||||
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
static Int p_show_statistics_opt( USES_REGS1 ) {
|
||||
IOSTREAM *out;
|
||||
long total_bytes = 0, aux_bytes;
|
||||
|
||||
if ((out = YAP_TermToStream(Deref(ARG1))) == NULL)
|
||||
return (FALSE);
|
||||
aux_bytes = 0;
|
||||
fprintf(GLOBAL_stdout, "Execution data structures\n");
|
||||
aux_bytes += show_statistics_table_entries();
|
||||
aux_bytes += show_statistics_subgoal_frames();
|
||||
aux_bytes += show_statistics_dependency_frames();
|
||||
aux_bytes += show_statistics_or_frames();
|
||||
aux_bytes += show_statistics_suspension_frames();
|
||||
fprintf(GLOBAL_stdout, " Memory in use (I): %10ld bytes\n\n", aux_bytes);
|
||||
Sfprintf(out, "Execution data structures\n");
|
||||
aux_bytes += show_statistics_table_entries(out);
|
||||
aux_bytes += show_statistics_subgoal_frames(out);
|
||||
aux_bytes += show_statistics_dependency_frames(out);
|
||||
aux_bytes += show_statistics_or_frames(out);
|
||||
aux_bytes += show_statistics_suspension_frames(out);
|
||||
Sfprintf(out, " Memory in use (I): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
aux_bytes = 0;
|
||||
fprintf(GLOBAL_stdout, "Local trie data structures\n");
|
||||
aux_bytes += show_statistics_subgoal_trie_nodes();
|
||||
aux_bytes += show_statistics_answer_trie_nodes();
|
||||
aux_bytes += show_statistics_subgoal_trie_hashes();
|
||||
aux_bytes += show_statistics_answer_trie_hashes();
|
||||
fprintf(GLOBAL_stdout, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
|
||||
Sfprintf(out, "Local trie data structures\n");
|
||||
aux_bytes += show_statistics_subgoal_trie_nodes(out);
|
||||
aux_bytes += show_statistics_answer_trie_nodes(out);
|
||||
aux_bytes += show_statistics_subgoal_trie_hashes(out);
|
||||
aux_bytes += show_statistics_answer_trie_hashes(out);
|
||||
Sfprintf(out, " Memory in use (II): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
aux_bytes = 0;
|
||||
fprintf(GLOBAL_stdout, "Global trie data structures\n");
|
||||
aux_bytes += show_statistics_global_trie_nodes();
|
||||
aux_bytes += show_statistics_global_trie_hashes();
|
||||
fprintf(GLOBAL_stdout, " Memory in use (III): %10ld bytes\n\n", aux_bytes);
|
||||
Sfprintf(out, "Global trie data structures\n");
|
||||
aux_bytes += show_statistics_global_trie_nodes(out);
|
||||
aux_bytes += show_statistics_global_trie_hashes(out);
|
||||
Sfprintf(out, " Memory in use (III): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
aux_bytes = 0;
|
||||
fprintf(GLOBAL_stdout, "Cut support data structures\n");
|
||||
aux_bytes += show_statistics_query_goal_solution_frames();
|
||||
aux_bytes += show_statistics_query_goal_answer_frames();
|
||||
Sfprintf(out, "Cut support data structures\n");
|
||||
aux_bytes += show_statistics_query_goal_solution_frames(out);
|
||||
aux_bytes += show_statistics_query_goal_answer_frames(out);
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
aux_bytes += show_statistics_table_subgoal_solution_frames();
|
||||
aux_bytes += show_statistics_table_subgoal_answer_frames();
|
||||
aux_bytes += show_statistics_table_subgoal_solution_frames(out);
|
||||
aux_bytes += show_statistics_table_subgoal_answer_frames(out);
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
fprintf(GLOBAL_stdout, " Memory in use (IV): %10ld bytes\n\n", aux_bytes);
|
||||
Sfprintf(out, " Memory in use (IV): %10ld bytes\n\n", aux_bytes);
|
||||
total_bytes += aux_bytes;
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
fprintf(GLOBAL_stdout, "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
|
||||
Sfprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes (%ld pages in use)\n",
|
||||
total_bytes, Pg_str_in_use(GLOBAL_pages_void));
|
||||
fprintf(GLOBAL_stdout, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||
Sfprintf(out, "Total memory allocated: %10ld bytes (%ld pages in total)\n",
|
||||
Pg_pg_alloc(GLOBAL_pages_void) * Yap_page_size, Pg_pg_alloc(GLOBAL_pages_void));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
|
||||
Sfprintf(out, "Total memory in use (I+II+III+IV): %10ld bytes\n", total_bytes);
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
#endif /* YAPOR && TABLING */
|
||||
@ -945,19 +991,20 @@ static inline void show_answers(void) {
|
||||
}
|
||||
switch(GLOBAL_answers) {
|
||||
case YES_ANSWER:
|
||||
fprintf(GLOBAL_stderr, "[ yes");
|
||||
Sfprintf(Serror, "[ yes");
|
||||
break;
|
||||
case NO_ANSWER:
|
||||
fprintf(GLOBAL_stderr, "[ no");
|
||||
Sfprintf(Serror, "[ no");
|
||||
break;
|
||||
case 1:
|
||||
fprintf(GLOBAL_stderr, "[ 1 answer found");
|
||||
Sfprintf(Serror, "[ 1 answer found");
|
||||
break;
|
||||
default:
|
||||
fprintf(GLOBAL_stderr, "[ %d answers found", GLOBAL_answers);
|
||||
Sfprintf(Serror, "[ %d answers found", GLOBAL_answers);
|
||||
break;
|
||||
}
|
||||
fprintf(GLOBAL_stderr, " (in %f seconds) ]\n\n", GLOBAL_execution_time);
|
||||
Sfprintf(Serror, " (in %f seconds) ]\n\n", GLOBAL_execution_time);
|
||||
Sflush(Serror);
|
||||
|
||||
if (GLOBAL_performance_mode == PERFORMANCE_ON) {
|
||||
for (i = GLOBAL_number_goals; i > 0; i--) {
|
||||
@ -1017,14 +1064,15 @@ static inline void answer_to_stdout(char *answer) {
|
||||
else break;
|
||||
}
|
||||
output[length_output] = 0;
|
||||
fprintf(GLOBAL_stderr, " %s\n", output);
|
||||
Sfprintf(Serror, " %s\n", output);
|
||||
Sflush(Serror);
|
||||
return;
|
||||
}
|
||||
#endif /* YAPOR */
|
||||
|
||||
|
||||
#ifdef TABLING
|
||||
static inline long show_statistics_table_entries(void) {
|
||||
static inline long show_statistics_table_entries(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_TABLING
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1042,17 +1090,17 @@ static inline long show_statistics_table_entries(void) {
|
||||
}
|
||||
TABLING_ERROR_CHECKING(statistics_table_entries, Pg_str_free(GLOBAL_pages_tab_ent) != cont);
|
||||
#endif /* DEBUG_TABLING */
|
||||
fprintf(GLOBAL_stdout, " Table entries: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Table entries: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry), Pg_pg_alloc(GLOBAL_pages_tab_ent), Pg_str_in_use(GLOBAL_pages_tab_ent));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Table entries: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Table entries: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry), Pg_str_in_use(GLOBAL_pages_tab_ent));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_tab_ent) * sizeof(struct table_entry);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_subgoal_frames(void) {
|
||||
static inline long show_statistics_subgoal_frames(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_TABLING
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1070,17 +1118,17 @@ static inline long show_statistics_subgoal_frames(void) {
|
||||
}
|
||||
TABLING_ERROR_CHECKING(statistics_subgoal_frames, Pg_str_free(GLOBAL_pages_sg_fr) != cont);
|
||||
#endif /* DEBUG_TABLING */
|
||||
fprintf(GLOBAL_stdout, " Subgoal frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Subgoal frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame), Pg_pg_alloc(GLOBAL_pages_sg_fr), Pg_str_in_use(GLOBAL_pages_sg_fr));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Subgoal frames: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Subgoal frames: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame), Pg_str_in_use(GLOBAL_pages_sg_fr));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_sg_fr) * sizeof(struct subgoal_frame);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_dependency_frames(void) {
|
||||
static inline long show_statistics_dependency_frames(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_TABLING
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1098,17 +1146,17 @@ static inline long show_statistics_dependency_frames(void) {
|
||||
}
|
||||
TABLING_ERROR_CHECKING(statistics_dependency_frames, Pg_str_free(GLOBAL_pages_dep_fr) != cont);
|
||||
#endif /* DEBUG_TABLING */
|
||||
fprintf(GLOBAL_stdout, " Dependency frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Dependency frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame), Pg_pg_alloc(GLOBAL_pages_dep_fr), Pg_str_in_use(GLOBAL_pages_dep_fr));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Dependency frames: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Dependency frames: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame), Pg_str_in_use(GLOBAL_pages_dep_fr));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_dep_fr) * sizeof(struct dependency_frame);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_subgoal_trie_nodes(void) {
|
||||
static inline long show_statistics_subgoal_trie_nodes(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_TABLING
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1126,17 +1174,17 @@ static inline long show_statistics_subgoal_trie_nodes(void) {
|
||||
}
|
||||
TABLING_ERROR_CHECKING(statistics_subgoal_trie_nodes, Pg_str_free(GLOBAL_pages_sg_node) != cont);
|
||||
#endif /* DEBUG_TABLING */
|
||||
fprintf(GLOBAL_stdout, " Subgoal trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Subgoal trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node), Pg_pg_alloc(GLOBAL_pages_sg_node), Pg_str_in_use(GLOBAL_pages_sg_node));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Subgoal trie nodes: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Subgoal trie nodes: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node), Pg_str_in_use(GLOBAL_pages_sg_node));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_sg_node) * sizeof(struct subgoal_trie_node);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_answer_trie_nodes(void) {
|
||||
static inline long show_statistics_answer_trie_nodes(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_TABLING
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1154,17 +1202,17 @@ static inline long show_statistics_answer_trie_nodes(void) {
|
||||
}
|
||||
TABLING_ERROR_CHECKING(statistics_answer_trie_nodes, Pg_str_free(GLOBAL_pages_ans_node) != cont);
|
||||
#endif /* DEBUG_TABLING */
|
||||
fprintf(GLOBAL_stdout, " Answer trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Answer trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node), Pg_pg_alloc(GLOBAL_pages_ans_node), Pg_str_in_use(GLOBAL_pages_ans_node));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Answer trie nodes: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Answer trie nodes: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node), Pg_str_in_use(GLOBAL_pages_ans_node));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_ans_node) * sizeof(struct answer_trie_node);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_subgoal_trie_hashes(void) {
|
||||
static inline long show_statistics_subgoal_trie_hashes(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_TABLING
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1182,17 +1230,17 @@ static inline long show_statistics_subgoal_trie_hashes(void) {
|
||||
}
|
||||
TABLING_ERROR_CHECKING(statistics_subgoal_trie_hashes, Pg_str_free(GLOBAL_pages_sg_hash) != cont);
|
||||
#endif /* DEBUG_TABLING */
|
||||
fprintf(GLOBAL_stdout, " Subgoal trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Subgoal trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash), Pg_pg_alloc(GLOBAL_pages_sg_hash), Pg_str_in_use(GLOBAL_pages_sg_hash));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Subgoal trie hashes: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Subgoal trie hashes: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash), Pg_str_in_use(GLOBAL_pages_sg_hash));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_sg_hash) * sizeof(struct subgoal_trie_hash);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_answer_trie_hashes(void) {
|
||||
static inline long show_statistics_answer_trie_hashes(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_TABLING
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1210,17 +1258,17 @@ static inline long show_statistics_answer_trie_hashes(void) {
|
||||
}
|
||||
TABLING_ERROR_CHECKING(statistics_answer_trie_hashes, Pg_str_free(GLOBAL_pages_ans_hash) != cont);
|
||||
#endif /* DEBUG_TABLING */
|
||||
fprintf(GLOBAL_stdout, " Answer trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Answer trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash), Pg_pg_alloc(GLOBAL_pages_ans_hash), Pg_str_in_use(GLOBAL_pages_ans_hash));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Answer trie hashes: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Answer trie hashes: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash), Pg_str_in_use(GLOBAL_pages_ans_hash));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_ans_hash) * sizeof(struct answer_trie_hash);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_global_trie_nodes(void) {
|
||||
static inline long show_statistics_global_trie_nodes(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_TABLING
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1238,17 +1286,17 @@ static inline long show_statistics_global_trie_nodes(void) {
|
||||
}
|
||||
TABLING_ERROR_CHECKING(statistics_global_trie_nodes, Pg_str_free(GLOBAL_pages_gt_node) != cont);
|
||||
#endif /* DEBUG_TABLING */
|
||||
fprintf(GLOBAL_stdout, " Global trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Global trie nodes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node), Pg_pg_alloc(GLOBAL_pages_gt_node), Pg_str_in_use(GLOBAL_pages_gt_node));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Global trie nodes: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Global trie nodes: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node), Pg_str_in_use(GLOBAL_pages_gt_node));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_gt_node) * sizeof(struct global_trie_node);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_global_trie_hashes(void) {
|
||||
static inline long show_statistics_global_trie_hashes(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_TABLING
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1266,10 +1314,10 @@ static inline long show_statistics_global_trie_hashes(void) {
|
||||
}
|
||||
TABLING_ERROR_CHECKING(statistics_global_trie_hashes, Pg_str_free(GLOBAL_pages_gt_hash) != cont);
|
||||
#endif /* DEBUG_TABLING */
|
||||
fprintf(GLOBAL_stdout, " Global trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Global trie hashes: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash), Pg_pg_alloc(GLOBAL_pages_gt_hash), Pg_str_in_use(GLOBAL_pages_gt_hash));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Global trie hashes: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Global trie hashes: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash), Pg_str_in_use(GLOBAL_pages_gt_hash));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_gt_hash) * sizeof(struct global_trie_hash);
|
||||
@ -1278,7 +1326,7 @@ static inline long show_statistics_global_trie_hashes(void) {
|
||||
|
||||
|
||||
#ifdef YAPOR
|
||||
static inline long show_statistics_or_frames(void) {
|
||||
static inline long show_statistics_or_frames(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_YAPOR
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1296,17 +1344,17 @@ static inline long show_statistics_or_frames(void) {
|
||||
}
|
||||
YAPOR_ERROR_CHECKING(statistics_or_frames, Pg_str_free(GLOBAL_pages_or_fr ) != cont);
|
||||
#endif /* DEBUG_YAPOR */
|
||||
fprintf(GLOBAL_stdout, " Or-frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Or-frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame), Pg_pg_alloc(GLOBAL_pages_or_fr ), Pg_str_in_use(GLOBAL_pages_or_fr ));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Or-frames: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Or-frames: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame), Pg_str_in_use(GLOBAL_pages_or_fr ));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_or_fr ) * sizeof(struct or_frame);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_query_goal_solution_frames(void) {
|
||||
static inline long show_statistics_query_goal_solution_frames(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_YAPOR
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1324,17 +1372,17 @@ static inline long show_statistics_query_goal_solution_frames(void) {
|
||||
}
|
||||
YAPOR_ERROR_CHECKING(statistics_query_goal_solution_frames, Pg_str_free(GLOBAL_pages_qg_sol_fr ) != cont);
|
||||
#endif /* DEBUG_YAPOR */
|
||||
fprintf(GLOBAL_stdout, " Query goal solution frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Query goal solution frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame), Pg_pg_alloc(GLOBAL_pages_qg_sol_fr ), Pg_str_in_use(GLOBAL_pages_qg_sol_fr ));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Query goal solution frames: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Query goal solution frames: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame), Pg_str_in_use(GLOBAL_pages_qg_sol_fr ));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_qg_sol_fr ) * sizeof(struct query_goal_solution_frame);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_query_goal_answer_frames(void) {
|
||||
static inline long show_statistics_query_goal_answer_frames(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_YAPOR
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1352,10 +1400,10 @@ static inline long show_statistics_query_goal_answer_frames(void) {
|
||||
}
|
||||
YAPOR_ERROR_CHECKING(statistics_query_goal_answer_frames, Pg_str_free(GLOBAL_pages_qg_ans_fr) != cont);
|
||||
#endif /* DEBUG_YAPOR */
|
||||
fprintf(GLOBAL_stdout, " Query goal answer frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Query goal answer frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_pg_alloc(GLOBAL_pages_qg_ans_fr), Pg_str_in_use(GLOBAL_pages_qg_ans_fr));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Query goal answer frames: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Query goal answer frames: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame), Pg_str_in_use(GLOBAL_pages_qg_ans_fr));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_qg_ans_fr) * sizeof(struct query_goal_answer_frame);
|
||||
@ -1364,7 +1412,7 @@ static inline long show_statistics_query_goal_answer_frames(void) {
|
||||
|
||||
|
||||
#if defined(YAPOR) && defined(TABLING)
|
||||
static inline long show_statistics_suspension_frames(void) {
|
||||
static inline long show_statistics_suspension_frames(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_OPTYAP
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1382,10 +1430,10 @@ static inline long show_statistics_suspension_frames(void) {
|
||||
}
|
||||
OPTYAP_ERROR_CHECKING(statistics_suspension_frames, Pg_str_free(GLOBAL_pages_susp_fr) != cont);
|
||||
#endif /* DEBUG_OPTYAP */
|
||||
fprintf(GLOBAL_stdout, " Suspension frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Suspension frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame), Pg_pg_alloc(GLOBAL_pages_susp_fr), Pg_str_in_use(GLOBAL_pages_susp_fr));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Suspension frames: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Suspension frames: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame), Pg_str_in_use(GLOBAL_pages_susp_fr));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_susp_fr) * sizeof(struct suspension_frame);
|
||||
@ -1393,7 +1441,7 @@ static inline long show_statistics_suspension_frames(void) {
|
||||
|
||||
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
static inline long show_statistics_table_subgoal_solution_frames(void) {
|
||||
static inline long show_statistics_table_subgoal_solution_frames(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_OPTYAP
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1411,17 +1459,17 @@ static inline long show_statistics_table_subgoal_solution_frames(void) {
|
||||
}
|
||||
OPTYAP_ERROR_CHECKING(statistics_table_subgoal_solution_frames, Pg_str_free(GLOBAL_pages_tg_sol_fr) != cont);
|
||||
#endif /* DEBUG_OPTYAP */
|
||||
fprintf(GLOBAL_stdout, " Table subgoal solution frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Table subgoal solution frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame), Pg_pg_alloc(GLOBAL_pages_tg_sol_fr), Pg_str_in_use(GLOBAL_pages_tg_sol_fr));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Table subgoal solution frames: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Table subgoal solution frames: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame), Pg_str_in_use(GLOBAL_pages_tg_sol_fr));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_tg_sol_fr) * sizeof(struct table_subgoal_solution_frame);
|
||||
}
|
||||
|
||||
|
||||
static inline long show_statistics_table_subgoal_answer_frames(void) {
|
||||
static inline long show_statistics_table_subgoal_answer_frames(IOSTREAM *out) {
|
||||
#ifdef USE_PAGES_MALLOC
|
||||
#ifdef DEBUG_OPTYAP
|
||||
pg_hd_ptr pg_hd;
|
||||
@ -1439,10 +1487,10 @@ static inline long show_statistics_table_subgoal_answer_frames(void) {
|
||||
}
|
||||
OPTYAP_ERROR_CHECKING(statistics_table_subgoal_answer_frames, Pg_str_free(GLOBAL_pages_tg_ans_fr) != cont);
|
||||
#endif /* DEBUG_OPTYAP */
|
||||
fprintf(GLOBAL_stdout, " Table subgoal answer frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Sfprintf(out, " Table subgoal answer frames: %10ld bytes (%ld pages and %ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame), Pg_pg_alloc(GLOBAL_pages_tg_ans_fr), Pg_str_in_use(GLOBAL_pages_tg_ans_fr));
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Table subgoal answer frames: %10ld bytes (%ld structs in use)\n",
|
||||
Sfprintf(out, " Table subgoal answer frames: %10ld bytes (%ld structs in use)\n",
|
||||
Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame), Pg_str_in_use(GLOBAL_pages_tg_ans_fr));
|
||||
#endif /* USE_PAGES_MALLOC */
|
||||
return Pg_str_in_use(GLOBAL_pages_tg_ans_fr) * sizeof(struct table_subgoal_answer_frame);
|
||||
|
@ -11,6 +11,12 @@
|
||||
** **
|
||||
************************************************************************/
|
||||
|
||||
#ifdef TABLING
|
||||
#include "SWI-Stream.h"
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
||||
/***************************
|
||||
** opt.memory.c **
|
||||
***************************/
|
||||
@ -59,8 +65,8 @@ void free_subgoal_trie(sg_node_ptr, int, int);
|
||||
void free_answer_trie(ans_node_ptr, int, int);
|
||||
void free_subgoal_hash_chain(sg_hash_ptr);
|
||||
void free_answer_hash_chain(ans_hash_ptr);
|
||||
void show_table(tab_ent_ptr, int);
|
||||
void show_global_trie(int);
|
||||
void show_table(tab_ent_ptr, int, IOSTREAM *);
|
||||
void show_global_trie(int, IOSTREAM *);
|
||||
#endif /* TABLING */
|
||||
|
||||
|
||||
|
@ -304,7 +304,7 @@
|
||||
-> we need a shared data structure to avoid redundant computations!
|
||||
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
|
||||
#else
|
||||
fprintf(stderr,"PROBLEM: cp_last_answer field is local to the cp!\n");
|
||||
Sfprintf(Serror, "PROBLEM: cp_last_answer field is local to the cp!\n");
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
|
@ -17,13 +17,8 @@
|
||||
|
||||
#include "Yap.h"
|
||||
#ifdef TABLING
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#include "Yatom.h"
|
||||
#include "YapHeap.h"
|
||||
#include "yapio.h"
|
||||
#include "tab.macros.h"
|
||||
|
||||
static inline sg_node_ptr subgoal_trie_check_insert_entry(tab_ent_ptr, sg_node_ptr, Term);
|
||||
@ -78,6 +73,7 @@ static inline void traverse_update_arity(char *, int *, int *);
|
||||
*******************************/
|
||||
|
||||
static struct trie_statistics{
|
||||
IOSTREAM *out;
|
||||
int show;
|
||||
long subgoals;
|
||||
long subgoals_incomplete;
|
||||
@ -94,6 +90,7 @@ static struct trie_statistics{
|
||||
long global_trie_references;
|
||||
} trie_stats;
|
||||
|
||||
#define TrStat_out trie_stats.out
|
||||
#define TrStat_show trie_stats.show
|
||||
#define TrStat_subgoals trie_stats.subgoals
|
||||
#define TrStat_sg_incomplete trie_stats.subgoals_incomplete
|
||||
@ -110,7 +107,7 @@ static struct trie_statistics{
|
||||
#define SHOW_TABLE_ARITY_ARRAY_SIZE 10000
|
||||
#define SHOW_TABLE_STRUCTURE(MESG, ARGS...) \
|
||||
if (TrStat_show == SHOW_MODE_STRUCTURE) \
|
||||
fprintf(GLOBAL_stdout, MESG, ##ARGS)
|
||||
Sfprintf(TrStat_out, MESG, ##ARGS)
|
||||
|
||||
#define CHECK_DECREMENT_GLOBAL_TRIE_REFERENCE(REF,MODE) \
|
||||
if (MODE == TRAVERSE_MODE_NORMAL && IsVarTerm(REF) && REF > VarIndexOfTableTerm(MAX_TABLE_VARS)) { \
|
||||
@ -185,41 +182,41 @@ static struct trie_statistics{
|
||||
|
||||
static inline CELL *exec_substitution_loop(gt_node_ptr current_node, CELL **stack_vars_ptr, CELL *stack_terms) {
|
||||
/************************************************************************
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
YENV --> | N+1 | <-- stack_vars
|
||||
-----------
|
||||
| VAR_N |
|
||||
-----------
|
||||
| ... |
|
||||
-----------
|
||||
| VAR_0 |
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
TR --> | | <-- stack_terms_limit
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
----------|
|
||||
| TERM_N | <-- stack_terms
|
||||
----------| *
|
||||
| ... | /|\
|
||||
----------| | stack_terms_pair_offset (TRIE_COMPACT_PAIRS)
|
||||
| TERM_1 | \|/
|
||||
=========== *
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
YENV --> | N+1 | <-- stack_vars
|
||||
-----------
|
||||
| VAR_N |
|
||||
-----------
|
||||
| ... |
|
||||
-----------
|
||||
| VAR_0 |
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
TR --> | | <-- stack_terms_limit
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
----------|
|
||||
| TERM_N | <-- stack_terms
|
||||
----------| *
|
||||
| ... | /|\
|
||||
----------| | stack_terms_pair_offset (TRIE_COMPACT_PAIRS)
|
||||
| TERM_1 | \|/
|
||||
=========== *
|
||||
LOCAL_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
||||
-----------
|
||||
-----------
|
||||
************************************************************************/
|
||||
CACHE_REGS
|
||||
CELL *stack_vars = *stack_vars_ptr;
|
||||
@ -1297,9 +1294,10 @@ void free_answer_hash_chain(ans_hash_ptr hash) {
|
||||
}
|
||||
|
||||
|
||||
void show_table(tab_ent_ptr tab_ent, int show_mode) {
|
||||
void show_table(tab_ent_ptr tab_ent, int show_mode, IOSTREAM *out) {
|
||||
sg_node_ptr sg_node;
|
||||
|
||||
TrStat_out = out;
|
||||
TrStat_show = show_mode;
|
||||
if (show_mode == SHOW_MODE_STATISTICS) {
|
||||
TrStat_subgoals = 0;
|
||||
@ -1313,9 +1311,9 @@ void show_table(tab_ent_ptr tab_ent, int show_mode) {
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
TrStat_ans_nodes = 0;
|
||||
TrStat_gt_refs = 0;
|
||||
fprintf(GLOBAL_stdout, "Table statistics for predicate '%s/%d'\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
||||
Sfprintf(TrStat_out, "Table statistics for predicate '%s/%d'\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
||||
} else { /* SHOW_MODE_STRUCTURE */
|
||||
fprintf(GLOBAL_stdout, "Table structure for predicate '%s/%d'\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
||||
Sfprintf(TrStat_out, "Table structure for predicate '%s/%d'\n", AtomName(TabEnt_atom(tab_ent)), TabEnt_arity(tab_ent));
|
||||
}
|
||||
sg_node = TrNode_child(TabEnt_subgoal_trie(tab_ent));
|
||||
if (sg_node) {
|
||||
@ -1349,34 +1347,34 @@ void show_table(tab_ent_ptr tab_ent, int show_mode) {
|
||||
} else
|
||||
SHOW_TABLE_STRUCTURE(" EMPTY\n");
|
||||
if (show_mode == SHOW_MODE_STATISTICS) {
|
||||
fprintf(GLOBAL_stdout, " Subgoal trie structure\n");
|
||||
fprintf(GLOBAL_stdout, " Subgoals: %ld (%ld incomplete)\n", TrStat_subgoals, TrStat_sg_incomplete);
|
||||
fprintf(GLOBAL_stdout, " Subgoal trie nodes: %ld\n", TrStat_sg_nodes);
|
||||
fprintf(GLOBAL_stdout, " Answer trie structure(s)\n");
|
||||
Sfprintf(TrStat_out, " Subgoal trie structure\n");
|
||||
Sfprintf(TrStat_out, " Subgoals: %ld (%ld incomplete)\n", TrStat_subgoals, TrStat_sg_incomplete);
|
||||
Sfprintf(TrStat_out, " Subgoal trie nodes: %ld\n", TrStat_sg_nodes);
|
||||
Sfprintf(TrStat_out, " Answer trie structure(s)\n");
|
||||
#ifdef TABLING_INNER_CUTS
|
||||
fprintf(GLOBAL_stdout, " Answers: %ld (%ld pruned)\n", TrStat_answers, TrStat_answers_pruned);
|
||||
Sfprintf(TrStat_out, " Answers: %ld (%ld pruned)\n", TrStat_answers, TrStat_answers_pruned);
|
||||
#else
|
||||
fprintf(GLOBAL_stdout, " Answers: %ld\n", TrStat_answers);
|
||||
Sfprintf(TrStat_out, " Answers: %ld\n", TrStat_answers);
|
||||
#endif /* TABLING_INNER_CUTS */
|
||||
fprintf(GLOBAL_stdout, " Answers 'TRUE': %ld\n", TrStat_answers_true);
|
||||
fprintf(GLOBAL_stdout, " Answers 'NO': %ld\n", TrStat_answers_no);
|
||||
fprintf(GLOBAL_stdout, " Answer trie nodes: %ld\n", TrStat_ans_nodes);
|
||||
fprintf(GLOBAL_stdout, " Global trie references: %ld\n", TrStat_gt_refs);
|
||||
Sfprintf(TrStat_out, " Answers 'TRUE': %ld\n", TrStat_answers_true);
|
||||
Sfprintf(TrStat_out, " Answers 'NO': %ld\n", TrStat_answers_no);
|
||||
Sfprintf(TrStat_out, " Answer trie nodes: %ld\n", TrStat_ans_nodes);
|
||||
Sfprintf(TrStat_out, " Global trie references: %ld\n", TrStat_gt_refs);
|
||||
}
|
||||
fflush(GLOBAL_stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void show_global_trie(int show_mode) {
|
||||
void show_global_trie(int show_mode, IOSTREAM *out) {
|
||||
TrStat_out = out;
|
||||
TrStat_show = show_mode;
|
||||
if (show_mode == SHOW_MODE_STATISTICS) {
|
||||
TrStat_gt_terms = 0;
|
||||
TrStat_gt_nodes = 1;
|
||||
TrStat_gt_refs = 0;
|
||||
fprintf(GLOBAL_stdout, "Global trie statistics\n");
|
||||
Sfprintf(TrStat_out, "Global trie statistics\n");
|
||||
} else { /* SHOW_MODE_STRUCTURE */
|
||||
fprintf(GLOBAL_stdout, "Global trie structure\n");
|
||||
Sfprintf(TrStat_out, "Global trie structure\n");
|
||||
}
|
||||
if (TrNode_child(GLOBAL_root_gt)) {
|
||||
char *str = (char *) malloc(sizeof(char) * SHOW_TABLE_STR_ARRAY_SIZE);
|
||||
@ -1388,9 +1386,9 @@ void show_global_trie(int show_mode) {
|
||||
} else
|
||||
SHOW_TABLE_STRUCTURE(" EMPTY\n");
|
||||
if (show_mode == SHOW_MODE_STATISTICS) {
|
||||
fprintf(GLOBAL_stdout, " Terms: %ld\n", TrStat_gt_terms);
|
||||
fprintf(GLOBAL_stdout, " Global trie nodes: %ld\n", TrStat_gt_nodes);
|
||||
fprintf(GLOBAL_stdout, " Global trie auto references: %ld\n", TrStat_gt_refs);
|
||||
Sfprintf(TrStat_out, " Terms: %ld\n", TrStat_gt_terms);
|
||||
Sfprintf(TrStat_out, " Global trie nodes: %ld\n", TrStat_gt_nodes);
|
||||
Sfprintf(TrStat_out, " Global trie auto references: %ld\n", TrStat_gt_refs);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -791,43 +791,43 @@ static inline sg_node_ptr subgoal_search_loop(tab_ent_ptr tab_ent, sg_node_ptr c
|
||||
#endif /* MODE_TERMS_LOOP */
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
/************************************************************************
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
| VAR_N | <-- stack_vars
|
||||
----------- *
|
||||
| ... | /|\
|
||||
----------- | subs_arity (N+1)
|
||||
| VAR_0 | \|/
|
||||
----------- *
|
||||
YENV --> | |
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
TR --> | | <-- stack_terms_limit
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
----------|
|
||||
| TERM_N | <-- stack_terms
|
||||
----------| *
|
||||
| ... | /|\
|
||||
----------| |
|
||||
| TERM_1 | |
|
||||
----------| |
|
||||
| NULL | \|/
|
||||
=========== *
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
| VAR_N | <-- stack_vars
|
||||
----------- *
|
||||
| ... | /|\
|
||||
----------- | subs_arity (N+1)
|
||||
| VAR_0 | \|/
|
||||
----------- *
|
||||
YENV --> | |
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
TR --> | | <-- stack_terms_limit
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
----------|
|
||||
| TERM_N | <-- stack_terms
|
||||
----------| *
|
||||
| ... | /|\
|
||||
----------| |
|
||||
| TERM_1 | |
|
||||
----------| |
|
||||
| NULL | \|/
|
||||
=========== *
|
||||
LOCAL_TrailTop --> | |
|
||||
-----------
|
||||
-----------
|
||||
************************************************************************/
|
||||
CACHE_REGS
|
||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||
@ -1005,33 +1005,33 @@ static inline ans_node_ptr answer_search_loop(sg_fr_ptr sg_fr, ans_node_ptr curr
|
||||
#endif /* MODE_TERMS_LOOP */
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
/************************************************************************
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
TR --> | VAR_0 | <-- stack_vars_base
|
||||
----------- *
|
||||
| ... | /|\
|
||||
----------- | vars_arity (N+1)
|
||||
| VAR_N | \|/
|
||||
----------- *
|
||||
| | <-- stack_terms_limit
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
----------|
|
||||
| TERM_N | <-- stack_terms
|
||||
----------| *
|
||||
| ... | /|\
|
||||
----------| |
|
||||
| TERM_1 | |
|
||||
----------| |
|
||||
| NULL | \|/
|
||||
=========== *
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
TR --> | VAR_0 | <-- stack_vars_base
|
||||
----------- *
|
||||
| ... | /|\
|
||||
----------- | vars_arity (N+1)
|
||||
| VAR_N | \|/
|
||||
----------- *
|
||||
| | <-- stack_terms_limit
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
----------|
|
||||
| TERM_N | <-- stack_terms
|
||||
----------| *
|
||||
| ... | /|\
|
||||
----------| |
|
||||
| TERM_1 | |
|
||||
----------| |
|
||||
| NULL | \|/
|
||||
=========== *
|
||||
LOCAL_TrailTop --> | |
|
||||
-----------
|
||||
-----------
|
||||
************************************************************************/
|
||||
CACHE_REGS
|
||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||
@ -1219,31 +1219,31 @@ static inline CELL *load_substitution_loop(gt_node_ptr current_node, int *vars_a
|
||||
static inline CELL *load_answer_loop(ans_node_ptr current_node) {
|
||||
#endif /* MODE_GLOBAL_TRIE_LOOP */
|
||||
/************************************************************************
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
TR --> | VAR_0 | <-- stack_vars_base
|
||||
----------- *
|
||||
| ... | /|\
|
||||
----------- | vars_arity (N+1)
|
||||
| VAR_N | \|/
|
||||
----------- *
|
||||
| | <-- stack_terms_limit
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
----------|
|
||||
| TERM_N | <-- stack_terms
|
||||
----------| *
|
||||
| ... | /|\
|
||||
----------| | stack_terms_pair_offset (TRIE_COMPACT_PAIRS)
|
||||
| TERM_1 | \|/
|
||||
=========== *
|
||||
===========
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
-----------
|
||||
TR --> | VAR_0 | <-- stack_vars_base
|
||||
----------- *
|
||||
| ... | /|\
|
||||
----------- | vars_arity (N+1)
|
||||
| VAR_N | \|/
|
||||
----------- *
|
||||
| | <-- stack_terms_limit
|
||||
-----------
|
||||
| |
|
||||
| ... |
|
||||
| |
|
||||
----------|
|
||||
| TERM_N | <-- stack_terms
|
||||
----------| *
|
||||
| ... | /|\
|
||||
----------| | stack_terms_pair_offset (TRIE_COMPACT_PAIRS)
|
||||
| TERM_1 | \|/
|
||||
=========== *
|
||||
LOCAL_TrailTop --> | | <-- stack_terms_base (TRIE_COMPACT_PAIRS)
|
||||
-----------
|
||||
-----------
|
||||
************************************************************************/
|
||||
CACHE_REGS
|
||||
#ifdef MODE_GLOBAL_TRIE_LOOP
|
||||
|
166
pl/tabling.yap
166
pl/tabling.yap
@ -17,8 +17,72 @@
|
||||
tabling_mode(:,?),
|
||||
abolish_table(:),
|
||||
show_table(:),
|
||||
show_table(?,:),
|
||||
table_statistics(:),
|
||||
table_statistics(:,:).
|
||||
table_statistics(?,:).
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% show_tabled_predicates/0 %%
|
||||
%% show_global_trie/0 %%
|
||||
%% show_all_tables/0 %%
|
||||
%% show_all_local_tables/0 %%
|
||||
%% global_trie_statistics/0 %%
|
||||
%% tabling_statistics/0 %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
show_tabled_predicates :-
|
||||
current_output(Stream),
|
||||
show_tabled_predicates(Stream).
|
||||
|
||||
show_global_trie :-
|
||||
current_output(Stream),
|
||||
show_global_trie(Stream).
|
||||
|
||||
show_all_tables :-
|
||||
current_output(Stream),
|
||||
show_all_tables(Stream).
|
||||
|
||||
show_all_local_tables :-
|
||||
current_output(Stream),
|
||||
show_all_local_tables(Stream).
|
||||
|
||||
global_trie_statistics :-
|
||||
current_output(Stream),
|
||||
global_trie_statistics(Stream).
|
||||
|
||||
tabling_statistics :-
|
||||
current_output(Stream),
|
||||
tabling_statistics(Stream).
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% tabling_statistics/2 %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
%% should match with code in OPTYap/opt.preds.c
|
||||
tabling_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
|
||||
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
|
||||
tabling_statistics(table_entries,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(1,BytesInUse,StructsInUse).
|
||||
tabling_statistics(subgoal_frames,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(2,BytesInUse,StructsInUse).
|
||||
tabling_statistics(dependency_frames,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(3,BytesInUse,StructsInUse).
|
||||
tabling_statistics(subgoal_trie_nodes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(6,BytesInUse,StructsInUse).
|
||||
tabling_statistics(answer_trie_nodes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(7,BytesInUse,StructsInUse).
|
||||
tabling_statistics(subgoal_trie_hashes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(8,BytesInUse,StructsInUse).
|
||||
tabling_statistics(answer_trie_hashes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(9,BytesInUse,StructsInUse).
|
||||
tabling_statistics(global_trie_nodes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(10,BytesInUse,StructsInUse).
|
||||
tabling_statistics(global_trie_hashes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(11,BytesInUse,StructsInUse).
|
||||
|
||||
|
||||
|
||||
@ -195,98 +259,80 @@ abolish_table(Pred) :-
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% show_table/1 %%
|
||||
%% show_table/2 %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
show_table(Pred) :-
|
||||
'$current_module'(Mod),
|
||||
'$do_show_table'(Mod,Pred).
|
||||
current_output(Stream),
|
||||
show_table(Stream,Pred).
|
||||
|
||||
'$do_show_table'(Mod,Pred) :-
|
||||
show_table(Stream,Pred) :-
|
||||
'$current_module'(Mod),
|
||||
'$do_show_table'(Stream,Mod,Pred).
|
||||
|
||||
'$do_show_table'(_,Mod,Pred) :-
|
||||
var(Pred), !,
|
||||
'$do_error'(instantiation_error,show_table(Mod:Pred)).
|
||||
'$do_show_table'(_,Mod:Pred) :- !,
|
||||
'$do_show_table'(Mod,Pred).
|
||||
'$do_show_table'(_,[]) :- !.
|
||||
'$do_show_table'(Mod,[HPred|TPred]) :- !,
|
||||
'$do_show_table'(Mod,HPred),
|
||||
'$do_show_table'(Mod,TPred).
|
||||
'$do_show_table'(Mod,(Pred1,Pred2)) :- !,
|
||||
'$do_show_table'(Mod,Pred1),
|
||||
'$do_show_table'(Mod,Pred2).
|
||||
'$do_show_table'(Mod,PredName/PredArity) :-
|
||||
'$do_show_table'(Stream,_,Mod:Pred) :- !,
|
||||
'$do_show_table'(Stream,Mod,Pred).
|
||||
'$do_show_table'(_,_,[]) :- !.
|
||||
'$do_show_table'(Stream,Mod,[HPred|TPred]) :- !,
|
||||
'$do_show_table'(Stream,Mod,HPred),
|
||||
'$do_show_table'(Stream,Mod,TPred).
|
||||
'$do_show_table'(Stream,Mod,(Pred1,Pred2)) :- !,
|
||||
'$do_show_table'(Stream,Mod,Pred1),
|
||||
'$do_show_table'(Stream,Mod,Pred2).
|
||||
'$do_show_table'(Stream,Mod,PredName/PredArity) :-
|
||||
atom(PredName),
|
||||
integer(PredArity),
|
||||
functor(PredFunctor,PredName,PredArity),
|
||||
'$flags'(PredFunctor,Mod,Flags,Flags), !,
|
||||
(
|
||||
Flags /\ 0x000040 =\= 0, !, '$c_show_table'(Mod,PredFunctor)
|
||||
Flags /\ 0x000040 =\= 0, !, '$c_show_table'(Stream,Mod,PredFunctor)
|
||||
;
|
||||
'$do_error'(domain_error(table,Mod:PredName/PredArity),show_table(Mod:PredName/PredArity))
|
||||
).
|
||||
'$do_show_table'(Mod,Pred) :-
|
||||
'$do_show_table'(_,Mod,Pred) :-
|
||||
'$do_error'(type_error(callable,Mod:Pred),show_table(Mod:Pred)).
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% table_statistics/1 %%
|
||||
%% table_statistics/2 %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
table_statistics(Pred) :-
|
||||
'$current_module'(Mod),
|
||||
'$do_table_statistics'(Mod,Pred).
|
||||
current_output(Stream),
|
||||
table_statistics(Stream,Pred).
|
||||
|
||||
'$do_table_statistics'(Mod,Pred) :-
|
||||
table_statistics(Stream,Pred) :-
|
||||
'$current_module'(Mod),
|
||||
'$do_table_statistics'(Stream,Mod,Pred).
|
||||
|
||||
'$do_table_statistics'(_,Mod,Pred) :-
|
||||
var(Pred), !,
|
||||
'$do_error'(instantiation_error,table_statistics(Mod:Pred)).
|
||||
'$do_table_statistics'(_,Mod:Pred) :- !,
|
||||
'$do_table_statistics'(Mod,Pred).
|
||||
'$do_table_statistics'(_,[]) :- !.
|
||||
'$do_table_statistics'(Mod,[HPred|TPred]) :- !,
|
||||
'$do_table_statistics'(Mod,HPred),
|
||||
'$do_table_statistics'(Mod,TPred).
|
||||
'$do_table_statistics'(Mod,(Pred1,Pred2)) :- !,
|
||||
'$do_table_statistics'(Mod,Pred1),
|
||||
'$do_table_statistics'(Mod,Pred2).
|
||||
'$do_table_statistics'(Mod,PredName/PredArity) :-
|
||||
'$do_table_statistics'(Stream,_,Mod:Pred) :- !,
|
||||
'$do_table_statistics'(Stream,Mod,Pred).
|
||||
'$do_table_statistics'(_,_,[]) :- !.
|
||||
'$do_table_statistics'(Stream,Mod,[HPred|TPred]) :- !,
|
||||
'$do_table_statistics'(Stream,Mod,HPred),
|
||||
'$do_table_statistics'(Stream,Mod,TPred).
|
||||
'$do_table_statistics'(Stream,Mod,(Pred1,Pred2)) :- !,
|
||||
'$do_table_statistics'(Stream,Mod,Pred1),
|
||||
'$do_table_statistics'(Stream,Mod,Pred2).
|
||||
'$do_table_statistics'(Stream,Mod,PredName/PredArity) :-
|
||||
atom(PredName),
|
||||
integer(PredArity),
|
||||
functor(PredFunctor,PredName,PredArity),
|
||||
'$flags'(PredFunctor,Mod,Flags,Flags), !,
|
||||
(
|
||||
Flags /\ 0x000040 =\= 0, !, '$c_table_statistics'(Mod,PredFunctor)
|
||||
Flags /\ 0x000040 =\= 0, !, '$c_table_statistics'(Stream,Mod,PredFunctor)
|
||||
;
|
||||
'$do_error'(domain_error(table,Mod:PredName/PredArity),table_statistics(Mod:PredName/PredArity))
|
||||
).
|
||||
'$do_table_statistics'(Mod,Pred) :-
|
||||
'$do_table_statistics'(_,Mod,Pred) :-
|
||||
'$do_error'(type_error(callable,Mod:Pred),table_statistics(Mod:Pred)).
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% tabling_statistics/2 %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
%% should match with code in OPTYap/opt.preds.c
|
||||
tabling_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
|
||||
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
|
||||
tabling_statistics(table_entries,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(1,BytesInUse,StructsInUse).
|
||||
tabling_statistics(subgoal_frames,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(2,BytesInUse,StructsInUse).
|
||||
tabling_statistics(dependency_frames,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(3,BytesInUse,StructsInUse).
|
||||
tabling_statistics(subgoal_trie_nodes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(6,BytesInUse,StructsInUse).
|
||||
tabling_statistics(answer_trie_nodes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(7,BytesInUse,StructsInUse).
|
||||
tabling_statistics(subgoal_trie_hashes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(8,BytesInUse,StructsInUse).
|
||||
tabling_statistics(answer_trie_hashes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(9,BytesInUse,StructsInUse).
|
||||
tabling_statistics(global_trie_nodes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(10,BytesInUse,StructsInUse).
|
||||
tabling_statistics(global_trie_hashes,[BytesInUse,StructsInUse]) :-
|
||||
'$c_get_optyap_statistics'(11,BytesInUse,StructsInUse).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
17
pl/yapor.yap
17
pl/yapor.yap
@ -12,12 +12,25 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:- meta_predicate
|
||||
or_statistics(:,:),
|
||||
opt_statistics(:,:),
|
||||
default_sequential(:).
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% or_statistics/0 %%
|
||||
%% opt_statistics/0 %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
or_statistics :-
|
||||
current_output(Stream),
|
||||
or_statistics(Stream).
|
||||
|
||||
opt_statistics :-
|
||||
current_output(Stream),
|
||||
opt_statistics(Stream).
|
||||
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% or_statistics/2 %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
Reference in New Issue
Block a user