@@ -38,6 +38,8 @@ struct benchmark_options{
38
38
int precreate ;
39
39
int dset_count ;
40
40
41
+ int result_position ; // in the global structure
42
+
41
43
int offset ;
42
44
int iterations ;
43
45
int global_iteration ;
@@ -339,7 +341,7 @@ static void compute_histogram(const char * name, time_result_t * times, time_sta
339
341
stats -> max = times [repeats - 1 ].runtime ;
340
342
}
341
343
342
- static void end_phase (const char * name , phase_stat_t * p ){
344
+ static void end_phase (const char * name , phase_stat_t * p , phase_stat_t * result ){
343
345
int ret ;
344
346
char buff [MAX_PATHLEN ];
345
347
@@ -449,6 +451,10 @@ static void end_phase(const char * name, phase_stat_t * p){
449
451
free (g_stat .time_delete );
450
452
}
451
453
454
+ // copy the result back for the API
455
+ memcpy (& result [o .result_position ], & g_stat , sizeof (g_stat ));
456
+ o .result_position ++ ;
457
+
452
458
// allocate memory if necessary
453
459
// ret = mem_preallocate(& limit_memory_P, o.limit_memory_between_phases, o.verbosity >= 3);
454
460
// if( ret != 0){
@@ -777,7 +783,7 @@ static void store_position(int position){
777
783
fclose (f );
778
784
}
779
785
780
- int md_workbench_run (int argc , char * * argv , MPI_Comm world_com , FILE * out_logfile ){
786
+ phase_stat_t * md_workbench_run (int argc , char * * argv , MPI_Comm world_com , FILE * out_logfile ){
781
787
int ret ;
782
788
int printhelp = 0 ;
783
789
char * limit_memory_P = NULL ;
@@ -867,6 +873,7 @@ int md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logf
867
873
double bench_start ;
868
874
bench_start = GetTimeStamp ();
869
875
phase_stat_t phase_stats ;
876
+ phase_stat_t * all_phases_stats = malloc (sizeof (phase_stat_t ) * (2 + o .iterations ));
870
877
871
878
if (o .rank == 0 && o .print_detailed_stats && ! o .quiet_output ){
872
879
print_detailed_stat_header ();
@@ -885,7 +892,7 @@ int md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logf
885
892
phase_stats .phase_start_timer = GetTimeStamp ();
886
893
run_precreate (& phase_stats , current_index );
887
894
phase_stats .t = GetTimeStamp () - phase_stats .phase_start_timer ;
888
- end_phase ("precreate" , & phase_stats );
895
+ end_phase ("precreate" , & phase_stats , all_phases_stats );
889
896
}
890
897
891
898
if (o .phase_benchmark ){
@@ -898,7 +905,7 @@ int md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logf
898
905
MPI_Barrier (o .com );
899
906
phase_stats .phase_start_timer = GetTimeStamp ();
900
907
run_benchmark (& phase_stats , & current_index );
901
- end_phase ("benchmark" , & phase_stats );
908
+ end_phase ("benchmark" , & phase_stats , all_phases_stats );
902
909
903
910
if (o .adaptive_waiting_mode ){
904
911
o .relative_waiting_factor = 0.0625 ;
@@ -907,7 +914,7 @@ int md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logf
907
914
MPI_Barrier (o .com );
908
915
phase_stats .phase_start_timer = GetTimeStamp ();
909
916
run_benchmark (& phase_stats , & current_index );
910
- end_phase ("benchmark" , & phase_stats );
917
+ end_phase ("benchmark" , & phase_stats , all_phases_stats );
911
918
o .relative_waiting_factor *= 2 ;
912
919
}
913
920
}
@@ -920,7 +927,7 @@ int md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logf
920
927
phase_stats .phase_start_timer = GetTimeStamp ();
921
928
run_cleanup (& phase_stats , current_index );
922
929
phase_stats .t = GetTimeStamp () - phase_stats .phase_start_timer ;
923
- end_phase ("cleanup" , & phase_stats );
930
+ end_phase ("cleanup" , & phase_stats , all_phases_stats );
924
931
925
932
if (o .rank == 0 ){
926
933
if (o .backend -> rmdir (o .prefix , o .backend_options ) != 0 ) {
@@ -939,7 +946,6 @@ int md_workbench_run(int argc, char ** argv, MPI_Comm world_com, FILE * out_logf
939
946
oprintf ("Total runtime: %.0fs time: " , t_all );
940
947
printTime ();
941
948
}
942
-
943
949
//mem_free_preallocated(& limit_memory_P);
944
- return 0 ;
950
+ return all_phases_stats ;
945
951
}
0 commit comments