From 8e04644abdc73446e85bac72bcced171a927b1f0 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 29 Oct 2010 10:43:31 -0500 Subject: [svn-r19698] Description: Bring r19668:19697 from trunk to revise_chunks branch. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode --- CMakeLists.txt | 3 +- CTestConfig.cmake | 6 + config/cmake/runTest.cmake | 7 +- configure.in | 176 ++++++++++++- perform/CMakeLists.txt | 2 +- src/H5config.h.in | 8 + test/dangle.c | 129 ++++++++++ test/dt_arith.c | 32 +++ testpar/t_mdset.c | 604 +++++++++++++++++++++++++++++++++++--------- testpar/testphdf5.h | 2 + tools/h5copy/CMakeLists.txt | 51 +++- tools/misc/CMakeLists.txt | 81 ++++++ 12 files changed, 970 insertions(+), 131 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10503ac..e4ae935 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -398,8 +398,7 @@ IF (HDF5_ENABLE_PARALLEL) SET (H5_HAVE_PARALLEL 1) # MPI checks, only do these if MPI_FOUND is true, otherwise they always fail # and once set, they are cached as false and not regenerated - SET (CMAKE_REQUIRED_INCLUDES "${MPI_INCLUDE_PATH}/mpi.h" ) - SET (CMAKE_REQUIRED_LIBRARIES "${MPI_LIBRARY}" ) + SET (CMAKE_REQUIRED_LIBRARIES "${MPI_LIBRARY};${MPI_EXTRA_LIBRARY}" ) CHECK_FUNCTION_EXISTS (MPI_File_get_size H5_HAVE_MPI_GET_SIZE) # Used by Fortran + MPI CHECK_SYMBOL_EXISTS (MPI_Comm_c2f "${MPI_INCLUDE_PATH}/mpi.h" H5_HAVE_MPI_MULTI_LANG_Comm) diff --git a/CTestConfig.cmake b/CTestConfig.cmake index eb7dbee..5c1e07f 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -13,3 +13,9 @@ set(CTEST_DROP_LOCATION "/cdash/submit.php?project=HDF5+Trunk") set(CTEST_DROP_SITE_CDASH TRUE) set(UPDATE_TYPE svn) + +set(VALGRIND_COMMAND "/usr/bin/valgrind") +set(VALGRIND_COMMAND_OPTIONS "--tool=memcheck") +set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") +set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck") +set(CTEST_TESTING_TIMEOUT 3600) diff --git a/config/cmake/runTest.cmake b/config/cmake/runTest.cmake index de69217..c9334c1 100644 --- a/config/cmake/runTest.cmake +++ b/config/cmake/runTest.cmake @@ -59,11 +59,16 @@ MESSAGE (STATUS "COMMAND Error: ${TEST_ERROR}") IF (TEST_MASK) FILE (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) - #STRING(REGEX REPLACE "Modified:[^\n]+\n" "Modified: XXXX-XX-XX XX:XX:XX XXX\n" TEST_STREAM "${TEST_STREAM}") STRING(REGEX REPLACE "Storage:[^\n]+\n" "Storage:
\n" TEST_STREAM "${TEST_STREAM}") FILE (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") ENDIF (TEST_MASK) +IF (TEST_MASK_MOD) + FILE (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + STRING(REGEX REPLACE "Modified:[^\n]+\n" "Modified: XXXX-XX-XX XX:XX:XX XXX\n" TEST_STREAM "${TEST_STREAM}") + FILE (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +ENDIF (TEST_MASK_MOD) + IF (TEST_FILTER) FILE (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) STRING(REGEX REPLACE "${TEST_FILTER}" "" TEST_STREAM "${TEST_STREAM}") diff --git a/configure.in b/configure.in index b927e31..0e37500 100644 --- a/configure.in +++ b/configure.in @@ -694,9 +694,9 @@ dnl the executable name to run the executable on dnl multiple processors. For the serial library the dnl value will normally be the empty string. For dnl parallel library it should be something like -dnl `mpi -np $$NPROCS' where NPROCS will eventually -dnl contain the number of processors on which to run -dnl the executable (the double dollarsigns are to +dnl "mpiexec -n \$\${NPROCS:=6}" where NPROCS will +dnl eventually contain the number of processors on which +dnl to run the executable (the double dollarsigns are to dnl protect the expansion until make executes the dnl command). The value of this variable is dnl substituted in *.in files. @@ -738,7 +738,7 @@ case "$CC_BASENAME" in RUNSERIAL="${RUNSERIAL:-none}" if test -z "$RUNPARALLEL"; then - RUNPARALLEL="$path/mpiexec -n \$\${NPROCS:=3}" + RUNPARALLEL="$path/mpiexec -n \$\${NPROCS:=6}" fi else AC_MSG_RESULT([none]) @@ -792,7 +792,7 @@ if test "X$HDF_FORTRAN" = "Xyes"; then RUNSERIAL="${RUNSERIAL:-none}" if test -z "$RUNPARALLEL"; then - RUNPARALLEL="$path/mpiexec -n \$\${NPROCS:=2}" + RUNPARALLEL="$path/mpiexec -n \$\${NPROCS:=6}" fi else AC_MSG_RESULT([none]) @@ -2550,7 +2550,7 @@ case "X-$enable_parallel" in dnl Find the path where aprun is located. for path in `echo $PATH | ${TR} ":" " "`; do if test -x $path/aprun; then - RUNPARALLEL="aprun -q -n \$\${NPROCS:=3}" + RUNPARALLEL="aprun -q -n \$\${NPROCS:=6}" break; fi done @@ -2558,7 +2558,7 @@ case "X-$enable_parallel" in dnl Set RUNPARALLEL to mpiexec if not set yet. if test "X$PARALLEL" = "Xyes" -a -z "$RUNPARALLEL"; then - RUNPARALLEL="mpiexec -n \$\${NPROCS:=3}" + RUNPARALLEL="mpiexec -n \$\${NPROCS:=6}" fi ;; @@ -3548,6 +3548,167 @@ else fi dnl ---------------------------------------------------------------------- +dnl Set the flag to indicate that the machine is using a special algorithm to convert +dnl 'long double' to '(unsigned) long' values. (This flag should only be set for +dnl the IBM Power6 Linux. When the bit sequence of long double is +dnl 0x4351ccf385ebc8a0bfcc2a3c3d855620, the converted value of (unsigned)long +dnl is 0x004733ce17af227f, not the same as the library's conversion to 0x004733ce17af2282. +dnl The machine's conversion gets the correct value. We define the macro and disable +dnl this kind of test until we figure out what algorithm they use. +dnl +AC_MSG_CHECKING([if using special algorithm to convert long double to (unsigned) long values]) + +if test ${ac_cv_sizeof_long_double} = 0; then + hdf5_cv_ldouble_to_long_special=${hdf5_cv_ldouble_to_long_special=no} +else + AC_CACHE_VAL([hdf5_cv_ldouble_to_long_special], + [AC_TRY_RUN([ + int main(void) + { + long double ld = 20041683600089727.779961L; + long ll; + unsigned long ull; + unsigned char s[16]; + unsigned char s2[8]; + int ret = 1; + + if(sizeof(long double) == 16 && sizeof(long) == 8) { + /*make sure the long double type has 16 bytes in size and + * 11 bits of exponent. If it is, + *the bit sequence should be like below. It's not + *a decent way to check but this info isn't available. */ + memcpy(s, &ld, 16); + if(s[0]==0x43 && s[1]==0x51 && s[2]==0xcc && s[3]==0xf3 && + s[4]==0x85 && s[5]==0xeb && s[6]==0xc8 && s[7]==0xa0 && + s[8]==0xbf && s[9]==0xcc && s[10]==0x2a && s[11]==0x3c) { + + /* Assign the hexadecimal value of long double type. */ + s[0]=0x43; s[1]=0x51; s[2]=0xcc; s[3]=0xf3; + s[4]=0x85; s[5]=0xeb; s[6]=0xc8; s[7]=0xa0; + s[8]=0xbf; s[9]=0xcc; s[10]=0x2a; s[11]=0x3c; + s[12]=0x3d; s[13]=0x85; s[14]=0x56; s[15]=0x20; + + memcpy(&ld, s, 16); + + ll = (long)ld; + memcpy(s2, &ll, 8); + + /* The library's algorithm converts it to 0x 00 47 33 ce 17 af 22 82 + * and gets wrong value 20041683600089730 on the IBM Power6 Linux. + * But the IBM Power6 Linux converts it to 0x00 47 33 ce 17 af 22 7f + * and gets the correct value 20041683600089727. It uses some special + * algorithm. We're going to define the macro and skip the test until + * we can figure out how they do it. */ + if(s2[0]==0x00 && s2[1]==0x47 && s2[2]==0x33 && s2[3]==0xce && + s2[4]==0x17 && s2[5]==0xaf && s2[6]==0x22 && s2[7]==0x7f) + ret = 0; + + ull = (unsigned long)ld; + memcpy(s2, &ull, 8); + + /* The unsigned long is the same as signed long. */ + if(s2[0]==0x00 && s2[1]==0x47 && s2[2]==0x33 && s2[3]==0xce && + s2[4]==0x17 && s2[5]==0xaf && s2[6]==0x22 && s2[7]==0x7f) + ret = 0; + } + } + + done: + exit(ret); + } + ], [hdf5_cv_ldouble_to_long_special=yes], [hdf5_cv_ldouble_to_long_special=no],)]) +fi + +if test ${hdf5_cv_ldouble_to_long_special} = "yes"; then + AC_DEFINE([LDOUBLE_TO_LONG_SPECIAL], [1], + [Define if your system converts long double to (unsigned) long values with special algorithm.]) + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +dnl ---------------------------------------------------------------------- +dnl Set the flag to indicate that the machine is using a special algorithm +dnl to convert some values of '(unsigned) long' to 'long double' values. +dnl (This flag should be off for all machines, except for IBM Power6 Linux, +dnl when the bit sequences are 003fff..., 007fff..., 00ffff..., 01ffff..., +dnl ..., 7fffff..., the compiler uses a unknown algorithm. We define a +dnl macro and skip the test for now until we know about the algorithm. +dnl +AC_MSG_CHECKING([if using special algorithm to convert (unsigned) long to long double values]) + +if test ${ac_cv_sizeof_long_double} = 0; then + hdf5_cv_long_to_ldouble_special=${hdf5_cv_long_to_ldouble_special=no} +else + AC_CACHE_VAL([hdf5_cv_long_to_ldouble_special], + [AC_TRY_RUN([ + int main(void) + { + long double ld; + long ll; + unsigned long ull; + unsigned char s[16]; + int flag=0, ret=1; + + /*Determine if long double has 16 byte in size, 11 bit exponent, and + *the bias is 0x3ff */ + if(sizeof(long double) == 16) { + ld = 1.0L; + memcpy(s, &ld, 16); + if(s[0]==0x3f && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 && + s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00) + flag = 1; + } + + if(flag==1 && sizeof(long)==8) { + ll = 0x003fffffffffffffL; + ld = (long double)ll; + memcpy(s, &ld, 16); + /* The library converts the value to 0x434fffffffffffff8000000000000000. + * In decimal it is 18014398509481982.000000, one value short of the original. + * The IBM Power6 Linux converts it to 0x4350000000000000bff0000000000000. + * The value is correct in decimal. It uses some special + * algorithm. We're going to define the macro and skip the test until + * we can figure out how they do it. */ + if(s[0]==0x43 && s[1]==0x50 && s[2]==0x00 && s[3]==0x00 && + s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00 && + s[8]==0xbf && s[9]==0xf0 && s[10]==0x00 && s[11]==0x00 && + s[12]==0x00 && s[13]==0x00 && s[14]==0x00 && s[15]==0x00) + ret = 0; + } + if(flag==1 && sizeof(unsigned long)==8) { + ull = 0xffffffffffffffffUL; + ld = (long double)ull; + memcpy(s, &ld, 16); + /* Use a different value from signed long to test. The problem is the same + * for both long and unsigned long. The value is 18446744073709551615. + * The library converts the value to 0x43effffffffffffffe000000000000000. + * In decimal it's 18446744073709548544.000000, very different from the original. + * The IBM Power6 Linux converts it to 0x43f0000000000000bff0000000000000. + * The value is correct in decimal. It uses some special + * algorithm. We're going to define the macro and skip the test until + * we can figure out how they do it. */ + if(s[0]==0x43 && s[1]==0xf0 && s[2]==0x00 && s[3]==0x00 && + s[4]==0x00 && s[5]==0x00 && s[6]==0x00 && s[7]==0x00 && + s[8]==0xbf && s[9]==0xf0 && s[10]==0x00 && s[11]==0x00 && + s[12]==0x00 && s[13]==0x00 && s[14]==0x00 && s[15]==0x00) + ret = 0; + } + done: + exit(ret); + } + ], [hdf5_cv_long_to_ldouble_special=yes], [hdf5_cv_long_to_ldouble_special=no],)]) +fi + +if test ${hdf5_cv_long_to_ldouble_special} = "yes"; then + AC_DEFINE([LONG_TO_LDOUBLE_SPECIAL], [1], + [Define if your system can convert (unsigned) long to long double values with special algorithm.]) + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +dnl ---------------------------------------------------------------------- dnl Set the flag to indicate that the machine can accurately convert dnl 'long double' to '(unsigned) long long' values. (This flag should be set for dnl all machines, except for Mac OS 10.4 and SGI IRIX64 6.5. When the bit sequence @@ -3610,6 +3771,7 @@ else AC_MSG_RESULT([no]) fi + dnl ---------------------------------------------------------------------- dnl Set the flag to indicate that the machine can accurately convert dnl '(unsigned) long long' to 'long double' values. (This flag should be set for diff --git a/perform/CMakeLists.txt b/perform/CMakeLists.txt index 56868d6..f85e1d4 100644 --- a/perform/CMakeLists.txt +++ b/perform/CMakeLists.txt @@ -103,7 +103,7 @@ IF (H5_HAVE_PARALLEL) ) ADD_EXECUTABLE (h5perf ${h5perf_SRCS}) H5_NAMING (h5perf) - TARGET_WIN_PROPERTIESS (h5perf) + TARGET_WIN_PROPERTIES (h5perf) TARGET_LINK_LIBRARIES (h5perf ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) ADD_TEST (NAME h5perf COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) diff --git a/src/H5config.h.in b/src/H5config.h.in index 3283893..c53ccca 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -435,6 +435,10 @@ values correctly. */ #undef LDOUBLE_TO_LLONG_ACCURATE +/* Define if your system converts long double to (unsigned) long values with + special algorithm. */ +#undef LDOUBLE_TO_LONG_SPECIAL + /* Define if your system can convert long double to unsigned int values correctly. */ #undef LDOUBLE_TO_UINT_ACCURATE @@ -446,6 +450,10 @@ values correctly. */ #undef LLONG_TO_LDOUBLE_CORRECT +/* Define if your system can convert (unsigned) long to long double values + with special algorithm. */ +#undef LONG_TO_LDOUBLE_SPECIAL + /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR diff --git a/test/dangle.c b/test/dangle.c index 2f8a67e..dfa73ba 100644 --- a/test/dangle.c +++ b/test/dangle.c @@ -513,6 +513,132 @@ error: /*------------------------------------------------------------------------- + * Function: test_dangle_force + * + * Purpose: Shut down all danging IDs with generic file & ID routines, + * instead of letting library shut then down. + * + * Return: Success: zero + * Failure: non-zero + * + * Programmer: Quincey Koziol + * Friday, October 29, 2010 + * + *------------------------------------------------------------------------- + */ +static int +test_dangle_force(void) +{ + char filename[1024]; + hid_t fid; /* File ID */ + hid_t gid, gid2; /* Group IDs */ + hid_t dsid, dsid2; /* Dataset IDs */ + hid_t sid; /* Dataspace ID */ + hid_t aid, aid2; /* Attribute IDs */ + hid_t tid, tid2; /* Named datatype IDs */ + ssize_t count; /* Count of open objects */ + hid_t *objs = NULL; /* Pointer to list of open objects */ + size_t u; /* Local index variable */ + + TESTING("force dangling IDs to close, from API routines"); + + h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Create a dataspace for the dataset & attribute to use */ + if((sid = H5Screate(H5S_SCALAR)) < 0) + FAIL_STACK_ERROR + + /* Create a dataset */ + if((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Re-open the dataset */ + if((dsid2 = H5Dopen2(fid, DSETNAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Create an attribute on the dataset */ + if((aid = H5Acreate2(dsid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Re-open the attribute */ + if((aid2 = H5Aopen(dsid, ATTRNAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Close the dataspace ID */ + if(H5Sclose(sid) < 0) + FAIL_STACK_ERROR + + /* Open a group ID */ + if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Open group again */ + if((gid2 = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Create a named datatype */ + if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) + FAIL_STACK_ERROR + if(H5Tcommit2(fid, TYPENAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR + + /* Re-open the named datatype */ + if((tid2 = H5Topen2(fid, TYPENAME, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Increment the ref count on all the "second" objects */ + if(H5Iinc_ref(dsid2) < 0) + FAIL_STACK_ERROR + if(H5Iinc_ref(aid2) < 0) + FAIL_STACK_ERROR + if(H5Iinc_ref(gid2) < 0) + FAIL_STACK_ERROR + if(H5Iinc_ref(aid2) < 0) + FAIL_STACK_ERROR + + /* Get the number of open objects */ + if((count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL)) < 0) + FAIL_STACK_ERROR + if(0 == count) + TEST_ERROR; + + /* Allocate the array of object IDs */ + objs = (hid_t*)HDmalloc(sizeof(hid_t) * (size_t)count); + + /* Get the list of open IDs */ + if(H5Fget_obj_ids(H5F_OBJ_ALL, H5F_OBJ_ALL, (size_t)count, objs) < 0) + FAIL_STACK_ERROR + + /* Close all open IDs */ + for(u = 0; u < (size_t)count; u++) + while(H5Iget_type(objs[u]) != H5I_BADID && H5Iget_ref(objs[u]) > 0) + H5Idec_ref(objs[u]); + + /* Get the number of open objects */ + if((count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL)) < 0) + FAIL_STACK_ERROR + if(0 != count) + TEST_ERROR; + + /* Clean up temporary file */ + HDremove(filename); + + /* Release object ID array */ + HDfree(objs); + + PASSED(); + return 0; + +error: + if(objs) + HDfree(objs); + return 1; +} + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Executes dangling ID tests @@ -556,6 +682,9 @@ main(void) nerrors += test_dangle_datatype2(H5F_CLOSE_STRONG); nerrors += test_dangle_attribute(H5F_CLOSE_STRONG); + /* Close open IDs "the hard way" */ + nerrors += test_dangle_force(); + /* Check for errors */ if (nerrors) goto error; diff --git a/test/dt_arith.c b/test/dt_arith.c index 413f326..078242d 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -5107,9 +5107,25 @@ run_int_fp_conv(const char *name) nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_INT, H5T_NATIVE_LDOUBLE); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UINT, H5T_NATIVE_LDOUBLE); #if H5_SIZEOF_LONG!=H5_SIZEOF_INT +#ifndef H5_LONG_TO_LDOUBLE_SPECIAL nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_LDOUBLE); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_LDOUBLE); +#else + { + char str[256]; /*string */ + + sprintf(str, "Testing %s %s -> %s conversions", + name, "(unsigned) long", "long double"); + printf("%-70s", str); + SKIPPED(); +#if H5_SIZEOF_LONG_DOUBLE!=0 + HDputs(" Test skipped due to the special algorithm of hardware conversion."); +#else + HDputs(" Test skipped due to disabled long double."); +#endif + } #endif +#endif /* H5_SIZEOF_LONG!=H5_SIZEOF_INT */ #if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG #if H5_LLONG_TO_LDOUBLE_CORRECT nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_LDOUBLE); @@ -5272,9 +5288,25 @@ run_fp_int_conv(const char *name) } #endif /*H5_LDOUBLE_TO_UINT_ACCURATE*/ #if H5_SIZEOF_LONG!=H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE!=0 +#ifndef H5_LDOUBLE_TO_LONG_SPECIAL nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_LDOUBLE, H5T_NATIVE_ULONG); +#else + { + char str[256]; /*string */ + + sprintf(str, "Testing %s %s -> %s conversions", + name, "long double", "(unsigned) long"); + printf("%-70s", str); + SKIPPED(); +#if H5_SIZEOF_LONG_DOUBLE!=0 + HDputs(" Test skipped due to the special algorithm of hardware conversion."); +#else + HDputs(" Test skipped due to disabled long double."); +#endif + } #endif +#endif /*H5_SIZEOF_LONG!=H5_SIZEOF_INT && H5_SIZEOF_LONG_DOUBLE!=0 */ #if H5_SIZEOF_LONG_LONG!=H5_SIZEOF_LONG && H5_SIZEOF_LONG_DOUBLE!=0 #ifdef H5_LDOUBLE_TO_LLONG_ACCURATE diff --git a/testpar/t_mdset.c b/testpar/t_mdset.c index 841d0b1..9a6856d 100644 --- a/testpar/t_mdset.c +++ b/testpar/t_mdset.c @@ -1711,36 +1711,106 @@ void io_mode_confusion(void) * * JRM -- 10/13/10 * - * Changes: None. + * Changes: + * Break it into two parts, a writer to write the file and a reader + * the correctness of the writer. AKC -- 2010/10/27 */ #define NUM_DATA_SETS 4 #define LOCAL_DATA_SIZE 4 #define LARGE_ATTR_SIZE 256 +/* Since all even and odd processes are split into writer and reader comm + * respectively, process 0 and 1 in COMM_WORLD become the root process of + * the writer and reader comm respectively. + */ +#define Writer_Root 0 +#define Reader_Root 1 +#define Reader_wait(mpi_err, xsteps) \ + mpi_err = MPI_Bcast(&xsteps, 1, MPI_INT, Writer_Root, MPI_COMM_WORLD) +#define Reader_result(mpi_err, xsteps_done) \ + mpi_err = MPI_Bcast(&xsteps_done, 1, MPI_INT, Reader_Root, MPI_COMM_WORLD) +#define Reader_check(mpi_err, xsteps, xsteps_done) \ + { Reader_wait(mpi_err, xsteps); \ + Reader_result(mpi_err, xsteps_done);} + +/* object names used by both rr_obj_hdr_flush_confusion and + * rr_obj_hdr_flush_confusion_reader. + */ +const char * dataset_name[NUM_DATA_SETS] = + { + "dataset_0", + "dataset_1", + "dataset_2", + "dataset_3" + }; +const char * att_name[NUM_DATA_SETS] = + { + "attribute_0", + "attribute_1", + "attribute_2", + "attribute_3" + }; +const char * lg_att_name[NUM_DATA_SETS] = + { + "large_attribute_0", + "large_attribute_1", + "large_attribute_2", + "large_attribute_3" + }; void rr_obj_hdr_flush_confusion(void) { - const char * dataset_name[NUM_DATA_SETS] = - { - "dataset_0", - "dataset_1", - "dataset_2", - "dataset_3" - }; - const char * att_name[NUM_DATA_SETS] = - { - "attribute_0", - "attribute_1", - "attribute_2", - "attribute_3" - }; - const char * lg_att_name[NUM_DATA_SETS] = - { - "large_attribute_0", - "large_attribute_1", - "large_attribute_2", - "large_attribute_3" - }; + /* MPI variables */ + /* private communicator size and rank */ + int mpi_size; + int mpi_rank; + int mrc; /* mpi error code */ + int is_reader; /* 1 for reader process; 0 for writer process. */ + MPI_Comm comm; + + + /* test bed related variables */ + const char * fcn_name = "rr_obj_hdr_flush_confusion"; + const hbool_t verbose = FALSE; + + /* Create two new private communicators from MPI_COMM_WORLD. + * Even and odd ranked processes go to comm_writers and comm_readers + * respectively. + */ + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + if (mpi_size < 3){ + HDfprintf(stdout, "%s needs at least 3 processes to run. Terminated.\n", + fcn_name); + nerrors++; + return; + } + is_reader = mpi_rank % 2; + mrc = MPI_Comm_split(MPI_COMM_WORLD, is_reader, mpi_rank, &comm); + VRFY((mrc==MPI_SUCCESS), "MPI_Comm_split"); + + /* The reader proocesses branches off to do reading + * while the writer processes continues to do writing + * Whenever writers finish one writing step, including a H5Fflush, + * they inform the readers, via MPI_COMM_WORLD, to verify. + * They will wait for the result from the readers before doing the next + * step. When all steps are done, they inform readers to end. + */ + if (is_reader) + rr_obj_hdr_flush_confusion_reader(comm); + else + rr_obj_hdr_flush_confusion_writer(comm); + + MPI_Comm_free(&comm); + if(verbose ) + HDfprintf(stdout, "%0d:%s: Done.\n", mpi_rank, fcn_name); + + return; + +} /* rr_obj_hdr_flush_confusion() */ + +void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) +{ int i; int j; hid_t file_id = -1; @@ -1767,11 +1837,19 @@ void rr_obj_hdr_flush_confusion(void) double lg_att[LARGE_ATTR_SIZE]; /* MPI variables */ + /* world communication size and rank */ + int mpi_world_size; + int mpi_world_rank; + /* private communicator size and rank */ int mpi_size; int mpi_rank; + int mrc; /* mpi error code */ + /* steps to verify and have been verified */ + int steps = 0; + int steps_done = 0; /* test bed related variables */ - const char * fcn_name = "rr_obj_hdr_flush_confusion"; + const char * fcn_name = "rr_obj_hdr_flush_confusion_writer"; const hbool_t verbose = FALSE; const H5Ptest_param_t * pt; char * filename; @@ -1780,11 +1858,13 @@ void rr_obj_hdr_flush_confusion(void) * setup test bed related variables: */ - pt = GetTestParameters(); + pt = (const H5Ptest_param_t *)GetTestParameters(); filename = pt->name; - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_world_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_world_size); + MPI_Comm_rank(comm, &mpi_rank); + MPI_Comm_size(comm, &mpi_size); /* * Set up file access property list with parallel I/O access @@ -1797,7 +1877,7 @@ void rr_obj_hdr_flush_confusion(void) fapl_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((fapl_id != -1), "H5Pcreate(H5P_FILE_ACCESS) failed"); - err = H5Pset_fapl_mpio(fapl_id, MPI_COMM_WORLD, MPI_INFO_NULL); + err = H5Pset_fapl_mpio(fapl_id, comm, MPI_INFO_NULL); VRFY((err >= 0 ), "H5Pset_fapl_mpio() failed"); @@ -1817,7 +1897,7 @@ void rr_obj_hdr_flush_confusion(void) /* - * create the data sets. + * Step 1: create the data sets and write data. */ if(verbose ) @@ -1833,12 +1913,11 @@ void rr_obj_hdr_flush_confusion(void) VRFY((disk_space[i] >= 0), "H5Screate_simple(1) failed.\n"); dataset[i] = H5Dcreate2(file_id, dataset_name[i], H5T_NATIVE_DOUBLE, - disk_space[i], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + disk_space[i], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset[i] >= 0), "H5Dcreate(1) failed.\n"); } - /* * setup data transfer property list */ @@ -1866,28 +1945,23 @@ void rr_obj_hdr_flush_confusion(void) mem_start[0] = (hsize_t)(0); for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { - data[j] = (double)(mpi_rank + 1); } for ( i = 0; i < NUM_DATA_SETS; i++ ) { - err = H5Sselect_hyperslab(disk_space[i], H5S_SELECT_SET, disk_start, NULL, disk_count, NULL); VRFY((err >= 0), "H5Sselect_hyperslab(1) failed.\n"); - mem_space[i] = H5Screate_simple(1, mem_size, NULL); VRFY((mem_space[i] >= 0), "H5Screate_simple(2) failed.\n"); - err = H5Sselect_hyperslab(mem_space[i], H5S_SELECT_SET, mem_start, NULL, mem_count, NULL); VRFY((err >= 0), "H5Sselect_hyperslab(2) failed.\n"); - err = H5Dwrite(dataset[i], H5T_NATIVE_DOUBLE, mem_space[i], disk_space[i], dxpl_id, data); VRFY((err >= 0), "H5Dwrite(1) failed.\n"); - - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) data[j] *= 10.0; + for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) + data[j] *= 10.0; } /* @@ -1898,14 +1972,14 @@ void rr_obj_hdr_flush_confusion(void) HDfprintf(stdout, "%0d:%s: closing dataspaces.\n", mpi_rank, fcn_name); for ( i = 0; i < NUM_DATA_SETS; i++ ) { - err = H5Sclose(disk_space[i]); VRFY((err >= 0), "H5Sclose(disk_space[i]) failed.\n"); - err = H5Sclose(mem_space[i]); VRFY((err >= 0), "H5Sclose(mem_space[i]) failed.\n"); } + /* End of Step 1: create the data sets and write data. */ + /* * flush the metadata cache */ @@ -1916,36 +1990,31 @@ void rr_obj_hdr_flush_confusion(void) err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); VRFY((err >= 0), "H5Fflush(1) failed.\n"); + /* Tell the reader to check the file up to steps. */ + steps++; + Reader_check(mrc, steps, steps_done); /* - * write attributes to each dataset + * Step 2: write attributes to each dataset */ if(verbose ) HDfprintf(stdout, "%0d:%s: writing attributes.\n", mpi_rank, fcn_name); att_size[0] = (hsize_t)(LOCAL_DATA_SIZE); - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { - att[j] = (double)(j + 1); } for ( i = 0; i < NUM_DATA_SETS; i++ ) { - att_space[i] = H5Screate_simple(1, att_size, NULL); VRFY((att_space[i] >= 0), "H5Screate_simple(3) failed.\n"); - att_id[i] = H5Acreate2(dataset[i], att_name[i], H5T_NATIVE_DOUBLE, att_space[i], H5P_DEFAULT, H5P_DEFAULT); VRFY((att_id[i] >= 0), "H5Acreate(1) failed.\n"); - - err = H5Awrite(att_id[i], H5T_NATIVE_DOUBLE, att); VRFY((err >= 0), "H5Awrite(1) failed.\n"); - for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { - att[j] /= 10.0; } } @@ -1962,11 +2031,12 @@ void rr_obj_hdr_flush_confusion(void) err = H5Sclose(att_space[i]); VRFY((err >= 0), "H5Sclose(att_space[i]) failed.\n"); - err = H5Aclose(att_id[i]); VRFY((err >= 0), "H5Aclose(att_id[i]) failed.\n"); } + /* End of Step 2: write attributes to each dataset */ + /* * flush the metadata cache again */ @@ -1977,9 +2047,12 @@ void rr_obj_hdr_flush_confusion(void) err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); VRFY((err >= 0), "H5Fflush(2) failed.\n"); + /* Tell the reader to check the file up to steps. */ + steps++; + Reader_check(mrc, steps, steps_done); /* - * write large attributes to each dataset + * Step 3: write large attributes to each dataset */ if(verbose ) @@ -1989,28 +2062,23 @@ void rr_obj_hdr_flush_confusion(void) lg_att_size[0] = (hsize_t)(LARGE_ATTR_SIZE); for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { - lg_att[j] = (double)(j + 1); } for ( i = 0; i < NUM_DATA_SETS; i++ ) { - lg_att_space[i] = H5Screate_simple(1, lg_att_size, NULL); VRFY((lg_att_space[i] >= 0), "H5Screate_simple(4) failed.\n"); - lg_att_id[i] = H5Acreate2(dataset[i], lg_att_name[i], H5T_NATIVE_DOUBLE, lg_att_space[i], H5P_DEFAULT, H5P_DEFAULT); VRFY((lg_att_id[i] >= 0), "H5Acreate(2) failed.\n"); - - err = H5Awrite(lg_att_id[i], H5T_NATIVE_DOUBLE, lg_att); VRFY((err >= 0), "H5Awrite(2) failed.\n"); - for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { - lg_att[j] /= 10.0; } } + + /* Step 3: write large attributes to each dataset */ /* * flush the metadata cache yet again to clean the object headers. @@ -2028,9 +2096,12 @@ void rr_obj_hdr_flush_confusion(void) err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); VRFY((err >= 0), "H5Fflush(3) failed.\n"); + /* Tell the reader to check the file up to steps. */ + steps++; + Reader_check(mrc, steps, steps_done); /* - * write different large attributes to each dataset + * Step 4: write different large attributes to each dataset */ if(verbose ) @@ -2038,21 +2109,33 @@ void rr_obj_hdr_flush_confusion(void) mpi_rank, fcn_name); for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { - lg_att[j] = (double)(j + 2); } for ( i = 0; i < NUM_DATA_SETS; i++ ) { - err = H5Awrite(lg_att_id[i], H5T_NATIVE_DOUBLE, lg_att); VRFY((err >= 0), "H5Awrite(2) failed.\n"); - for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { - lg_att[j] /= 10.0; } } + /* End of Step 4: write different large attributes to each dataset */ + + /* + * flush the metadata cache again + */ + if(verbose ) + HDfprintf(stdout, "%0d:%s: flushing metadata cache.\n", + mpi_rank, fcn_name); + err = H5Fflush(file_id, H5F_SCOPE_GLOBAL); + VRFY((err >= 0), "H5Fflush(3) failed.\n"); + + /* Tell the reader to check the file up to steps. */ + steps++; + Reader_check(mrc, steps, steps_done); + + /* Step 5: Close all objects and the file */ /* * close large attribute IDs and spaces @@ -2066,7 +2149,6 @@ void rr_obj_hdr_flush_confusion(void) err = H5Sclose(lg_att_space[i]); VRFY((err >= 0), "H5Sclose(lg_att_space[i]) failed.\n"); - err = H5Aclose(lg_att_id[i]); VRFY((err >= 0), "H5Aclose(lg_att_id[i]) failed.\n"); } @@ -2080,7 +2162,6 @@ void rr_obj_hdr_flush_confusion(void) HDfprintf(stdout, "%0d:%s: closing datasets .\n", mpi_rank, fcn_name); for ( i = 0; i < NUM_DATA_SETS; i++ ) { - err = H5Dclose(dataset[i]); VRFY((err >= 0), "H5Dclose(dataset[i])1 failed.\n"); } @@ -2105,83 +2186,380 @@ void rr_obj_hdr_flush_confusion(void) err = H5Fclose(file_id); VRFY((err >= 0 ), "H5Fclose(1) failed"); - - /* - * Must now open file and attempt to read data sets -- do this on process - * zero only. Test passes if we are able to do this, and fails otherwise. - */ - if ( mpi_rank == 0 ) { + /* End of Step 5: Close all objects and the file */ + /* Tell the reader to check the file up to steps. */ + steps++; + Reader_check(mrc, steps, steps_done); - /* - * Re-open the file - */ - if(verbose) - HDfprintf(stdout, "%0d:%s: re-opening file.\n", mpi_rank, fcn_name); - file_id = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); - VRFY((file_id >= 0 ), "H5Fopen() failed"); - /* - * Attempt to open the data sets - */ + /* All done. Inform reader to end. */ + steps=0; + Reader_check(mrc, steps, steps_done); - if(verbose ) - HDfprintf(stdout, "%0d:%s: opening datasets.\n", - mpi_rank, fcn_name); + if(verbose ) + HDfprintf(stdout, "%0d:%s: Done.\n", mpi_rank, fcn_name); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + return; - dataset[i] = -1; - } +} /* rr_obj_hdr_flush_confusion_writer() */ + +void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) +{ + int i; + int j; + hid_t file_id = -1; + hid_t fapl_id = -1; + hid_t dxpl_id = -1; + hid_t lg_att_id[NUM_DATA_SETS]; + hid_t lg_att_type[NUM_DATA_SETS]; + hid_t disk_space[NUM_DATA_SETS]; + hid_t mem_space[NUM_DATA_SETS]; + hid_t dataset[NUM_DATA_SETS]; + hsize_t disk_count[1]; + hsize_t disk_start[1]; + hsize_t mem_count[1]; + hsize_t mem_size[1]; + hsize_t mem_start[1]; + herr_t err; + htri_t tri_err; + double data[LOCAL_DATA_SIZE]; + double data_read[LOCAL_DATA_SIZE]; + double att[LOCAL_DATA_SIZE]; + double att_read[LOCAL_DATA_SIZE]; + double lg_att[LARGE_ATTR_SIZE]; + double lg_att_read[LARGE_ATTR_SIZE]; - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + /* MPI variables */ + /* world communication size and rank */ + int mpi_world_size; + int mpi_world_rank; + /* private communicator size and rank */ + int mpi_size; + int mpi_rank; + int mrc; /* mpi error code */ + int steps = -1; /* How far (steps) to verify the file */ + int steps_done = -1; /* How far (steps) have been verified */ - dataset[i] = H5Dopen2(file_id, dataset_name[i], H5P_DEFAULT); + /* test bed related variables */ + const char * fcn_name = "rr_obj_hdr_flush_confusion_reader"; + const hbool_t verbose = FALSE; + const H5Ptest_param_t * pt; + char * filename; - if ( dataset[i] < 0 ) { + /* + * setup test bed related variables: + */ - nerrors++; + pt = (const H5Ptest_param_t *)GetTestParameters(); + filename = pt->name; + + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_world_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_world_size); + MPI_Comm_rank(comm, &mpi_rank); + MPI_Comm_size(comm, &mpi_size); + + /* Repeatedly re-open the file and verify its contents until it is */ + /* told to end (when steps=0). */ + while (steps_done != 0){ + Reader_wait(mrc, steps); + VRFY((mrc >= 0), "Reader_wait failed"); + steps_done = 0; + + if (steps > 0 ){ + /* + * Set up file access property list with parallel I/O access + */ + + if(verbose ) + HDfprintf(stdout, "%0d:%s: Setting up property list.\n", + mpi_rank, fcn_name); + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + VRFY((fapl_id != -1), "H5Pcreate(H5P_FILE_ACCESS) failed"); + err = H5Pset_fapl_mpio(fapl_id, comm, MPI_INFO_NULL); + VRFY((err >= 0 ), "H5Pset_fapl_mpio() failed"); + + /* + * Create a new file collectively and release property list identifier. + */ + + if(verbose ) + HDfprintf(stdout, "%0d:%s: Re-open file \"%s\".\n", + mpi_rank, fcn_name, filename); + + file_id = H5Fopen(filename, H5F_ACC_RDONLY, fapl_id); + VRFY((file_id >= 0 ), "H5Fopen() failed"); + err = H5Pclose(fapl_id); + VRFY((err >= 0 ), "H5Pclose(fapl_id) failed"); + +#if 1 + if (steps >= 1){ + /*=====================================================* + * Step 1: open the data sets and read data. + *=====================================================*/ + + if(verbose ) + HDfprintf(stdout, "%0d:%s: opening the datasets.\n", + mpi_rank, fcn_name); + + for ( i = 0; i < NUM_DATA_SETS; i++ ) { + dataset[i] = -1; + } + + for ( i = 0; i < NUM_DATA_SETS; i++ ) { + dataset[i] = H5Dopen2(file_id, dataset_name[i], H5P_DEFAULT); + VRFY((dataset[i] >= 0), "H5Dopen(1) failed.\n"); + disk_space[i] = H5Dget_space(dataset[i]); + VRFY((disk_space[i] >= 0), "H5Dget_space failed.\n"); + } + + /* + * setup data transfer property list + */ + + if(verbose ) + HDfprintf(stdout, "%0d:%s: Setting up dxpl.\n", mpi_rank, fcn_name); + + dxpl_id = H5Pcreate(H5P_DATASET_XFER); + VRFY((dxpl_id != -1), "H5Pcreate(H5P_DATASET_XFER) failed.\n"); + err = H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE); + VRFY((err >= 0), + "H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) failed.\n"); + + /* + * read data from the data sets + */ + + if(verbose ) + HDfprintf(stdout, "%0d:%s: Reading datasets.\n", mpi_rank, fcn_name); + + disk_count[0] = (hsize_t)(LOCAL_DATA_SIZE); + disk_start[0] = (hsize_t)(LOCAL_DATA_SIZE * mpi_rank); + mem_count[0] = (hsize_t)(LOCAL_DATA_SIZE); + mem_start[0] = (hsize_t)(0); + + /* set up expected data for verification */ + for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { + data[j] = (double)(mpi_rank + 1); + } + + for ( i = 0; i < NUM_DATA_SETS; i++ ) { + err = H5Sselect_hyperslab(disk_space[i], H5S_SELECT_SET, disk_start, + NULL, disk_count, NULL); + VRFY((err >= 0), "H5Sselect_hyperslab(1) failed.\n"); + mem_space[i] = H5Screate_simple(1, mem_size, NULL); + VRFY((mem_space[i] >= 0), "H5Screate_simple(2) failed.\n"); + err = H5Sselect_hyperslab(mem_space[i], H5S_SELECT_SET, + mem_start, NULL, mem_count, NULL); + VRFY((err >= 0), "H5Sselect_hyperslab(2) failed.\n"); + err = H5Dread(dataset[i], H5T_NATIVE_DOUBLE, mem_space[i], + disk_space[i], dxpl_id, data_read); + VRFY((err >= 0), "H5Dread(1) failed.\n"); + + /* compare read data with expected data */ + for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) + if (data_read[j] != data[j]){ + HDfprintf(stdout, + "%0d:%s: Reading datasets value failed in " + "Dataset %d, at position %d: expect %f, got %f.\n", + mpi_rank, fcn_name, i, j, data[j], data_read[j]); + nerrors++; + } + for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) + data[j] *= 10.0; + } + + /* + * close the data spaces + */ + + if(verbose ) + HDfprintf(stdout, "%0d:%s: closing dataspaces.\n", mpi_rank, fcn_name); + + for ( i = 0; i < NUM_DATA_SETS; i++ ) { + err = H5Sclose(disk_space[i]); + VRFY((err >= 0), "H5Sclose(disk_space[i]) failed.\n"); + err = H5Sclose(mem_space[i]); + VRFY((err >= 0), "H5Sclose(mem_space[i]) failed.\n"); + } + steps_done++; + } + /* End of Step 1: open the data sets and read data. */ +#endif + +#if 1 + /*=====================================================* + * Step 2: reading attributes from each dataset + *=====================================================*/ + + if (steps >= 2){ + if(verbose ) + HDfprintf(stdout, "%0d:%s: reading attributes.\n", mpi_rank, fcn_name); + + for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { + + att[j] = (double)(j + 1); + } + + for ( i = 0; i < NUM_DATA_SETS; i++ ) { + hid_t att_id, att_type; + + att_id = H5Aopen(dataset[i], att_name[i], H5P_DEFAULT); + VRFY((att_id >= 0), "H5Aopen failed.\n"); + att_type = H5Aget_type(att_id); + VRFY((att_type >= 0), "H5Aget_type failed.\n"); + tri_err = H5Tequal(att_type, H5T_NATIVE_DOUBLE); + VRFY((tri_err >= 0), "H5Tequal failed.\n"); + if (tri_err==0){ + HDfprintf(stdout, + "%0d:%s: Mismatched Attribute type of Dataset %d.\n", + mpi_rank, fcn_name, i); + nerrors++; + }else{ + /* should verify attribute size before H5Aread */ + err = H5Aread(att_id, H5T_NATIVE_DOUBLE, att_read); + VRFY((err >= 0), "H5Aread failed.\n"); + /* compare read attribute data with expected data */ + for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) + if (att_read[j] != att[j]){ + HDfprintf(stdout, + "%0d:%s: Mismatched attribute data read in Dataset %d, at position %d: expect %f, got %f.\n", + mpi_rank, fcn_name, i, j, att[j], att_read[j]); + nerrors++; + } + for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) { + + att[j] /= 10.0; + } + } + err = H5Aclose(att_id); + VRFY((err >= 0), "H5Aclose failed.\n"); + } + steps_done++; + } + /* End of Step 2: reading attributes from each dataset */ +#endif + + +#if 1 + /*=====================================================* + * Step 3 or 4: read large attributes from each dataset. + * Step 4 has different attribute value from step 3. + *=====================================================*/ + + if (steps >= 3){ + if(verbose ) + HDfprintf(stdout, "%0d:%s: reading large attributes.\n", mpi_rank, fcn_name); + + for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { + + lg_att[j] = (steps==3) ? (double)(j + 1) : (double)(j+2); + } + + for ( i = 0; i < NUM_DATA_SETS; i++ ) { + lg_att_id[i] = H5Aopen(dataset[i], lg_att_name[i], H5P_DEFAULT); + VRFY((lg_att_id[i] >= 0), "H5Aopen(2) failed.\n"); + lg_att_type[i] = H5Aget_type(lg_att_id[i]); + VRFY((err >= 0), "H5Aget_type failed.\n"); + tri_err = H5Tequal(lg_att_type[i], H5T_NATIVE_DOUBLE); + VRFY((tri_err >= 0), "H5Tequal failed.\n"); + if (tri_err==0){ + HDfprintf(stdout, + "%0d:%s: Mismatched Large attribute type of Dataset %d.\n", + mpi_rank, fcn_name, i); + nerrors++; + }else{ + /* should verify large attribute size before H5Aread */ + err = H5Aread(lg_att_id[i], H5T_NATIVE_DOUBLE, lg_att_read); + VRFY((err >= 0), "H5Aread failed.\n"); + /* compare read attribute data with expected data */ + for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) + if (lg_att_read[j] != lg_att[j]){ + HDfprintf(stdout, + "%0d:%s: Mismatched large attribute data read in Dataset %d, at position %d: expect %f, got %f.\n", + mpi_rank, fcn_name, i, j, lg_att[j], lg_att_read[j]); + nerrors++; + } + for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) { + + lg_att[j] /= 10.0; + } + } + err = H5Tclose(lg_att_type[i]); + VRFY((err >= 0), "H5Tclose failed.\n"); + err = H5Aclose(lg_att_id[i]); + VRFY((err >= 0), "H5Aclose failed.\n"); + } + /* Both step 3 and 4 use this same read checking code. */ + steps_done = (steps==3) ? 3 : 4; } - } - /* - * Close the data sets - */ + /* End of Step 3 or 4: read large attributes from each dataset */ +#endif - if(verbose ) - HDfprintf(stdout, "%0d:%s: closing datasets again.\n", - mpi_rank, fcn_name); - for ( i = 0; i < NUM_DATA_SETS; i++ ) { + /*=====================================================* + * Step 5: read all objects from the file + *=====================================================*/ + if (steps>=5){ + /* nothing extra to verify. The file is closed normally. */ + /* Just increment steps_done */ + steps_done++; + } + + /* + * Close the data sets + */ - if ( dataset[i] >= 0 ) { + if(verbose ) + HDfprintf(stdout, "%0d:%s: closing datasets again.\n", + mpi_rank, fcn_name); - err = H5Dclose(dataset[i]); - VRFY((err >= 0), "H5Dclose(dataset[i])1 failed.\n"); + for ( i = 0; i < NUM_DATA_SETS; i++ ) { + if ( dataset[i] >= 0 ) { + err = H5Dclose(dataset[i]); + VRFY((err >= 0), "H5Dclose(dataset[i])1 failed.\n"); + } } - } - /* - * Close the file - */ - if(verbose) - HDfprintf(stdout, "%0d:%s: closing file again.\n", - mpi_rank, fcn_name); - err = H5Fclose(file_id); - VRFY((err >= 0 ), "H5Fclose(1) failed"); + /* + * close the data transfer property list. + */ - } + if(verbose ) + HDfprintf(stdout, "%0d:%s: closing dxpl .\n", mpi_rank, fcn_name); + + err = H5Pclose(dxpl_id); + VRFY((err >= 0), "H5Pclose(dxpl_id) failed.\n"); + + /* + * Close the file + */ + if(verbose) + HDfprintf(stdout, "%0d:%s: closing file again.\n", + mpi_rank, fcn_name); + err = H5Fclose(file_id); + VRFY((err >= 0 ), "H5Fclose(1) failed"); + + } /* else if (steps_done==0) */ + Reader_result(mrc, steps_done); + } /* end while(1) */ if(verbose ) HDfprintf(stdout, "%0d:%s: Done.\n", mpi_rank, fcn_name); return; - -} /* rr_obj_hdr_flush_confusion() */ +} /* rr_obj_hdr_flush_confusion_reader() */ #undef NUM_DATA_SETS #undef LOCAL_DATA_SIZE #undef LARGE_ATTR_SIZE +#undef Reader_check +#undef Reader_wait +#undef Reader_result +#undef Writer_Root +#undef Reader_Root /*============================================================================= * End of t_mdset.c diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h index 609db05..555f137 100644 --- a/testpar/testphdf5.h +++ b/testpar/testphdf5.h @@ -238,6 +238,8 @@ void coll_irregular_complex_chunk_read(void); void coll_irregular_complex_chunk_write(void); void io_mode_confusion(void); void rr_obj_hdr_flush_confusion(void); +void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm); +void rr_obj_hdr_flush_confusion_writer(MPI_Comm comm); void lower_dim_size_comp_test(void); void link_chunk_collective_io_test(void); void contig_hyperslab_dr_pio_test(void); diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt index ccb1466..afb1ca7 100644 --- a/tools/h5copy/CMakeLists.txt +++ b/tools/h5copy/CMakeLists.txt @@ -46,6 +46,7 @@ IF (BUILD_TESTING) h5copy_extlinks_trg.h5 h5copy_ref.h5 h5copytst.h5 + h5copy_misc1.out ) FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") @@ -101,10 +102,9 @@ IF (BUILD_TESTING) ENDIF (NOT ${resultcode} STREQUAL "2") ENDMACRO (ADD_H5_TEST testname resultcode testfile vparam srcname dstname) - - MACRO (ADD_H5LS_TEST file) + MACRO (ADD_H5LS_TEST file filetest) ADD_TEST ( - NAME H5COPY-H5LS_${file} + NAME H5COPY-H5LS_${file}-${filetest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS=-Svr;./testfiles/${file}.out.h5" @@ -115,7 +115,22 @@ IF (BUILD_TESTING) -D "TEST_MASK=true" -P "${HDF5_RESOURCES_DIR}/runTest.cmake" ) - ENDMACRO (ADD_H5LS_TEST file) + ENDMACRO (ADD_H5LS_TEST file filetest) + + MACRO (ADD_H5_CMP_TEST testname resultcode testfile vparam srcname dstname) + ADD_TEST ( + NAME H5COPY-CMP-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS=-i;${testfile}.h5;-o;./testfiles/${testfile}.out.h5;-${vparam};-s;${srcname};-d;${dstname}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${testname}.out.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=./testfiles/${testname}.out" + -D "TEST_MASK=true" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + ENDMACRO (ADD_H5_CMP_TEST testname resultcode testfile vparam srcname dstname) ############################################################################## ############################################################################## @@ -184,7 +199,7 @@ IF (BUILD_TESTING) ADD_H5_TEST (G_H_grp_nested 0 ${HDF_FILE1} vp /grp_nested /G/H/grp_nested) # Verify that the file created above is correct - ADD_H5LS_TEST (${HDF_FILE1}) + ADD_H5LS_TEST (${HDF_FILE1} basic) ############# COPY REFERENCES ############## @@ -202,7 +217,7 @@ IF (BUILD_TESTING) ADD_H5_TEST (region_ref 2 ${HDF_FILE2} v / /COPY ref) # Verify that the file created above is correct - ADD_H5LS_TEST (${HDF_FILE2}) + ADD_H5LS_TEST (${HDF_FILE2} refs) ############# COPY EXT LINKS ############## @@ -241,7 +256,29 @@ IF (BUILD_TESTING) ADD_H5_TEST (ext_link_group_f 2 ${HDF_EXT_SRC_FILE} v /group_ext /copy2_group ext) # Verify that the file created above is correct - ADD_H5LS_TEST (${HDF_EXT_SRC_FILE}) + ADD_H5LS_TEST (${HDF_EXT_SRC_FILE} links) + +############# Test misc. ############## + + ADD_CUSTOM_COMMAND ( + TARGET h5copy + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/testfiles/h5copytst.h5 ${PROJECT_BINARY_DIR}/h5copytst.h5 + ) + + # Remove any output file left over from previous test run + ADD_TEST ( + NAME H5COPY-clear-misc + COMMAND ${CMAKE_COMMAND} + -E remove + ./testfiles/${HDF_FILE1}.out.h5 + ./testfiles/${HDF_FILE1}.out.out + ./testfiles/${HDF_FILE1}.out.out.err + ) + + # "Test copying object into group which doesn't exist, without -p" + ADD_H5_CMP_TEST (h5copy_misc1 1 ${HDF_FILE1} v /simple /g1/g2/simple) ENDIF (BUILD_TESTING) diff --git a/tools/misc/CMakeLists.txt b/tools/misc/CMakeLists.txt index a1e2e49..77962ec 100644 --- a/tools/misc/CMakeLists.txt +++ b/tools/misc/CMakeLists.txt @@ -89,6 +89,31 @@ IF (BUILD_TESTING) ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_file} ${dest} ) ENDFOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) + + SET (HDF5_MKGRP_TEST_FILES + h5mkgrp_help + h5mkgrp_version + h5mkgrp_single + h5mkgrp_single_latest + h5mkgrp_several + h5mkgrp_several_latest + h5mkgrp_nested + h5mkgrp_nested_latest + h5mkgrp_nested_mult + h5mkgrp_nested_mult_latest + ) + + FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/../testfiles") + FOREACH (h5_mkgrp_file ${HDF5_MKGRP_TEST_FILES}) + SET (dest "${PROJECT_BINARY_DIR}/${h5_mkgrp_file}") + #MESSAGE (STATUS " Copying ${h5_mkgrp_file}") + ADD_CUSTOM_COMMAND ( + TARGET h5mkgrp + POST_BUILD + COMMAND ${XLATE_UTILITY} + ARGS ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_mkgrp_file}.ls ${dest}.ls -l3 + ) + ENDFOREACH (h5_mkgrp_file ${HDF5_MKGRP_TEST_FILES}) ############################################################################## ############################################################################## @@ -96,6 +121,40 @@ IF (BUILD_TESTING) ############################################################################## ############################################################################## + MACRO (ADD_H5_TEST resultfile resultcode resultoption) + ADD_TEST ( + NAME H5MKGRP-clear-${resultfile}${resultoption} + COMMAND ${CMAKE_COMMAND} + -E remove + ${PROJECT_BINARY_DIR}/../testfiles/${resultfile}.h5 + ${PROJECT_BINARY_DIR}/${resultfile}.out + ${PROJECT_BINARY_DIR}/${resultfile}.out.err + ) + IF (NOT ${resultoption} STREQUAL " ") + ADD_TEST ( + NAME H5MKGRP-${resultfile}${resultoption} + COMMAND $ ${resultoption} ${PROJECT_BINARY_DIR}/../testfiles/${resultfile}.h5 ${ARGN} + ) + ELSE (NOT ${resultoption} STREQUAL " ") + ADD_TEST ( + NAME H5MKGRP-${resultfile}${resultoption} + COMMAND $ ${PROJECT_BINARY_DIR}/../testfiles/${resultfile}.h5 ${ARGN} + ) + ENDIF (NOT ${resultoption} STREQUAL " ") + ADD_TEST ( + NAME H5MKGRP-H5LS-${resultfile}${resultoption} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-v;-r;../testfiles/${resultfile}.h5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_MASK_MOD=true" + -D "TEST_REFERENCE=${resultfile}.ls" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + ENDMACRO (ADD_H5_TEST resultfile resultcode resultoption) + ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -141,6 +200,28 @@ IF (BUILD_TESTING) SET (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5repart_test ) + + # Check that help & version is displayed properly + ADD_H5_TEST (h5mkgrp_help 1 "-h") + ADD_H5_TEST (h5mkgrp_version 1 "-V") + + # Create single group at root level + ADD_H5_TEST (h5mkgrp_single 0 " " single) + ADD_H5_TEST (h5mkgrp_single 0 "-v" single) + ADD_H5_TEST (h5mkgrp_single 0 "-p" single) + ADD_H5_TEST (h5mkgrp_single_latest 0 "-l" latest) + + # Create several groups at root level + ADD_H5_TEST (h5mkgrp_several 0 " " one two) + ADD_H5_TEST (h5mkgrp_several 0 "-v" one two) + ADD_H5_TEST (h5mkgrp_several 0 "-p" one two) + ADD_H5_TEST (h5mkgrp_several_latest 0 "-l" one two) + + # Create various nested groups + ADD_H5_TEST (h5mkgrp_nested 0 "-p" /one/two) + ADD_H5_TEST (h5mkgrp_nested_latest 0 "-lp" /one/two) + ADD_H5_TEST (h5mkgrp_nested_mult 0 "-p" /one/two /three/four) + ADD_H5_TEST (h5mkgrp_nested_mult_latest 0 "-lp" /one/two /three/four) ENDIF (BUILD_TESTING) ############################################################################## -- cgit v0.12