From c7a381b324da6cbbc62a841f1fecd320920532e2 Mon Sep 17 00:00:00 2001 From: Leon Arber Date: Sun, 1 Oct 2006 16:27:47 -0500 Subject: [svn-r12697] Purpose: New Feature Description: Preliminary test of H5Fflush to verify that it still works when using MPIO collective mode. Platforms: Linux (heping) --- testpar/Makefile.am | 2 +- testpar/Makefile.in | 30 ++++++-- testpar/t_pflush1.c | 174 ++++++++++++++++++++++++++++++++++++++++++++ testpar/t_pflush2.c | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 402 insertions(+), 7 deletions(-) create mode 100644 testpar/t_pflush1.c create mode 100644 testpar/t_pflush2.c diff --git a/testpar/Makefile.am b/testpar/Makefile.am index 26eb27f..352b7e3 100644 --- a/testpar/Makefile.am +++ b/testpar/Makefile.am @@ -24,7 +24,7 @@ INCLUDES=-I$(top_srcdir)/src -I$(top_srcdir)/test # Test programs and scripts. These are our main targets. # -TEST_PROG_PARA=t_mpi t_posix_compliant testphdf5 t_cache +TEST_PROG_PARA=t_mpi t_posix_compliant testphdf5 t_cache t_pflush1 t_pflush2 TEST_SCRIPT_PARA=testph5.sh check_PROGRAMS = $(TEST_PROG_PARA) diff --git a/testpar/Makefile.in b/testpar/Makefile.in index f600fc1..2e29272 100644 --- a/testpar/Makefile.in +++ b/testpar/Makefile.in @@ -29,7 +29,7 @@ # # hdf5 Parallel Library Test Makefile(.in) # -SOURCES = t_cache.c t_mpi.c t_posix_compliant.c $(testphdf5_SOURCES) +SOURCES = t_cache.c t_mpi.c t_pflush1.c t_pflush2.c t_posix_compliant.c $(testphdf5_SOURCES) srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -66,7 +66,8 @@ mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs CONFIG_HEADER = $(top_builddir)/src/H5config.h CONFIG_CLEAN_FILES = testph5.sh am__EXEEXT_1 = t_mpi$(EXEEXT) t_posix_compliant$(EXEEXT) \ - testphdf5$(EXEEXT) t_cache$(EXEEXT) + testphdf5$(EXEEXT) t_cache$(EXEEXT) t_pflush1$(EXEEXT) \ + t_pflush2$(EXEEXT) t_cache_SOURCES = t_cache.c t_cache_OBJECTS = t_cache.$(OBJEXT) t_cache_LDADD = $(LDADD) @@ -77,6 +78,14 @@ t_mpi_SOURCES = t_mpi.c t_mpi_OBJECTS = t_mpi.$(OBJEXT) t_mpi_LDADD = $(LDADD) t_mpi_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +t_pflush1_SOURCES = t_pflush1.c +t_pflush1_OBJECTS = t_pflush1.$(OBJEXT) +t_pflush1_LDADD = $(LDADD) +t_pflush1_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +t_pflush2_SOURCES = t_pflush2.c +t_pflush2_OBJECTS = t_pflush2.$(OBJEXT) +t_pflush2_LDADD = $(LDADD) +t_pflush2_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) t_posix_compliant_SOURCES = t_posix_compliant.c t_posix_compliant_OBJECTS = t_posix_compliant.$(OBJEXT) t_posix_compliant_LDADD = $(LDADD) @@ -100,9 +109,10 @@ LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = t_cache.c t_mpi.c t_posix_compliant.c $(testphdf5_SOURCES) -DIST_SOURCES = t_cache.c t_mpi.c t_posix_compliant.c \ - $(testphdf5_SOURCES) +SOURCES = t_cache.c t_mpi.c t_pflush1.c t_pflush2.c \ + t_posix_compliant.c $(testphdf5_SOURCES) +DIST_SOURCES = t_cache.c t_mpi.c t_pflush1.c t_pflush2.c \ + t_posix_compliant.c $(testphdf5_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -344,7 +354,7 @@ INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/test # Test programs and scripts. These are our main targets. # -TEST_PROG_PARA = t_mpi t_posix_compliant testphdf5 t_cache +TEST_PROG_PARA = t_mpi t_posix_compliant testphdf5 t_cache t_pflush1 t_pflush2 TEST_SCRIPT_PARA = testph5.sh check_SCRIPTS = $(TEST_SCRIPT) testphdf5_SOURCES = testphdf5.c t_dset.c t_file.c t_mdset.c t_ph5basic.c \ @@ -419,6 +429,12 @@ t_cache$(EXEEXT): $(t_cache_OBJECTS) $(t_cache_DEPENDENCIES) t_mpi$(EXEEXT): $(t_mpi_OBJECTS) $(t_mpi_DEPENDENCIES) @rm -f t_mpi$(EXEEXT) $(LINK) $(t_mpi_LDFLAGS) $(t_mpi_OBJECTS) $(t_mpi_LDADD) $(LIBS) +t_pflush1$(EXEEXT): $(t_pflush1_OBJECTS) $(t_pflush1_DEPENDENCIES) + @rm -f t_pflush1$(EXEEXT) + $(LINK) $(t_pflush1_LDFLAGS) $(t_pflush1_OBJECTS) $(t_pflush1_LDADD) $(LIBS) +t_pflush2$(EXEEXT): $(t_pflush2_OBJECTS) $(t_pflush2_DEPENDENCIES) + @rm -f t_pflush2$(EXEEXT) + $(LINK) $(t_pflush2_LDFLAGS) $(t_pflush2_OBJECTS) $(t_pflush2_LDADD) $(LIBS) t_posix_compliant$(EXEEXT): $(t_posix_compliant_OBJECTS) $(t_posix_compliant_DEPENDENCIES) @rm -f t_posix_compliant$(EXEEXT) $(LINK) $(t_posix_compliant_LDFLAGS) $(t_posix_compliant_OBJECTS) $(t_posix_compliant_LDADD) $(LIBS) @@ -439,6 +455,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_file.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_mdset.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_mpi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_pflush1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_pflush2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_ph5basic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_posix_compliant.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_span_tree.Po@am__quote@ diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c new file mode 100644 index 0000000..f2292b2 --- /dev/null +++ b/testpar/t_pflush1.c @@ -0,0 +1,174 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Leon Arber + * Sept. 28, 2006. + * + * Purpose: This is the first half of a two-part test that makes sure + * that a file can be read after a parallel application crashes as long + * as the file was flushed first. We simulate a crash by + * calling _exit(0) since this doesn't flush HDF5 caches but + * still exits with success. + */ +#include +#include "h5test.h" + +const char *FILENAME[] = { + "flush", + "noflush", + NULL +}; + +static double the_data[100][100]; + +/*------------------------------------------------------------------------- + * Function: create_file + * + * Purpose: Creates file used in part 1 of the test + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Leon Arber + * Sept. 26, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t create_file(char* name, hid_t fapl) +{ + hid_t file, dcpl, space, dset, groups, grp, plist; + hsize_t ds_size[2] = {100, 100}; + hsize_t ch_size[2] = {5, 5}; + hsize_t i, j; + + + + if ((file=H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; + + /* Create a chunked dataset */ + if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; + if (H5Pset_chunk(dcpl, 2, ch_size)<0) goto error; + if ((space=H5Screate_simple(2, ds_size, NULL))<0) goto error; + if ((dset=H5Dcreate(file, "dset", H5T_NATIVE_FLOAT, space, H5P_DEFAULT))<0) + goto error; + + plist = H5Pcreate(H5P_DATASET_XFER); + H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); + + + /* Write some data */ + for (i=0; i + * Sept. 28, 2006. + * + * Purpose: This is the second half of a two-part test that makes sure + * that a file can be read after a parallel application crashes as long + * as the file was flushed first. We simulate a crash by + * calling _exit(0) since this doesn't flush HDF5 caches but + * still exits with success. + */ + +#include "h5test.h" + +const char *FILENAME[] = { + "flush", + "noflush", + NULL +}; + +static double the_data[100][100]; + + +/*------------------------------------------------------------------------- + * Function: check_file + * + * Purpose: Part 2 of a two-part H5Fflush() test. + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Leon Arber + * Sept. 26, 2006. + * + *------------------------------------------------------------------------- + */ +int check_file(char* name, hid_t fapl) +{ + hid_t file, space, dset, groups, grp, plist; + hsize_t ds_size[2]; + double error; + hsize_t i, j; + + plist = H5Pcreate(H5P_DATASET_XFER); + H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); + + if ((file=H5Fopen(name, H5F_ACC_RDONLY, fapl))<0) goto error; + + /* Open the dataset */ + if ((dset=H5Dopen(file, "dset"))<0) goto error; + if ((space=H5Dget_space(dset))<0) goto error; + if (H5Sget_simple_extent_dims(space, ds_size, NULL)<0) goto error; + assert(100==ds_size[0] && 100==ds_size[1]); + + /* Read some data */ + if (H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, plist, + the_data)<0) goto error; + for (i=0; i0.0001) { + H5_FAILED(); + printf(" dset[%lu][%lu] = %g\n", + (unsigned long)i, (unsigned long)j, the_data[i][j]); + printf(" should be %g\n", + (double)(hssize_t)i/(hssize_t)(j+1)); + goto error; + } + } + } + + /* Open some groups */ + if ((groups=H5Gopen(file, "some_groups"))<0) goto error; + for (i=0; i<100; i++) { + sprintf(name, "grp%02u", (unsigned)i); + if ((grp=H5Gopen(groups, name))<0) goto error; + if (H5Gclose(grp)<0) goto error; + } + + if (H5Gclose(groups)<0) goto error; + if (H5Pclose(plist)<0) goto error; + if (H5Dclose(dset)<0) goto error; + if (H5Fclose(file)<0) goto error; + return 0; +error: + return 1; + + +} + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Part 2 of a two-part H5Fflush() test. + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Robb Matzke + * Friday, October 23, 1998 + * + * Modifications: + * Leon Arber + * Sept. 26, 2006, expand to check for case where the was file not flushed. + * + *------------------------------------------------------------------------- + */ +int +main(int argc, char* argv[]) +{ + hid_t fapl; + H5E_auto_stack_t func; + + char name[1024]; + const char *envval = NULL; + + int mpi_size, mpi_rank; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; + + MPI_Init(&argc, &argv); + MPI_Comm_size(comm, &mpi_size); + MPI_Comm_rank(comm, &mpi_rank); + + fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_mpio(fapl, comm, info); + + if(mpi_rank == 0) + TESTING("H5Fflush (part2 with flush)"); + + /* Don't run this test using the core or split file drivers */ + envval = HDgetenv("HDF5_DRIVER"); + if (envval == NULL) + envval = "nomatch"; + if (HDstrcmp(envval, "core") && HDstrcmp(envval, "split")) { + /* Check the case where the file was flushed */ + h5_fixname(FILENAME[0], fapl, name, sizeof name); + if(check_file(name, fapl)) + { + H5_FAILED() + goto error; + } + else if(mpi_rank == 0) + PASSED(); + + + /* Check the case where the file was not flushed. This should give an error + * so we turn off the error stack temporarily */ + if(mpi_rank == 0) + TESTING("H5Fflush (part2 without flush)"); + H5Eget_auto_stack(H5E_DEFAULT,&func,NULL); + H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL); + + h5_fixname(FILENAME[1], fapl, name, sizeof name); + if(check_file(name, fapl)) + { + if(mpi_rank == 0) + PASSED() + } + else + { + H5_FAILED() + goto error; + } + H5Eset_auto_stack(H5E_DEFAULT, func, NULL); + + + h5_cleanup(FILENAME, fapl); + } + else + { + SKIPPED(); + puts(" Test not compatible with current Virtual File Driver"); + } + return 0; + + error: + return 1; +} + + + + -- cgit v0.12