diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2022-04-14 15:39:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 15:39:01 (GMT) |
commit | 9a18a396d21ec2622e62301016f5b912ff4d5a1f (patch) | |
tree | b269524f24af6fe4c87d9e1adbc817bdbf7df1c1 /tools | |
parent | 615fe7370fa960ca7a3d4fc2b1f53905c2f1358c (diff) | |
download | hdf5-9a18a396d21ec2622e62301016f5b912ff4d5a1f.zip hdf5-9a18a396d21ec2622e62301016f5b912ff4d5a1f.tar.gz hdf5-9a18a396d21ec2622e62301016f5b912ff4d5a1f.tar.bz2 |
1.10 Add option for h5repack timing #1142 (#1576)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/src/h5repack/h5repack.c | 90 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack.h | 8 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_copy.c | 141 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_filters.c | 4 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_main.c | 18 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_refs.c | 11 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_verify.c | 2 | ||||
-rw-r--r-- | tools/test/h5repack/testfiles/h5repack-help.txt | 3 |
8 files changed, 196 insertions, 81 deletions
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 005f522..16221f1 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -221,6 +221,7 @@ h5repack_addlayout(const char *str, pack_opt_t *options) * to free the stack. *------------------------------------------------------------------------- */ + hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) @@ -256,9 +257,8 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t dt->id_out = H5I_INVALID_HID; /* Check if this type is the one requested */ - if (oinfo.addr == dt->addr_in) { + if (oinfo.addr == dt->addr_in) dt_ret = dt; - } } /* end if named datatype */ } /* end for each object in traversal table */ } /* end else (create the stack) */ @@ -346,24 +346,28 @@ done: int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) { - hid_t attr_id = H5I_INVALID_HID; /* attr ID */ - hid_t attr_out = H5I_INVALID_HID; /* attr ID */ - hid_t space_id = H5I_INVALID_HID; /* space ID */ - hid_t ftype_id = H5I_INVALID_HID; /* file type ID */ - hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */ - size_t msize; /* size of type */ - void * buf = NULL; /* data buffer */ - hsize_t nelmts; /* number of elements in dataset */ - int rank; /* rank of dataset */ - htri_t is_named; /* Whether the datatype is named */ - hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ - char name[255]; - H5O_info_t oinfo; /* object info */ - int j; - unsigned u; - hbool_t is_ref = 0; - H5T_class_t type_class = -1; - int ret_value = 0; + hid_t attr_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr_out = H5I_INVALID_HID; /* attr ID */ + hid_t space_id = H5I_INVALID_HID; /* space ID */ + hid_t ftype_id = H5I_INVALID_HID; /* file type ID */ + hid_t wtype_id = H5I_INVALID_HID; /* read/write type ID */ + size_t msize; /* size of type */ + void * buf = NULL; /* data buffer */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + htri_t is_named; /* Whether the datatype is named */ + hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ + H5_timer_t timer; /* Timer for read/write operations */ + H5_timevals_t times; /* Elapsed time for each operation */ + static double read_time = 0; + static double write_time = 0; + char name[255]; + H5O_info_t oinfo; /* object info */ + int j; + unsigned u; + hbool_t is_ref = 0; + H5T_class_t type_class = -1; + int ret_value = 0; if (H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed"); @@ -460,6 +464,9 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ } /* end for each member */ } /* end if type_class is H5T_COMPOUND */ + read_time = 0; + write_time = 0; + if (!is_ref) { /*----------------------------------------------------------------- * read to memory @@ -470,8 +477,17 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ if (buf == NULL) { H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Aread(attr_id, wtype_id, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + read_time += times.elapsed; + } /*----------------------------------------------------------------- * copy @@ -480,8 +496,18 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ if ((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed on ,%s>", name); + + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Awrite(attr_out, wtype_id, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + write_time += times.elapsed; + } /*close*/ if (H5Aclose(attr_out) < 0) @@ -495,7 +521,9 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ buf = NULL; } /*H5T_REFERENCE*/ - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_ATTR_TIME, "attr", read_time, write_time, name); + else HDprintf(FORMAT_OBJ_ATTR, "attr", name); /*--------------------------------------------------------------------- @@ -561,7 +589,7 @@ check_options(pack_opt_t *options) * Objects to layout *------------------------------------------------------------------------- */ - if (options->verbose && have_request(options)) { + if (options->verbose > 0 && have_request(options)) { if (options->all_layout == 1) { HDprintf("All objects to modify layout are...\n"); switch (options->layout_g) { @@ -602,7 +630,7 @@ check_options(pack_opt_t *options) char *name = options->op_tbl->objs[i].path; if (options->op_tbl->objs[i].chunk.rank > 0) { - if (options->verbose) { + if (options->verbose > 0) { HDprintf(" <%s> with chunk size ", name); for (k = 0; k < options->op_tbl->objs[i].chunk.rank; k++) HDprintf("%d ", (int)options->op_tbl->objs[i].chunk.chunk_lengths[k]); @@ -611,7 +639,7 @@ check_options(pack_opt_t *options) has_ck = 1; } else if (options->op_tbl->objs[i].chunk.rank == -2) { /* TODO: replace 'magic number' */ - if (options->verbose) + if (options->verbose > 0) HDprintf(" <%s> %s\n", name, "NONE (contiguous)"); has_ck = 1; } @@ -625,7 +653,7 @@ check_options(pack_opt_t *options) *------------------------------------------------------------------------- */ - if (options->verbose && have_request(options)) { + if (options->verbose > 0 && have_request(options)) { if (options->all_filter == 1) { HDprintf("All objects to apply filter are...\n"); for (k = 0; k < options->n_filter_g; k++) { @@ -662,7 +690,7 @@ check_options(pack_opt_t *options) char * name = pack.path; for (j = 0; j < pack.nfilters; j++) { - if (options->verbose) { + if (options->verbose > 0) { if (pack.filter[j].filtn >= 0) { if (pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) { HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), @@ -700,7 +728,7 @@ check_options(pack_opt_t *options) *------------------------------------------------------------------------ */ if (options->ublock_filename != NULL && options->ublock_size == 0) { - if (options->verbose) { + if (options->verbose > 0) { HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename); options->ublock_size = 1024; @@ -773,21 +801,21 @@ check_objects(const char *fname, pack_opt_t *options) *------------------------------------------------------------------------- */ - if (options->verbose) + if (options->verbose > 0) HDprintf("Opening file. Searching %zu objects to modify ...\n", travt->nobjs); for (i = 0; i < options->op_tbl->nelems; i++) { pack_info_t obj = options->op_tbl->objs[i]; char * name = obj.path; - if (options->verbose) + if (options->verbose > 0) HDprintf(" <%s>", name); /* the input object names are present in the file and are valid */ if (h5trav_getindext(name, travt) < 0) H5TOOLS_GOTO_ERROR((-1), "%s Could not find <%s> in file <%s>. Exiting...\n", - (options->verbose ? "\n" : ""), name, fname); - if (options->verbose) + (options->verbose > 0 ? "\n" : ""), name, fname); + if (options->verbose > 0) HDprintf("...Found\n"); for (ifil = 0; ifil < obj.nfilters; ifil++) { diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h index 3503ce9..84583e1 100644 --- a/tools/src/h5repack/h5repack.h +++ b/tools/src/h5repack/h5repack.h @@ -27,6 +27,12 @@ #define FORMAT_OBJ_ATTR " %-27s %s\n" /* obj type, name */ #define MAX_COMPACT_DSIZE 64512 /* max data size for compact layout. -1k for header size */ +/* timing formats */ +#define FORMAT_OBJ_TIME " %-27s %e/%e %s\n" /* obj type, name */ +#define FORMAT_OBJ_ATTR_TIME " %-27s %e/%e %s\n" /* obj type, name */ +#define FORMAT_OBJ_NOTIME " %-27s %s\n" /* obj type, name */ +#define FORMAT_OBJ_ATTR_NOTIME " %-27s %s\n" /* obj type, name */ + /* File space default information */ #define FS_PAGESIZE_DEF 4096 #define FS_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR @@ -118,7 +124,7 @@ typedef struct { int grp_compact; /* Set the maximum number of links to store as header messages in the group */ int grp_indexed; /* Set the minimum number of links to store in the indexed format */ int msg_size[8]; /* Minimum size of shared messages: dataspace, - datatype, fill value, filter pipleline, attribute */ + datatype, fill value, filter pipeline, attribute */ const char * ublock_filename; /* user block file name */ hsize_t ublock_size; /* user block size */ hsize_t meta_block_size; /* metadata aggregation block size (for H5Pset_meta_block_size) */ diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index b3c8ffb..c7c0758 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -39,7 +39,8 @@ */ static int get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t size_datum, hsize_t dims_hslab[], hsize_t *hslab_nbytes_p); -static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr); +static void print_dataset_info(hid_t dcpl_id, char *objname, double per, int pr, pack_opt_t *options, + double read_time, double write_time); static int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options); static int copy_user_block(const char *infile, const char *outfile, hsize_t size); #if defined(H5REPACK_DEBUG_USER_BLOCK) @@ -298,7 +299,7 @@ copy_objects(const char *fnamein, const char *fnameout, pack_opt_t *options) * create the output file *------------------------------------------------------------------------- */ - if (options->verbose) + if (options->verbose > 0) HDprintf("Making new file ...\n"); if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, options->fout_fapl)) < 0) @@ -401,18 +402,18 @@ done: /*------------------------------------------------------------------------- * Function: get_hyperslab * - * Purpose: Calulate a hyperslab from a dataset for higher performance. - * The size of hyperslab is limitted by H5TOOLS_BUFSIZE. - * Return the hyperslab dimentions and size in byte. + * Purpose: Calculate a hyperslab from a dataset for higher performance. + * The size of hyperslab is limited by H5TOOLS_BUFSIZE. + * Return the hyperslab dimensions and size in byte. * * Return: 0 - SUCCEED, -1 FAILED * * Parameters: * dcpl_id : [IN] dataset creation property. * rank_dset : [IN] dataset rank - * dims_dset[] : [IN] dataset dimentions + * dims_dset[] : [IN] dataset dimensions * size_datum : [IN] size of a data element in byte - * dims_hslab[] : [OUT] calculated hyperslab dimentions + * dims_hslab[] : [OUT] calculated hyperslab dimensions * * hslab_nbytes_p : [OUT] total byte of the hyperslab * * Update: @@ -427,7 +428,7 @@ done: * 3. If not chunked, each data element would be a unit of collection and * the boundary would be dataset's dims. * - * The calulation starts from the last dimention (h5dump dims output). + * The calculation starts from the last dimension (h5dump dims output). *-----------------------------------------*/ int @@ -441,8 +442,8 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t si hsize_t size_chunk = 1; hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ - hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */ - hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */ + hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimensions */ + hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimensions */ hsize_t hslab_nbytes; /* size of hyperslab in byte */ int ret_value = 0; @@ -467,18 +468,18 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t si /* 1. if a chunk fit in hyperslab buffer */ if (nchunk_fit >= 1) { - /* Calulate a hyperslab that contains as many chunks that can fit + /* Calculate a hyperslab that contains as many chunks that can fit * in hyperslab buffer. Hyperslab will be increased starting from - * the last dimention of the dataset (see h5dump's dims output). + * the last dimension of the dataset (see h5dump's dims output). * The calculation boundary is dataset dims. * In the loop, used mapping from a datum to a chunk to figure out * chunk based hyperslab. */ for (k = rank_dset; k > 0; --k) { - /* map dataset dimentions with a chunk dims */ + /* map dataset dimensions with a chunk dims */ chunk_dims_map[k - 1] = dims_dset[k - 1] / dims_chunk[k - 1]; - /* if reminder exist, increse by 1 to cover partial edge chunks */ + /* if reminder exist, increase by 1 to cover partial edge chunks */ if (dims_dset[k - 1] % dims_chunk[k - 1] > 0) chunk_dims_map[k - 1]++; @@ -491,7 +492,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t si if (nchunk_fit == 0) nchunk_fit = 1; - /* get hyperslab dimentions as unmapping to actual size */ + /* get hyperslab dimensions as unmapping to actual size */ dims_hslab[k - 1] = MIN((hs_dims_map[k - 1] * dims_chunk[k - 1]), dims_dset[k - 1]); /* calculate total size for the hyperslab */ @@ -500,9 +501,9 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t si } /* 2. if a chunk is bigger than hyperslab buffer */ else { - /* Calulate a hyperslab that contains as many data elements that + /* Calculate a hyperslab that contains as many data elements that * can fit in hyperslab buffer. Hyperslab will be increased - * starting from the last dimention of the chunk (see h5dump's dims + * starting from the last dimension of the chunk (see h5dump's dims * output). * The calculation boundary is a chunk dims. */ @@ -512,7 +513,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t si /* if a datum is bigger than rest of buffer */ if (ndatum_fit == 0) ndatum_fit = 1; - /* get hyperslab dimentions within a chunk boundary */ + /* get hyperslab dimensions within a chunk boundary */ dims_hslab[k - 1] = MIN(dims_chunk[k - 1], ndatum_fit); /* calculate total size for the hyperslab */ @@ -525,9 +526,9 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t si } /* 3. if dataset is not chunked */ else { - /* Calulate a hyperslab that contains as many data elements that can + /* Calculate a hyperslab that contains as many data elements that can * fit in hyperslab buffer. Hyperslab will be increased starting from - * the last dimention of the dataset (see h5dump's dims output). + * the last dimension of the dataset (see h5dump's dims output). * The calculation boundary is dataset dims. */ for (k = rank_dset; k > 0; --k) { @@ -536,7 +537,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, const hsize_t dims_dset[], size_t si /* if a datum is bigger than rest of buffer */ if (ndatum_fit == 0) ndatum_fit = 1; - /* get hyperslab dimentions within dataset boundary */ + /* get hyperslab dimensions within dataset boundary */ dims_hslab[k - 1] = MIN(dims_dset[k - 1], ndatum_fit); /* calculate total size for the hyperslab */ @@ -600,7 +601,7 @@ done: * in (2) is that, when using the strip mine size, it assures that the "remaining" part * of the dataset that does not fill an entire strip mine is processed. * - * 1. figure out a hyperslab (dimentions) and size (refer to get_hyperslab()). + * 1. figure out a hyperslab (dimensions) and size (refer to get_hyperslab()). * 2. Calculate the hyperslab selections as the selection is moving forward. * Selection would be same as the hyperslab except for the remaining edge portion * of the dataset. The code take care of the remaining portion if exist. @@ -643,6 +644,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti int req_filter; /* there was a request for a filter */ int req_obj_layout = 0; /* request layout to current object */ unsigned crt_order_flags; /* group creation order flag */ + H5_timer_t timer; /* Timer for read/write operations */ + H5_timevals_t times; /* Elapsed time for each operation */ + static double read_time = 0; + static double write_time = 0; h5tool_link_info_t linkinfo; unsigned i; unsigned u; @@ -661,7 +666,12 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti *------------------------------------------------------------------------- */ - if (options->verbose) { + if (options->verbose == 2) { + HDprintf("-----------------------------------------------------------------\n"); + HDprintf(" Type Filter (Compression) Timing read/write Name\n"); + HDprintf("-----------------------------------------------------------------\n"); + } + else { HDprintf("-----------------------------------------\n"); HDprintf(" Type Filter (Compression) Name\n"); HDprintf("-----------------------------------------\n"); @@ -682,7 +692,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti *------------------------------------------------------------------------- */ case H5TRAV_TYPE_GROUP: - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_NOTIME, "group", travt->objs[i].name); + else HDprintf(FORMAT_OBJ, "group", travt->objs[i].name); /* open input group */ @@ -749,6 +761,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti case H5TRAV_TYPE_DATASET: { hbool_t use_h5ocopy; + read_time = 0.0; + write_time = 0.0; + has_filter = 0; req_filter = 0; @@ -936,7 +951,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti H5P_DEFAULT, dcpl_out, H5P_DEFAULT); if (dset_out == H5I_INVALID_HID) { H5TOOLS_INFO("H5Dcreate2 failed"); - if (options->verbose) + if (options->verbose > 0) HDprintf(" warning: could not create dataset <%s>. Applying original " "settings\n", travt->objs[i].name); @@ -977,11 +992,27 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti } if (buf != NULL) { + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + read_time += times.elapsed; + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, dxpl_id, buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + write_time += times.elapsed; + } /* Check if we have VL data in the dataset's * datatype that must be reclaimed */ @@ -1079,12 +1110,28 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti hs_select_nelmts = 1; } /* end (else) rank == 0 */ + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + read_time += times.elapsed; + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, dxpl_id, hslab_buf) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + write_time += times.elapsed; + } /* reclaim any VL memory, if necessary */ if (vl_data) @@ -1114,7 +1161,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti * print amount of compression used *------------------------------------------------------------------------- */ - if (options->verbose) { + if (options->verbose > 0) { double ratio = 0; /* only print the compression ration if there was a filter request */ @@ -1125,10 +1172,12 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti /* compression ratio = uncompressed size / compressed size */ if (dsize_out != 0) ratio = (double)dsize_in / (double)dsize_out; - print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1); + print_dataset_info(dcpl_out, travt->objs[i].name, ratio, 1, options, + read_time, write_time); } else - print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0); + print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0, options, + read_time, write_time); /* print a message that the filter was not applied * (in case there was a filter) @@ -1185,6 +1234,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti if (H5Pset_copy_object(ocpl_id, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed"); + if (options->verbose == 2) { + H5_timer_init(&timer); + H5_timer_start(&timer); + } if (H5Ocopy(fidin, /* Source file or group identifier */ travt->objs[i].name, /* Name of the source object to be copied */ fidout, /* Destination file or group identifier */ @@ -1192,6 +1245,11 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti ocpl_id, /* Properties which apply to the copy */ H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed"); + if (options->verbose == 2) { + H5_timer_stop(&timer); + H5_timer_get_times(timer, ×); + write_time += times.elapsed; + } if (H5Pclose(ocpl_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); @@ -1212,7 +1270,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti if (H5Dclose(dset_out) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_TIME, "dset", 0.0, write_time, travt->objs[i].name); + else HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); } /* end whether we have request for filter/chunking */ @@ -1225,7 +1285,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti *------------------------------------------------------------------------- */ case H5TRAV_TYPE_NAMED_DATATYPE: - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_NOTIME, "type", travt->objs[i].name); + else HDprintf(FORMAT_OBJ, "type", travt->objs[i].name); if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) @@ -1265,7 +1327,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti */ case H5TRAV_TYPE_LINK: case H5TRAV_TYPE_UDLINK: - if (options->verbose) + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_NOTIME, "link", travt->objs[i].name); + else HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); /* Check -X option. */ @@ -1390,7 +1454,8 @@ done: *------------------------------------------------------------------------- */ static void -print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) +print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr, pack_opt_t *options, double read_time, + double write_time) { char strfilter[255]; #if defined(PRINT_DEBUG) @@ -1479,7 +1544,10 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) } /* end for each filter */ if (!pr) - HDprintf(FORMAT_OBJ, "dset", objname); + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_TIME, "dset", read_time, write_time, objname); + else + HDprintf(FORMAT_OBJ, "dset", objname); else { char str[512], temp[512]; @@ -1487,7 +1555,10 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) HDstrcat(str, strfilter); HDsprintf(temp, " (%.3f:1)", ratio); HDstrcat(str, temp); - HDprintf(FORMAT_OBJ, str, objname); + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_TIME, str, read_time, write_time, objname); + else + HDprintf(FORMAT_OBJ, str, objname); } } /* end print_dataset_info() */ @@ -1515,7 +1586,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) /* Copy the userblock from the input file to the output file */ while (size > 0) { - ssize_t nread, nbytes; /* # of bytes transfered, etc. */ + ssize_t nread, nbytes; /* # of bytes transferred, etc. */ char rbuf[USERBLOCK_XFER_SIZE]; /* Buffer for reading */ const char *wbuf; /* Pointer into buffer, for writing */ diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c index 32476ce..76bac5e 100644 --- a/tools/src/h5repack/h5repack_filters.c +++ b/tools/src/h5repack/h5repack_filters.c @@ -231,7 +231,7 @@ aux_assign_obj(const char * name, /* object name from traverse list */ * do extra checking in the case of SZIP; delete all filters in the case * of H5Z_FILTER_NONE present in the PACK_INFO_T filter array * - * Return: 0 success, -1 an error occured + * Return: 0 success, -1 an error occurred *------------------------------------------------------------------------- */ @@ -258,7 +258,7 @@ apply_filters(const char * name, /* object name from traverse list */ H5TOOLS_GOTO_DONE(0); /*------------------------------------------------------------------------- - * initialize the assigment object + * initialize the assignment object *------------------------------------------------------------------------- */ init_packobject(&obj); diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index bc6a605..193b200 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -31,7 +31,7 @@ const char *outfile = NULL; * Command-line options: The user can specify short or long-named * parameters. */ -static const char * s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:vz:E*G:LM:P:S:T:VXW"; +static const char * s_opts = "a:b:c:d:e:f:hi:j:k:l:m:no:q:s:t:u:v*z:E*G:LM:P:S:T:VXW"; static struct long_options l_opts[] = {{"alignment", require_arg, 'a'}, {"block", require_arg, 'b'}, {"compact", require_arg, 'c'}, @@ -39,18 +39,18 @@ static struct long_options l_opts[] = {{"alignment", require_arg, 'a'}, {"file", require_arg, 'e'}, {"filter", require_arg, 'f'}, {"help", no_arg, 'h'}, - {"infile", require_arg, 'i'}, /* for backward compability */ + {"infile", require_arg, 'i'}, /* for backward compatibility */ {"low", require_arg, 'j'}, {"high", require_arg, 'k'}, {"layout", require_arg, 'l'}, {"minimum", require_arg, 'm'}, {"native", no_arg, 'n'}, - {"outfile", require_arg, 'o'}, /* for backward compability */ + {"outfile", require_arg, 'o'}, /* for backward compatibility */ {"sort_by", require_arg, 'q'}, {"ssize", require_arg, 's'}, {"threshold", require_arg, 't'}, {"ublock", require_arg, 'u'}, - {"verbose", no_arg, 'v'}, + {"verbose", optional_arg, 'v'}, {"sort_order", require_arg, 'z'}, {"enable-error-stack", optional_arg, 'E'}, {"fs_pagesize", require_arg, 'G'}, @@ -87,7 +87,8 @@ usage(const char *prog) " Optional value 2 also prints file open errors.\n"); PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n"); - PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n"); + PRINTVALSTREAM(rawoutstream, " -v N, --verbose=N Verbose mode, print object information.\n"); + PRINTVALSTREAM(rawoutstream, " N - is an integer greater than 1, 2 displays read/write timing\n"); PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n"); PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); @@ -492,7 +493,12 @@ parse_command_line(int argc, const char *const *argv, pack_opt_t *options) goto done; case 'v': - options->verbose = 1; + if (opt_arg != NULL) { + if (2 == HDatoi(opt_arg)) + options->verbose = 2; + } + else + options->verbose = 1; break; case 'f': diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c index 6f2afca..7b1715e 100644 --- a/tools/src/h5repack/h5repack_refs.c +++ b/tools/src/h5repack/h5repack_refs.c @@ -182,8 +182,11 @@ do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti /* create the reference, -1 parameter for objects */ if (H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); - if (options->verbose) { - HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); + if (options->verbose > 0) { + if (options->verbose == 2) + HDprintf(FORMAT_OBJ_NOTIME, "dset", travt->objs[i].name); + else + HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); HDprintf("object <%s> object reference created to <%s>\n", travt->objs[i].name, refname); } @@ -276,7 +279,7 @@ do_copy_refobjs(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *opti H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); if (H5Sclose(region_id) < 0) H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); - if (options->verbose) { + if (options->verbose > 0) { HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); HDprintf("object <%s> region reference created to <%s>\n", travt->objs[i].name, refname); @@ -536,7 +539,7 @@ copy_refs_attr(hid_t loc_in, hid_t loc_out, trav_table_t *travt, hid_t fidout) / } /* This line below needs to be moved in this loop instead of inserting outside. Otherwise, ref_comp_field_n may be >0 for the next attribute, which may not be - the reference type and will be accidently treated as the reference type. + the reference type and will be accidentally treated as the reference type. It will then cause the H5Acreate2 failed since that attribute is already created. KY 2020-02-10 */ diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c index b62fe6d..dcee7ee 100644 --- a/tools/src/h5repack/h5repack_verify.c +++ b/tools/src/h5repack/h5repack_verify.c @@ -397,7 +397,7 @@ h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); /*------------------------------------------------------------------------- - * traverse the suppplied object list + * traverse the supplied object list *------------------------------------------------------------------------- */ for (i = 0; i < trav->nobjs; i++) { diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index d06d43a..a8f2da4 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -6,7 +6,8 @@ usage: h5repack [OPTIONS] file1 file2 Optional value 2 also prints file open errors. OPTIONS -h, --help Print a usage message and exit - -v, --verbose Verbose mode, print object information + -v N, --verbose=N Verbose mode, print object information. + N - is an integer greater than 1, 2 displays read/write timing -V, --version Print version number and exit -n, --native Use a native HDF5 type when repacking -L, --latest Use latest version of file format |