diff --git a/src/fiat/drhook/drhook.c b/src/fiat/drhook/drhook.c index de98a62..8d5cb45 100644 --- a/src/fiat/drhook/drhook.c +++ b/src/fiat/drhook/drhook.c @@ -1051,7 +1051,8 @@ insert_calltree(int tid, drhook_key_t *keyptr) static void remove_calltree(int tid, drhook_key_t *keyptr, const double *delta_wall, const double *delta_cpu, - const long long int *delta_cycles,long_long * delta_counters) + const long long int *delta_cycles,long_long * delta_counters + ) { if (tid >= 1 && tid <= numthreads) { drhook_calltree_t *treeptr = thiscall[tid-1]; @@ -1061,10 +1062,10 @@ remove_calltree(int tid, drhook_key_t *keyptr, drhook_key_t *parent_keyptr = treeptr->prev->keyptr; if (parent_keyptr) { /* extra security */ #if defined(DR_HOOK_HAVE_PAPI) - drhook_papi_add(NULL, - parent_keyptr->delta_counters_child, - delta_counters - ); + drhook_papi_add(NULL, + parent_keyptr->delta_counters_child, + delta_counters + ); #endif if (opt_walltime) { parent_keyptr->delta_wall_child += (*delta_wall); @@ -1626,7 +1627,7 @@ signal_drhook(int sig SIG_EXTRA_ARGS) ------------------------------------------------------------*/ /* if (sig != SIGTERM) signal(SIGTERM, SIG_DFL); */ /* Let the default SIGTERM to occur */ - + // max_threads = drhook_oml_get_max_threads(); if (nsigs == 1) { /*---- First call to signal handler: call alarm(drhook_harakiri_timeout), tracebacks, exit ------*/ @@ -2648,7 +2649,7 @@ process_options() opt_callpath = 1; OPTPRINT(fp,"%s%s",comma,"CALLPATH"); comma = ","; } else { - printf("DrHook: Note - no match for HOOK_OPT : %s\n",p); + printf("DrHook: Note - no match for HOOK_OPT : %s\n",p); } p = strtok(NULL,delim); } @@ -2865,9 +2866,9 @@ getkey(int tid, const char *name, int name_len, (opt_trim && strncasecmp(keyptr->name, name, name_len) == 0)))) { if (opt_walltime) keyptr->wall_in = walltime ? *walltime : WALLTIME(); if (opt_cputime) keyptr->cpu_in = cputime ? *cputime : CPUTIME(); - if (opt_cycles) keyptr->cycles_in = cycles ? *cycles : ec_get_cycles(); + if (opt_cycles) keyptr->cycles_in = cycles ? *cycles : ec_get_cycles(); #if defined(DR_HOOK_HAVE_PAPI) - drhook_papi_readAll(keyptr->counters_in); + drhook_papi_readAll(keyptr->counters_in); #endif if (any_memstat) memstat(keyptr,&tid,1); if (opt_calls) { @@ -3465,7 +3466,7 @@ c_drhook_check_watch_(const char *where, double cputime = opt_cputime ? CPUTIME() : 0; \ long long int cycles = opt_cycles ? ec_get_cycles() : 0; \ long long int hwm = opt_gethwm ? gethwm_() : 0; \ - long long int stk = opt_getstk ? getstk_() : 0; \ + long long int stk = opt_getstk ? getstk_() : 0; \ PAPIREAD /*=== c_drhook_set_lhook_ ===*/ @@ -4349,11 +4350,11 @@ c_drhook_print_(const int *ftnunitno, while (keyptr) { if (keyptr->name && (keyptr->status == 0 || signal_handler_called)) { #if defined(DR_HOOK_HAVE_PAPI) - drhook_papi_subtract(p->counter_self, - keyptr->delta_counters_all, - keyptr->delta_counters_child); - drhook_papi_cpy(p->counter_tot, - keyptr->delta_counters_all); + drhook_papi_subtract(p->counter_self, + keyptr->delta_counters_all, + keyptr->delta_counters_child + ); + drhook_papi_cpy(p->counter_tot, keyptr->delta_counters_all); #endif p->self = opt_wallprof ? keyptr->delta_wall_all - keyptr->delta_wall_child : @@ -4406,19 +4407,20 @@ c_drhook_print_(const int *ftnunitno, pfx,TIMESTR(tid),FFL, myproc,filename); } - fp = fopen(filename,"w"); + fp = fopen(filename,"w"); if (!fp) goto finish_3; - if (opt_papi==1){ - if ((myproc == 1 && mon_out_procs == -1) || mon_out_procs == myproc) { - fprintf(stderr, - "%s %s [%s@%s:%d] Writing counter information of proc#%d into file '%s'\n", - pfx,TIMESTR(tid),FFL, - myproc,csvfilename); - } - fpcsv = fopen(csvfilename,"w"); - if (!fpcsv) goto finish_3; - } + if (opt_papi==1){ + if ((myproc == 1 && mon_out_procs == -1) || mon_out_procs == myproc) { + fprintf(stderr, + "%s %s [%s@%s:%d] Writing counter information of proc#%d into file '%s'\n", + pfx,TIMESTR(tid),FFL, + myproc,csvfilename + ); + } + fpcsv = fopen(csvfilename,"w"); + if (!fpcsv) goto finish_3; + } /* alphanumerical sorting to find out clusters of the same routine but on different threads */ /* also find out total wall clock time */ @@ -4574,105 +4576,109 @@ c_drhook_print_(const int *ftnunitno, } } - fprintf(fp,"\n"); - { - len = - fprintf(fp," # %% Time Cumul Self Total # of calls Self Total "); - } - fprintf(fp,"Routine@"); - if (opt_clusterinfo) fprintf(fp," [Cluster:(id,size)]"); - fprintf(fp,"\n"); - if (opt_sizeinfo) fprintf(fp,"%*s %s\n",len-20," ","(Size; Size/sec; Size/call; MinSize; MaxSize)"); - fprintf(fp, " (self) (sec) (sec) (sec) ms/call ms/call\n"); - fprintf(fp,"\n"); - - cumul = 0; - for (j=0; jcluster]; - if (p->pc < percent_limit) break; - if (opt_cputime) { - cumul += p->self; - } - else { - if (p->is_max || cluster_size == 1) cumul += p->self; - } - - { - fprintf(fp, fmt, - ++j, p->pc, cumul, p->self, p->total, p->calls, - p->percall_ms_self, p->percall_ms_total, - p->is_max ? "*" : " "); - } - print_routine_name(fp, p, len, cluster_size); - - if (opt_sizeinfo && p->sizeinfo > 0) { - char s1[DRHOOK_STRBUF], s2[DRHOOK_STRBUF], s3[DRHOOK_STRBUF]; - char s4[DRHOOK_STRBUF], s5[DRHOOK_STRBUF]; - lld_commie(p->sizeinfo,s1); - dbl_commie(p->sizespeed,s2); - dbl_commie(p->sizeavg,s3); - lld_commie(p->min_sizeinfo,s4); - lld_commie(p->max_sizeinfo,s5); - fprintf(fp,"\n%*s (%s; %s; %s; %s; %s)",len-20," ",s1,s2,s3,s4,s5); - } - fprintf(fp,"\n"); - p++; - } /* for (j=0; j"); + if (opt_clusterinfo) + fprintf(fp, " [Cluster:(id,size)]"); + fprintf(fp, "\n"); + if (opt_sizeinfo) + fprintf(fp, "%*s %s\n",len-20," ","(Size; Size/sec; Size/call; MinSize; MaxSize)"); + fprintf(fp, " (self) (sec) (sec) (sec) ms/call ms/call\n"); + fprintf(fp, "\n"); + + cumul = 0; + for (j = 0; j < nprof; ) { + int cluster_size = clusize[p->cluster]; + if (p->pc < percent_limit) + break; + if (opt_cputime) { + cumul += p->self; + } else { + if (p->is_max || cluster_size == 1) + cumul += p->self; + } + + { + fprintf(fp, fmt, + ++j, p->pc, cumul, p->self, p->total, p->calls, + p->percall_ms_self, p->percall_ms_total, + p->is_max ? "*" : " "); + } + print_routine_name(fp, p, len, cluster_size); + + if (opt_sizeinfo && p->sizeinfo > 0) { + char s1[DRHOOK_STRBUF], s2[DRHOOK_STRBUF], s3[DRHOOK_STRBUF]; + char s4[DRHOOK_STRBUF], s5[DRHOOK_STRBUF]; + lld_commie(p->sizeinfo,s1); + dbl_commie(p->sizespeed,s2); + dbl_commie(p->sizeavg,s3); + lld_commie(p->min_sizeinfo,s4); + lld_commie(p->max_sizeinfo,s5); + fprintf(fp,"\n%*s (%s; %s; %s; %s; %s)",len-20," ",s1,s2,s3,s4,s5); + } + fprintf(fp,"\n"); + p++; + } /* for (j=0; jcluster]; - if (opt_cputime) - cumul += p->self; - else - if (p->is_max || cluster_size == 1) cumul += p->self; - - { - fprintf(fpcsv, csvfmt, - p->name, - myproc-1, - p->tid-1 - ,++j, p->pc, cumul, p->self, p->total, p->calls, - p->is_max ? "*" : " "); - for (int c=0;ccounter_self[c]); - for (int c=0;ccounter_tot[c]); - if (first_counter_is_cyc==1) - fprintf(fpcsv,",%.3f,%.3f", - p->counter_self[0]/p->self/1000000.0, - p->counter_tot[0]/p->total/1000000.0 - ); - } - fprintf(fpcsv,"\n"); - p++; - } /* for (j=0; jcluster]; + if (opt_cputime) + cumul += p->self; + else + if (p->is_max || cluster_size == 1) cumul += p->self; + + { + fprintf(fpcsv, csvfmt, + p->name, + myproc-1, + p->tid-1, + ++j, p->pc, cumul, p->self, p->total, p->calls, + p->is_max ? "*" : " " + ); + for (int c=0;ccounter_self[c]); + for (int c=0;ccounter_tot[c]); + if (first_counter_is_cyc==1) + fprintf(fpcsv,",%.3f,%.3f", + p->counter_self[0]/p->self/1000000.0, + p->counter_tot[0]/p->total/1000000.0 + ); + } + fprintf(fpcsv, "\n"); + p++; + } /* for (j=0; j 0) { snprintf(pmsg,STD_MSG_LEN,"DRHOOK:PAPI: Error, library version mismatch between compilation and run!\n"); @@ -209,10 +208,10 @@ int drhook_papi_init(int rank){ } snprintf(pmsg,STD_MSG_LEN,"DRHOOK:PAPI: Version %d.%d.%d initialised with %d threads", - PAPI_VERSION_MAJOR( lib_version ), - PAPI_VERSION_MINOR( lib_version ), - PAPI_VERSION_REVISION( lib_version ), - nthreads ); + PAPI_VERSION_MAJOR( lib_version ), + PAPI_VERSION_MINOR( lib_version ), + PAPI_VERSION_REVISION( lib_version ), + nthreads); if (drhook_papi_rank==0 && !silent) printf("%s\n",pmsg); @@ -271,17 +270,17 @@ int dr_hook_papi_start_threads(int* events){ snprintf(pmsg,STD_MSG_LEN,"DRHOOK:PAPI: Error, add_event failed: %d (%s)",papiErr,PAPI_strerror(papiErr)); printf("%s\n",pmsg); if (papiErr == PAPI_EINVAL) - printf("Invalid argument\n"); + printf("Invalid argument\n"); else if (papiErr == PAPI_ENOMEM) - printf("Out of memory\n"); + printf("Out of memory\n"); else if (papiErr == PAPI_ENOEVST) - printf("EventSet does not exist\n"); + printf("EventSet does not exist\n"); else if (papiErr == PAPI_EISRUN) - printf("EventSet is running\n"); + printf("EventSet is running\n"); else if (papiErr == PAPI_ECNFLCT) - printf("Conflict\n"); + printf("Conflict\n"); else if (papiErr == PAPI_ENOEVNT) - printf("Preset not available\n"); + printf("Preset not available\n"); return 0; } else { @@ -304,8 +303,8 @@ int dr_hook_papi_start_threads(int* events){ } #if defined(DEBUG) for (int counter=0;counter