From 5449df4880af0fb5f9a76eb010f79deb51e5521e Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Tue, 7 Oct 2014 15:40:06 -0500 Subject: [svn-r25682] bring 25651 and 25659 from trunk. Fix for: HDFFV-8715 HDF5_PARAPREFIX is ignored in parallel dense attribute and performance tests. --- perform/perf.c | 18 +++++++--- test/h5test.c | 94 +++++++++++++++++++++++++++++++++++++++++------------ test/h5test.h | 4 +-- testpar/t_dset.c | 7 +++- testpar/testphdf5.c | 2 +- 5 files changed, 97 insertions(+), 28 deletions(-) diff --git a/perform/perf.c b/perform/perf.c index f006afb..7d329f0 100644 --- a/perform/perf.c +++ b/perform/perf.c @@ -46,7 +46,6 @@ # include #endif - /* Macro definitions */ /* Verify: * if val is false (0), print mesg and if fatal is true (non-zero), die. @@ -64,6 +63,8 @@ } \ } while(0) #define RANK 1 +#define MAX_PATH 1024 + hsize_t dims[RANK]; /* dataset dim sizes */ hsize_t block[RANK], stride[RANK], count[RANK]; hssize_t start[RANK]; @@ -90,6 +91,11 @@ char opt_file[256] = "perftest.out"; char opt_pvfstab[256] = "notset"; int opt_pvfstab_set = 0; +const char *FILENAME[] = { + opt_file, + NULL +}; + /* function prototypes */ static int parse_args(int argc, char **argv); @@ -114,6 +120,7 @@ int main(int argc, char **argv) MPI_File fh; MPI_Status status; int nchars; + char filename[MAX_PATH]; herr_t ret; /* Generic return value */ /* startup MPI and determine the rank of this process */ @@ -126,7 +133,6 @@ int main(int argc, char **argv) if (mynod == 0) printf("# Using hdf5-io calls.\n"); - /* kindof a weird hack- if the location of the pvfstab file was * specified on the command line, then spit out this location into * the appropriate environment variable: */ @@ -198,8 +204,10 @@ int main(int argc, char **argv) } } + h5_fixname_no_suffix(FILENAME[0], acc_tpl, filename, sizeof filename); + /* create the parallel file */ - fid = H5Fcreate(opt_file, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); VRFY((fid >= 0), "H5Fcreate succeeded", H5FATAL); /* define a contiquous dataset of opt_iter*nprocs*opt_block chars */ @@ -261,7 +269,7 @@ int main(int argc, char **argv) MPI_Barrier(MPI_COMM_WORLD); /* reopen the file for reading */ - fid=H5Fopen(opt_file,H5F_ACC_RDONLY,acc_tpl); + fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); VRFY((fid >= 0), "", H5FATAL); /* open the dataset */ @@ -382,6 +390,7 @@ die_jar_jar_die: free(tmp); if (opt_correct) free(tmp2); + MPI_Finalize(); return(0); @@ -405,6 +414,7 @@ parse_args(int argc, char **argv) break; case 'f': /* filename */ strncpy(opt_file, optarg, 255); + FILENAME[0] = opt_file; break; case 'p': /* pvfstab file */ strncpy(opt_pvfstab, optarg, 255); diff --git a/test/h5test.c b/test/h5test.c index fce8c9b..f434823 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -92,6 +92,8 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ static const char *multi_letters = "msbrglo"; static herr_t h5_errors(hid_t estack, void *client_data); +static char * h5_fixname_real(const char *base_name, hid_t fapl, const char *suffix, + char *fullname, size_t size); /*------------------------------------------------------------------------- @@ -268,9 +270,59 @@ h5_reset(void) char * h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) { + return (h5_fixname_real(base_name, fapl, ".h5", fullname, size)); +} + + +/*------------------------------------------------------------------------- + * Function: h5_fixname_no_suffix + * + * Purpose: Same as h5_fixname but with no suffix appended + * + * Return: Success: The FULLNAME pointer. + * + * Failure: NULL if BASENAME or FULLNAME is the null + * pointer or if FULLNAME isn't large enough for + * the result. + * + *------------------------------------------------------------------------- + */ +char * +h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size) +{ + return (h5_fixname_real(base_name, fapl, NULL, fullname, size)); +} + + +/*------------------------------------------------------------------------- + * Function: h5_fixname_real + * + * Purpose: Create a file name from a file base name like `test' and + * return it through the FULLNAME (at most SIZE characters + * counting the null terminator). The full name is created by + * prepending the contents of HDF5_PREFIX (separated from the + * base name by a slash) and appending a file extension based on + * the driver supplied, resulting in something like + * `ufs:/u/matzke/test.h5'. + * + * Return: Success: The FULLNAME pointer. + * + * Failure: NULL if BASENAME or FULLNAME is the null + * pointer or if FULLNAME isn't large enough for + * the result. + * + * Programmer: Robb Matzke + * Thursday, November 19, 1998 + * + *------------------------------------------------------------------------- + */ +static char * +h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, + char *fullname, size_t size) +{ const char *prefix = NULL; - const char *suffix = ".h5"; /* suffix has default */ char *ptr, last = '\0'; + const char *suffix = _suffix; size_t i, j; hid_t driver = -1; int isppdriver = 0; /* if the driver is MPI parallel */ @@ -285,10 +337,12 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) if((driver = H5Pget_driver(fapl)) < 0) return NULL; - if(H5FD_FAMILY == driver) - suffix = "%05d.h5"; - else if (H5FD_MULTI == driver) - suffix = NULL; + if(suffix) { + if(H5FD_FAMILY == driver) + suffix = "%05d.h5"; + else if (H5FD_MULTI == driver) + suffix = NULL; + } } /* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX @@ -318,11 +372,11 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) */ if(isppdriver) { #ifdef H5_HAVE_PARALLEL - /* + /* * For parallel: * First use command line option, then the environment * variable, then try the constant - */ + */ static int explained = 0; prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX")); @@ -335,12 +389,12 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) if (mpi_rank == 0) printf("*** Hint ***\n" - "You can use environment variable HDF5_PARAPREFIX to " - "run parallel test files in a\n" - "different directory or to add file type prefix. E.g.,\n" - " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" - " export HDF5_PARAPREFIX\n" - "*** End of Hint ***\n"); + "You can use environment variable HDF5_PARAPREFIX to " + "run parallel test files in a\n" + "different directory or to add file type prefix. E.g.,\n" + " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" + " export HDF5_PARAPREFIX\n" + "*** End of Hint ***\n"); explained = TRUE; #ifdef HDF5_PARAPREFIX @@ -352,7 +406,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* * For serial: * First use the environment variable, then try the constant - */ + */ prefix = HDgetenv("HDF5_PREFIX"); #ifdef HDF5_PREFIX @@ -425,18 +479,18 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) return NULL; } } else if (HDstrlen(base_name) >= size) { - /* Buffer is too small */ - return NULL; + /* Buffer is too small */ + return NULL; } else { - HDstrcpy(fullname, base_name); - } + HDstrcpy(fullname, base_name); + } /* Append a suffix */ if (suffix) { - if (HDstrlen(fullname) + HDstrlen(suffix) >= size) + if (HDstrlen(fullname) + HDstrlen(suffix) >= size) return NULL; - HDstrcat(fullname, suffix); + HDstrcat(fullname, suffix); } /* Remove any double slashes in the filename */ diff --git a/test/h5test.h b/test/h5test.h index 90e4cad..d31e963 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -141,8 +141,8 @@ extern "C" { /* Generally useful testing routines */ H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl); -H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, - size_t size); +H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size); +H5TEST_DLL char *h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size); H5TEST_DLL hid_t h5_fileaccess(void); H5TEST_DLL void h5_no_hwconv(void); H5TEST_DLL const char *h5_rmprefix(const char *filename); diff --git a/testpar/t_dset.c b/testpar/t_dset.c index 2bc3b09..281b1c0 100644 --- a/testpar/t_dset.c +++ b/testpar/t_dset.c @@ -4365,6 +4365,11 @@ test_dense_attr(void) hid_t atFileSpace, atid; hsize_t atDims[1] = {10000}; herr_t status; + const char *filename; + + /* get filename */ + filename = (const char *)GetTestParameters(); + HDassert( filename != NULL ); /* set up MPI parameters */ MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); @@ -4376,7 +4381,7 @@ test_dense_attr(void) VRFY((status >= 0), "H5Pset_libver_bounds succeeded"); status = H5Pset_fapl_mpio(fpid, MPI_COMM_WORLD, MPI_INFO_NULL); VRFY((status >= 0), "H5Pset_fapl_mpio succeeded"); - fid = H5Fcreate("ph5Dense.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fpid); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fpid); VRFY((fid > 0), "H5Fcreate succeeded"); status = H5Pclose(fpid); VRFY((status >= 0), "H5Pclose succeeded"); diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index 865d381..932e632 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -525,7 +525,7 @@ int main(int argc, char **argv) } AddTest("denseattr", test_dense_attr, NULL, - "Store Dense Attributes", NULL); + "Store Dense Attributes", PARATESTFILE); /* Display testing information */ -- cgit v0.12