Skip to content

Commit dc4da9d

Browse files
author
Noah Lane Lewis
committed
Add per timestep timing.
1 parent 675c86d commit dc4da9d

File tree

8 files changed

+192
-89
lines changed

8 files changed

+192
-89
lines changed

commons/h5bench_util.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ ts_delayed_close(mem_monitor *mon, unsigned long *metadata_time_total, int dset_
175175
if (!mon || !metadata_time_total)
176176
return -1;
177177

178-
time_step * ts_run;
178+
time_step *ts_run;
179179
size_t num_in_progress;
180180
H5ES_status_t op_failed;
181181
unsigned long t1, t2;
@@ -212,7 +212,7 @@ mem_monitor_check_run(mem_monitor *mon, unsigned long *metadata_time_total, unsi
212212
return -1;
213213
if (!has_vol_async)
214214
return 0;
215-
time_step * ts_run;
215+
time_step *ts_run;
216216
size_t num_in_progress;
217217
hbool_t op_failed;
218218
unsigned long t1, t2, t3, t4;
@@ -248,14 +248,23 @@ mem_monitor_check_run(mem_monitor *mon, unsigned long *metadata_time_total, unsi
248248
return 0;
249249
}
250250

251+
/**
252+
* data_wait_time_per_step, metadata_wait_time_per_step can
253+
* safely but set to NULL if info is not needed.
254+
*/
251255
int
252-
mem_monitor_final_run(mem_monitor *mon, unsigned long *metadata_time_total, unsigned long *data_time_total)
256+
mem_monitor_final_run(mem_monitor *mon, unsigned long *metadata_time_total, unsigned long *data_time_total,
257+
unsigned long *data_wait_time_per_step, unsigned long *metadata_wait_time_per_step)
253258
{
259+
if (metadata_wait_time_per_step != NULL)
260+
memset(metadata_wait_time_per_step, 0, mon->time_step_cnt * sizeof(unsigned long));
261+
if (data_wait_time_per_step)
262+
memset(data_wait_time_per_step, 0, mon->time_step_cnt * sizeof(unsigned long));
254263
*metadata_time_total = 0;
255264
*data_time_total = 0;
256265
size_t num_in_progress;
257266
hbool_t op_failed;
258-
time_step * ts_run;
267+
time_step *ts_run;
259268
unsigned long t1, t2, t3, t4, t5, t6;
260269
unsigned long meta_time = 0, data_time = 0;
261270
int dset_cnt = 8;
@@ -292,7 +301,6 @@ mem_monitor_final_run(mem_monitor *mon, unsigned long *metadata_time_total, unsi
292301
ts_run->status = TS_READY;
293302
}
294303
}
295-
296304
t2 = get_time_usec();
297305
meta_time += (t2 - t1);
298306

@@ -317,6 +325,10 @@ mem_monitor_final_run(mem_monitor *mon, unsigned long *metadata_time_total, unsi
317325

318326
t6 = get_time_usec();
319327

328+
if (metadata_wait_time_per_step != NULL)
329+
metadata_wait_time_per_step[i] = ((t2 - t1) + (t4 - t3));
330+
if (data_wait_time_per_step != NULL)
331+
data_wait_time_per_step[i] = (t3 - t2);
320332
meta_time += ((t2 - t1) + (t4 - t3));
321333
data_time += (t3 - t2);
322334
ts_run->status = TS_DONE;
@@ -439,7 +451,7 @@ parse_time(char *str_in, duration *time)
439451
if (!time)
440452
time = calloc(1, sizeof(duration));
441453
unsigned long long num = 0;
442-
char * unit_str;
454+
char *unit_str;
443455
parse_unit(str_in, &num, &unit_str);
444456

445457
if (!unit_str)
@@ -470,7 +482,7 @@ str_to_ull(char *str_in, unsigned long long *num_out)
470482
return -1;
471483
}
472484
unsigned long long num = 0;
473-
char * unit_str;
485+
char *unit_str;
474486
int ret = parse_unit(str_in, &num, &unit_str);
475487
if (ret < 0)
476488
return -1;

commons/h5bench_util.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ typedef struct bench_params {
115115
} access_pattern;
116116

117117
// write_pattern bench_pattern;
118-
char * data_file_path;
119-
char * pattern_name;
118+
char *data_file_path;
119+
char *pattern_name;
120120
int meta_coll; // for write only, metadata collective
121121
int data_coll; // data collective
122122
int cnt_time_step;
@@ -140,9 +140,9 @@ typedef struct bench_params {
140140
unsigned long chunk_dim_1;
141141
unsigned long chunk_dim_2;
142142
unsigned long chunk_dim_3;
143-
char * csv_path;
144-
char * env_meta_path;
145-
FILE * csv_fs;
143+
char *csv_path;
144+
char *env_meta_path;
145+
FILE *csv_fs;
146146
int file_per_proc;
147147
int align;
148148
unsigned long align_threshold;
@@ -153,10 +153,10 @@ typedef struct bench_params {
153153
typedef struct data_md {
154154
unsigned long long particle_cnt;
155155
unsigned long long dim_1, dim_2, dim_3;
156-
float * x, *y, *z;
157-
float * px, *py, *pz;
158-
int * id_1;
159-
float * id_2;
156+
float *x, *y, *z;
157+
float *px, *py, *pz;
158+
int *id_1;
159+
float *id_2;
160160
} data_contig_md;
161161

162162
typedef struct csv_hanle {
@@ -183,7 +183,7 @@ typedef struct mem_monitor {
183183
unsigned long long mem_used;
184184
unsigned long long mem_threshold;
185185
async_mode mode;
186-
time_step * time_steps;
186+
time_step *time_steps;
187187
} mem_monitor;
188188

189189
unsigned long long read_time_val(duration time, time_unit unit);
@@ -200,7 +200,8 @@ int ts_delayed_close(mem_monitor *mon, unsigned long *metadata_time_tot
200200
int mem_monitor_check_run(mem_monitor *mon, unsigned long *metadata_time_total,
201201
unsigned long *data_time_total);
202202
int mem_monitor_final_run(mem_monitor *mon, unsigned long *metadata_time_total,
203-
unsigned long *data_time_total);
203+
unsigned long *data_time_total, unsigned long *data_wait_time_per_step,
204+
unsigned long *metadata_wait_time_per_step);
204205
// Uniform random number
205206
float uniform_random_number();
206207

h5bench_patterns/h5bench_append.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ hid_t PARTICLE_COMPOUND_TYPE_SEPARATES[8];
3333

3434
herr_t ierr;
3535
data_contig_md *BUF_STRUCT;
36-
mem_monitor * MEM_MONITOR;
36+
mem_monitor *MEM_MONITOR;
3737

3838
void
3939
print_data(int n)
@@ -71,7 +71,7 @@ append_h5_data(bench_params params, time_step *ts, hid_t loc, hid_t *dset_ids, h
7171

7272
dapl = H5Pcreate(H5P_DATASET_ACCESS);
7373

74-
int * data_1D_INT, **data_2D_INT, ***data_3D_INT;
74+
int *data_1D_INT, **data_2D_INT, ***data_3D_INT;
7575
float *data_1D_FLOAT, **data_2D_FLOAT, ***data_3D_FLOAT;
7676

7777
if (params.num_dims == 1) {
@@ -473,7 +473,7 @@ _run_benchmark_modify(hid_t file_id, hid_t fapl, hid_t gapl, hid_t filespace, be
473473
*inner_metadata_time += (meta_time1 + meta_time2 + meta_time3 + meta_time4 + meta_time5);
474474
}
475475

476-
mem_monitor_final_run(MEM_MONITOR, &metadata_time_imp, &read_time_imp);
476+
mem_monitor_final_run(MEM_MONITOR, &metadata_time_imp, &read_time_imp, NULL, NULL);
477477
*raw_read_time_out += read_time_imp;
478478
*inner_metadata_time += metadata_time_imp;
479479
*total_data_size_out = nts * actual_read_cnt * (6 * sizeof(float) + 2 * sizeof(int));
@@ -657,7 +657,7 @@ main(int argc, char *argv[])
657657

658658
if (MY_RANK == 0) {
659659
human_readable value;
660-
char * mode_str = NULL;
660+
char *mode_str = NULL;
661661

662662
if (has_vol_async) {
663663
mode_str = "ASYNC";

h5bench_patterns/h5bench_overwrite.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ hid_t PARTICLE_COMPOUND_TYPE_SEPARATES[8];
3232

3333
herr_t ierr;
3434
data_contig_md *BUF_STRUCT;
35-
mem_monitor * MEM_MONITOR;
35+
mem_monitor *MEM_MONITOR;
3636

3737
void
3838
print_data(int n)
@@ -67,7 +67,7 @@ overwrite_h5_data(bench_params params, time_step *ts, hid_t loc, hid_t *dset_ids
6767

6868
dapl = H5Pcreate(H5P_DATASET_ACCESS);
6969

70-
int * data_1D_INT, **data_2D_INT, ***data_3D_INT;
70+
int *data_1D_INT, **data_2D_INT, ***data_3D_INT;
7171
float *data_1D_FLOAT, **data_2D_FLOAT, ***data_3D_FLOAT;
7272

7373
if (params.num_dims == 1) {
@@ -449,7 +449,7 @@ _run_benchmark_modify(hid_t file_id, hid_t fapl, hid_t gapl, hid_t filespace, be
449449
*inner_metadata_time += (meta_time1 + meta_time2 + meta_time3 + meta_time4 + meta_time5);
450450
}
451451

452-
mem_monitor_final_run(MEM_MONITOR, &metadata_time_imp, &read_time_imp);
452+
mem_monitor_final_run(MEM_MONITOR, &metadata_time_imp, &read_time_imp, NULL, NULL);
453453
*raw_read_time_out += read_time_imp;
454454
*inner_metadata_time += metadata_time_imp;
455455
*total_data_size_out = nts * actual_read_cnt * (6 * sizeof(float) + 2 * sizeof(int));
@@ -633,7 +633,7 @@ main(int argc, char *argv[])
633633

634634
if (MY_RANK == 0) {
635635
human_readable value;
636-
char * mode_str = NULL;
636+
char *mode_str = NULL;
637637

638638
if (has_vol_async) {
639639
mode_str = "ASYNC";

h5bench_patterns/h5bench_read.c

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int subfiling = 0;
6363

6464
herr_t ierr;
6565
data_contig_md *BUF_STRUCT;
66-
mem_monitor * MEM_MONITOR;
66+
mem_monitor *MEM_MONITOR;
6767

6868
void
6969
print_data(int n)
@@ -468,10 +468,14 @@ set_dataspace(bench_params params, unsigned long long try_read_elem_cnt, hid_t *
468468
int
469469
_run_benchmark_read(hid_t file_id, hid_t fapl, hid_t gapl, hid_t filespace, bench_params params,
470470
unsigned long *total_data_size_out, unsigned long *raw_read_time_out,
471-
unsigned long *inner_metadata_time)
471+
unsigned long *inner_metadata_time, unsigned long *data_time_per_step,
472+
unsigned long *metadata_time_per_step, unsigned long *data_wait_time_per_step,
473+
unsigned long *metadata_wait_time_per_step)
472474
{
473-
*raw_read_time_out = 0;
474-
*inner_metadata_time = 0;
475+
*raw_read_time_out = 0;
476+
*inner_metadata_time = 0;
477+
memset(metadata_time_per_step, 0, params.cnt_time_step * sizeof(unsigned long));
478+
memset(data_time_per_step, 0, params.cnt_time_step * sizeof(unsigned long));
475479
int nts = params.cnt_time_step;
476480
unsigned long long read_elem_cnt = params.try_num_particles;
477481
hid_t grp;
@@ -563,11 +567,14 @@ _run_benchmark_read(hid_t file_id, hid_t fapl, hid_t gapl, hid_t filespace, benc
563567
}
564568
}
565569

566-
*raw_read_time_out += (read_time_exp + read_time_imp);
567-
*inner_metadata_time += (meta_time1 + meta_time2 + meta_time3 + meta_time4 + meta_time5);
570+
metadata_time_per_step[ts_index] = (meta_time1 + meta_time2 + meta_time3 + meta_time4 + meta_time5);
571+
data_time_per_step[ts_index] = (read_time_exp + read_time_imp);
572+
*raw_read_time_out += data_time_per_step[ts_index];
573+
*inner_metadata_time += metadata_time_per_step[ts_index];
568574
}
569575

570-
mem_monitor_final_run(MEM_MONITOR, &metadata_time_imp, &read_time_imp);
576+
mem_monitor_final_run(MEM_MONITOR, &metadata_time_imp, &read_time_imp, data_wait_time_per_step,
577+
metadata_wait_time_per_step);
571578
*raw_read_time_out += read_time_imp;
572579
*inner_metadata_time += metadata_time_imp;
573580
*total_data_size_out = nts * actual_read_cnt * (6 * sizeof(float) + 2 * sizeof(int));
@@ -609,13 +616,12 @@ main(int argc, char *argv[])
609616
assert(MPI_THREAD_MULTIPLE == mpi_thread_lvl_provided);
610617
MPI_Comm_rank(MPI_COMM_WORLD, &MY_RANK);
611618
MPI_Comm_size(MPI_COMM_WORLD, &NUM_RANKS);
612-
613-
int sleep_time = 0;
614-
615-
bench_params params;
616-
617-
char *cfg_file_path = argv[1];
618-
char *file_name = argv[2]; // data file to read
619+
int sleep_time = 0;
620+
bench_params params;
621+
char *cfg_file_path = argv[1];
622+
char *file_name = argv[2]; // data file to read
623+
unsigned long *data_time_per_step = NULL, *metadata_time_per_step = NULL;
624+
unsigned long *data_wait_time_per_step = NULL, *metadata_wait_time_per_step = NULL;
619625

620626
if (MY_RANK == 0) {
621627
printf("Configuration file: %s\n", argv[1]);
@@ -709,6 +715,11 @@ main(int argc, char *argv[])
709715
printf("Number of particles available per rank: %llu \n", NUM_PARTICLES);
710716
}
711717

718+
data_time_per_step = malloc(NUM_TIMESTEPS * sizeof(unsigned long));
719+
metadata_time_per_step = malloc(NUM_TIMESTEPS * sizeof(unsigned long));
720+
data_wait_time_per_step = malloc(NUM_TIMESTEPS * sizeof(unsigned long));
721+
metadata_wait_time_per_step = malloc(NUM_TIMESTEPS * sizeof(unsigned long));
722+
712723
MPI_Barrier(MPI_COMM_WORLD);
713724

714725
MPI_Allreduce(&NUM_PARTICLES, &TOTAL_PARTICLES, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
@@ -730,7 +741,8 @@ main(int argc, char *argv[])
730741
unsigned long raw_read_time, metadata_time, local_data_size;
731742

732743
int ret = _run_benchmark_read(file_id, fapl, gapl, filespace, params, &local_data_size, &raw_read_time,
733-
&metadata_time);
744+
&metadata_time, data_time_per_step, metadata_time_per_step,
745+
data_wait_time_per_step, metadata_wait_time_per_step);
734746

735747
if (ret < 0) {
736748
if (MY_RANK == 0)
@@ -751,7 +763,7 @@ main(int argc, char *argv[])
751763

752764
if (MY_RANK == 0) {
753765
human_readable value;
754-
char * mode_str = NULL;
766+
char *mode_str = NULL;
755767

756768
if (has_vol_async) {
757769
mode_str = "ASYNC";
@@ -810,6 +822,29 @@ main(int argc, char *argv[])
810822
value = format_human_readable(or_bs);
811823
fprintf(params.csv_fs, "observed rate, %.3f, %cB/s\n", value.value, value.unit);
812824
fprintf(params.csv_fs, "observed time, %.3f, %s\n", oct_s, "seconds");
825+
// Per timestep data time
826+
for (int i = 0; i < NUM_TIMESTEPS; i++) {
827+
float t = (float)data_time_per_step[i] / (1000.0 * 1000.0);
828+
fprintf(params.csv_fs, "timestep %d data time, %.3f, %s\n", i, t, "seconds");
829+
}
830+
// Per timestep inner metadata time
831+
for (int i = 0; i < NUM_TIMESTEPS; i++) {
832+
float t = (float)metadata_time_per_step[i] / (1000.0 * 1000.0);
833+
fprintf(params.csv_fs, "timestep %d metadata time, %.3f, %s\n", i, t, "seconds");
834+
}
835+
// Print wait time if async is enabled
836+
if (has_vol_async) {
837+
// Per timestep data wait time
838+
for (int i = 0; i < NUM_TIMESTEPS; i++) {
839+
float t = (float)data_wait_time_per_step[i] / (1000.0 * 1000.0);
840+
fprintf(params.csv_fs, "timestep %d data wait time, %.3f, %s\n", i, t, "seconds");
841+
}
842+
// Per timestep metadata wait time
843+
for (int i = 0; i < NUM_TIMESTEPS; i++) {
844+
float t = (float)metadata_wait_time_per_step[i] / (1000.0 * 1000.0);
845+
fprintf(params.csv_fs, "timestep %d metadata wait time, %.3f, %s\n", i, t, "seconds");
846+
}
847+
}
813848
fclose(params.csv_fs);
814849
}
815850
}
@@ -824,6 +859,16 @@ main(int argc, char *argv[])
824859

825860
done:
826861
H5close();
862+
863+
if (data_time_per_step)
864+
free(data_time_per_step);
865+
if (metadata_time_per_step)
866+
free(metadata_time_per_step);
867+
if (data_wait_time_per_step)
868+
free(data_wait_time_per_step);
869+
if (metadata_wait_time_per_step)
870+
free(metadata_wait_time_per_step);
871+
827872
MPI_Finalize();
828873
return 0;
829874
}

0 commit comments

Comments
 (0)