@@ -1051,7 +1051,8 @@ insert_calltree(int tid, drhook_key_t *keyptr)
1051
1051
static void
1052
1052
remove_calltree (int tid , drhook_key_t * keyptr ,
1053
1053
const double * delta_wall , const double * delta_cpu ,
1054
- const long long int * delta_cycles ,long_long * delta_counters )
1054
+ const long long int * delta_cycles ,long_long * delta_counters
1055
+ )
1055
1056
{
1056
1057
if (tid >= 1 && tid <= numthreads ) {
1057
1058
drhook_calltree_t * treeptr = thiscall [tid - 1 ];
@@ -1061,10 +1062,10 @@ remove_calltree(int tid, drhook_key_t *keyptr,
1061
1062
drhook_key_t * parent_keyptr = treeptr -> prev -> keyptr ;
1062
1063
if (parent_keyptr ) { /* extra security */
1063
1064
#if defined(DR_HOOK_HAVE_PAPI )
1064
- drhook_papi_add (NULL ,
1065
- parent_keyptr -> delta_counters_child ,
1066
- delta_counters
1067
- );
1065
+ drhook_papi_add (NULL ,
1066
+ parent_keyptr -> delta_counters_child ,
1067
+ delta_counters
1068
+ );
1068
1069
#endif
1069
1070
if (opt_walltime ) {
1070
1071
parent_keyptr -> delta_wall_child += (* delta_wall );
@@ -1626,7 +1627,7 @@ signal_drhook(int sig SIG_EXTRA_ARGS)
1626
1627
------------------------------------------------------------*/
1627
1628
1628
1629
/* if (sig != SIGTERM) signal(SIGTERM, SIG_DFL); */ /* Let the default SIGTERM to occur */
1629
-
1630
+
1630
1631
// max_threads = drhook_oml_get_max_threads();
1631
1632
if (nsigs == 1 ) {
1632
1633
/*---- First call to signal handler: call alarm(drhook_harakiri_timeout), tracebacks, exit ------*/
@@ -2648,7 +2649,7 @@ process_options()
2648
2649
opt_callpath = 1 ;
2649
2650
OPTPRINT (fp ,"%s%s" ,comma ,"CALLPATH" ); comma = "," ;
2650
2651
} else {
2651
- printf ("DrHook: Note - no match for HOOK_OPT : %s\n" ,p );
2652
+ printf ("DrHook: Note - no match for HOOK_OPT : %s\n" ,p );
2652
2653
}
2653
2654
p = strtok (NULL ,delim );
2654
2655
}
@@ -2865,9 +2866,9 @@ getkey(int tid, const char *name, int name_len,
2865
2866
(opt_trim && strncasecmp (keyptr -> name , name , name_len ) == 0 )))) {
2866
2867
if (opt_walltime ) keyptr -> wall_in = walltime ? * walltime : WALLTIME ();
2867
2868
if (opt_cputime ) keyptr -> cpu_in = cputime ? * cputime : CPUTIME ();
2868
- if (opt_cycles ) keyptr -> cycles_in = cycles ? * cycles : ec_get_cycles ();
2869
+ if (opt_cycles ) keyptr -> cycles_in = cycles ? * cycles : ec_get_cycles ();
2869
2870
#if defined(DR_HOOK_HAVE_PAPI )
2870
- drhook_papi_readAll (keyptr -> counters_in );
2871
+ drhook_papi_readAll (keyptr -> counters_in );
2871
2872
#endif
2872
2873
if (any_memstat ) memstat (keyptr ,& tid ,1 );
2873
2874
if (opt_calls ) {
@@ -3465,7 +3466,7 @@ c_drhook_check_watch_(const char *where,
3465
3466
double cputime = opt_cputime ? CPUTIME() : 0; \
3466
3467
long long int cycles = opt_cycles ? ec_get_cycles() : 0; \
3467
3468
long long int hwm = opt_gethwm ? gethwm_() : 0; \
3468
- long long int stk = opt_getstk ? getstk_() : 0; \
3469
+ long long int stk = opt_getstk ? getstk_() : 0; \
3469
3470
PAPIREAD
3470
3471
3471
3472
/*=== c_drhook_set_lhook_ ===*/
@@ -4349,11 +4350,11 @@ c_drhook_print_(const int *ftnunitno,
4349
4350
while (keyptr ) {
4350
4351
if (keyptr -> name && (keyptr -> status == 0 || signal_handler_called )) {
4351
4352
#if defined(DR_HOOK_HAVE_PAPI )
4352
- drhook_papi_subtract (p -> counter_self ,
4353
- keyptr -> delta_counters_all ,
4354
- keyptr -> delta_counters_child );
4355
- drhook_papi_cpy ( p -> counter_tot ,
4356
- keyptr -> delta_counters_all );
4353
+ drhook_papi_subtract (p -> counter_self ,
4354
+ keyptr -> delta_counters_all ,
4355
+ keyptr -> delta_counters_child
4356
+ );
4357
+ drhook_papi_cpy ( p -> counter_tot , keyptr -> delta_counters_all );
4357
4358
#endif
4358
4359
p -> self = opt_wallprof ?
4359
4360
keyptr -> delta_wall_all - keyptr -> delta_wall_child :
@@ -4406,19 +4407,20 @@ c_drhook_print_(const int *ftnunitno,
4406
4407
pfx ,TIMESTR (tid ),FFL ,
4407
4408
myproc ,filename );
4408
4409
}
4409
- fp = fopen (filename ,"w" );
4410
+ fp = fopen (filename ,"w" );
4410
4411
if (!fp ) goto finish_3 ;
4411
4412
4412
- if (opt_papi == 1 ){
4413
- if ((myproc == 1 && mon_out_procs == -1 ) || mon_out_procs == myproc ) {
4414
- fprintf (stderr ,
4415
- "%s %s [%s@%s:%d] Writing counter information of proc#%d into file '%s'\n" ,
4416
- pfx ,TIMESTR (tid ),FFL ,
4417
- myproc ,csvfilename );
4418
- }
4419
- fpcsv = fopen (csvfilename ,"w" );
4420
- if (!fpcsv ) goto finish_3 ;
4421
- }
4413
+ if (opt_papi == 1 ){
4414
+ if ((myproc == 1 && mon_out_procs == -1 ) || mon_out_procs == myproc ) {
4415
+ fprintf (stderr ,
4416
+ "%s %s [%s@%s:%d] Writing counter information of proc#%d into file '%s'\n" ,
4417
+ pfx ,TIMESTR (tid ),FFL ,
4418
+ myproc ,csvfilename
4419
+ );
4420
+ }
4421
+ fpcsv = fopen (csvfilename ,"w" );
4422
+ if (!fpcsv ) goto finish_3 ;
4423
+ }
4422
4424
4423
4425
/* alphanumerical sorting to find out clusters of the same routine but on different threads */
4424
4426
/* also find out total wall clock time */
@@ -4574,105 +4576,109 @@ c_drhook_print_(const int *ftnunitno,
4574
4576
}
4575
4577
}
4576
4578
4577
- fprintf (fp ,"\n" );
4578
- {
4579
- len =
4580
- fprintf (fp ," # %% Time Cumul Self Total # of calls Self Total " );
4581
- }
4582
- fprintf (fp ,"Routine@<thread-id>" );
4583
- if (opt_clusterinfo ) fprintf (fp ," [Cluster:(id,size)]" );
4584
- fprintf (fp ,"\n" );
4585
- if (opt_sizeinfo ) fprintf (fp ,"%*s %s\n" ,len - 20 ," " ,"(Size; Size/sec; Size/call; MinSize; MaxSize)" );
4586
- fprintf (fp , " (self) (sec) (sec) (sec) ms/call ms/call\n" );
4587
- fprintf (fp ,"\n" );
4588
-
4589
- cumul = 0 ;
4590
- for (j = 0 ; j < nprof ; ) {
4591
- int cluster_size = clusize [p -> cluster ];
4592
- if (p -> pc < percent_limit ) break ;
4593
- if (opt_cputime ) {
4594
- cumul += p -> self ;
4595
- }
4596
- else {
4597
- if (p -> is_max || cluster_size == 1 ) cumul += p -> self ;
4598
- }
4599
-
4600
- {
4601
- fprintf (fp , fmt ,
4602
- ++ j , p -> pc , cumul , p -> self , p -> total , p -> calls ,
4603
- p -> percall_ms_self , p -> percall_ms_total ,
4604
- p -> is_max ? "*" : " " );
4605
- }
4606
- print_routine_name (fp , p , len , cluster_size );
4607
-
4608
- if (opt_sizeinfo && p -> sizeinfo > 0 ) {
4609
- char s1 [DRHOOK_STRBUF ], s2 [DRHOOK_STRBUF ], s3 [DRHOOK_STRBUF ];
4610
- char s4 [DRHOOK_STRBUF ], s5 [DRHOOK_STRBUF ];
4611
- lld_commie (p -> sizeinfo ,s1 );
4612
- dbl_commie (p -> sizespeed ,s2 );
4613
- dbl_commie (p -> sizeavg ,s3 );
4614
- lld_commie (p -> min_sizeinfo ,s4 );
4615
- lld_commie (p -> max_sizeinfo ,s5 );
4616
- fprintf (fp ,"\n%*s (%s; %s; %s; %s; %s)" ,len - 20 ," " ,s1 ,s2 ,s3 ,s4 ,s5 );
4617
- }
4618
- fprintf (fp ,"\n" );
4619
- p ++ ;
4620
- } /* for (j=0; j<nprof; ) */
4579
+ fprintf (fp ,"\n" );
4580
+ {
4581
+ len =
4582
+ fprintf (fp ," # %% Time Cumul Self Total # of calls Self Total " );
4583
+ }
4584
+ fprintf (fp , "Routine@<thread-id>" );
4585
+ if (opt_clusterinfo )
4586
+ fprintf (fp , " [Cluster:(id,size)]" );
4587
+ fprintf (fp , "\n" );
4588
+ if (opt_sizeinfo )
4589
+ fprintf (fp , "%*s %s\n" ,len - 20 ," " ,"(Size; Size/sec; Size/call; MinSize; MaxSize)" );
4590
+ fprintf (fp , " (self) (sec) (sec) (sec) ms/call ms/call\n" );
4591
+ fprintf (fp , "\n" );
4592
+
4593
+ cumul = 0 ;
4594
+ for (j = 0 ; j < nprof ; ) {
4595
+ int cluster_size = clusize [p -> cluster ];
4596
+ if (p -> pc < percent_limit )
4597
+ break ;
4598
+ if (opt_cputime ) {
4599
+ cumul += p -> self ;
4600
+ } else {
4601
+ if (p -> is_max || cluster_size == 1 )
4602
+ cumul += p -> self ;
4603
+ }
4604
+
4605
+ {
4606
+ fprintf (fp , fmt ,
4607
+ ++ j , p -> pc , cumul , p -> self , p -> total , p -> calls ,
4608
+ p -> percall_ms_self , p -> percall_ms_total ,
4609
+ p -> is_max ? "*" : " " );
4610
+ }
4611
+ print_routine_name (fp , p , len , cluster_size );
4612
+
4613
+ if (opt_sizeinfo && p -> sizeinfo > 0 ) {
4614
+ char s1 [DRHOOK_STRBUF ], s2 [DRHOOK_STRBUF ], s3 [DRHOOK_STRBUF ];
4615
+ char s4 [DRHOOK_STRBUF ], s5 [DRHOOK_STRBUF ];
4616
+ lld_commie (p -> sizeinfo ,s1 );
4617
+ dbl_commie (p -> sizespeed ,s2 );
4618
+ dbl_commie (p -> sizeavg ,s3 );
4619
+ lld_commie (p -> min_sizeinfo ,s4 );
4620
+ lld_commie (p -> max_sizeinfo ,s5 );
4621
+ fprintf (fp ,"\n%*s (%s; %s; %s; %s; %s)" ,len - 20 ," " ,s1 ,s2 ,s3 ,s4 ,s5 );
4622
+ }
4623
+ fprintf (fp ,"\n" );
4624
+ p ++ ;
4625
+ } /* for (j=0; j<nprof; ) */
4621
4626
fclose (fp );
4622
4627
4623
4628
#if defined(DR_HOOK_HAVE_PAPI )
4624
- if (opt_papi ){
4625
- p = prof ;
4626
- int first_counter_is_cyc = 0 ;
4627
- char event_name [drhook_papi_max_name_len ()];
4628
- drhook_papi_counter_name (0 ,event_name );
4629
- if (strcmp (event_name ,"PAPI_TOT_CYC" )== 0 )
4630
- first_counter_is_cyc = 1 ;
4631
- {
4632
- len =
4633
- fprintf (fpcsv ,"Routine,MPI Rank,ThreadId,SelfRank,%% Self Time,Cumul,Excl Time,Incl. Time,#Calls" );
4634
- for (int c = 0 ;c < drhook_papi_num_counters ();c ++ ){
4635
- drhook_papi_counter_name (c ,event_name );
4636
- fprintf (fpcsv ,",%s(excl)" ,event_name );
4637
- }
4638
- for (int c = 0 ;c < drhook_papi_num_counters ();c ++ ) {
4639
- drhook_papi_counter_name (c ,event_name );
4640
- fprintf (fpcsv ,",%s(incl)" ,event_name );
4641
- }
4642
- if (first_counter_is_cyc == 1 )
4643
- fprintf (fpcsv ,",Mcyc/sec(excl),Mcyc/sec(incl)" );
4644
- fprintf (fpcsv ,"\n" );
4645
- }
4646
-
4647
- cumul = 0 ;
4648
- for (j = 0 ; j < nprof ; ) {
4649
- int cluster_size = clusize [p -> cluster ];
4650
- if (opt_cputime )
4651
- cumul += p -> self ;
4652
- else
4653
- if (p -> is_max || cluster_size == 1 ) cumul += p -> self ;
4654
-
4655
- {
4656
- fprintf (fpcsv , csvfmt ,
4657
- p -> name ,
4658
- myproc - 1 ,
4659
- p -> tid - 1
4660
- ,++ j , p -> pc , cumul , p -> self , p -> total , p -> calls ,
4661
- p -> is_max ? "*" : " " );
4662
- for (int c = 0 ;c < drhook_papi_num_counters ();c ++ )
4663
- fprintf (fpcsv ,",%lld" ,p -> counter_self [c ]);
4664
- for (int c = 0 ;c < drhook_papi_num_counters ();c ++ )
4665
- fprintf (fpcsv ,",%lld" ,p -> counter_tot [c ]);
4666
- if (first_counter_is_cyc == 1 )
4667
- fprintf (fpcsv ,",%.3f,%.3f" ,
4668
- p -> counter_self [0 ]/p -> self /1000000.0 ,
4669
- p -> counter_tot [0 ]/p -> total /1000000.0
4670
- );
4671
- }
4672
- fprintf (fpcsv ,"\n" );
4673
- p ++ ;
4674
- } /* for (j=0; j<nprof; ) */
4675
- }
4629
+ if (opt_papi ){
4630
+ p = prof ;
4631
+ int first_counter_is_cyc = 0 ;
4632
+ char event_name [drhook_papi_max_name_len ()];
4633
+ drhook_papi_counter_name (0 , event_name );
4634
+ if (strcmp (event_name ,"PAPI_TOT_CYC" ) == 0 )
4635
+ first_counter_is_cyc = 1 ;
4636
+ {
4637
+ len =
4638
+ fprintf (fpcsv ,"Routine,MPI Rank,ThreadId,SelfRank,%% Self Time,Cumul,Excl Time,Incl. Time,#Calls" );
4639
+ for (int c = 0 ; c < drhook_papi_num_counters (); c ++ ) {
4640
+ drhook_papi_counter_name (c , event_name );
4641
+ fprintf (fpcsv , ",%s(excl)" , event_name );
4642
+ }
4643
+ for (int c = 0 ; c < drhook_papi_num_counters (); c ++ ) {
4644
+ drhook_papi_counter_name (c , event_name );
4645
+ fprintf (fpcsv , ",%s(incl)" , event_name );
4646
+ }
4647
+ if (first_counter_is_cyc == 1 )
4648
+ fprintf (fpcsv , ",Mcyc/sec(excl),Mcyc/sec(incl)" );
4649
+ fprintf (fpcsv , "\n" );
4650
+ }
4651
+
4652
+ cumul = 0 ;
4653
+ for (j = 0 ; j < nprof ; ) {
4654
+ int cluster_size = clusize [p -> cluster ];
4655
+ if (opt_cputime )
4656
+ cumul += p -> self ;
4657
+ else
4658
+ if (p -> is_max || cluster_size == 1 ) cumul += p -> self ;
4659
+
4660
+ {
4661
+ fprintf (fpcsv , csvfmt ,
4662
+ p -> name ,
4663
+ myproc - 1 ,
4664
+ p -> tid - 1 ,
4665
+ ++ j , p -> pc , cumul , p -> self , p -> total , p -> calls ,
4666
+ p -> is_max ? "*" : " "
4667
+ );
4668
+ for (int c = 0 ;c < drhook_papi_num_counters ();c ++ )
4669
+ fprintf (fpcsv ,",%lld" ,p -> counter_self [c ]);
4670
+ for (int c = 0 ;c < drhook_papi_num_counters ();c ++ )
4671
+ fprintf (fpcsv ,",%lld" ,p -> counter_tot [c ]);
4672
+ if (first_counter_is_cyc == 1 )
4673
+ fprintf (fpcsv ,",%.3f,%.3f" ,
4674
+ p -> counter_self [0 ]/p -> self /1000000.0 ,
4675
+ p -> counter_tot [0 ]/p -> total /1000000.0
4676
+ );
4677
+ }
4678
+ fprintf (fpcsv , "\n" );
4679
+ p ++ ;
4680
+ } /* for (j=0; j<nprof; ) */
4681
+ }
4676
4682
#endif
4677
4683
finish_3 :
4678
4684
free_drhook (filename );
0 commit comments