Merge branch 'master' of git.dcc.fc.up.pt:yap-6.3
This commit is contained in:
commit
53b694edd0
@ -13086,7 +13086,7 @@ Yap_absmi(int inp)
|
||||
goto fail;
|
||||
}
|
||||
PP = PredMetaCall;
|
||||
SREG = (CELL *) pen;
|
||||
SREG = (CELL *) PP;
|
||||
ASP = ENV_YREG;
|
||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
||||
@ -13097,7 +13097,7 @@ Yap_absmi(int inp)
|
||||
goto creep_pe;
|
||||
}
|
||||
saveregs_and_ycache();
|
||||
if (!Yap_gc(((PredEntry *)SREG)->ArityOfPE, ENV, NEXTOP(PREG, Osbpp))) {
|
||||
if (!Yap_gc(PP->ArityOfPE, ENV, NEXTOP(PREG, Osbpp))) {
|
||||
Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage);
|
||||
}
|
||||
setregs_and_ycache();
|
||||
@ -13295,7 +13295,7 @@ Yap_absmi(int inp)
|
||||
goto fail;
|
||||
}
|
||||
PP = PredMetaCall;
|
||||
SREG = (CELL *) pen;
|
||||
SREG = (CELL *) PP;
|
||||
ASP = ENV_YREG;
|
||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
||||
@ -13306,7 +13306,7 @@ Yap_absmi(int inp)
|
||||
goto creep_pe;
|
||||
}
|
||||
saveregs_and_ycache();
|
||||
if (!Yap_gc(((PredEntry *)SREG)->ArityOfPE, ENV, NEXTOP(PREG, Osbmp))) {
|
||||
if (!Yap_gc(PP->ArityOfPE, ENV, NEXTOP(PREG, Osbmp))) {
|
||||
Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage);
|
||||
}
|
||||
setregs_and_ycache();
|
||||
|
@ -3953,9 +3953,10 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
((LogUpdClause *)(cip->code_addr))->ClSize = size;
|
||||
Yap_LUClauseSpace += size;
|
||||
} else
|
||||
} else {
|
||||
((StaticClause *)(cip->code_addr))->ClSize = size;
|
||||
Yap_ClauseSpace += size;
|
||||
}
|
||||
} else {
|
||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||
Yap_LUIndexSpace_Tree += size;
|
||||
|
@ -435,6 +435,8 @@ X_API Int STD_PROTO(YAP_Init,(YAP_init_args *));
|
||||
X_API Int STD_PROTO(YAP_FastInit,(char *));
|
||||
X_API PredEntry *STD_PROTO(YAP_FunctorToPred,(Functor));
|
||||
X_API PredEntry *STD_PROTO(YAP_AtomToPred,(Atom));
|
||||
X_API PredEntry *STD_PROTO(YAP_FunctorToPredInModule,(Functor, Term));
|
||||
X_API PredEntry *STD_PROTO(YAP_AtomToPredInModule,(Atom, Term));
|
||||
X_API Int STD_PROTO(YAP_CallProlog,(Term));
|
||||
X_API void *STD_PROTO(YAP_AllocSpaceFromYap,(unsigned int));
|
||||
X_API void *STD_PROTO(YAP_ReallocSpaceFromYap,(void*,unsigned int));
|
||||
@ -2249,6 +2251,20 @@ YAP_AtomToPred(Atom at)
|
||||
return RepPredProp(PredPropByAtom(at, CurrentModule));
|
||||
}
|
||||
|
||||
X_API PredEntry *
|
||||
YAP_FunctorToPredInModule(Functor func, Term mod)
|
||||
{
|
||||
CACHE_REGS
|
||||
return RepPredProp(PredPropByFunc(func, mod));
|
||||
}
|
||||
|
||||
X_API PredEntry *
|
||||
YAP_AtomToPredInModule(Atom at, Term mod)
|
||||
{
|
||||
CACHE_REGS
|
||||
return RepPredProp(PredPropByAtom(at, mod));
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
run_emulator(YAP_dogoalinfo *dgi)
|
||||
|
@ -357,4 +357,5 @@
|
||||
|
||||
#undef MAX_THREADS
|
||||
|
||||
#endif /* YAP_CONFIG_H */
|
||||
#endif /* YAP_CONFIG_H */
|
||||
|
||||
|
@ -234,7 +234,6 @@ AC_ARG_WITH(gmp,
|
||||
CFLAGS="$CFLAGS -I${yap_cv_gmp}/include"
|
||||
fi,
|
||||
[yap_cv_gmp=yes])
|
||||
|
||||
AC_ARG_WITH(R,
|
||||
[ --with-R[=DIR] interface to R language],
|
||||
if test "$withval" = yes; then
|
||||
@ -854,7 +853,7 @@ fi
|
||||
|
||||
if test "$yap_cv_cudd" != no; then
|
||||
oldlibs="$LIBS"
|
||||
if test "$yap_cv_cudd" != "NONE"; then
|
||||
if test "$yap_cv_cudd" != "NONE" -a "$yap_cv_cudd" != "yes"; then
|
||||
CUDD_CPPFLAGS="-I $yap_cv_cudd/include"
|
||||
cudd_dir="$yap_cv_cudd"
|
||||
elif test "$prefix" != "NONE"; then
|
||||
@ -864,9 +863,8 @@ if test "$yap_cv_cudd" != no; then
|
||||
CUDD_CPPFLAGS="-I /usr/local/include"
|
||||
cudd_dir=/usr/local
|
||||
fi
|
||||
OLD_CFLAGS="$CPPFLAGS"
|
||||
OLD_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $CUDD_CPPFLAGS"
|
||||
CPPFLAGS="$OLD_CFLAGS"
|
||||
AC_CHECK_HEADERS(util.h cudd/util.h cudd.h cudd/cudd.h)
|
||||
AC_CHECK_HEADERS(cuddInt.h cudd/cuddInt.h)
|
||||
dnl cudd can be most everywhere
|
||||
@ -899,6 +897,7 @@ if test "$yap_cv_cudd" != no; then
|
||||
LIBS="$LIBS -L $cudd_dir/cudd"
|
||||
fi
|
||||
AC_SEARCH_LIBS(Cudd_Init, [cudd], [cudd_installed="yes"], [cudd_installed="no"])
|
||||
CPPFLAGS="$OLD_CPPFLAGS"
|
||||
if test "$cudd_installed" = yes; then
|
||||
CUDD_LDFLAGS="$LIBS"
|
||||
else
|
||||
|
62
docs/yap.tex
62
docs/yap.tex
@ -200,6 +200,7 @@ Subnodes of Library
|
||||
* Heaps:: Labelled binary tree where the key of each node is less
|
||||
than or equal to the keys of its children.
|
||||
* Lambda:: Ulrich Neumerkel's Lambda Library
|
||||
* DBUsage:: Information bout data base usage.
|
||||
* LineUtilities:: Line Manipulation Utilities
|
||||
* Lists:: List Manipulation
|
||||
* MapList:: SWI-Compatible Apply library.
|
||||
@ -8660,6 +8661,7 @@ Library, Extensions, Built-ins, Top
|
||||
than or equal to the keys of its children.
|
||||
* LAM:: LAM MPI
|
||||
* Lambda:: Ulrich Neumerkel's Lambda Library
|
||||
* DBUsage:: Information bout data base usage.
|
||||
* Lists:: List Manipulation
|
||||
* LineUtilities:: Line Manipulation Utilities
|
||||
* MapList:: SWI-Compatible Apply library.
|
||||
@ -12697,7 +12699,7 @@ The vertices @var{Vertices} have no outgoing edge in graph
|
||||
|
||||
@end table
|
||||
|
||||
@node UnDGraphs, Lambda , DGraphs, Library
|
||||
@node UnDGraphs, DBUsage , DGraphs, Library
|
||||
@section Undirected Graphs
|
||||
@cindex undirected graphs
|
||||
|
||||
@ -12793,7 +12795,50 @@ directed graph @var{DGraph}.
|
||||
|
||||
@end table
|
||||
|
||||
@node Lambda, LAM, UnDGraphs, Library
|
||||
@node DBUsage, Lambda, UnDGraphs, Library
|
||||
@section Memory Usage in Prolog Data-Base
|
||||
@cindex DBUsage
|
||||
|
||||
This library provides a set of utilities for studying memory usage in YAP.
|
||||
The following routines are available once included with the
|
||||
@code{use_module(library(dbusage))} command.
|
||||
|
||||
@table @code
|
||||
@item db_usage
|
||||
@findex db_usage/0
|
||||
@snindex db_usage/0
|
||||
@cnindex db_usage/0
|
||||
Give general overview of data-base usage in the system.
|
||||
|
||||
@item db_static
|
||||
@findex db_static/0
|
||||
@snindex db_static/0
|
||||
@cnindex db_static/0
|
||||
List memory usage for every static predicate.
|
||||
|
||||
@item db_static(+@var{Threshold})
|
||||
@findex db_static/0
|
||||
@snindex db_static/0
|
||||
@cnindex db_static/0
|
||||
List memory usage for every static predicate. Predicate must use more
|
||||
than @var{Threshold} bytes.
|
||||
|
||||
@item db_dynamic
|
||||
@findex db_dynamic/0
|
||||
@snindex db_dynamic/0
|
||||
@cnindex db_dynamic/0
|
||||
List memory usage for every dynamic predicate.
|
||||
|
||||
@item db_dynamic(+@var{Threshold})
|
||||
@findex db_dynamic/0
|
||||
@snindex db_dynamic/0
|
||||
@cnindex db_dynamic/0
|
||||
List memory usage for every dynamic predicate. Predicate must use more
|
||||
than @var{Threshold} bytes.
|
||||
|
||||
@end table
|
||||
|
||||
@node Lambda, LAM, DBUsage, Library
|
||||
@section Lambda Expressions
|
||||
@cindex Lambda Expressions
|
||||
|
||||
@ -16923,6 +16968,19 @@ Return the predicate whose main functor is @var{f}.
|
||||
@findex YAP_AtomToPred (C-Interface function)
|
||||
Return the arity 0 predicate whose name is @var{at}.
|
||||
|
||||
@item @code{YAP_PredEntryPtr}
|
||||
YAP_FunctorToPredInModule(@code{YAP_Functor} @var{f}, @code{YAP_Module} @var{m}),
|
||||
@findex YAP_FunctorToPredInModule (C-Interface function)
|
||||
Return the predicate in module @var{m} whose main functor is @var{f}.
|
||||
|
||||
@item @code{YAP_PredEntryPtr} YAP_AtomToPred(@code{YAP_Atom} @var{at},
|
||||
@findex YAP_AtomToPred (C-Interface function)
|
||||
Return the arity 0 predicate whose name is @var{at}.
|
||||
|
||||
@item @code{YAP_PredEntryPtr} YAP_AtomToPred(@code{YAP_Atom} @var{at}, @code{YAP_Module} @var{m}),
|
||||
@findex YAP_AtomToPredInModule (C-Interface function)
|
||||
Return the arity 0 predicate in module @var{m} whose name is @var{at}.
|
||||
|
||||
@item @code{YAP_Bool} YAP_EnterGoal(@code{YAP_PredEntryPtr} @var{pe},
|
||||
@code{YAP_Term *} @var{array}, @code{YAP_dogoalinfo *} @var{infop})
|
||||
@findex YAP_EnterGoal (C-Interface function)
|
||||
|
@ -296,6 +296,11 @@ extern X_API YAP_PredEntryPtr PROTO(YAP_FunctorToPred,(YAP_Functor));
|
||||
/* int YAP_AtomToPred(struct pred_entry *, YAP_Term *) */
|
||||
extern X_API YAP_PredEntryPtr PROTO(YAP_AtomToPred,(YAP_Atom));
|
||||
|
||||
extern X_API YAP_PredEntryPtr PROTO(YAP_FunctorToPredInModule,(YAP_Functor, YAP_Module));
|
||||
|
||||
/* int YAP_AtomToPred(struct pred_entry *, YAP_Term *) */
|
||||
extern X_API YAP_PredEntryPtr PROTO(YAP_AtomToPredInModule,(YAP_Atom, YAP_Module));
|
||||
|
||||
/* int YAP_EnterGoal(void) */
|
||||
extern X_API YAP_Bool PROTO(YAP_EnterGoal,(YAP_PredEntryPtr, YAP_Term *, YAP_dogoalinfo *));
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
:- module(dbusage, [
|
||||
db_usage/0,
|
||||
db_static/0,
|
||||
db_dynamic/0
|
||||
db_static/1,
|
||||
db_dynamic/0,
|
||||
db_dynamic/1
|
||||
]).
|
||||
|
||||
db_usage :-
|
||||
@ -13,8 +15,8 @@ db_usage :-
|
||||
HeapUsedK is HeapUsed//1024,
|
||||
HeapFreeK is HeapFree//1024,
|
||||
StackSpace is (GInU+SInU+FreeS+TInU+FreeT)//1024,
|
||||
format(user_error, 'Heap Space = ~d KB (+ ~dKB free)~n',[HeapUsedK,HeapFreeK]),
|
||||
format(user_error, 'Stack Space = ~d KB~n',[StackSpace]),
|
||||
format(user_error, 'Heap Space = ~D KB (+ ~D KB free)~n',[HeapUsedK,HeapFreeK]),
|
||||
format(user_error, 'Stack Space = ~D KB~n',[StackSpace]),
|
||||
findall(p(Cls,CSz,ISz),
|
||||
(current_module(M),
|
||||
current_predicate(_,M:P),
|
||||
@ -22,12 +24,12 @@ db_usage :-
|
||||
sumall(LAll, TCls, TCSz, TISz),
|
||||
statistics(atoms,[AtomN,AtomS]),
|
||||
AtomSK is AtomS//1024,
|
||||
format(user_error, '~d Atoms taking ~d KB~n',[AtomN,AtomSK]),
|
||||
format(user_error, '~D Atoms taking ~D KB~n',[AtomN,AtomSK]),
|
||||
TSz is TCSz+TISz,
|
||||
TSzK is TSz//1024,
|
||||
TCSzK is TCSz//1024,
|
||||
TISzK is TISz//1024,
|
||||
format(user_error, 'Total User Code~n ~d clauses taking ~d KB~n ~d KB in clauses + ~d KB in indices~n',
|
||||
format(user_error, 'Total User Code~n ~D clauses taking ~D KB~n ~D KB in clauses + ~D KB in indices~n',
|
||||
[TCls,TSzK,TCSzK,TISzK]),
|
||||
statistics(static_code,[SCl,SI,SI1,SI2,SI3]),
|
||||
SClK is SCl//1024,
|
||||
@ -37,7 +39,7 @@ db_usage :-
|
||||
SI3K is SI3//1024,
|
||||
ST is SCl+SI,
|
||||
STK is ST//1024,
|
||||
format(user_error, 'Total Static code=~d KB~n ~dKB in clauses + ~dKB in indices (~d+~d+~d)~n',
|
||||
format(user_error, 'Total Static code=~D KB~n ~D KB in clauses + ~D KB in indices (~D+~D+~D)~n',
|
||||
[STK,SClK,SIK,SI1K,SI2K,SI3K]),
|
||||
statistics(dynamic_code,[DCl,DI,DI1,DI2,DI3,DI4]),
|
||||
DClK is DCl//1024,
|
||||
@ -48,20 +50,20 @@ db_usage :-
|
||||
DI4K is DI4//1024,
|
||||
DT is DCl+DI,
|
||||
DTK is DT//1024,
|
||||
format(user_error, 'Total Dynamic code=~d KB~n ~dKB in clauses + ~dKB in indices (~d+~d+~d+~d)~n',
|
||||
format(user_error, 'Total Dynamic code=~D KB~n ~D KB in clauses + ~D KB in indices (~D+~D+~D+~D)~n',
|
||||
[DTK,DClK,DIK,DI1K,DI2K,DI3K,DI4K]),
|
||||
total_erased(DCls,DSZ,ICls,ISZ),
|
||||
(DCls =:= 0 ->
|
||||
true
|
||||
;
|
||||
DSZK is DSZ//1024,
|
||||
format(user_error, ' ~d erased clauses not reclaimed (~dKB)~n',[DCls,DSZK])
|
||||
format(user_error, ' ~D erased clauses not reclaimed (~D KB)~n',[DCls,DSZK])
|
||||
),
|
||||
(ICls =:= 0 ->
|
||||
true
|
||||
;
|
||||
ISZK is ISZ//1024,
|
||||
format(user_error, ' ~d erased indices not reclaimed (~dKB)~n',[ICls,ISZK])
|
||||
format(user_error, ' ~D erased indices not reclaimed (~D KB)~n',[ICls,ISZK])
|
||||
),
|
||||
!.
|
||||
|
||||
@ -70,23 +72,31 @@ db_usage:-
|
||||
|
||||
|
||||
db_static :-
|
||||
db_static(-1).
|
||||
|
||||
db_static(Min) :-
|
||||
setof(p(Sz,M:P,Cls,CSz,ISz),
|
||||
PN^(current_module(M),
|
||||
current_predicate(PN,M:P),
|
||||
\+ predicate_property(M:P,dynamic),
|
||||
predicate_statistics(M:P,Cls,CSz,ISz),
|
||||
Sz is (CSz+ISz)),All),
|
||||
Sz is (CSz+ISz),
|
||||
Sz > Min),All),
|
||||
format(user_error,' Static user code~n===========================~n',[]),
|
||||
display_preds(All).
|
||||
|
||||
db_dynamic :-
|
||||
db_dynamic(-1).
|
||||
|
||||
db_dynamic(Min) :-
|
||||
setof(p(Sz,M:P,Cls,CSz,ISz,ECls,ECSz,EISz),
|
||||
PN^(current_module(M),
|
||||
current_predicate(PN,M:P),
|
||||
predicate_property(M:P,dynamic),
|
||||
predicate_statistics(M:P,Cls,CSz,ISz),
|
||||
predicate_erased_statistics(M:P,ECls,ECSz,EISz),
|
||||
Sz is (CSz+ISz+ECSz+EISz)),
|
||||
Sz is (CSz+ISz+ECSz+EISz),
|
||||
Sz > Min),
|
||||
All),
|
||||
format(user_error,' Dynamic user code~n===========================~n',[]),
|
||||
display_dpreds(All).
|
||||
@ -98,7 +108,7 @@ display_preds([p(Sz,M:P,Cls,CSz,ISz)|_]) :-
|
||||
KCSz is CSz//1024,
|
||||
KISz is ISz//1024,
|
||||
(M = user -> Name = A/N ; Name = M:A/N),
|
||||
format(user_error,'~w~t~36+:~t~d~7+ clauses using~|~t~d~8+ KB (~d + ~d)~n',[Name,Cls,KSz,KCSz,KISz]),
|
||||
format(user_error,'~w~t~36+:~t~D~7+ clauses using~|~t~D~8+ KB (~D + ~D)~n',[Name,Cls,KSz,KCSz,KISz]),
|
||||
fail.
|
||||
display_preds([_|All]) :-
|
||||
display_preds(All).
|
||||
@ -111,20 +121,20 @@ display_dpreds([p(Sz,M:P,Cls,CSz,ISz,ECls,ECSz,EISz)|_]) :-
|
||||
KCSz is CSz//1024,
|
||||
KISz is ISz//1024,
|
||||
(M = user -> Name = A/N ; Name = M:A/N),
|
||||
format(user_error,'~w~t~36+:~t~d~7+ clauses using~|~t~d~8+ KB (~d + ~d)~n',[Name,Cls,KSz,KCSz,KISz]),
|
||||
format(user_error,'~w~t~36+:~t~D~7+ clauses using~|~t~D~8+ KB (~D + ~D)~n',[Name,Cls,KSz,KCSz,KISz]),
|
||||
(ECls =:= 0
|
||||
->
|
||||
true
|
||||
;
|
||||
ECSzK is ECSz//1024,
|
||||
format(user_error,' ~d erased clauses: ~d KB~n',[ECls,ECSzK])
|
||||
format(user_error,' ~D erased clauses: ~D KB~n',[ECls,ECSzK])
|
||||
),
|
||||
(EISz =:= 0
|
||||
->
|
||||
true
|
||||
;
|
||||
EISzK is EISz//1024,
|
||||
format(user_error,' ~d KB erased indices~n',[EISzK])
|
||||
format(user_error,' ~D KB erased indices~n',[EISzK])
|
||||
),
|
||||
fail.
|
||||
display_dpreds([_|All]) :-
|
||||
|
@ -40,7 +40,7 @@ CWD=$(PWD)
|
||||
|
||||
DYNAMIC =
|
||||
CFLAGS = @CFLAGS@
|
||||
INCLUDE = @CUDD_CPPFLAGS@
|
||||
INCLUDE = -I@abs_top_builddir@ @CUDD_CPPFLAGS@
|
||||
LINKFLAGS = -lm
|
||||
LINKLIBS = @CUDD_LDFLAGS@
|
||||
|
||||
|
@ -192,7 +192,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include "../../../config.h"
|
||||
#include "config.h"
|
||||
#if HAVE_UTIL_H
|
||||
#include <util.h>
|
||||
#endif
|
||||
|
@ -40,7 +40,7 @@ CWD=$(PWD)
|
||||
|
||||
DYNAMIC =
|
||||
CFLAGS = @CFLAGS@
|
||||
INCLUDE = @CUDD_CPPFLAGS@
|
||||
INCLUDE = -I@abs_top_builddir@ @CUDD_CPPFLAGS@
|
||||
LINKFLAGS = -lm
|
||||
LINKLIBS = @CUDD_LDFLAGS@
|
||||
|
||||
|
@ -191,7 +191,7 @@
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include "pqueue.h"
|
||||
#include "../../../config.h"
|
||||
#include "config.h"
|
||||
#if HAVE_UTIL_H
|
||||
#include <util.h>
|
||||
#endif
|
||||
|
@ -893,6 +893,7 @@ predicate_statistics(P,NCls,Sz,ISz) :-
|
||||
'$static_pred_statistics'(P,M,NCls,Sz,ISz).
|
||||
|
||||
predicate_erased_statistics(P,NCls,Sz,ISz) :-
|
||||
var(P), !,
|
||||
current_predicate(_,P),
|
||||
predicate_erased_statistics(P,NCls,Sz,ISz).
|
||||
predicate_erased_statistics(M:P,NCls,Sz,ISz) :- !,
|
||||
|
Reference in New Issue
Block a user