Skip to content

Commit

Permalink
Skip calling H5Pget_filter() when H5Pget_nfilters() returns 0, indica…
Browse files Browse the repository at this point in the history
…ting no filter is used in read
  • Loading branch information
skyFzz committed Aug 13, 2024
1 parent 59fbabf commit 2e09379
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 0 additions & 2 deletions commons/h5bench_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ ts_delayed_close(mem_monitor *mon, unsigned long *metadata_time_total, int dset_
unsigned long meta_time = 0;

if (!has_vol_async) {
printf("DEBUG - ts_delayed_close() does not work, has_vol_async == 0\n");
return 0;
}

Expand All @@ -215,7 +214,6 @@ ts_delayed_close(mem_monitor *mon, unsigned long *metadata_time_total, int dset_
}
}
*metadata_time_total = meta_time;
printf("DEBUG - ts_delayed_close() works\n");
return 0;
}

Expand Down
28 changes: 16 additions & 12 deletions h5bench_patterns/h5bench_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ filter_info_init()
{
FILTER_INFO.USE_COMPRESS = 0;
FILTER_INFO.cd_nelmts = (size_t *)malloc(sizeof(size_t));
*(FILTER_INFO.cd_nelmts) = 10;
FILTER_INFO.cd_values = (unsigned int *)malloc(10 * sizeof(unsigned int));
FILTER_INFO.name = (char *)malloc(10 * sizeof(char));
FILTER_INFO.filter_config = (unsigned int *)malloc(1 * sizeof(unsigned int));
Expand All @@ -126,14 +127,20 @@ get_filter_info(hid_t dset_id)
dcpl = H5Dget_create_plist(dset_id);

if (dcpl < 0) {
printf("Invalid dataset creation property list identifier.");
return 1;
printf("Invalid dataset creation property list identifier.\n");
return -1;
}

// Check the number of filters in the pipeline, skip calling H5Pget_filter if 0 filter is detected in the pipeline
int num_filters = H5Pget_nfilters(dcpl);
if (num_filters <= 0) {
return 0;
}

FILTER_INFO.filter_id = H5Pget_filter2(dcpl, 0, H5Z_FLAG_MANDATORY, FILTER_INFO.cd_nelmts, FILTER_INFO.cd_values, 10, FILTER_INFO.name, FILTER_INFO.filter_config);

if (FILTER_INFO.filter_id < 0) {
return 1;
printf("Failed to retrieve filter information.\n");
return -1;
}

FILTER_INFO.USE_COMPRESS = 1;
Expand Down Expand Up @@ -175,14 +182,12 @@ read_h5_data(time_step *ts, hid_t loc, hid_t *dset_ids, hid_t filespace, hid_t m
dset_ids[6] = H5Dopen_async(loc, "py", dapl, ts->es_meta_create);
dset_ids[7] = H5Dopen_async(loc, "pz", dapl, ts->es_meta_create);

int err = get_filter_info(dset_ids[0]);
if (MY_RANK = 0) {
if (err) {
printf(" No compression filter on the dataset\n");
} else {
printf(" Read filter info successfully\n");
int ret = get_filter_info(dset_ids[0]);
if (ret < 0) {
if (MY_RANK == 0) {
printf("get_filter_info() failed\n");
}
}
}

t2 = get_time_usec();

Expand Down Expand Up @@ -793,7 +798,6 @@ main(int argc, char *argv[])

MPI_Allreduce(&NUM_PARTICLES, &TOTAL_PARTICLES, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
MPI_Scan(&NUM_PARTICLES, &FILE_OFFSET, 1, MPI_LONG_LONG, MPI_SUM, MPI_COMM_WORLD);
// E.g. Rank 2: `FILE_OFFSET_2 = (NUM_PARTICLES_0 + NUM_PARTICLES_1 + NUM_PARTICLES_2) - NUM_PARTICLES_2` = NUM_PARTICLES_0 + NUM_PARTICLES_1
FILE_OFFSET -= NUM_PARTICLES;
// Allocate memory for each particlee
BUF_STRUCT = prepare_contig_memory_multi_dim(params.dim_1, params.dim_2, params.dim_3);
Expand Down

0 comments on commit 2e09379

Please sign in to comment.