Skip to content

Commit ba3edb1

Browse files
author
Noah Lane Lewis
committed
Per step time tracking
1 parent fef9000 commit ba3edb1

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
@@ -102,8 +102,8 @@ typedef struct bench_params {
102102
} access_pattern;
103103

104104
// write_pattern bench_pattern;
105-
char * data_file_path;
106-
char * pattern_name;
105+
char *data_file_path;
106+
char *pattern_name;
107107
int meta_coll; // for write only, metadata collective
108108
int data_coll; // data collective
109109
int cnt_time_step;
@@ -123,9 +123,9 @@ typedef struct bench_params {
123123
unsigned long chunk_dim_1;
124124
unsigned long chunk_dim_2;
125125
unsigned long chunk_dim_3;
126-
char * csv_path;
127-
char * env_meta_path;
128-
FILE * csv_fs;
126+
char *csv_path;
127+
char *env_meta_path;
128+
FILE *csv_fs;
129129
int file_per_proc;
130130
int align;
131131
unsigned long align_threshold;
@@ -136,10 +136,10 @@ typedef struct bench_params {
136136
typedef struct data_md {
137137
unsigned long long particle_cnt;
138138
unsigned long long dim_1, dim_2, dim_3;
139-
float * x, *y, *z;
140-
float * px, *py, *pz;
141-
int * id_1;
142-
float * id_2;
139+
float *x, *y, *z;
140+
float *px, *py, *pz;
141+
int *id_1;
142+
float *id_2;
143143
} data_contig_md;
144144

145145
typedef struct csv_hanle {
@@ -166,7 +166,7 @@ typedef struct mem_monitor {
166166
unsigned long long mem_used;
167167
unsigned long long mem_threshold;
168168
async_mode mode;
169-
time_step * time_steps;
169+
time_step *time_steps;
170170
} mem_monitor;
171171

172172
unsigned long long read_time_val(duration time, time_unit unit);
@@ -183,7 +183,8 @@ int ts_delayed_close(mem_monitor *mon, unsigned long *metadata_time_tot
183183
int mem_monitor_check_run(mem_monitor *mon, unsigned long *metadata_time_total,
184184
unsigned long *data_time_total);
185185
int mem_monitor_final_run(mem_monitor *mon, unsigned long *metadata_time_total,
186-
unsigned long *data_time_total);
186+
unsigned long *data_time_total, unsigned long *data_wait_time_per_step,
187+
unsigned long *metadata_wait_time_per_step);
187188
// Uniform random number
188189
float uniform_random_number();
189190

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)
@@ -278,10 +278,14 @@ set_dataspace(bench_params params, unsigned long long try_read_elem_cnt, hid_t *
278278
int
279279
_run_benchmark_read(hid_t file_id, hid_t fapl, hid_t gapl, hid_t filespace, bench_params params,
280280
unsigned long *total_data_size_out, unsigned long *raw_read_time_out,
281-
unsigned long *inner_metadata_time)
281+
unsigned long *inner_metadata_time, unsigned long *data_time_per_step,
282+
unsigned long *metadata_time_per_step, unsigned long *data_wait_time_per_step,
283+
unsigned long *metadata_wait_time_per_step)
282284
{
283-
*raw_read_time_out = 0;
284-
*inner_metadata_time = 0;
285+
*raw_read_time_out = 0;
286+
*inner_metadata_time = 0;
287+
memset(metadata_time_per_step, 0, params.cnt_time_step * sizeof(unsigned long));
288+
memset(data_time_per_step, 0, params.cnt_time_step * sizeof(unsigned long));
285289
int nts = params.cnt_time_step;
286290
unsigned long long read_elem_cnt = params.try_num_particles;
287291
hid_t grp;
@@ -370,11 +374,14 @@ _run_benchmark_read(hid_t file_id, hid_t fapl, hid_t gapl, hid_t filespace, benc
370374
}
371375
}
372376

373-
*raw_read_time_out += (read_time_exp + read_time_imp);
374-
*inner_metadata_time += (meta_time1 + meta_time2 + meta_time3 + meta_time4 + meta_time5);
377+
metadata_time_per_step[ts_index] = (meta_time1 + meta_time2 + meta_time3 + meta_time4 + meta_time5);
378+
data_time_per_step[ts_index] = (read_time_exp + read_time_imp);
379+
*raw_read_time_out += data_time_per_step[ts_index];
380+
*inner_metadata_time += metadata_time_per_step[ts_index];
375381
}
376382

377-
mem_monitor_final_run(MEM_MONITOR, &metadata_time_imp, &read_time_imp);
383+
mem_monitor_final_run(MEM_MONITOR, &metadata_time_imp, &read_time_imp, data_wait_time_per_step,
384+
metadata_wait_time_per_step);
378385
*raw_read_time_out += read_time_imp;
379386
*inner_metadata_time += metadata_time_imp;
380387
*total_data_size_out = nts * actual_read_cnt * (6 * sizeof(float) + 2 * sizeof(int));
@@ -416,13 +423,12 @@ main(int argc, char *argv[])
416423
assert(MPI_THREAD_MULTIPLE == mpi_thread_lvl_provided);
417424
MPI_Comm_rank(MPI_COMM_WORLD, &MY_RANK);
418425
MPI_Comm_size(MPI_COMM_WORLD, &NUM_RANKS);
419-
420-
int sleep_time = 0;
421-
422-
bench_params params;
423-
424-
char *cfg_file_path = argv[1];
425-
char *file_name = argv[2]; // data file to read
426+
int sleep_time = 0;
427+
bench_params params;
428+
char *cfg_file_path = argv[1];
429+
char *file_name = argv[2]; // data file to read
430+
unsigned long *data_time_per_step = NULL, *metadata_time_per_step = NULL;
431+
unsigned long *data_wait_time_per_step = NULL, *metadata_wait_time_per_step = NULL;
426432

427433
if (MY_RANK == 0) {
428434
printf("Configuration file: %s\n", argv[1]);
@@ -516,6 +522,11 @@ main(int argc, char *argv[])
516522
printf("Number of particles available per rank: %llu \n", NUM_PARTICLES);
517523
}
518524

525+
data_time_per_step = malloc(NUM_TIMESTEPS * sizeof(unsigned long));
526+
metadata_time_per_step = malloc(NUM_TIMESTEPS * sizeof(unsigned long));
527+
data_wait_time_per_step = malloc(NUM_TIMESTEPS * sizeof(unsigned long));
528+
metadata_wait_time_per_step = malloc(NUM_TIMESTEPS * sizeof(unsigned long));
529+
519530
MPI_Barrier(MPI_COMM_WORLD);
520531

521532
MPI_Allreduce(&NUM_PARTICLES, &TOTAL_PARTICLES, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
@@ -537,7 +548,8 @@ main(int argc, char *argv[])
537548
unsigned long raw_read_time, metadata_time, local_data_size;
538549

539550
int ret = _run_benchmark_read(file_id, fapl, gapl, filespace, params, &local_data_size, &raw_read_time,
540-
&metadata_time);
551+
&metadata_time, data_time_per_step, metadata_time_per_step,
552+
data_wait_time_per_step, metadata_wait_time_per_step);
541553

542554
if (ret < 0) {
543555
if (MY_RANK == 0)
@@ -558,7 +570,7 @@ main(int argc, char *argv[])
558570

559571
if (MY_RANK == 0) {
560572
human_readable value;
561-
char * mode_str = NULL;
573+
char *mode_str = NULL;
562574

563575
if (has_vol_async) {
564576
mode_str = "ASYNC";
@@ -617,6 +629,29 @@ main(int argc, char *argv[])
617629
value = format_human_readable(or_bs);
618630
fprintf(params.csv_fs, "observed rate, %.3f, %cB/s\n", value.value, value.unit);
619631
fprintf(params.csv_fs, "observed time, %.3f, %s\n", oct_s, "seconds");
632+
// Per timestep data time
633+
for (int i = 0; i < NUM_TIMESTEPS; i++) {
634+
float t = (float)data_time_per_step[i] / (1000.0 * 1000.0);
635+
fprintf(params.csv_fs, "timestep %d data time, %.3f, %s\n", i, t, "seconds");
636+
}
637+
// Per timestep inner metadata time
638+
for (int i = 0; i < NUM_TIMESTEPS; i++) {
639+
float t = (float)metadata_time_per_step[i] / (1000.0 * 1000.0);
640+
fprintf(params.csv_fs, "timestep %d metadata time, %.3f, %s\n", i, t, "seconds");
641+
}
642+
// Print wait time if async is enabled
643+
if (has_vol_async) {
644+
// Per timestep data wait time
645+
for (int i = 0; i < NUM_TIMESTEPS; i++) {
646+
float t = (float)data_wait_time_per_step[i] / (1000.0 * 1000.0);
647+
fprintf(params.csv_fs, "timestep %d data wait time, %.3f, %s\n", i, t, "seconds");
648+
}
649+
// Per timestep metadata wait time
650+
for (int i = 0; i < NUM_TIMESTEPS; i++) {
651+
float t = (float)metadata_wait_time_per_step[i] / (1000.0 * 1000.0);
652+
fprintf(params.csv_fs, "timestep %d metadata wait time, %.3f, %s\n", i, t, "seconds");
653+
}
654+
}
620655
fclose(params.csv_fs);
621656
}
622657
}
@@ -631,6 +666,16 @@ main(int argc, char *argv[])
631666

632667
done:
633668
H5close();
669+
670+
if (data_time_per_step)
671+
free(data_time_per_step);
672+
if (metadata_time_per_step)
673+
free(metadata_time_per_step);
674+
if (data_wait_time_per_step)
675+
free(data_wait_time_per_step);
676+
if (metadata_wait_time_per_step)
677+
free(metadata_wait_time_per_step);
678+
634679
MPI_Finalize();
635680
return 0;
636681
}

0 commit comments

Comments
 (0)