diff options
author | M. Scot Breitenfeld <brtnfld@hdfgroup.org> | 2018-06-04 19:41:12 (GMT) |
---|---|---|
committer | M. Scot Breitenfeld <brtnfld@hdfgroup.org> | 2018-06-04 19:41:12 (GMT) |
commit | f484649347152316229f607f782ea269ebbc5994 (patch) | |
tree | 9f8ffda1440436cbd01b1c34495533c14ea92039 /tools | |
parent | cc611c696fbff4731c4eef3882ef985ac3ebab1d (diff) | |
parent | afc6beb7760d2c7ee13f2456deac3da4e1ae4b2e (diff) | |
download | hdf5-f484649347152316229f607f782ea269ebbc5994.zip hdf5-f484649347152316229f607f782ea269ebbc5994.tar.gz hdf5-f484649347152316229f607f782ea269ebbc5994.tar.bz2 |
Merge branch 'develop' into hdf5_1_10.sync
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/h5diff.c | 12 | ||||
-rw-r--r-- | tools/lib/h5diff_array.c | 4 | ||||
-rw-r--r-- | tools/lib/h5diff_attr.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 8 | ||||
-rw-r--r-- | tools/lib/h5tools_dump.c | 2 | ||||
-rw-r--r-- | tools/lib/h5tools_ref.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 2 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 6 | ||||
-rw-r--r-- | tools/lib/h5trav.c | 22 | ||||
-rw-r--r-- | tools/lib/h5trav.h | 2 | ||||
-rw-r--r-- | tools/src/h5dump/h5dump.c | 2 | ||||
-rw-r--r-- | tools/src/h5dump/h5dump_ddl.c | 12 | ||||
-rw-r--r-- | tools/src/h5dump/h5dump_xml.c | 10 | ||||
-rw-r--r-- | tools/src/h5format_convert/h5format_convert.c | 2 | ||||
-rw-r--r-- | tools/src/h5ls/h5ls.c | 6 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack.c | 4 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_refs.c | 4 | ||||
-rw-r--r-- | tools/src/h5stat/h5stat.c | 4 | ||||
-rw-r--r-- | tools/test/perform/direct_write_perf.c | 684 |
19 files changed, 740 insertions, 54 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 94cca58..28b1f00 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -433,7 +433,7 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata) HGOTO_DONE(0); if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, - trav_grp_objs,trav_grp_symlinks, tinfo) < 0) { + trav_grp_objs,trav_grp_symlinks, tinfo, H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); opts->err_stat = 1; HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents"); @@ -465,7 +465,7 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata) HGOTO_DONE(0); if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, - trav_grp_objs,trav_grp_symlinks, tinfo) < 0) { + trav_grp_objs,trav_grp_symlinks, tinfo, H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); opts->err_stat = 1; HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents\n"); @@ -645,7 +645,7 @@ h5diff(const char *fname1, /* optional data pass */ info1_obj->opts = (diff_opt_t*)opts; - if(H5Oget_info_by_name(file1_id, obj1fullname, &oinfo1, H5P_DEFAULT) < 0) { + if(H5Oget_info_by_name2(file1_id, obj1fullname, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { parallel_print("Error: Could not get file contents\n"); HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents"); } @@ -695,7 +695,7 @@ h5diff(const char *fname1, /* optional data pass */ info2_obj->opts = (diff_opt_t*)opts; - if(H5Oget_info_by_name(file2_id, obj2fullname, &oinfo2, H5P_DEFAULT) < 0) { + if(H5Oget_info_by_name2(file2_id, obj2fullname, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { parallel_print("Error: Could not get file contents\n"); HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents"); } @@ -846,7 +846,7 @@ h5diff(const char *fname1, info1_grp->opts = (diff_opt_t*)opts; if(h5trav_visit(file1_id, obj1fullname, TRUE, TRUE, - trav_grp_objs, trav_grp_symlinks, info1_grp) < 0) { + trav_grp_objs, trav_grp_symlinks, info1_grp, H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); HGOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents"); } @@ -860,7 +860,7 @@ h5diff(const char *fname1, info2_grp->opts = (diff_opt_t*)opts; if(h5trav_visit(file2_id, obj2fullname, TRUE, TRUE, - trav_grp_objs, trav_grp_symlinks, info2_grp) < 0) { + trav_grp_objs, trav_grp_symlinks, info2_grp, H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); HGOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents"); } /* end if */ diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 11f5e41..9d5f062 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -2096,8 +2096,8 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t if (nfound_b && opts->m_verbose) { H5O_info_t oi1, oi2; - H5Oget_info(obj1_id, &oi1); - H5Oget_info(obj2_id, &oi2); + H5Oget_info2(obj1_id, &oi1, H5O_INFO_BASIC); + H5Oget_info2(obj2_id, &oi2, H5O_INFO_BASIC); parallel_print("Referenced dataset %lu %lu\n", (unsigned long) oi1.addr, (unsigned long) oi2.addr); parallel_print( "------------------------------------------------------------\n"); diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 7f08cc7..4ad4c90 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -154,9 +154,9 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t h5difftrace("build_match_list_attrs start\n"); - if(H5Oget_info(loc1_id, &oinfo1) < 0) + if(H5Oget_info2(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info first object failed"); - if(H5Oget_info(loc2_id, &oinfo2) < 0) + if(H5Oget_info2(loc2_id, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info second object failed"); table_attrs_init(&table_lp); diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 11888bc..470df63 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1758,14 +1758,14 @@ h5tools_is_obj_same(hid_t loc_id1, const char *name1, hbool_t ret_val = 0; if ( name1 && HDstrcmp(name1, ".")) - H5Oget_info_by_name(loc_id1, name1, &oinfo1, H5P_DEFAULT); + H5Oget_info_by_name2(loc_id1, name1, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT); else - H5Oget_info(loc_id1, &oinfo1); + H5Oget_info2(loc_id1, &oinfo1, H5O_INFO_BASIC); if ( name2 && HDstrcmp(name2, ".")) - H5Oget_info_by_name(loc_id2, name2, &oinfo2, H5P_DEFAULT); + H5Oget_info_by_name2(loc_id2, name2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT); else - H5Oget_info(loc_id2, &oinfo2); + H5Oget_info2(loc_id2, &oinfo2, H5O_INFO_BASIC); if (oinfo1.fileno == oinfo2.fileno && oinfo1.addr==oinfo2.addr) ret_val = 1; diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 38ace81..69cecb0 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -1905,7 +1905,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ H5O_info_t oinfo; obj_t *obj = NULL; /* Found object */ - H5Oget_info(type, &oinfo); + H5Oget_info2(type, &oinfo, H5O_INFO_BASIC); obj = search_obj(h5dump_type_table, oinfo.addr); if(obj) { diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index d6e5f01..e98a8e2 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -113,7 +113,7 @@ init_ref_path_table(void) return (-1); /* Iterate over objects in this file */ - if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) { + if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL, H5O_INFO_BASIC) < 0) { error_msg("unable to construct reference path table\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ @@ -184,7 +184,7 @@ ref_path_table_lookup(const char *thepath) /* Get the object info now */ /* (returns failure for dangling soft links) */ - if(H5Oget_info_by_name(thefile, thepath, &oi, H5P_DEFAULT) < 0) + if(H5Oget_info_by_name2(thefile, thepath, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) return HADDR_UNDEF; /* Return OID */ diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index a018394..3d595ca 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -1120,7 +1120,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai const char *path; obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp); - H5Oget_info(obj, &oi); + H5Oget_info2(obj, &oi, H5O_INFO_BASIC); /* Print object type and close object */ switch(oi.type) { diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 5272e81..8ac0d32 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -507,7 +507,7 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen if(H5Tcommitted(type) > 0) { H5O_info_t type_oinfo; - H5Oget_info(type, &type_oinfo); + H5Oget_info2(type, &type_oinfo, H5O_INFO_BASIC); if(search_obj(info->type_table, type_oinfo.addr) == NULL) add_obj(info->type_table, type_oinfo.addr, name, FALSE); } /* end if */ @@ -573,7 +573,7 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table, info->dset_table = *dset_table; /* Find all shared objects */ - return(h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info)); + return(h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info, H5O_INFO_BASIC)); } @@ -729,7 +729,7 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_ } /* get target object info */ - if(H5Oget_info_by_name(file_id, linkpath, &trg_oinfo, lapl) < 0) { + if(H5Oget_info_by_name2(file_id, linkpath, &trg_oinfo, H5O_INFO_BASIC, lapl) < 0) { if(link_info->opt.msg_mode == 1) parallel_print("Warning: unable to get object information for <%s>\n", linkpath); HGOTO_DONE(FAIL); diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index b6d32f7..917d5f5 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -43,6 +43,7 @@ typedef struct { hbool_t is_absolute; /* Whether the traversal has absolute paths */ const char *base_grp_name; /* Name of the group that serves as the base * for iteration */ + unsigned fields; /* Fields needed in H5O_info_t struct */ } trav_ud_traverse_t; typedef struct { @@ -201,7 +202,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, H5O_info_t oinfo; /* Get information about the object */ - if(H5Oget_info_by_name(loc_id, path, &oinfo, H5P_DEFAULT) < 0) { + if(H5Oget_info_by_name2(loc_id, path, &oinfo, udata->fields, H5P_DEFAULT) < 0) { if(new_name) HDfree(new_name); return(H5_ITER_ERROR); @@ -251,13 +252,13 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, */ static int traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, - hbool_t recurse, const trav_visitor_t *visitor) + hbool_t recurse, const trav_visitor_t *visitor, unsigned fields) { H5O_info_t oinfo; /* Object info for starting group */ int ret_value = SUCCEED; /* Get info for starting object */ - if(H5Oget_info_by_name(file_id, grp_name, &oinfo, H5P_DEFAULT) < 0) + if(H5Oget_info_by_name2(file_id, grp_name, &oinfo, fields, H5P_DEFAULT) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info_by_name failed"); /* Visit the starting object */ @@ -282,6 +283,7 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, udata.visitor = visitor; udata.is_absolute = (*grp_name == '/'); udata.base_grp_name = grp_name; + udata.fields = fields; /* Check for iteration of links vs. visiting all links recursively */ if(recurse) { @@ -356,9 +358,9 @@ trav_fileinfo_add(trav_info_t *info, hid_t loc_id) size_t idx = info->nused - 1; if ( info->paths[idx].path && HDstrcmp(info->paths[idx].path, ".")) - H5Oget_info_by_name(loc_id, info->paths[idx].path, &oinfo, H5P_DEFAULT); + H5Oget_info_by_name2(loc_id, info->paths[idx].path, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); else - H5Oget_info(loc_id, &oinfo); + H5Oget_info2(loc_id, &oinfo, H5O_INFO_BASIC); info->paths[idx].objno = oinfo.addr; info->paths[idx].fileno = oinfo.fileno; @@ -436,7 +438,7 @@ h5trav_getinfo(hid_t file_id, trav_info_t *info) info_visitor.udata = info; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(file_id, "/", TRUE, TRUE, &info_visitor) < 0) + if(traverse(file_id, "/", TRUE, TRUE, &info_visitor, H5O_INFO_BASIC) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); done: @@ -602,7 +604,7 @@ h5trav_gettable(hid_t fid, trav_table_t *table) table_visitor.udata = table; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(fid, "/", TRUE, TRUE, &table_visitor) < 0) + if(traverse(fid, "/", TRUE, TRUE, &table_visitor, H5O_INFO_BASIC) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); done: @@ -1027,7 +1029,7 @@ h5trav_print(hid_t fid) print_visitor.udata = &print_udata; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(fid, "/", TRUE, TRUE, &print_visitor) < 0) + if(traverse(fid, "/", TRUE, TRUE, &print_visitor, H5O_INFO_BASIC) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); done: @@ -1047,7 +1049,7 @@ done: int h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, - void *udata) + void *udata, unsigned fields) { trav_visitor_t visitor; /* Visitor structure for objects */ int ret_value = SUCCEED; @@ -1058,7 +1060,7 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, visitor.udata = udata; /* Traverse all objects in the file, visiting each object & link */ - if(traverse(fid, grp_name, visit_start, recurse, &visitor) < 0) + if(traverse(fid, grp_name, visit_start, recurse, &visitor, fields) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); done: diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index c2ad9b7..a1d33b7 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -134,7 +134,7 @@ extern "C" { H5TOOLS_DLL void h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order); H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, - h5trav_lnk_func_t visit_lnk, void *udata); + h5trav_lnk_func_t visit_lnk, void *udata, unsigned fields); H5TOOLS_DLL herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path); H5TOOLS_DLL hbool_t symlink_is_visited(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path); diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index 25e4858..a5f0369 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -1482,7 +1482,7 @@ main(int argc, const char *argv[]) } /* Get object info for root group */ - if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) { + if(H5Oget_info_by_name2(fid, "/", &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__); h5tools_setstatus(EXIT_FAILURE); goto done; diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index 6646626..5c47abd 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -229,7 +229,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ATTR H5O_info_t oinfo; /* Stat the object */ - if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) { + if(H5Oget_info_by_name2(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { error_msg("unable to get object information for \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; @@ -706,7 +706,7 @@ dump_named_datatype(hid_t tid, const char *name) h5tools_dump_header_format->datatypeblockbegin); h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); - H5Oget_info(tid, &oinfo); + H5Oget_info2(tid, &oinfo, H5O_INFO_BASIC); /* Must check for uniqueness of all objects if we've traversed an elink, * otherwise only check if the reference count > 1. @@ -876,7 +876,7 @@ dump_group(hid_t gid, const char *name) h5tools_dump_comment(rawoutstream, outputformat, &ctx, gid); - H5Oget_info(gid, &oinfo); + H5Oget_info2(gid, &oinfo, H5O_INFO_BASIC); /* Must check for uniqueness of all objects if we've traversed an elink, * otherwise only check if the reference count > 1. @@ -1512,7 +1512,7 @@ handle_paths(hid_t fid, const char *path_name, void H5_ATTR_UNUSED * data, int H handle_udata.fid = fid; handle_udata.op_name = path_name; - if(h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata) < 0) { + if(h5trav_visit(fid, "/", TRUE, TRUE, obj_search, lnk_search, &handle_udata, H5O_INFO_BASIC) < 0) { error_msg("error traversing information\n"); h5tools_setstatus(EXIT_FAILURE); } @@ -1800,7 +1800,7 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis } /* end if */ - H5Oget_info(dsetid, &oinfo); + H5Oget_info2(dsetid, &oinfo, H5O_INFO_BASIC); if(oinfo.rc > 1 || hit_elink) { obj_t *found_obj; /* Found object */ @@ -2101,7 +2101,7 @@ dump_extlink(hid_t group, const char *linkname, const char *objname) goto fail; /* Get object info */ - if (H5Oget_info(oid, &oi) < 0) { + if (H5Oget_info2(oid, &oi, H5O_INFO_BASIC) < 0) { H5Oclose(oid); goto fail; } diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 4e13df3..e399d8f 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -180,7 +180,7 @@ xml_dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void H5_ H5O_info_t oinfo; /* Stat the object */ - if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) { + if(H5Oget_info_by_name2(group, name, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { error_msg("unable to get object information for \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; @@ -881,7 +881,7 @@ xml_print_datatype(hid_t type, unsigned in_group) obj_t *found_obj; /* Found object */ /* detect a shared datatype, output only once */ - H5Oget_info(type, &oinfo); + H5Oget_info2(type, &oinfo, H5O_INFO_BASIC); found_obj = search_obj(type_table, oinfo.addr); if(found_obj) { @@ -1534,7 +1534,7 @@ xml_dump_datatype(hid_t type) obj_t *found_obj; /* Found object */ /* Datatype is a shared or named datatype */ - H5Oget_info(type, &oinfo); + H5Oget_info2(type, &oinfo, H5O_INFO_BASIC); found_obj = search_obj(type_table, oinfo.addr); if(found_obj) { @@ -2362,7 +2362,7 @@ xml_dump_named_datatype(hid_t type, const char *name) h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); /* Check uniqueness of named datatype */ - H5Oget_info(type, &oinfo); + H5Oget_info2(type, &oinfo, H5O_INFO_BASIC); if(oinfo.rc > 1) { obj_t *found_obj; /* Found object */ @@ -2548,7 +2548,7 @@ xml_dump_group(hid_t gid, const char *name) } } - H5Oget_info(gid, &oinfo); + H5Oget_info2(gid, &oinfo, H5O_INFO_BASIC); if(oinfo.rc > 1) { obj_t *found_obj; /* Found object */ diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c index 2bfe280..0fc0289 100644 --- a/tools/src/h5format_convert/h5format_convert.c +++ b/tools/src/h5format_convert/h5format_convert.c @@ -430,7 +430,7 @@ main(int argc, const char *argv[]) } else { /* Convert all datasets in the file */ if(verbose_g) HDfprintf(stdout, "Processing all datasets in the file...\n"); - if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid) < 0) + if(h5trav_visit(fid, "/", TRUE, TRUE, convert_dsets_cb, NULL, &fid, H5O_INFO_BASIC) < 0) goto done; } /* end else */ diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index a07d308..4bc1526 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -1320,7 +1320,7 @@ print_type(h5tools_str_t *buffer, hid_t type, int ind) if(H5Tcommitted(type)) { H5O_info_t oi; - if(H5Oget_info(type, &oi) >= 0) + if(H5Oget_info2(type, &oi, H5O_INFO_BASIC) >= 0) h5tools_str_append(buffer,"shared-%lu:"H5_PRINTF_HADDR_FMT" ", oi.fileno, oi.addr); else @@ -2386,7 +2386,7 @@ visit_obj(hid_t file, const char *oname, iter_t *iter) h5tools_str_reset(&buffer); /* Retrieve info for object to list */ - if(H5Oget_info_by_name(file, oname, &oi, H5P_DEFAULT) < 0) { + if(H5Oget_info_by_name2(file, oname, &oi, H5O_INFO_BASIC|H5O_INFO_TIME, H5P_DEFAULT) < 0) { if(iter->symlink_target) { h5tools_str_append(&buffer, "{**NOT FOUND**}\n"); iter->symlink_target = FALSE; @@ -2414,7 +2414,7 @@ visit_obj(hid_t file, const char *oname, iter_t *iter) iter->name_start = iter->base_len; /* Specified name is a group. List the complete contents of the group. */ - h5trav_visit(file, oname, (hbool_t) (display_root_g || iter->symlink_target), recursive_g, list_obj, list_lnk, iter); + h5trav_visit(file, oname, (hbool_t) (display_root_g || iter->symlink_target), recursive_g, list_obj, list_lnk, iter, H5O_INFO_BASIC|H5O_INFO_TIME); /* Close group */ if(!iter->symlink_target) diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index e7f4aae..a63e56f 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -222,7 +222,7 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, H5O_info_t oinfo; /* Object info of input dtype */ hid_t ret_value = -1; /* The identifier of the named dtype in the out file */ - if (H5Oget_info(type_in, &oinfo) < 0) + if (H5Oget_info2(type_in, &oinfo, H5O_INFO_BASIC) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed"); if (*named_dt_head_p) { @@ -352,7 +352,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, hbool_t is_ref = 0; H5T_class_t type_class = -1; - if (H5Oget_info(loc_in, &oinfo) < 0) + if (H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed"); /*------------------------------------------------------------------------- diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c index 7b610a3..a275443 100644 --- a/tools/src/h5repack/h5repack_refs.c +++ b/tools/src/h5repack/h5repack_refs.c @@ -456,7 +456,7 @@ static int copy_refs_attr(hid_t loc_in, int ref_comp_field_n = 0; - if(H5Oget_info(loc_in, &oinfo) < 0) + if(H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed"); for(u = 0; u < (unsigned)oinfo.num_attrs; u++) { @@ -807,7 +807,7 @@ MapIdToName(hid_t refobj_id, trav_table_t *travt) H5O_info_t ref_oinfo; /* Stat for the refobj id */ /* obtain information to identify the referenced object uniquely */ - if(H5Oget_info(refobj_id, &ref_oinfo) < 0) + if(H5Oget_info2(refobj_id, &ref_oinfo, H5O_INFO_BASIC) < 0) goto out; if(ref_oinfo.addr == travt->objs[u].objno) { diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index 6f196b4..da713ac 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -1788,14 +1788,14 @@ main(int argc, const char *argv[]) unsigned u; for(u = 0; u < hand->obj_count; u++) { - if(h5trav_visit(fid, hand->obj[u], TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) + if(h5trav_visit(fid, hand->obj[u], TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) < 0) warn_msg("Unable to traverse object \"%s\"\n", hand->obj[u]); else print_statistics(hand->obj[u], &iter); } /* end for */ } /* end if */ else { - if(h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) + if(h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter, H5O_INFO_ALL) < 0) warn_msg("Unable to traverse objects/links in file \"%s\"\n", fname); else print_statistics("/", &iter); diff --git a/tools/test/perform/direct_write_perf.c b/tools/test/perform/direct_write_perf.c new file mode 100644 index 0000000..f13cd24 --- /dev/null +++ b/tools/test/perform/direct_write_perf.c @@ -0,0 +1,684 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This tests the performance of the H5Dwrite_chunk() function. + * + */ + +#include "hdf5.h" + +#ifdef H5_HAVE_FILTER_DEFLATE +#include <zlib.h> + +#if !defined(WIN32) && !defined(__MINGW32__) + +#include <math.h> + +#ifdef H5_STDC_HEADERS +# include <errno.h> +# include <fcntl.h> +# include <stdio.h> +# include <stdlib.h> +#endif + +#ifdef H5_HAVE_UNISTD_H +# include <sys/types.h> +# include <unistd.h> +#endif + +#ifdef H5_HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif + +#if defined(H5_TIME_WITH_SYS_TIME) +# include <sys/time.h> +# include <time.h> +#elif defined(H5_HAVE_SYS_TIME_H) +# include <sys/time.h> +#else +# include <time.h> +#endif + +const char *FILENAME[] = { + "direct_write", + "unix.raw", + NULL +}; + +/* + * Print the current location on the standard output stream. + */ +#define FUNC __func__ +#define AT() printf (" at %s:%d in %s()...\n", \ + __FILE__, __LINE__, FUNC); +#define H5_FAILED() {puts("*FAILED*");fflush(stdout);} +#define TEST_ERROR {H5_FAILED(); AT(); goto error;} +#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);} +#define PASSED() {puts(" PASSED");fflush(stdout);} + +#define DIRECT_UNCOMPRESSED_DSET "direct_uncompressed_dset" +#define DIRECT_COMPRESSED_DSET "direct_compressed_dset" +#define REG_COMPRESSED_DSET "reg_compressed_dset" +#define REG_NO_COMPRESS_DSET "reg_no_compress_dset" +#define RANK 3 +#define NX 100 +#define NY 1000 +#define NZ 250 +#define CHUNK_NX 1 +#define CHUNK_NY 1000 +#define CHUNK_NZ 250 + +#define DEFLATE_SIZE_ADJUST(s) (ceil(((double)(s))*1.001)+12) +char filename[1024]; +unsigned int *outbuf[NX]; +size_t data_size[NX]; +double total_size = 0.0; +unsigned int *direct_buf[NX]; +double MB = 1048576.0; + +/*-------------------------------------------------- + * Function to report IO rate + *-------------------------------------------------- + */ +void reportTime(struct timeval start, double mbytes) +{ + struct timeval timeval_stop,timeval_diff; + + /*end timing*/ + gettimeofday(&timeval_stop,NULL); + + /* Calculate the elapsed gettimeofday time */ + timeval_diff.tv_usec=timeval_stop.tv_usec-start.tv_usec; + timeval_diff.tv_sec=timeval_stop.tv_sec-start.tv_sec; + + if(timeval_diff.tv_usec<0) { + timeval_diff.tv_usec+=1000000; + timeval_diff.tv_sec--; + } /* end if */ + +/*printf("mbytes=%lf, sec=%lf, usec=%lf\n", mbytes, (double)timeval_diff.tv_sec, (double)timeval_diff.tv_usec);*/ + printf("MBytes/second: %lf\n", (double)mbytes/((double)timeval_diff.tv_sec+((double)timeval_diff.tv_usec/(double)1000000.0))); +} + +/*-------------------------------------------------- + * Create file, datasets, and initialize data + *-------------------------------------------------- + */ +int create_file(hid_t fapl_id) +{ + hid_t file; /* handles */ + hid_t fapl; + hid_t cparms; + hid_t dataspace, dataset; + hsize_t dims[RANK] = {NX, NY, NZ}; + hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + unsigned int aggression = 9; /* Compression aggression setting */ + int ret; + int i, j, n; + + int flag; + int unix_file; + + unsigned int *p; + size_t buf_size = CHUNK_NY*CHUNK_NZ*sizeof(unsigned int); + + const Bytef *z_src; + Bytef *z_dst; /*destination buffer */ + uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); + uLong z_src_nbytes = (uLong)buf_size; + + TESTING("Create a file and dataset"); + + /* + * Create the data space with unlimited dimensions. + */ + if((dataspace = H5Screate_simple(RANK, dims, NULL)) < 0) + TEST_ERROR; + + /* + * Create a new file. If file exists its contents will be overwritten. + */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + TEST_ERROR; + + /* + * Modify dataset creation properties, i.e. enable chunking and compression + */ + if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + + if(H5Pset_chunk( cparms, RANK, chunk_dims) < 0) + TEST_ERROR; + + /* + * Create a new dataset within the file using cparms + * creation properties. + */ + if((dataset = H5Dcreate2(file, DIRECT_UNCOMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, + cparms, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dataset) < 0) + TEST_ERROR; + + if((dataset = H5Dcreate2(file, REG_NO_COMPRESS_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, + cparms, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dataset) < 0) + TEST_ERROR; + + /* Set compression */ + if(H5Pset_deflate( cparms, aggression) < 0) + TEST_ERROR; + + if((dataset = H5Dcreate2(file, DIRECT_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, + cparms, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dataset) < 0) + TEST_ERROR; + + + if((dataset = H5Dcreate2(file, REG_COMPRESSED_DSET, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, + cparms, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dataset) < 0) + TEST_ERROR; + + if(H5Fclose(file) < 0) + TEST_ERROR; + + if(H5Sclose(dataspace) < 0) + TEST_ERROR; + + if(H5Pclose(cparms) < 0) + TEST_ERROR; + + /* create a unix file*/ + flag = O_CREAT|O_TRUNC|O_WRONLY; + + if ((unix_file=open(FILENAME[1],flag,S_IRWXU))== -1) + TEST_ERROR; + + if (close(unix_file) < 0) + { + printf(" unable to close the file\n"); + TEST_ERROR; + } + + + /* Initialize data for chunks */ + for(i = 0; i < NX; i++) { + p = direct_buf[i] = (unsigned int*)malloc(CHUNK_NY*CHUNK_NZ*sizeof(unsigned int)); + + for(j=0; j < CHUNK_NY*CHUNK_NZ; j++, p++) + *p = rand() % 65000; + + z_src = (const Bytef*)direct_buf[i]; + + z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(buf_size); + /* Allocate output (compressed) buffer */ + outbuf[i] = (unsigned int*)malloc((size_t)z_dst_nbytes); + z_dst = (Bytef *)outbuf[i]; + + /* Perform compression from the source to the destination buffer */ + ret = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression); + + data_size[i] = (size_t)z_dst_nbytes; + total_size += data_size[i]; + + /* Check for various zlib errors */ + if(Z_BUF_ERROR == ret) { + fprintf(stderr, "overflow"); + TEST_ERROR; + } else if(Z_MEM_ERROR == ret) { + fprintf(stderr, "deflate memory error"); + TEST_ERROR; + } else if(Z_OK != ret) { + fprintf(stderr, "other deflate error"); + TEST_ERROR; + } + } + + + PASSED(); + +error: + H5E_BEGIN_TRY { + H5Dclose(dataset); + H5Sclose(dataspace); + H5Pclose(cparms); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} + +/*-------------------------------------------------- + * Benchmark the performance of the new function + * with precompressed data. + *-------------------------------------------------- + */ +int +test_direct_write_uncompressed_data(hid_t fapl_id) +{ + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t dxpl; + herr_t status; + int i; + + unsigned filter_mask = 0; + hsize_t offset[RANK] = {0, 0, 0}; + + struct timeval timeval_start; + + TESTING("H5Dwrite_chunk for uncompressed data"); + + if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + + /* Start the timer */ + gettimeofday(&timeval_start,NULL); + + /* Reopen the file and dataset */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + TEST_ERROR; + + if((dataset = H5Dopen2(file, DIRECT_UNCOMPRESSED_DSET, H5P_DEFAULT)) < 0) + TEST_ERROR; + + + /* Write the compressed chunk data repeatedly to cover all the chunks in the + * dataset, using the direct writing function. */ + for(i=0; i<NX; i++) { + status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, CHUNK_NY*CHUNK_NZ*sizeof(unsigned int), direct_buf[i]); + (offset[0])++; + } + + /* + * Close/release resources. + */ + H5Dclose(dataset); + H5Pclose(dxpl); + H5Fclose(file); + + /* Report the performance */ + reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dataset); + H5Pclose(dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} + + +/*-------------------------------------------------- + * Benchmark the performance of the new function + * with precompressed data. + *-------------------------------------------------- + */ +int +test_direct_write_compressed_data(hid_t fapl_id) +{ + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t dxpl; + herr_t status; + int i; + + unsigned filter_mask = 0; + hsize_t offset[RANK] = {0, 0, 0}; + + struct timeval timeval_start; + + TESTING("H5DOwrite_chunk for pre-compressed data"); + + if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + + /* Start the timer */ + gettimeofday(&timeval_start,NULL); + + /* Reopen the file and dataset */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + TEST_ERROR; + + if((dataset = H5Dopen2(file, DIRECT_COMPRESSED_DSET, H5P_DEFAULT)) < 0) + TEST_ERROR; + + + /* Write the compressed chunk data repeatedly to cover all the chunks in the + * dataset, using the direct writing function. */ + for(i=0; i<NX; i++) { + status = H5Dwrite_chunk(dataset, dxpl, filter_mask, offset, data_size[i], outbuf[i]); + (offset[0])++; + } + + /* + * Close/release resources. + */ + H5Dclose(dataset); + H5Pclose(dxpl); + H5Fclose(file); + + /* Report the performance */ + reportTime(timeval_start, (double)(total_size/MB)); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dataset); + H5Pclose(dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} + +/*-------------------------------------------------- + * Benchmark the performance of the regular H5Dwrite + * with compression filter enabled. + *-------------------------------------------------- + */ +int +test_compressed_write(hid_t fapl_id) +{ + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t mem_space; + hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + hid_t dxpl; + herr_t status; + int i; + + hsize_t start[RANK]; /* Start of hyperslab */ + hsize_t stride[RANK]; /* Stride of hyperslab */ + hsize_t count[RANK]; /* Block count */ + hsize_t block[RANK]; /* Block sizes */ + + struct timeval timeval_start; + + TESTING("H5Dwrite with compression enabled"); + + if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + + if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + TEST_ERROR; + + /* Start the timer */ + gettimeofday(&timeval_start,NULL); + + /* Reopen the file and dataset */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + TEST_ERROR; + + if((dataset = H5Dopen2(file, REG_COMPRESSED_DSET, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if((dataspace = H5Dget_space(dataset)) < 0) + TEST_ERROR; + + start[0] = start[1] = start[2] = 0; + stride[0] = stride[1] = stride[2] = 1; + count[0] = count[1] = count[2] = 1; + block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ; + + for(i=0; i<NX; i++) { + /* + * Select hyperslab for one chunk in the file + */ + if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) + TEST_ERROR; + (start[0])++; + + if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, + H5P_DEFAULT, direct_buf[i])) < 0) + TEST_ERROR; + } + + /* + * Close/release resources. + */ + H5Dclose(dataset); + H5Sclose(dataspace); + H5Sclose(mem_space); + H5Pclose(dxpl); + H5Fclose(file); + + /* Report the performance */ + reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dataset); + H5Sclose(dataspace); + H5Sclose(mem_space); + H5Pclose(dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} + +/*-------------------------------------------------- + * Benchmark the performance of the regular H5Dwrite + * with compression + *-------------------------------------------------- + */ +int +test_no_compress_write(hid_t fapl_id) +{ + hid_t file; /* handles */ + hid_t dataspace, dataset; + hid_t mem_space; + hsize_t chunk_dims[RANK] ={CHUNK_NX, CHUNK_NY, CHUNK_NZ}; + hid_t dxpl; + herr_t status; + int i; + + hsize_t start[RANK]; /* Start of hyperslab */ + hsize_t stride[RANK]; /* Stride of hyperslab */ + hsize_t count[RANK]; /* Block count */ + hsize_t block[RANK]; /* Block sizes */ + + struct timeval timeval_start; + + TESTING("H5Dwrite without compression"); + + if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + + if((mem_space = H5Screate_simple(RANK, chunk_dims, NULL)) < 0) + TEST_ERROR; + + /* Start the timer */ + gettimeofday(&timeval_start,NULL); + + /* Reopen the file and dataset */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) + TEST_ERROR; + + if((dataset = H5Dopen2(file, REG_NO_COMPRESS_DSET, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if((dataspace = H5Dget_space(dataset)) < 0) + TEST_ERROR; + + start[0] = start[1] = start[2] = 0; + stride[0] = stride[1] = stride[2] = 1; + count[0] = count[1] = count[2] = 1; + block[0] = CHUNK_NX; block[1] = CHUNK_NY; block[2] = CHUNK_NZ; + + for(i=0; i<NX; i++) { + /* + * Select hyperslab for one chunk in the file + */ + if((status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start, stride, count, block)) < 0) + TEST_ERROR; + (start[0])++; + + if((status = H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, dataspace, + H5P_DEFAULT, direct_buf[i])) < 0) + TEST_ERROR; + } + + /* + * Close/release resources. + */ + H5Dclose(dataset); + H5Sclose(dataspace); + H5Sclose(mem_space); + H5Pclose(dxpl); + H5Fclose(file); + + /* Report the performance */ + reportTime(timeval_start, (double)(NX*NY*NZ*sizeof(unsigned int)/MB)); + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(dataset); + H5Sclose(dataspace); + H5Sclose(mem_space); + H5Pclose(dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} + +/*-------------------------------------------------- + * Benchmark the performance for writing compressed + * data to a Unix file + *-------------------------------------------------- + */ +int +test_unix_write(void) +{ + int file, flag; + ssize_t op_size; + int i; + struct timeval timeval_start; + + TESTING("Write compressed data to a Unix file"); + + /* create file*/ + flag = O_WRONLY; + + /* Start the timer */ + gettimeofday(&timeval_start,NULL); + + if ((file=open(FILENAME[1],flag))== -1) + TEST_ERROR; + + /* Write the compressed chunk data repeatedly to cover all the chunks in the + * dataset, using the direct writing function. */ + for(i=0; i<NX; i++) { + op_size = write(file, outbuf[i],data_size[i]); + if (op_size < 0) + { + printf(" Error in writing data to file because %s \n", strerror(errno)); + TEST_ERROR; + } + else if (op_size == 0) + { + printf(" unable to write sufficent data to file because %s \n", strerror(errno)); + TEST_ERROR; + } + } + + if (close(file) < 0) + { + printf(" unable to close the file\n"); + TEST_ERROR; + } + + /* Report the performance */ + reportTime(timeval_start, (double)(total_size/MB)); + + PASSED(); + return 0; + +error: + return 1; +} + +/*-------------------------------------------------- + * Main function + *-------------------------------------------------- + */ +int +main (void) +{ + hid_t fapl = H5P_DEFAULT; + int i; + + sprintf(filename, "%s.h5", FILENAME[0]); + + create_file(fapl); + test_direct_write_uncompressed_data(fapl); + test_direct_write_compressed_data(fapl); + test_no_compress_write(fapl); + test_compressed_write(fapl); + test_unix_write(); + + for(i=0; i<NX; i++) { + free(outbuf[i]); + free(direct_buf[i]); + } + + return 0; +} + +#else /* WIN32 / MINGW32 */ + +int +main(void) +{ + printf("Non-POSIX platform. Exiting.\n"); + return EXIT_FAILURE; +} /* end main() */ + +#endif /* WIN32 / MINGW32 */ + +#else /* !H5_HAVE_FILTER_DEFLATE */ + +/* + * Function: main + * Purpose: Dummy main() function for if HDF5 was configured without + * zlib stuff. + * Return: EXIT_SUCCESS + */ +int +main(void) +{ + HDfprintf(stdout, "No compression IO performance because zlib was not configured\n"); + return EXIT_SUCCESS; +} + +#endif /* !H5_HAVE_FILTER_DEFLATE */ + |