Skip to content

Commit

Permalink
Fix whitespacing
Browse files Browse the repository at this point in the history
This commit removes all tabs, in favour of two spaces, in files touched by ecmwf-ifs#26 and ecmwf-ifs#27.
  • Loading branch information
Andrew-Beggs-ECMWF committed Aug 28, 2024
1 parent 7c56580 commit 0cf6b5d
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 141 deletions.
250 changes: 128 additions & 122 deletions src/fiat/drhook/drhook.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);
Expand Down Expand Up @@ -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 ------*/
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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_ ===*/
Expand Down Expand Up @@ -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 :
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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@<thread-id>");
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; j<nprof; ) */
fprintf(fp,"\n");
{
len =
fprintf(fp," # %% Time Cumul Self Total # of calls Self Total ");
}
fprintf(fp, "Routine@<thread-id>");
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; j<nprof; ) */
fclose(fp);

#if defined(DR_HOOK_HAVE_PAPI)
if (opt_papi){
p=prof;
int first_counter_is_cyc=0;
char event_name[drhook_papi_max_name_len()];
drhook_papi_counter_name(0,event_name);
if (strcmp(event_name,"PAPI_TOT_CYC")==0)
first_counter_is_cyc=1;
{
len =
fprintf(fpcsv,"Routine,MPI Rank,ThreadId,SelfRank,%% Self Time,Cumul,Excl Time,Incl. Time,#Calls");
for (int c=0;c<drhook_papi_num_counters();c++){
drhook_papi_counter_name(c,event_name);
fprintf(fpcsv,",%s(excl)",event_name);
}
for (int c=0;c<drhook_papi_num_counters();c++) {
drhook_papi_counter_name(c,event_name);
fprintf(fpcsv,",%s(incl)",event_name);
}
if (first_counter_is_cyc==1)
fprintf(fpcsv,",Mcyc/sec(excl),Mcyc/sec(incl)");
fprintf(fpcsv,"\n");
}

cumul = 0;
for (j=0; j<nprof; ) {
int cluster_size = clusize[p->cluster];
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;c<drhook_papi_num_counters();c++)
fprintf(fpcsv,",%lld",p->counter_self[c]);
for (int c=0;c<drhook_papi_num_counters();c++)
fprintf(fpcsv,",%lld",p->counter_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<nprof; ) */
}
if (opt_papi){
p=prof;
int first_counter_is_cyc=0;
char event_name[drhook_papi_max_name_len()];
drhook_papi_counter_name(0, event_name);
if (strcmp(event_name,"PAPI_TOT_CYC") == 0)
first_counter_is_cyc=1;
{
len =
fprintf(fpcsv,"Routine,MPI Rank,ThreadId,SelfRank,%% Self Time,Cumul,Excl Time,Incl. Time,#Calls");
for (int c=0; c < drhook_papi_num_counters(); c++) {
drhook_papi_counter_name(c, event_name);
fprintf(fpcsv, ",%s(excl)", event_name);
}
for (int c=0; c < drhook_papi_num_counters(); c++) {
drhook_papi_counter_name(c, event_name);
fprintf(fpcsv, ",%s(incl)", event_name);
}
if (first_counter_is_cyc == 1)
fprintf(fpcsv, ",Mcyc/sec(excl),Mcyc/sec(incl)");
fprintf(fpcsv, "\n");
}

cumul = 0;
for (j=0; j<nprof; ) {
int cluster_size = clusize[p->cluster];
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;c<drhook_papi_num_counters();c++)
fprintf(fpcsv,",%lld",p->counter_self[c]);
for (int c=0;c<drhook_papi_num_counters();c++)
fprintf(fpcsv,",%lld",p->counter_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<nprof; ) */
}
#endif
finish_3:
free_drhook(filename);
Expand Down
27 changes: 13 additions & 14 deletions src/fiat/drhook/drhook_papi.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ int drhook_papi_init(int rank){

paperr=PAPI_library_init(PAPI_VER_CURRENT);
if (paperr != PAPI_VER_CURRENT){
snprintf(pmsg,STD_MSG_LEN,"DRHOOK:PAPI:PAPI_library_init: ret code=%d version loaded =%d ",
paperr,PAPI_VER_CURRENT);
snprintf(pmsg,STD_MSG_LEN,"DRHOOK:PAPI:PAPI_library_init: ret code=%d version loaded =%d ", paperr,PAPI_VER_CURRENT);
printf("%s\n",pmsg);
if (paperr > 0) {
snprintf(pmsg,STD_MSG_LEN,"DRHOOK:PAPI: Error, library version mismatch between compilation and run!\n");
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 {
Expand All @@ -304,8 +303,8 @@ int dr_hook_papi_start_threads(int* events){
}
#if defined(DEBUG)
for (int counter=0;counter<number;counter++) {
snprintf(pmsg,STD_MSG_LEN,"DRHOOK:PAPI: Ev: %d=%d",counter,events[counter]);
printf("%s\n",pmsg);
snprintf(pmsg,STD_MSG_LEN,"DRHOOK:PAPI: Ev: %d=%d",counter,events[counter]);
printf("%s\n",pmsg);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/fiat/drhook/internal/drhook_run_omp_parallel.F90
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ subroutine drhook_run_omp_parallel_papi_startup(events,n, rcOut) bind(c)
rcOut=0
!$OMP PARALLEL
DO thread=0,nThreads-1
if (thread==myThread) then
if (thread==myThread) then
rc=dr_hook_papi_start_threads(events)
if (rc==0)rcOut=1
end if
Expand Down
Loading

0 comments on commit 0cf6b5d

Please sign in to comment.