diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-08-02 14:10:07 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-08-02 14:10:07 (GMT) |
commit | 8a594dbff5f64e659f791bfdcd60c2ec7957a258 (patch) | |
tree | 2f9dea4fb4323ad6554c5c5ed2f0d4c9a97d078a /src/H5FDmpiposix.c | |
parent | 529c7b27c78a42fddc90df243d8d3f43e8fec7d6 (diff) | |
download | hdf5-8a594dbff5f64e659f791bfdcd60c2ec7957a258.zip hdf5-8a594dbff5f64e659f791bfdcd60c2ec7957a258.tar.gz hdf5-8a594dbff5f64e659f791bfdcd60c2ec7957a258.tar.bz2 |
[svn-r8985] Purpose:
Bug fixes & code cleanups
Description:
Backport MPI-I/O changes from the development branch to the release
branch in preparation for bringing Kent's collective chunk I/O changes back.
Removed last vestiges of FPHDF5 from this branch, as it was never working
here.
Various code cleanups & syncrontizations to better align with development
branch code and reduce diffs.
Regenerate dependencies.
Platforms tested:
FreeBSD 4.10 (sleipnir) w/parallel
IRIX64 6.5 (modi4)
h5committested
Diffstat (limited to 'src/H5FDmpiposix.c')
-rw-r--r-- | src/H5FDmpiposix.c | 490 |
1 files changed, 275 insertions, 215 deletions
diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c index 3accc36..baef534 100644 --- a/src/H5FDmpiposix.c +++ b/src/H5FDmpiposix.c @@ -31,15 +31,20 @@ * on a non-parallel filesystem. * */ -#include "H5private.h" /*library functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /*error handling */ -#include "H5Fprivate.h" /*files */ -#include "H5FDprivate.h" /*file driver */ -#include "H5FDmpiposix.h" /* MPI/posix I/O file driver */ + +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ +#define PABLO_MASK H5FD_mpiposix_mask + +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FDmpi.h" /* MPI-based file drivers */ #include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /*memory allocation */ -#include "H5Pprivate.h" /*property lists */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* Features: * H5_HAVE_GPFS -- issue gpfs_fcntl() calls to hopefully improve @@ -184,6 +189,9 @@ static herr_t H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, static herr_t H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t fapl_id, haddr_t addr, size_t size, const void *buf); static herr_t H5FD_mpiposix_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing); +static int H5FD_mpiposix_mpi_rank(const H5FD_t *_file); +static int H5FD_mpiposix_mpi_size(const H5FD_t *_file); +static MPI_Comm H5FD_mpiposix_communicator(const H5FD_t *_file); /* MPIPOSIX-specific file access properties */ typedef struct H5FD_mpiposix_fapl_t { @@ -192,7 +200,8 @@ typedef struct H5FD_mpiposix_fapl_t { } H5FD_mpiposix_fapl_t; /* The MPIPOSIX file driver information */ -static const H5FD_class_t H5FD_mpiposix_g = { +static const H5FD_class_mpi_t H5FD_mpiposix_g = { + { /* Start of superclass information */ "mpiposix", /*name */ MAXADDR, /*maxaddr */ H5F_CLOSE_SEMI, /* fc_degree */ @@ -222,14 +231,39 @@ static const H5FD_class_t H5FD_mpiposix_g = { NULL, /*lock */ NULL, /*unlock */ H5FD_FLMAP_SINGLE /*fl_map */ + }, /* End of superclass information */ + H5FD_mpiposix_mpi_rank, /*get_rank */ + H5FD_mpiposix_mpi_size, /*get_size */ + H5FD_mpiposix_communicator /*get_comm */ }; /* Interface initialization */ -#define PABLO_MASK H5FD_mpiposix_mask -#define INTERFACE_INIT H5FD_mpiposix_init +#define INTERFACE_INIT H5FD_mpiposix_init_interface static int interface_initialize_g = 0; +/*-------------------------------------------------------------------------- +NAME + H5FD_mpiposix_init_interface -- Initialize interface-specific information +USAGE + herr_t H5FD_mpiposix_init_interface() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. (Just calls + H5FD_mpiposix_init currently). + +--------------------------------------------------------------------------*/ +static herr_t +H5FD_mpiposix_init_interface(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpiposix_init_interface) + + FUNC_LEAVE_NOAPI(H5FD_mpiposix_init()) +} /* H5FD_mpiposix_init_interface() */ + + /*------------------------------------------------------------------------- * Function: H5FD_mpiposix_init * @@ -252,18 +286,44 @@ H5FD_mpiposix_init(void) { hid_t ret_value=H5FD_MPIPOSIX_g; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_mpiposix_init, FAIL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_init, FAIL) if (H5I_VFL!=H5Iget_type(H5FD_MPIPOSIX_g)) - H5FD_MPIPOSIX_g = H5FDregister(&H5FD_mpiposix_g); + H5FD_MPIPOSIX_g = H5FD_register((const H5FD_class_t *)&H5FD_mpiposix_g,sizeof(H5FD_class_mpi_t)); /* Set return value */ ret_value=H5FD_MPIPOSIX_g; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_init() */ + +/*--------------------------------------------------------------------------- + * Function: H5FD_mpiposix_term + * + * Purpose: Shut down the VFD + * + * Return: <none> + * + * Programmer: Quincey Koziol + * Friday, Jan 30, 2004 + * + * Modification: + * + *--------------------------------------------------------------------------- + */ +void +H5FD_mpiposix_term(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpiposix_term) + + /* Reset VFL ID */ + H5FD_MPIPOSIX_g=0; + + FUNC_LEAVE_NOAPI_VOID +} /* end H5FD_mpiposix_term() */ + #ifdef H5_WANT_H5_V1_4_COMPAT /*------------------------------------------------------------------------- @@ -303,14 +363,14 @@ H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm) H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; - FUNC_ENTER_API(H5Pset_fapl_mpiposix, FAIL); + FUNC_ENTER_API(H5Pset_fapl_mpiposix, FAIL) H5TRACE2("e","iMc",fapl_id,comm); /* Check arguments */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list"); + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (MPI_COMM_NULL == comm) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator"); + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator") /* Initialize driver specific properties */ fa.comm = comm; @@ -320,7 +380,7 @@ H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm) ret_value= H5P_set_driver(plist, H5FD_MPIPOSIX, &fa); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_mpiposix() */ @@ -362,24 +422,24 @@ H5Pget_fapl_mpiposix(hid_t fapl_id, MPI_Comm *comm/*out*/) int mpi_code; /* mpi return code */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Pget_fapl_mpiposix, FAIL); + FUNC_ENTER_API(H5Pget_fapl_mpiposix, FAIL) H5TRACE2("e","ix",fapl_id,comm); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list"); + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (H5FD_MPIPOSIX!=H5P_get_driver(plist)) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver"); + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL==(fa=H5P_get_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info"); + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Get MPI Communicator */ if (comm){ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code); + HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) } done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_mpiposix() */ #else /* H5_WANT_H5_V1_4_COMPAT */ @@ -424,14 +484,14 @@ H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm, hbool_t use_gpfs) H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value; - FUNC_ENTER_API(H5Pset_fapl_mpiposix, FAIL); + FUNC_ENTER_API(H5Pset_fapl_mpiposix, FAIL) H5TRACE3("e","iMcb",fapl_id,comm,use_gpfs); /* Check arguments */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list"); + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (MPI_COMM_NULL == comm) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator"); + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator") /* Initialize driver specific properties */ fa.comm = comm; @@ -441,7 +501,7 @@ H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm, hbool_t use_gpfs) ret_value= H5P_set_driver(plist, H5FD_MPIPOSIX, &fa); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_mpiposix() */ @@ -483,135 +543,32 @@ H5Pget_fapl_mpiposix(hid_t fapl_id, MPI_Comm *comm/*out*/, hbool_t *use_gpfs/*ou int mpi_code; /* mpi return code */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Pget_fapl_mpiposix, FAIL); + FUNC_ENTER_API(H5Pget_fapl_mpiposix, FAIL) H5TRACE3("e","ixx",fapl_id,comm,use_gpfs); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list"); + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") if (H5FD_MPIPOSIX!=H5P_get_driver(plist)) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver"); + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") if (NULL==(fa=H5P_get_driver_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info"); + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Get MPI Communicator */ if (comm){ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code); + HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) } if (use_gpfs) *use_gpfs = fa->use_gpfs; done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Pget_fapl_mpiposix() */ #endif /* H5_WANT_H5_V1_4_COMPAT */ /*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_communicator - * - * Purpose: Returns the MPI communicator for the file. - * - * Return: Success: The communicator - * - * Failure: NULL - * - * Programmer: Quincey Koziol - * Thursday, July 11, 2002 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -MPI_Comm -H5FD_mpiposix_communicator(H5FD_t *_file) -{ - H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; - MPI_Comm ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5FD_mpiposix_communicator, MPI_COMM_NULL); - - assert(file); - assert(H5FD_MPIPOSIX==file->pub.driver_id); - - /* Set return value */ - ret_value=file->comm; - -done: - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5FD_mpi_posix_communicator() */ - - -/*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_mpi_rank - * - * Purpose: Returns the MPI rank for a process - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Thursday, July 11, 2002 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -H5FD_mpiposix_mpi_rank(H5FD_t *_file) -{ - H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; - int ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5FD_mpiposix_mpi_rank, FAIL); - - assert(file); - assert(H5FD_MPIPOSIX==file->pub.driver_id); - - /* Set return value */ - ret_value=file->mpi_rank; - -done: - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5FD_mpiposix_mpi_rank() */ - - -/*------------------------------------------------------------------------- - * Function: H5FD_mpiposix_mpi_size - * - * Purpose: Returns the number of MPI processes - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Thursday, July 11, 2002 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -H5FD_mpiposix_mpi_size(H5FD_t *_file) -{ - H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; - int ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(H5FD_mpiposix_mpi_size, FAIL); - - assert(file); - assert(H5FD_MPIPOSIX==file->pub.driver_id); - - /* Set return value */ - ret_value=file->mpi_size; - -done: - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5FD_mpiposix_mpi_size() */ - - -/*------------------------------------------------------------------------- * Function: H5FD_mpiposix_fapl_get * * Purpose: Returns a file access property list which could be used to @@ -640,17 +597,17 @@ H5FD_mpiposix_fapl_get(H5FD_t *_file) int mpi_code; /* MPI return code */ void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_get, NULL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_get, NULL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); if (NULL==(fa=H5MM_calloc(sizeof(H5FD_mpiposix_fapl_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Duplicate the communicator. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(file->comm, &fa->comm))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code); + HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) fa->use_gpfs = file->use_gpfs; @@ -658,7 +615,7 @@ H5FD_mpiposix_fapl_get(H5FD_t *_file) ret_value=fa; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_fapl_get() */ @@ -686,17 +643,17 @@ H5FD_mpiposix_fapl_copy(const void *_old_fa) H5FD_mpiposix_fapl_t *new_fa = NULL; int mpi_code; /* MPI return code */ - FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_copy, NULL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_copy, NULL) if (NULL==(new_fa=H5MM_malloc(sizeof(H5FD_mpiposix_fapl_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy the general information */ HDmemcpy(new_fa, old_fa, sizeof(H5FD_mpiposix_fapl_t)); /* Duplicate communicator. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(old_fa->comm, &new_fa->comm))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code); + HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) new_fa->use_gpfs = old_fa->use_gpfs; ret_value = new_fa; @@ -708,7 +665,7 @@ done: H5MM_xfree(new_fa); } - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_fapl_copy() */ @@ -734,7 +691,7 @@ H5FD_mpiposix_fapl_free(void *_fa) herr_t ret_value = SUCCEED; H5FD_mpiposix_fapl_t *fa = (H5FD_mpiposix_fapl_t*)_fa; - FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_free, FAIL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_free, FAIL) assert(fa); /* Free the internal communicator */ @@ -743,7 +700,7 @@ H5FD_mpiposix_fapl_free(void *_fa) H5MM_xfree(fa); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_fapl_free() */ @@ -792,19 +749,19 @@ H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id, H5FD_t *ret_value=NULL; /* Return value */ MPI_Comm comm_dup=MPI_COMM_NULL; - FUNC_ENTER_NOAPI(H5FD_mpiposix_open, NULL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_open, NULL) /* Check arguments */ if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name") if (0==maxaddr || HADDR_UNDEF==maxaddr) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr"); + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr") if (ADDR_OVERFLOW(maxaddr)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr"); + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") /* Obtain a pointer to mpiposix-specific file access properties */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") if (H5P_FILE_ACCESS_DEFAULT==fapl_id || H5FD_MPIPOSIX!=H5P_get_driver(plist)) { _fa.comm = MPI_COMM_SELF; /*default*/ _fa.use_gpfs = FALSE; @@ -817,13 +774,13 @@ H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id, /* Duplicate the communicator for use by this file. */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, &comm_dup))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code); + HMPI_GOTO_ERROR(NULL, "MPI_Comm_dup failed", mpi_code) /* Get the MPI rank of this process and the total number of processes */ if (MPI_SUCCESS != (mpi_code=MPI_Comm_rank (comm_dup, &mpi_rank))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_rank failed", mpi_code); + HMPI_GOTO_ERROR(NULL, "MPI_Comm_rank failed", mpi_code) if (MPI_SUCCESS != (mpi_code=MPI_Comm_size (comm_dup, &mpi_size))) - HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mpi_code); + HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mpi_code) /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; @@ -858,29 +815,29 @@ H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id, * to check for that situation and bail out now also. - QAK */ if (MPI_SUCCESS != (mpi_code= MPI_Bcast(&fd, sizeof(int), MPI_BYTE, 0, comm_dup))) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code); + HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) /* If the file open on process 0 failed, bail out on all processes now */ if(fd<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") /* Other processes (non 0) wait for broadcast result from process 0 and then open file */ if(mpi_rank!=0) { /* Open the file */ if ((fd=HDopen(name, o_flags, 0666))<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") } /* end if */ /* Process 0 fstat()s the file and broadcasts the results to the other processes */ if(mpi_rank==0) { /* Get the stat information */ if (HDfstat(fd, &sb)<0) - HGOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file"); + HGOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file") } /* end if */ /* Broadcast the results of the fstat() from process 0 */ if (MPI_SUCCESS != (mpi_code= MPI_Bcast(&sb, sizeof(h5_stat_t), MPI_BYTE, 0, comm_dup))) - HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code); + HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) #ifdef H5_HAVE_GPFS if (fa->use_gpfs) { @@ -902,13 +859,13 @@ H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id, hint.fr.length = 0; if (gpfs_fcntl(fd, &hint)<0) - HGOTO_ERROR(H5E_FILE, H5E_FCNTL, NULL, "failed to send hints to GPFS"); + HGOTO_ERROR(H5E_FILE, H5E_FCNTL, NULL, "failed to send hints to GPFS") } #endif /* H5_HAVE_GPFS */ /* Build the file struct and initialize it */ if (NULL==(file=H5MM_calloc(sizeof(H5FD_mpiposix_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") #ifdef REPORT_IO HDfprintf(stderr, "open: rank=%d name=%s file=0x%08lx\n", mpi_rank, name, (unsigned long)file); @@ -955,7 +912,7 @@ done: MPI_Comm_free(&comm_dup); } /* end if */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_open() */ @@ -981,21 +938,21 @@ H5FD_mpiposix_close(H5FD_t *_file) H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_mpiposix_close, FAIL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_close, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); /* Close the unix file */ if (HDclose(file->fd)<0) - HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file"); + HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") /* Clean up other stuff */ MPI_Comm_free(&file->comm); H5MM_xfree(file); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_close() */ @@ -1023,34 +980,34 @@ H5FD_mpiposix_cmp(const H5FD_t *_f1, const H5FD_t *_f2) const H5FD_mpiposix_t *f2 = (const H5FD_mpiposix_t*)_f2; int ret_value=0; - FUNC_ENTER_NOAPI(H5FD_mpiposix_cmp, H5FD_VFD_DEFAULT); + FUNC_ENTER_NOAPI(H5FD_mpiposix_cmp, H5FD_VFD_DEFAULT) #ifdef WIN32 - if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1); - if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1); + if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1) + if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1) - if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1); - if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1); + if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1) + if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1) #else #ifdef H5_DEV_T_IS_SCALAR - if (f1->device < f2->device) HGOTO_DONE(-1); - if (f1->device > f2->device) HGOTO_DONE(1); + if (f1->device < f2->device) HGOTO_DONE(-1) + if (f1->device > f2->device) HGOTO_DONE(1) #else /* H5_DEV_T_IS_SCALAR */ /* If dev_t isn't a scalar value on this system, just use memcmp to * determine if the values are the same or not. The actual return value * shouldn't really matter... */ - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1); - if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1); + if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1) + if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1) #endif /* H5_DEV_T_IS_SCALAR */ - if (f1->inode < f2->inode) HGOTO_DONE(-1); - if (f1->inode > f2->inode) HGOTO_DONE(1); + if (f1->inode < f2->inode) HGOTO_DONE(-1) + if (f1->inode > f2->inode) HGOTO_DONE(1) #endif done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_cmp() */ @@ -1075,7 +1032,7 @@ H5FD_mpiposix_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */) { herr_t ret_value=SUCCEED; - FUNC_ENTER_NOAPI(H5FD_mpiposix_query, FAIL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_query, FAIL) /* Set the VFL feature flags that this driver supports */ if(flags) { @@ -1094,7 +1051,7 @@ H5FD_mpiposix_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */) } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_query() */ @@ -1121,7 +1078,7 @@ H5FD_mpiposix_get_eoa(H5FD_t *_file) H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; haddr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_mpiposix_get_eoa, HADDR_UNDEF); + FUNC_ENTER_NOAPI(H5FD_mpiposix_get_eoa, HADDR_UNDEF) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); @@ -1130,7 +1087,7 @@ H5FD_mpiposix_get_eoa(H5FD_t *_file) ret_value=file->eoa; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_get_eoa() */ @@ -1157,7 +1114,7 @@ H5FD_mpiposix_set_eoa(H5FD_t *_file, haddr_t addr) H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_mpiposix_set_eoa, FAIL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_set_eoa, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); @@ -1165,7 +1122,7 @@ H5FD_mpiposix_set_eoa(H5FD_t *_file, haddr_t addr) file->eoa = addr; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpi_posix_set_eoa() */ @@ -1197,7 +1154,7 @@ H5FD_mpiposix_get_eof(H5FD_t *_file) H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file; haddr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_mpiposix_get_eof, HADDR_UNDEF); + FUNC_ENTER_NOAPI(H5FD_mpiposix_get_eof, HADDR_UNDEF) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); @@ -1206,7 +1163,7 @@ H5FD_mpiposix_get_eof(H5FD_t *_file) ret_value=MAX(file->eof,file->eoa); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_get_eof() */ @@ -1230,15 +1187,15 @@ H5FD_mpiposix_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle) H5FD_mpiposix_t *file = (H5FD_mpiposix_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5FD_mpiposix_get_handle, FAIL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_get_handle, FAIL) if(!file_handle) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle not valid") *file_handle = &(file->fd); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1272,7 +1229,7 @@ H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, ssize_t nbytes; /* Number of bytes read each I/O call */ herr_t ret_value=SUCCEED; - FUNC_ENTER_NOAPI(H5FD_mpiposix_read, FAIL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_read, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); @@ -1280,11 +1237,11 @@ H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, /* Check for overflow conditions */ if (HADDR_UNDEF==addr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow"); + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") if (addr+size>file->eoa) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow"); + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") #ifdef REPORT_IO { @@ -1298,7 +1255,7 @@ H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, /* Seek to the correct location */ if ((addr!=file->pos || OP_READ!=file->op) && file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position"); + HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* * Read data, being careful of interrupted system calls, partial results, @@ -1309,11 +1266,11 @@ H5FD_mpiposix_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, nbytes = HDread(file->fd, buf, size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed"); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") if (0==nbytes) { /* end of file but not end of format address space */ HDmemset(buf, 0, size); - size = 0; + break; } /* end if */ assert(nbytes>=0); assert((size_t)nbytes<=size); @@ -1334,7 +1291,7 @@ done: file->op = OP_UNKNOWN; } /* end if */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_read() */ @@ -1372,7 +1329,7 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5FD_mpiposix_write, FAIL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_write, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); @@ -1382,15 +1339,15 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, /* Check for overflow conditions */ if (HADDR_UNDEF==addr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined") if (REGION_OVERFLOW(addr, size)) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow"); + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") if (addr+size>file->eoa) - HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow"); + HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow") /* Obtain the data transfer properties */ if(NULL == (plist = H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") /* Metadata specific actions */ if(type!=H5FD_MEM_DRAW) { @@ -1408,11 +1365,11 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, */ if(H5P_exist_plist(plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME)>0) if(H5P_get(plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME,&block_before_meta_write)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get H5AC property"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get H5AC property") if(block_before_meta_write) if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(file->comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code); + HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) /* Only one process will do the actual write if all procs in comm write same metadata */ if (file->mpi_rank != H5_PAR_META_WRITE) @@ -1448,7 +1405,7 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hint.mar.accRangeArray[0].length = MIN(file->blksize-hint.mar.accRangeArray[0].start, size); hint.mar.accRangeArray[0].isWrite = 1; if (gpfs_fcntl(file->fd, &hint)<0) - HGOTO_ERROR(H5E_FILE, H5E_FCNTL, NULL, "failed to send hints to GPFS"); + HGOTO_ERROR(H5E_FILE, H5E_FCNTL, NULL, "failed to send hints to GPFS") } #endif /* H5_HAVE_GPFS */ } @@ -1456,7 +1413,7 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, /* Seek to the correct location */ if ((addr!=file->pos || OP_WRITE!=file->op) && file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position"); + HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") /* * Write the data, being careful of interrupted system calls and partial @@ -1467,7 +1424,7 @@ H5FD_mpiposix_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, nbytes = HDwrite(file->fd, buf, size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed"); + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") assert(nbytes>0); assert((size_t)nbytes<=size); size -= nbytes; @@ -1488,14 +1445,14 @@ done: } /* end if */ /* Guard against getting into metadata broadcast in failure cases */ else { - /* if only one process writes, need to broadcast the ret_value to other processes */ + /* when only one process writes, need to broadcast the ret_value to other processes */ if (type!=H5FD_MEM_DRAW) { if (MPI_SUCCESS != (mpi_code= MPI_Bcast(&ret_value, sizeof(ret_value), MPI_BYTE, H5_PAR_META_WRITE, file->comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code); + HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code) } /* end if */ } /* end else */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_write() */ @@ -1525,7 +1482,7 @@ H5FD_mpiposix_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing int mpi_code; /* MPI return code */ herr_t ret_value=SUCCEED; - FUNC_ENTER_NOAPI(H5FD_mpiposix_flush, FAIL); + FUNC_ENTER_NOAPI(H5FD_mpiposix_flush, FAIL) assert(file); assert(H5FD_MPIPOSIX==file->pub.driver_id); @@ -1543,10 +1500,10 @@ H5FD_mpiposix_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing li.QuadPart = file->eoa; SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN); if(SetEndOfFile((HANDLE)filehandle)==0) - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly"); + HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #else /* WIN32 */ if(-1==file_truncate(file->fd, (file_offset_t)file->eoa)) - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly"); + HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") #endif /* WIN32 */ } /* end if */ @@ -1557,7 +1514,7 @@ H5FD_mpiposix_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing * the new data written) */ if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(file->comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code); + HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) /* Update the 'last' eoa and eof values */ file->last_eoa=file->eoa; @@ -1569,8 +1526,111 @@ H5FD_mpiposix_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned UNUSED closing } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_mpiposix_flush() */ + +/*------------------------------------------------------------------------- + * Function: H5FD_mpiposix_mpi_rank + * + * Purpose: Returns the MPI rank for a process + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, July 11, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +H5FD_mpiposix_mpi_rank(const H5FD_t *_file) +{ + const H5FD_mpiposix_t *file = (const H5FD_mpiposix_t*)_file; + int ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5FD_mpiposix_mpi_rank, FAIL) + + assert(file); + assert(H5FD_MPIPOSIX==file->pub.driver_id); + + /* Set return value */ + ret_value=file->mpi_rank; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mpiposix_mpi_rank() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mpiposix_mpi_size + * + * Purpose: Returns the number of MPI processes + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Thursday, July 11, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +H5FD_mpiposix_mpi_size(const H5FD_t *_file) +{ + const H5FD_mpiposix_t *file = (const H5FD_mpiposix_t*)_file; + int ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5FD_mpiposix_mpi_size, FAIL) + + assert(file); + assert(H5FD_MPIPOSIX==file->pub.driver_id); + + /* Set return value */ + ret_value=file->mpi_size; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mpiposix_mpi_size() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_mpiposix_communicator + * + * Purpose: Returns the MPI communicator for the file. + * + * Return: Success: The communicator + * + * Failure: NULL + * + * Programmer: Quincey Koziol + * Thursday, July 11, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static MPI_Comm +H5FD_mpiposix_communicator(const H5FD_t *_file) +{ + const H5FD_mpiposix_t *file = (const H5FD_mpiposix_t*)_file; + MPI_Comm ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5FD_mpiposix_communicator, MPI_COMM_NULL) + + assert(file); + assert(H5FD_MPIPOSIX==file->pub.driver_id); + + /* Set return value */ + ret_value=file->comm; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_mpi_posix_communicator() */ + #endif /*H5_HAVE_PARALLEL*/ |