diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2007-06-02 18:19:36 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2007-06-02 18:19:36 (GMT) |
commit | 1280f90f8128a72f1b2cfe45d3a5a24334c222e0 (patch) | |
tree | a7969815417facfd248292e2830679fd4fbea9df /testpar | |
parent | 2aa1084117a0040dbb6c54246837cd3133f51bdf (diff) | |
download | hdf5-1280f90f8128a72f1b2cfe45d3a5a24334c222e0.zip hdf5-1280f90f8128a72f1b2cfe45d3a5a24334c222e0.tar.gz hdf5-1280f90f8128a72f1b2cfe45d3a5a24334c222e0.tar.bz2 |
[svn-r13829] Some systems (only SGI Altix ProPack 4 discovered so far) doesn't return correct
file size from MPI_File_get_size. Bypass this problem by replacing it with
stat. Add an option --disable-mpi-size in configure to indicate this function
doesn't work properly. Add a test in testpar/t_mpi.c, too. If it returns wrong
file size, print out a warning.
Tested on kagiso (parallel) because already tested the same change to v1.6 on
several platforms (kagiso, cobalt, copper, and sol).
Diffstat (limited to 'testpar')
-rw-r--r-- | testpar/Makefile.in | 1 | ||||
-rw-r--r-- | testpar/t_chunk_alloc.c | 14 | ||||
-rw-r--r-- | testpar/t_mpi.c | 40 |
3 files changed, 55 insertions, 0 deletions
diff --git a/testpar/Makefile.in b/testpar/Makefile.in index c0ae51d..49adf76 100644 --- a/testpar/Makefile.in +++ b/testpar/Makefile.in @@ -197,6 +197,7 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MPE = @MPE@ +MPI_GET_SIZE = @MPI_GET_SIZE@ OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ diff --git a/testpar/t_chunk_alloc.c b/testpar/t_chunk_alloc.c index 770a1fc..5b60c0e 100644 --- a/testpar/t_chunk_alloc.c +++ b/testpar/t_chunk_alloc.c @@ -36,7 +36,11 @@ get_filesize(const char *filename) int mpierr; MPI_File fd; MPI_Offset filesize; +#ifndef H5_HAVE_MPI_GET_SIZE + struct stat stat_buf; +#endif +#ifdef H5_HAVE_MPI_GET_SIZE mpierr = MPI_File_open(MPI_COMM_SELF, (char*)filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &fd); VRFY((mpierr == MPI_SUCCESS), ""); @@ -46,6 +50,16 @@ get_filesize(const char *filename) mpierr = MPI_File_close(&fd); VRFY((mpierr == MPI_SUCCESS), ""); +#else + /* Some systems (only SGI Altix Propack 4 so far) doesn't return correct + * file size for MPI_File_get_size. Use stat instead. + */ + if((mpierr=stat(filename, &stat_buf))<0) + VRFY((mpierr == MPI_SUCCESS), ""); + + /* Hopefully this casting is safe */ + filesize = (MPI_Offset)(stat_buf.st_size); +#endif return(filesize); } diff --git a/testpar/t_mpi.c b/testpar/t_mpi.c index 6465a94..f68c92b 100644 --- a/testpar/t_mpi.c +++ b/testpar/t_mpi.c @@ -202,9 +202,11 @@ test_mpio_gb_file(char *filename) int ntimes; /* how many times */ char *buf = NULL; char expected; + MPI_Offset size; MPI_Offset mpi_off; MPI_Offset mpi_off_old; MPI_Status mpi_stat; + struct stat stat_buf; int is_signed, sizeof_mpi_offset; nerrs = 0; @@ -376,6 +378,44 @@ test_mpio_gb_file(char *filename) */ mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc==MPI_SUCCESS), "Sync before leaving test"); + + /* + * Check if MPI_File_get_size works correctly. Some systems (only SGI Altix + * Propack 4 so far) return wrong file size. It can be avoided by reconfiguring + * with "--disable-mpi-size". + */ +#ifdef H5_HAVE_MPI_GET_SIZE + printf("Test if MPI_File_get_size works correctly with %s\n", filename); + + mrc = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, info, &fh); + VRFY((mrc==MPI_SUCCESS), ""); + + if (MAINPROCESS){ /* only process 0 needs to check it*/ + mrc = MPI_File_get_size(fh, &size); + VRFY((mrc==MPI_SUCCESS), ""); + + mrc=stat(filename, &stat_buf); + VRFY((mrc==0), ""); + + /* Hopefully this casting is safe */ + if(size != (MPI_Offset)(stat_buf.st_size)) { + printf("Warning: MPI_File_get_size doesn't return correct file size. To avoid using it in the library, reconfigure and rebuild the library with --disable-mpi-size.\n"); + } + } + + /* close file and free the communicator */ + mrc = MPI_File_close(&fh); + VRFY((mrc==MPI_SUCCESS), "MPI_FILE_CLOSE"); + + /* + * one more sync to ensure all processes have done reading + * before ending this test. + */ + mrc = MPI_Barrier(MPI_COMM_WORLD); + VRFY((mrc==MPI_SUCCESS), "Sync before leaving test"); +#else + printf("Skipped testing MPI_File_get_size because it's disabled\n"); +#endif } finish: |