Low Profiler Update
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1004 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
e9657e74c5
commit
6198cdb4bc
14
C/cdmgr.c
14
C/cdmgr.c
@ -3476,7 +3476,7 @@ add_code_in_pred(PredEntry *pp) {
|
|||||||
clcode = pp->CodeOfPred;
|
clcode = pp->CodeOfPred;
|
||||||
cl = ClauseCodeToStaticClause(clcode);
|
cl = ClauseCodeToStaticClause(clcode);
|
||||||
code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl);
|
code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl);
|
||||||
Yap_inform_profiler_of_clause(clcode, (yamop *)code_end, pp);
|
Yap_inform_profiler_of_clause(clcode, (yamop *)code_end, pp,0);
|
||||||
READ_UNLOCK(pp->PRWLock);
|
READ_UNLOCK(pp->PRWLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3490,7 +3490,7 @@ add_code_in_pred(PredEntry *pp) {
|
|||||||
StaticIndex *cl = ClauseCodeToStaticIndex(clcode);
|
StaticIndex *cl = ClauseCodeToStaticIndex(clcode);
|
||||||
code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl);
|
code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl);
|
||||||
}
|
}
|
||||||
Yap_inform_profiler_of_clause(clcode, (yamop *)code_end, pp);
|
Yap_inform_profiler_of_clause(clcode, (yamop *)code_end, pp,0);
|
||||||
}
|
}
|
||||||
clcode = pp->cs.p_code.FirstClause;
|
clcode = pp->cs.p_code.FirstClause;
|
||||||
if (clcode != NULL) {
|
if (clcode != NULL) {
|
||||||
@ -3500,7 +3500,7 @@ add_code_in_pred(PredEntry *pp) {
|
|||||||
char *code_end;
|
char *code_end;
|
||||||
|
|
||||||
code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl);
|
code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl);
|
||||||
Yap_inform_profiler_of_clause(cl->ClCode, (yamop *)code_end, pp);
|
Yap_inform_profiler_of_clause(cl->ClCode, (yamop *)code_end, pp,0);
|
||||||
cl = cl->ClNext;
|
cl = cl->ClNext;
|
||||||
} while (cl != NULL);
|
} while (cl != NULL);
|
||||||
} else if (pp->PredFlags & DynamicPredFlag) {
|
} else if (pp->PredFlags & DynamicPredFlag) {
|
||||||
@ -3510,7 +3510,7 @@ add_code_in_pred(PredEntry *pp) {
|
|||||||
|
|
||||||
cl = (CODEADDR)ClauseCodeToDynamicClause(clcode);
|
cl = (CODEADDR)ClauseCodeToDynamicClause(clcode);
|
||||||
code_end = cl + Yap_SizeOfBlock((CODEADDR)cl);
|
code_end = cl + Yap_SizeOfBlock((CODEADDR)cl);
|
||||||
Yap_inform_profiler_of_clause(clcode, (yamop *)code_end, pp);
|
Yap_inform_profiler_of_clause(clcode, (yamop *)code_end, pp,0);
|
||||||
if (clcode == pp->cs.p_code.LastClause)
|
if (clcode == pp->cs.p_code.LastClause)
|
||||||
break;
|
break;
|
||||||
clcode = NextDynamicClause(clcode);
|
clcode = NextDynamicClause(clcode);
|
||||||
@ -3521,7 +3521,7 @@ add_code_in_pred(PredEntry *pp) {
|
|||||||
char *code_end;
|
char *code_end;
|
||||||
|
|
||||||
code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl);
|
code_end = (char *)cl + Yap_SizeOfBlock((CODEADDR)cl);
|
||||||
Yap_inform_profiler_of_clause(cl->ClCode, (yamop *)code_end, pp);
|
Yap_inform_profiler_of_clause(cl->ClCode, (yamop *)code_end, pp,0);
|
||||||
if (cl->ClCode == pp->cs.p_code.FirstClause)
|
if (cl->ClCode == pp->cs.p_code.FirstClause)
|
||||||
break;
|
break;
|
||||||
cl = cl->ClNext;
|
cl = cl->ClNext;
|
||||||
@ -3553,8 +3553,8 @@ Yap_dump_code_area_for_profiler(void) {
|
|||||||
pp = pp->NextPredOfModule;
|
pp = pp->NextPredOfModule;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Yap_inform_profiler_of_clause(COMMA_CODE, FAILCODE, RepPredProp(Yap_GetPredPropByFunc(FunctorComma,0)));
|
Yap_inform_profiler_of_clause(COMMA_CODE, FAILCODE, RepPredProp(Yap_GetPredPropByFunc(FunctorComma,0)),0);
|
||||||
Yap_inform_profiler_of_clause(FAILCODE, FAILCODE+1, RepPredProp(Yap_GetPredPropByAtom(AtomFail,0)));
|
Yap_inform_profiler_of_clause(FAILCODE, FAILCODE+1, RepPredProp(Yap_GetPredPropByAtom(AtomFail,0)),0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LOW_PROF */
|
#endif /* LOW_PROF */
|
||||||
|
@ -2908,9 +2908,11 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod, Term src)
|
|||||||
goto restart_compilation;
|
goto restart_compilation;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef LOW_PROF
|
||||||
if (ProfilerOn) {
|
if (ProfilerOn) {
|
||||||
Yap_inform_profiler_of_clause(acode, ProfEnd, cglobs.cint.CurrentPred);
|
Yap_inform_profiler_of_clause(acode, ProfEnd, cglobs.cint.CurrentPred,0);
|
||||||
}
|
}
|
||||||
|
#endif /* LOW_PROF */
|
||||||
return(acode);
|
return(acode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3438,9 +3438,11 @@ Yap_PredIsIndexable(PredEntry *ap)
|
|||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#ifdef LOW_PROF
|
||||||
if (ProfilerOn) {
|
if (ProfilerOn) {
|
||||||
Yap_inform_profiler_of_clause(indx_out, ProfEnd, ap);
|
Yap_inform_profiler_of_clause(indx_out, ProfEnd, ap,-1);
|
||||||
}
|
}
|
||||||
|
#endif /* LOW_PROF */
|
||||||
if (ap->PredFlags & LogUpdatePredFlag) {
|
if (ap->PredFlags & LogUpdatePredFlag) {
|
||||||
LogUpdIndex *cl = ClauseCodeToLogUpdIndex(indx_out);
|
LogUpdIndex *cl = ClauseCodeToLogUpdIndex(indx_out);
|
||||||
cl->ClFlags |= SwitchRootMask;
|
cl->ClFlags |= SwitchRootMask;
|
||||||
|
6
C/init.c
6
C/init.c
@ -1206,6 +1206,12 @@ Yap_exit (int value)
|
|||||||
#if defined(YAPOR)
|
#if defined(YAPOR)
|
||||||
unmap_memory();
|
unmap_memory();
|
||||||
#endif /* YAPOR */
|
#endif /* YAPOR */
|
||||||
|
|
||||||
|
#ifdef LOW_PROF
|
||||||
|
remove("PROFPREDS");
|
||||||
|
remove("PROFILING");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (! (Yap_PrologMode & BootMode) )
|
if (! (Yap_PrologMode & BootMode) )
|
||||||
Yap_ShutdownLoadForeign();
|
Yap_ShutdownLoadForeign();
|
||||||
exit(value);
|
exit(value);
|
||||||
|
312
C/stdpreds.c
312
C/stdpreds.c
@ -101,100 +101,108 @@ STD_PROTO(static Int p_access_yap_flags, (void));
|
|||||||
STD_PROTO(static Int p_set_yap_flags, (void));
|
STD_PROTO(static Int p_set_yap_flags, (void));
|
||||||
|
|
||||||
#ifdef LOW_PROF
|
#ifdef LOW_PROF
|
||||||
STD_PROTO(static Int useprof, (void));
|
|
||||||
STD_PROTO(static Int useprof0, (void));
|
|
||||||
STD_PROTO(static Int profres, (void));
|
|
||||||
STD_PROTO(static Int profres2, (void));
|
|
||||||
|
|
||||||
#define TIMER_DEFAULT 1000
|
#define TIMER_DEFAULT 1000
|
||||||
|
#define MORE_INFO_FILE 1
|
||||||
typedef struct prof_files {
|
|
||||||
FILE *f_prof, *f_preds;
|
|
||||||
} prof_files_struct;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Yap_inform_profiler_of_clause(yamop *code_start, yamop *code_end, PredEntry *pe) {
|
Yap_inform_profiler_of_clause(yamop *code_start, yamop *code_end, PredEntry *pe,int index_code) {
|
||||||
/*
|
static Int order=0;
|
||||||
I can only open once, otherwise I'll have heaps of trouble
|
|
||||||
whenever Yap changes directory
|
|
||||||
*/
|
|
||||||
ProfPreds++;
|
ProfPreds++;
|
||||||
if (FPreds != NULL) {
|
if (FPreds != NULL) {
|
||||||
fprintf(FPreds,"+%p %p %p %uld\n",code_start,code_end, pe, ProfCalls);
|
Int temp;
|
||||||
|
order++;
|
||||||
|
if (index_code) temp=-order; else temp=order;
|
||||||
|
fprintf(FPreds,"+%p %p %p %d",code_start,code_end, pe, temp);
|
||||||
|
#if MORE_INFO_FILE
|
||||||
|
if (pe->FunctorOfPred->KindOfPE==47872) {
|
||||||
|
if (pe->ArityOfPE) {
|
||||||
|
fprintf(FPreds," %s/%d", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE);
|
||||||
|
} else {
|
||||||
|
fprintf(FPreds," %s",RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
fprintf(FPreds,"\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__linux__)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prof_alrm(int signo)
|
prof_alrm(int signo)
|
||||||
{
|
{
|
||||||
ProfCalls++;
|
// printf("%p\n", Yap_regp->P_);
|
||||||
fprintf(FProf,"%p\n", P);
|
fprintf(FProf,"%p\n", Yap_regp->P_);
|
||||||
|
// fprintf(FProf,"%p\n", P);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int set_prof_timer(int msec) {
|
static Int start_profilers(int msec)
|
||||||
static int n=-1;
|
{
|
||||||
struct itimerval t;
|
struct itimerval t;
|
||||||
|
|
||||||
if (msec==0 || n>0) {
|
if (ProfilerOn==msec) return(TRUE);
|
||||||
|
|
||||||
|
if (ProfilerOn) {
|
||||||
setitimer(ITIMER_PROF,NULL,NULL);
|
setitimer(ITIMER_PROF,NULL,NULL);
|
||||||
n=0;
|
fclose(FPreds);
|
||||||
|
fclose(FProf);
|
||||||
|
ProfilerOn = 0;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signal(SIGPROF,prof_alrm) == SIG_ERR) {
|
if (signal(SIGPROF,prof_alrm) == SIG_ERR) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
n=1;
|
FPreds=fopen("PROFPREDS","w+");
|
||||||
|
if (FPreds == NULL) return FALSE;
|
||||||
|
FProf=fopen("PROFILING","w+");
|
||||||
|
if (FProf==NULL) { fclose(FPreds); return FALSE; }
|
||||||
|
|
||||||
|
Yap_dump_code_area_for_profiler();
|
||||||
|
|
||||||
t.it_interval.tv_sec=0;
|
t.it_interval.tv_sec=0;
|
||||||
t.it_interval.tv_usec=msec;
|
t.it_interval.tv_usec=msec;
|
||||||
t.it_value.tv_sec=0;
|
t.it_value.tv_sec=0;
|
||||||
t.it_value.tv_usec=msec;
|
t.it_value.tv_usec=msec;
|
||||||
setitimer(ITIMER_PROF,&t,NULL);
|
setitimer(ITIMER_PROF,&t,NULL);
|
||||||
|
|
||||||
|
ProfilerOn = msec;
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
#endif /* Linux */
|
||||||
start_profilers(void)
|
|
||||||
{
|
|
||||||
ProfCalls = 0L;
|
|
||||||
if (FPreds == NULL) {
|
|
||||||
FPreds=fopen("PROFPREDS","w+");
|
|
||||||
}
|
|
||||||
if (FPreds == NULL)
|
|
||||||
return;
|
|
||||||
Yap_dump_code_area_for_profiler();
|
|
||||||
if (FProf != NULL) {
|
|
||||||
/* close previous profiling session */
|
|
||||||
fclose(FProf);
|
|
||||||
}
|
|
||||||
FProf=fopen("PROFILING","w+");
|
|
||||||
if (FProf==NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProfilerOn = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Int useprof(void) {
|
static Int useprof(void) {
|
||||||
|
#if defined(__linux__)
|
||||||
Term p;
|
Term p;
|
||||||
|
|
||||||
p=Deref(ARG1);
|
p=Deref(ARG1);
|
||||||
start_profilers();
|
return(start_profilers(IntOfTerm(p)));
|
||||||
return (set_prof_timer(IntOfTerm(p)));
|
#else
|
||||||
|
return(FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int useprof0(void) {
|
static Int useprof0(void) {
|
||||||
|
#if defined(__linux__)
|
||||||
start_profilers();
|
return(start_profilers(TIMER_DEFAULT));
|
||||||
return(set_prof_timer(TIMER_DEFAULT));
|
#else
|
||||||
|
return(FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__linux__)
|
||||||
|
|
||||||
typedef struct clause_entry {
|
typedef struct clause_entry {
|
||||||
yamop *beg, *end;
|
yamop *beg, *end;
|
||||||
PredEntry *pp;
|
PredEntry *pp;
|
||||||
UInt pcs;
|
UInt pcs; /* counter with total for each clause */
|
||||||
UInt ts, tf; /* start end timestamp towards retracts, eventually */
|
UInt pca; /* counter with total for each predicate (repeats for each clause)*/
|
||||||
|
Int ts; /* start end timestamp towards retracts, eventually */
|
||||||
|
Int tf;
|
||||||
} clauseentry;
|
} clauseentry;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -214,12 +222,14 @@ p_cmp(const void *c1, const void *c2)
|
|||||||
const clauseentry *cl2 = (const clauseentry *)c2;
|
const clauseentry *cl2 = (const clauseentry *)c2;
|
||||||
if (cl1->pp > cl2->pp) return 1;
|
if (cl1->pp > cl2->pp) return 1;
|
||||||
if (cl1->pp < cl2->pp) return -1;
|
if (cl1->pp < cl2->pp) return -1;
|
||||||
return 0;
|
|
||||||
|
/* else same pp, but they are always different on the ts */
|
||||||
|
if (cl1->ts > cl2->ts) return 1;
|
||||||
|
else return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static clauseentry *
|
||||||
search_pc_pred(yamop *pc_ptr,clauseentry *beg, clauseentry *end) {
|
search_pc_pred(yamop *pc_ptr,clauseentry *beg, clauseentry *end) {
|
||||||
/* binary search, dynamic clauses not supported yet */
|
|
||||||
Int i, j, f, l;
|
Int i, j, f, l;
|
||||||
f = 0; l = (end-beg);
|
f = 0; l = (end-beg);
|
||||||
i = l/2;
|
i = l/2;
|
||||||
@ -227,103 +237,189 @@ search_pc_pred(yamop *pc_ptr,clauseentry *beg, clauseentry *end) {
|
|||||||
if (beg[i].beg > pc_ptr) {
|
if (beg[i].beg > pc_ptr) {
|
||||||
l = i-1;
|
l = i-1;
|
||||||
if (l < f) {
|
if (l < f) {
|
||||||
printf("Could not find %p\n", pc_ptr);
|
return NULL;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
j = i;
|
j = i;
|
||||||
i = (f+l)/2;
|
i = (f+l)/2;
|
||||||
} else if (beg[i].end < pc_ptr) {
|
} else if (beg[i].end < pc_ptr) {
|
||||||
f = i+1;
|
f = i+1;
|
||||||
if (f > l) {
|
if (f > l) {
|
||||||
printf("Could not find %p\n", pc_ptr);
|
return NULL;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
i = (f+l)/2;
|
i = (f+l)/2;
|
||||||
} else if (beg[i].beg <= pc_ptr && beg[i].end >= pc_ptr) {
|
} else if (beg[i].beg <= pc_ptr && beg[i].end >= pc_ptr) {
|
||||||
beg[i].pcs++;
|
return (&beg[i]);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
printf("Could not find %p\n", pc_ptr);
|
return NULL;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
showprofres(int tipo) {
|
showprofres(UInt type) {
|
||||||
clauseentry *pr = (clauseentry *)TR, *t;
|
clauseentry *pr=(clauseentry *) TR, *t, *t2;
|
||||||
UInt i = ProfPreds;
|
UInt count=0, ProfCalls=0;
|
||||||
|
yamop *pc_ptr;
|
||||||
|
|
||||||
if (FPreds == NULL ||
|
if (ProfilerOn) {
|
||||||
FProf == NULL) return FALSE;
|
setitimer(ITIMER_PROF,NULL,NULL);
|
||||||
|
fclose(FPreds);
|
||||||
(void)fseek(FPreds, 0L, SEEK_SET);
|
fclose(FProf);
|
||||||
|
ProfilerOn = 0;
|
||||||
while (i) {
|
|
||||||
if (fscanf(FPreds,"+%p %p %p %uld\n",&(pr->beg),&(pr->end),&(pr->pp),&(pr->ts)) == 0){
|
|
||||||
/* error */
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* First part: Read information about predicates and store it on yap trail */
|
||||||
|
|
||||||
|
FPreds=fopen("PROFPREDS","r");
|
||||||
|
if (FPreds == NULL) return FALSE;
|
||||||
|
|
||||||
|
ProfPreds=0;
|
||||||
|
while (fscanf(FPreds,"+%p %p %p %d",&(pr->beg),&(pr->end),&(pr->pp),&(pr->ts)) > 0){
|
||||||
|
int c;
|
||||||
pr->pcs = 0L;
|
pr->pcs = 0L;
|
||||||
pr++;
|
pr++;
|
||||||
if (pr > (clauseentry *)Yap_TrailTop - 1024) {
|
if (pr > (clauseentry *)Yap_TrailTop - 1024) {
|
||||||
Yap_growtrail(64 * 1024L);
|
Yap_growtrail(64 * 1024L);
|
||||||
}
|
}
|
||||||
i--;
|
ProfPreds++;
|
||||||
}
|
|
||||||
|
|
||||||
/* so that we can write again */
|
do {
|
||||||
(void)fseek(FPreds, 0L, SEEK_END);
|
c=fgetc(FPreds);
|
||||||
|
} while(c!=EOF && c!='\n');
|
||||||
|
}
|
||||||
|
fclose(FPreds);
|
||||||
|
if (ProfPreds==0) return(FALSE);
|
||||||
|
|
||||||
qsort((void *)TR, ProfPreds, sizeof(clauseentry), cl_cmp);
|
qsort((void *)TR, ProfPreds, sizeof(clauseentry), cl_cmp);
|
||||||
|
|
||||||
(void)fseek(FProf, 0L, SEEK_SET);
|
/* Second part: Read Profiling to know how many times each predicate has been profiled */
|
||||||
for (; i < ProfCalls; i++) {
|
|
||||||
yamop *pc_ptr;
|
|
||||||
if (fscanf(FProf,"%p\n",&pc_ptr) == 0){
|
|
||||||
/* error */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
search_pc_pred(pc_ptr,(clauseentry *)TR,pr);
|
|
||||||
}
|
|
||||||
(void)fseek(FProf, 0L, SEEK_END);
|
|
||||||
qsort((void *)TR, ProfPreds, sizeof(clauseentry), p_cmp);
|
|
||||||
|
|
||||||
|
FProf=fopen("PROFILING","r");
|
||||||
|
if (FProf==NULL) { return FALSE; }
|
||||||
|
|
||||||
|
t2=NULL;
|
||||||
|
ProfCalls=0;
|
||||||
|
while(fscanf(FProf,"%p\n",&pc_ptr) >0){
|
||||||
|
if (type<10) ProfCalls++;
|
||||||
|
t=search_pc_pred(pc_ptr,(clauseentry *)TR,pr);
|
||||||
|
if (t!=NULL) { /* pc was found */
|
||||||
|
if (type<10) t->pcs++;
|
||||||
|
else {
|
||||||
|
if (t->pp==(PredEntry *)type) {
|
||||||
|
ProfCalls++;
|
||||||
|
if (t2!=NULL) t2->pcs++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t2=t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(FProf);
|
||||||
|
if (ProfCalls==0) return(FALSE);
|
||||||
|
|
||||||
|
/*I have the counting by clauses, but we also need them by predicate */
|
||||||
|
qsort((void *)TR, ProfPreds, sizeof(clauseentry), p_cmp);
|
||||||
t = (clauseentry *)TR;
|
t = (clauseentry *)TR;
|
||||||
while (t < pr) {
|
while (t < pr) {
|
||||||
UInt calls=t->pcs;
|
UInt calls=t->pcs;
|
||||||
|
|
||||||
|
t2=t+1;
|
||||||
|
while(t2<pr && t2->pp==t->pp) {
|
||||||
|
calls+=t2->pcs;
|
||||||
|
t2++;
|
||||||
|
}
|
||||||
|
while(t<t2) {
|
||||||
|
t->pca=calls;
|
||||||
|
t++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* counting done: now it is time to present the results */
|
||||||
|
|
||||||
|
if (type>10) {
|
||||||
|
PredEntry *myp = (PredEntry *)type;
|
||||||
|
if (myp->FunctorOfPred->KindOfPE==47872) {
|
||||||
|
printf("Details on predicate:");
|
||||||
|
printf(" %s",RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE);
|
||||||
|
printf(":%s",RepAtom(NameOfFunctor(myp->FunctorOfPred))->StrOfAE);
|
||||||
|
if (myp->ArityOfPE) printf("/%d\n",myp->ArityOfPE);
|
||||||
|
}
|
||||||
|
type=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type==0) { /* Results by predicate */
|
||||||
|
t = (clauseentry *)TR;
|
||||||
|
while (t < pr) {
|
||||||
|
UInt calls=t->pca;
|
||||||
PredEntry *myp = t->pp;
|
PredEntry *myp = t->pp;
|
||||||
|
|
||||||
|
if (calls && myp->FunctorOfPred->KindOfPE==47872) {
|
||||||
|
count+=calls;
|
||||||
|
printf("%p",myp);
|
||||||
|
printf(" %s",RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE);
|
||||||
|
printf(":%s",RepAtom(NameOfFunctor(myp->FunctorOfPred))->StrOfAE);
|
||||||
|
if (myp->ArityOfPE) printf("/%d",myp->ArityOfPE);
|
||||||
|
printf(" -> %u (%3.1f%c)\n",calls,(float) calls*100/ProfCalls,'%');
|
||||||
|
}
|
||||||
|
while (t<pr && t->pp == myp) t++;
|
||||||
|
}
|
||||||
|
count=ProfCalls-count;
|
||||||
|
if (count>0) printf("Unknown:Unknown -> %u (%3.1f%c)\n",count,(float) count*100/ProfCalls,'%');
|
||||||
|
printf("Total of Calls=%u \n",ProfCalls);
|
||||||
|
|
||||||
|
} else { /* Results by clauses */
|
||||||
|
t = (clauseentry *)TR;
|
||||||
|
while (t < pr) {
|
||||||
|
if (t->pca!=0 && (t->ts>=0 || t->pcs!=0) && t->pp->FunctorOfPred->KindOfPE==47872) {
|
||||||
|
UInt calls=t->pcs;
|
||||||
|
if (t->ts<0) { /* join all index entries */
|
||||||
|
t2=t+1;
|
||||||
|
while(t2<pr && t2->pp==t->pp && t2->ts<0) {
|
||||||
t++;
|
t++;
|
||||||
while (t->pp == myp) {
|
|
||||||
calls+=t->pcs;
|
calls+=t->pcs;
|
||||||
|
t2++;
|
||||||
|
}
|
||||||
|
printf("IDX");
|
||||||
|
} else {
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
count+=calls;
|
||||||
|
// printf("%p %p",t->pp, t->beg);
|
||||||
|
printf(" %s",RepAtom(AtomOfTerm(t->pp->ModuleOfPred))->StrOfAE);
|
||||||
|
printf(":%s",RepAtom(NameOfFunctor(t->pp->FunctorOfPred))->StrOfAE);
|
||||||
|
if (t->pp->ArityOfPE) printf("/%d",t->pp->ArityOfPE);
|
||||||
|
printf(" -> %u (%3.1f%c)\n",calls,(float) calls*100/ProfCalls,'%');
|
||||||
|
}
|
||||||
t++;
|
t++;
|
||||||
}
|
}
|
||||||
if (calls) {
|
count=ProfCalls-count;
|
||||||
if (myp->ArityOfPE) {
|
if (count>0) printf("Unknown:Unknown -> %u (%3.1f%c)\n",count,(float) count*100/ProfCalls,'%');
|
||||||
printf("%s:%s/%d -> %uld\n",
|
printf("Total of Calls=%u \n",ProfCalls);
|
||||||
RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE,
|
|
||||||
RepAtom(NameOfFunctor(myp->FunctorOfPred))->StrOfAE,
|
|
||||||
myp->ArityOfPE,
|
|
||||||
calls);
|
|
||||||
} else {
|
|
||||||
printf("%s:%s -> %uld\n",
|
|
||||||
RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE,
|
|
||||||
RepAtom((Atom)(myp->FunctorOfPred))->StrOfAE,
|
|
||||||
calls);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /*Linux */
|
||||||
|
|
||||||
|
|
||||||
static Int profres(void) {
|
static Int profres(void) {
|
||||||
return showprofres(0);
|
#if defined(__linux__)
|
||||||
|
Term p;
|
||||||
|
p=Deref(ARG1);
|
||||||
|
if (IsLongIntTerm(p)) return(showprofres(LongIntOfTerm(p)));
|
||||||
|
else return(showprofres(IntOfTerm(p)));
|
||||||
|
#else
|
||||||
|
return(FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int profres2(void) {
|
static Int profres0(void) {
|
||||||
return showprofres(1);
|
#if defined(__linux__)
|
||||||
|
return(showprofres(0));
|
||||||
|
#else
|
||||||
|
return(FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LOW_PROF */
|
#endif /* LOW_PROF */
|
||||||
@ -2652,8 +2748,8 @@ Yap_InitCPreds(void)
|
|||||||
#ifdef LOW_PROF
|
#ifdef LOW_PROF
|
||||||
Yap_InitCPred("useprof", 1, useprof, SafePredFlag);
|
Yap_InitCPred("useprof", 1, useprof, SafePredFlag);
|
||||||
Yap_InitCPred("useprof", 0, useprof0, SafePredFlag);
|
Yap_InitCPred("useprof", 0, useprof0, SafePredFlag);
|
||||||
Yap_InitCPred("profres", 0, profres, SafePredFlag);
|
Yap_InitCPred("profres", 1, profres, SafePredFlag);
|
||||||
Yap_InitCPred("profres2", 0, profres2, SafePredFlag);
|
Yap_InitCPred("profres", 0, profres0, SafePredFlag);
|
||||||
#endif
|
#endif
|
||||||
#ifndef YAPOR
|
#ifndef YAPOR
|
||||||
Yap_InitCPred("$default_sequential", 1, p_default_sequential, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("$default_sequential", 1, p_default_sequential, SafePredFlag|SyncPredFlag);
|
||||||
|
6
H/Heap.h
6
H/Heap.h
@ -10,7 +10,7 @@
|
|||||||
* File: Heap.h *
|
* File: Heap.h *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: Heap Init Structure *
|
* comments: Heap Init Structure *
|
||||||
* version: $Id: Heap.h,v 1.59 2004-02-16 19:22:40 vsc Exp $ *
|
* version: $Id: Heap.h,v 1.60 2004-02-25 19:06:31 rslopes Exp $ *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
/* information that can be stored in Code Space */
|
/* information that can be stored in Code Space */
|
||||||
@ -362,8 +362,6 @@ typedef struct various_codes {
|
|||||||
#if LOW_PROF
|
#if LOW_PROF
|
||||||
int profiler_on;
|
int profiler_on;
|
||||||
void *f_prof, *f_preds;
|
void *f_prof, *f_preds;
|
||||||
int profiler_pred_count;
|
|
||||||
UInt prof_calls;
|
|
||||||
UInt prof_preds;
|
UInt prof_preds;
|
||||||
#endif /* LOW_PROF */
|
#endif /* LOW_PROF */
|
||||||
struct reduction_counters call_counters;
|
struct reduction_counters call_counters;
|
||||||
@ -612,8 +610,6 @@ struct various_codes *heap_regs;
|
|||||||
#define ProfilerOn heap_regs->profiler_on
|
#define ProfilerOn heap_regs->profiler_on
|
||||||
#define FProf ((FILE *)heap_regs->f_prof)
|
#define FProf ((FILE *)heap_regs->f_prof)
|
||||||
#define FPreds ((FILE *)heap_regs->f_preds)
|
#define FPreds ((FILE *)heap_regs->f_preds)
|
||||||
#define ProfilerPredCount heap_regs->profiler_pred_count
|
|
||||||
#define ProfCalls heap_regs->prof_calls
|
|
||||||
#define ProfPreds heap_regs->prof_preds
|
#define ProfPreds heap_regs->prof_preds
|
||||||
#endif /* LOW_PROF */
|
#endif /* LOW_PROF */
|
||||||
#define ReductionsCounter heap_regs->call_counters.reductions
|
#define ReductionsCounter heap_regs->call_counters.reductions
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* File: Yap.proto *
|
* File: Yap.proto *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: Function declarations for YAP *
|
* comments: Function declarations for YAP *
|
||||||
* version: $Id: Yapproto.h,v 1.47 2004-02-19 19:24:45 vsc Exp $ *
|
* version: $Id: Yapproto.h,v 1.48 2004-02-25 19:06:31 rslopes Exp $ *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
/* prototype file for Yap */
|
/* prototype file for Yap */
|
||||||
@ -319,5 +319,5 @@ void STD_PROTO(Yap_init_optyap_preds,(void));
|
|||||||
|
|
||||||
#if LOW_PROF
|
#if LOW_PROF
|
||||||
void STD_PROTO(Yap_dump_code_area_for_profiler,(void));
|
void STD_PROTO(Yap_dump_code_area_for_profiler,(void));
|
||||||
void STD_PROTO(Yap_inform_profiler_of_clause,(yamop *,yamop *, struct pred_entry *));
|
void STD_PROTO(Yap_inform_profiler_of_clause,(yamop *,yamop *, struct pred_entry *,int index_code));
|
||||||
#endif /* LOW_PROF */
|
#endif /* LOW_PROF */
|
||||||
|
Reference in New Issue
Block a user