Skip to content

Commit

Permalink
Fix bug to deference cd_values for output. Increase the number of all…
Browse files Browse the repository at this point in the history
…owed cd_values to 10. Change input names to cd_nelmts and cd_values from num_aux_data and aux_data_*
  • Loading branch information
skyFzz committed Aug 9, 2024
1 parent 053b683 commit c65397e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 44 deletions.
48 changes: 34 additions & 14 deletions commons/h5bench_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,24 +890,39 @@ _set_params(char *key, char *val_in, bench_params *params_in_out, int do_write)
else
(*params_in_out).compress_filter = COMPRESS_FILTER_INVALID;
}
else if (strcmp(key, "NUM_AUXILIARY_DATA") == 0) {
else if (strcmp(key, "CD_NELMTS") == 0) {
(*params_in_out).cd_nelmts = atoi(val);
}
else if (strcmp(key, "AUXILIARY_DATA_1") == 0) {
else if (strcmp(key, "CD_VALUES_1") == 0) {
(*params_in_out).cd_value_1 = atoi(val);
}
else if (strcmp(key, "AUXILIARY_DATA_2") == 0) {
else if (strcmp(key, "CD_VALUES_2") == 0) {
(*params_in_out).cd_value_2 = atoi(val);
}
else if (strcmp(key, "AUXILIARY_DATA_3") == 0) {
else if (strcmp(key, "CD_VALUES_3") == 0) {
(*params_in_out).cd_value_3 = atoi(val);
}
else if (strcmp(key, "AUXILIARY_DATA_4") == 0) {
else if (strcmp(key, "CD_VALUES_4") == 0) {
(*params_in_out).cd_value_4 = atoi(val);
}
else if (strcmp(key, "AUXILIARY_DATA_5") == 0) {
else if (strcmp(key, "CD_VALUES_5") == 0) {
(*params_in_out).cd_value_5 = atoi(val);
}
else if (strcmp(key, "CD_VALUES_6") == 0) {
(*params_in_out).cd_value_6 = atoi(val);
}
else if (strcmp(key, "CD_VALUES_7") == 0) {
(*params_in_out).cd_value_7 = atoi(val);
}
else if (strcmp(key, "CD_VALUES_8") == 0) {
(*params_in_out).cd_value_8 = atoi(val);
}
else if (strcmp(key, "CD_VALUES_9") == 0) {
(*params_in_out).cd_value_9 = atoi(val);
}
else if (strcmp(key, "CD_VALUES_10") == 0) {
(*params_in_out).cd_value_10 = atoi(val);
}
else if (strcmp(key, "NUM_DIMS") == 0) {
int num = atoi(val);
if (num > 0)
Expand Down Expand Up @@ -1336,19 +1351,24 @@ print_params(const bench_params *p)

if (p->useCompress) {
printf("Use compression: %d\n", p->useCompress);
printf(" Compression_filter_name: %s\n", compress_filter_names[p->compress_filter]); // New
printf(" Compression_filter_id: %d\n", compress_filter_ids[p->compress_filter]); // New
printf(" Number of auxiliary data: %d\n", p->cd_nelmts); // new
cd_values = (unsigned int *)malloc(5 * sizeof(unsigned int)); // new
cd_values[0] = p->cd_value_1; // new
printf(" Compression_filter_name: %s\n", compress_filter_names[p->compress_filter]);
printf(" Compression_filter_id: %d\n", compress_filter_ids[p->compress_filter]);
printf(" Number of compression filter parameters: %d\n", p->cd_nelmts);
cd_values = (unsigned int *)malloc(10 * sizeof(unsigned int));
cd_values[0] = p->cd_value_1;
cd_values[1] = p->cd_value_2;
cd_values[2] = p->cd_value_3;
cd_values[3] = p->cd_value_4;
cd_values[4] = p->cd_value_5;
for (int i = 0; i < p->cd_nelmts; ++i) { // new
printf(" Auxiliary data %d: %d\n", i + 1, cd_values[i]);
cd_values[5] = p->cd_value_6;
cd_values[6] = p->cd_value_7;
cd_values[7] = p->cd_value_8;
cd_values[8] = p->cd_value_9;
cd_values[9] = p->cd_value_10;
for (int i = 0; i < p->cd_nelmts; ++i) {
printf(" Compression parameter %d: %d\n", i + 1, cd_values[i]);
}
free(cd_values); // new
free(cd_values);
printf(" chunk_dim1: %lu\n", p->chunk_dim_1);
if (p->num_dims >= 2) {
printf(" chunk_dim2: %lu\n", p->chunk_dim_2);
Expand Down
21 changes: 13 additions & 8 deletions commons/h5bench_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ typedef enum read_option {
CS
} read_option;

typedef enum compress_filter { // new
typedef enum compress_filter {
COMPRESS_FILTER_INVALID,
N_BIT,
SZIP,
Expand All @@ -115,7 +115,7 @@ typedef struct bench_params {
pattern mem_pattern;
pattern file_pattern;
read_option read_option;
compress_filter compress_filter; // new
compress_filter compress_filter;
int useCompress;
int useCSV;
async_mode asyncMode;
Expand Down Expand Up @@ -159,12 +159,17 @@ typedef struct bench_params {
unsigned long align_threshold;
unsigned long align_len;
unsigned long stdev_dim_1;
size_t cd_nelmts; // new
unsigned int cd_value_1; // new
unsigned int cd_value_2; // new
unsigned int cd_value_3; // new
unsigned int cd_value_4; // new
unsigned int cd_value_5; // new
size_t cd_nelmts;
unsigned int cd_value_1;
unsigned int cd_value_2;
unsigned int cd_value_3;
unsigned int cd_value_4;
unsigned int cd_value_5;
unsigned int cd_value_6;
unsigned int cd_value_7;
unsigned int cd_value_8;
unsigned int cd_value_9;
unsigned int cd_value_10;
} bench_params;

typedef struct data_md {
Expand Down
29 changes: 15 additions & 14 deletions h5bench_patterns/h5bench_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ herr_t ierr;
data_contig_md *BUF_STRUCT;
mem_monitor * MEM_MONITOR;

typedef struct filter_info { // new
typedef struct filter_info {
int USE_COMPRESS;
size_t *cd_nelmts;
unsigned int *cd_values;
Expand All @@ -74,7 +74,7 @@ typedef struct filter_info { // new
H5Z_filter_t filter_id;
} filter_info;

filter_info FILTER_INFO; // new
filter_info FILTER_INFO;

void
print_data(int n)
Expand All @@ -98,7 +98,7 @@ set_dspace_plist(hid_t *plist_id_out, int data_collective)

// Allocate memory for filter_info
void
filter_info_init() // new
filter_info_init()
{
FILTER_INFO.USE_COMPRESS = 0;
FILTER_INFO.cd_nelmts = (size_t *)malloc(sizeof(size_t));
Expand All @@ -120,7 +120,7 @@ filter_info_free()

// Retrieve information about a filter on a dataset
int
get_filter_info(hid_t dset_id) // new
get_filter_info(hid_t dset_id)
{
hid_t dcpl;
dcpl = H5Dget_create_plist(dset_id);
Expand All @@ -141,9 +141,9 @@ get_filter_info(hid_t dset_id) // new
if (MY_RANK == 0) {
printf(" Compression filter used to decompress: %s\n", FILTER_INFO.name);
printf(" Filter ID: %d\n", FILTER_INFO.filter_id);
printf(" Number of auxiliary data: %d\n", FILTER_INFO.cd_nelmts);
printf(" Number of compression filter parameters: %d\n", FILTER_INFO.cd_nelmts);
for (int i = 0; i < *(FILTER_INFO.cd_nelmts); ++i) {
printf(" Auxiliary data %d: %d\n", i, FILTER_INFO.cd_values[i]);
printf(" Compression parameter %d: %d\n", i, FILTER_INFO.cd_values[i]);
}
}

Expand Down Expand Up @@ -175,7 +175,7 @@ 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]); // new
int err = get_filter_info(dset_ids[0]);
if (MY_RANK = 0) {
if (err) {
printf(" No compression filter on the dataset\n");
Expand Down Expand Up @@ -590,7 +590,7 @@ _run_benchmark_read(hid_t file_id, hid_t fapl, hid_t gapl, hid_t filespace, benc
unsigned long read_time_exp = 0, metadata_time_exp = 0;
unsigned long read_time_imp = 0, metadata_time_imp = 0;
int dset_cnt = 8;
filter_info_init(); // new
filter_info_init();
for (int ts_index = 0; ts_index < nts; ts_index++) {
meta_time1 = 0, meta_time2 = 0, meta_time3 = 0, meta_time4 = 0, meta_time5 = 0;
sprintf(grp_name, "Timestep_%d", ts_index);
Expand Down Expand Up @@ -643,7 +643,7 @@ _run_benchmark_read(hid_t file_id, hid_t fapl, hid_t gapl, hid_t filespace, benc
*raw_read_time_out += (read_time_exp + read_time_imp);
*inner_metadata_time += (meta_time1 + meta_time2 + meta_time3 + meta_time4 + meta_time5);
}
filter_info_free(); // new

mem_monitor_final_run(MEM_MONITOR, &metadata_time_imp, &read_time_imp);
*raw_read_time_out += read_time_imp;
*inner_metadata_time += metadata_time_imp;
Expand Down Expand Up @@ -886,12 +886,12 @@ main(int argc, char *argv[])
value = format_human_readable(total_size_bytes);
fprintf(params.csv_fs, "total size, %.3lf, %cB\n", value.value, value.unit);

if (FILTER_INFO.USE_COMPRESS) { // new
if (FILTER_INFO.USE_COMPRESS) {
fprintf(params.csv_fs, "compression filter name, %s\n", FILTER_INFO.name);
fprintf(params.csv_fs, "filter ID, %d\n", FILTER_INFO.filter_id);
fprintf(params.csv_fs, "number of auxiliary data, %d\n", FILTER_INFO.cd_nelmts);
for (int i = 0; i < FILTER_INFO.cd_nelmts; ++i) {
fprintf(params.csv_fs, "auxiliary data %d, %d\n", i, FILTER_INFO.cd_values[i]);
fprintf(params.csv_fs, "number of compression filter parameters, %d\n", FILTER_INFO.cd_nelmts);
for (int i = 0; i < *(FILTER_INFO.cd_nelmts); ++i) {
fprintf(params.csv_fs, "compression parameter %d, %d\n", i, FILTER_INFO.cd_values[i]);
}
}

Expand All @@ -904,8 +904,9 @@ main(int argc, char *argv[])
fprintf(params.csv_fs, "observed time, %.3f, %s\n", oct_s, "seconds");
fclose(params.csv_fs);
}

}

filter_info_free();
error:
H5E_BEGIN_TRY
{
Expand Down
15 changes: 7 additions & 8 deletions h5bench_patterns/h5bench_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,13 +899,18 @@ set_globals(const bench_params *params)
herr_t ret;

// Construct auxiliary data for the filter
cd_values = (unsigned int *)malloc(5 * sizeof(unsigned int));
cd_values = (unsigned int *)malloc(10 * sizeof(unsigned int));
cd_values[0] = params->cd_value_1;
cd_values[1] = params->cd_value_2;
cd_values[2] = params->cd_value_3;
cd_values[3] = params->cd_value_4;
cd_values[4] = params->cd_value_5;

cd_values[5] = params->cd_value_6;
cd_values[6] = params->cd_value_7;
cd_values[7] = params->cd_value_8;
cd_values[8] = params->cd_value_9;
cd_values[9] = params->cd_value_10;

// Create a new property list instance
COMPRESS_INFO.dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
assert(COMPRESS_INFO.dcpl_id > 0);
Expand All @@ -914,12 +919,6 @@ set_globals(const bench_params *params)
ret = H5Premove_filter(COMPRESS_INFO.dcpl_id, H5Z_FILTER_ALL);
assert(ret >= 0);

/*
// Set shuffle filter prior to any compression filters
ret = H5Pset_shuffle(COMPRESS_INFO.dcpl_id);
assert(ret >= 0);
*/

/* Set chunked layout and chunk dimensions */
ret = H5Pset_layout(COMPRESS_INFO.dcpl_id, H5D_CHUNKED);
assert(ret >= 0);
Expand Down

0 comments on commit c65397e

Please sign in to comment.