diff --git a/C/tracer.c b/C/tracer.c index fe1004cce..7f7fbc012 100755 --- a/C/tracer.c +++ b/C/tracer.c @@ -372,6 +372,16 @@ static Int p_start_low_level_trace(void) return(TRUE); } +static Int p_total_choicepoints(void) +{ + return Yap_unify(MkIntegerTerm(Yap_total_choicepoints),ARG1); +} + +static Int p_reset_total_choicepoints(void) +{ + Yap_total_choicepoints = 0; +} + static Int p_show_low_level_trace(void) { fprintf(stderr,"Call counter=%lld\n",vsc_count); @@ -414,6 +424,8 @@ Yap_InitLowLevelTrace(void) #endif Yap_InitCPred("stop_low_level_trace", 0, p_stop_low_level_trace, SafePredFlag); Yap_InitCPred("show_low_level_trace", 0, p_show_low_level_trace, SafePredFlag); + Yap_InitCPred("total_choicepoints", 1, p_total_choicepoints, SafePredFlag); + Yap_InitCPred("reset_total_choicepoints", 0, p_reset_total_choicepoints, SafePredFlag); Yap_InitCPred("vsc_wait", 0, p_vsc_wait, SafePredFlag); } diff --git a/H/absmi.h b/H/absmi.h index 5427f460c..2310c6acb 100644 --- a/H/absmi.h +++ b/H/absmi.h @@ -731,6 +731,12 @@ Macros to check the limits of stacks while ( pt0 > XREGS ); \ ENDP(pt0) +#if LOW_LEVEL_TRACER +#define COUNT_CPS() Yap_total_choicepoints++ +#else +#define COUNT_CPS() +#endif + /*************************************************************** * Do the bulk of work in creating a choice-point * * AP: alternative pointer * @@ -747,6 +753,7 @@ Macros to check the limits of stacks #define store_yaam_regs(AP,I) \ { /* Jump to CP_BASE */ \ + COUNT_CPS(); \ S_YREG = (CELL *)((choiceptr)((S_YREG)-(I))-1); \ /* Save Information */ \ HBREG = H; \ @@ -760,6 +767,7 @@ Macros to check the limits of stacks } #define store_yaam_regs_for_either(AP,d0) \ + COUNT_CPS(); \ pt1 --; /* Jump to CP_BASE */ \ /* Save Information */ \ HBREG = H; \ diff --git a/H/dglobals.h b/H/dglobals.h index 17c514015..3e9b1de60 100644 --- a/H/dglobals.h +++ b/H/dglobals.h @@ -95,6 +95,9 @@ #define TotGcRecovered WL->tot_gc_recovered #define LastGcTime WL->last_gc_time #define LastSSTime WL->last_ss_time +#if LOW_LEVEL_TRACER +#define Yap_total_choicepoints WL->total_cps +#endif #if defined(YAPOR) || defined(THREADS) #define SignalLock WL->signal_lock diff --git a/H/hglobals.h b/H/hglobals.h index 87719458c..302f7ca9a 100644 --- a/H/hglobals.h +++ b/H/hglobals.h @@ -97,6 +97,9 @@ typedef struct worker_local { YAP_ULONG_LONG tot_gc_recovered; Int last_gc_time; Int last_ss_time; +#if LOW_LEVEL_TRACER + Int total_cps; +#endif #if defined(YAPOR) || defined(THREADS) lockvar signal_lock; diff --git a/H/iglobals.h b/H/iglobals.h index 4c6012a7e..1274d32fa 100644 --- a/H/iglobals.h +++ b/H/iglobals.h @@ -95,6 +95,9 @@ static void InitWorker(int wid) { FOREIGN_WL(wid)->tot_gc_recovered = 0L; FOREIGN_WL(wid)->last_gc_time = 0L; FOREIGN_WL(wid)->last_ss_time = 0L; +#if LOW_LEVEL_TRACER + FOREIGN_WL(wid)->total_cps = 0; +#endif #if defined(YAPOR) || defined(THREADS) INIT_LOCK(FOREIGN_WL(wid)->signal_lock); diff --git a/H/rglobals.h b/H/rglobals.h index 7aaa8d045..0eb573aa3 100644 --- a/H/rglobals.h +++ b/H/rglobals.h @@ -95,6 +95,9 @@ static void RestoreWorker(int wid) { +#if LOW_LEVEL_TRACER + +#endif #if defined(YAPOR) || defined(THREADS) REINIT_LOCK(FOREIGN_WL(wid)->signal_lock); diff --git a/misc/GLOBALS b/misc/GLOBALS index 1dcda6810..82bff09e1 100644 --- a/misc/GLOBALS +++ b/misc/GLOBALS @@ -104,6 +104,10 @@ YAP_ULONG_LONG tot_gc_recovered TotGcRecovered =0L Int last_gc_time LastGcTime =0L Int last_ss_time LastSSTime =0L +#if LOW_LEVEL_TRACER +Int total_cps Yap_total_choicepoints =0 +#endif + // global variables that cannot be global in a thread/or-p implementation #if defined(YAPOR) || defined(THREADS) lockvar signal_lock SignalLock MkLock