Merge pull request #1873 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:H5Pset_fapl_mpi to develop

* commit 'bd8da502cf5b763433e3c628a4043a4264529cec':
  Some refactoring prior to implementing new H5P MPI functions. * Macro cleanup and obvious warning fixes in parallel code. * Moved H5FD comm and info dup/free wrapper code to a new H5mpi.c file   and separated it to deal with each MPI type separately.
This commit is contained in:
Dana Robinson 2019-08-14 19:34:56 -05:00
commit 6b8d369a0c
10 changed files with 564 additions and 481 deletions

View File

@ -481,6 +481,7 @@
./src/H5err.txt
./src/H5detect.c
./src/H5make_libsettings.c
./src/H5mpi.c
./src/H5overflow.txt
./src/H5private.h
./src/H5public.h

View File

@ -8,6 +8,7 @@ set (H5_SOURCES
${HDF5_SRC_DIR}/H5.c
${HDF5_SRC_DIR}/H5checksum.c
${HDF5_SRC_DIR}/H5dbg.c
${HDF5_SRC_DIR}/H5mpi.c
${HDF5_SRC_DIR}/H5system.c
${HDF5_SRC_DIR}/H5timer.c
${HDF5_SRC_DIR}/H5trace.c

View File

@ -821,9 +821,8 @@ H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr)
{
H5AC_t * cache_ptr;
H5AC_aux_t * aux_ptr;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
FUNC_ENTER_PACKAGE_NOERR
/* Sanity check */
HDassert(entry_ptr);
@ -853,8 +852,7 @@ H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr)
/* Decrement the dirty byte count */
aux_ptr->dirty_bytes -= entry_ptr->size;
done:
FUNC_LEAVE_NOAPI(ret_value)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5AC__log_cleaned_entry() */

View File

@ -267,115 +267,6 @@ H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/)
FUNC_LEAVE_NOAPI(ret_value)
}
/*-------------------------------------------------------------------------
* Function: H5FD_mpi_comm_info_dup
*
* Purpose: Make duplicates of communicator and Info object.
* If the Info object is in fact MPI_INFO_NULL, no duplicate
* is made but the same value assigned to the new Info object
* handle.
*
* Return: Success: Non-negative. The new communicator and Info
* object handles are returned via comm_new and
* info_new pointers.
*
* Failure: Negative.
*
* Programmer: Albert Cheng
* Jan 8, 2003
*
* Modifications:
*-------------------------------------------------------------------------
*/
herr_t
H5FD_mpi_comm_info_dup(MPI_Comm comm, MPI_Info info, MPI_Comm *comm_new, MPI_Info *info_new)
{
herr_t ret_value=SUCCEED;
MPI_Comm comm_dup=MPI_COMM_NULL;
MPI_Info info_dup=MPI_INFO_NULL;
int mpi_code;
FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
if (MPI_COMM_NULL == comm)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "not a valid argument")
if (!comm_new || !info_new)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "bad pointers")
/* Dup them. Using temporary variables for error recovery cleanup. */
if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(comm, &comm_dup)))
HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code)
if (MPI_INFO_NULL != info){
if (MPI_SUCCESS != (mpi_code=MPI_Info_dup(info, &info_dup)))
HMPI_GOTO_ERROR(FAIL, "MPI_Info_dup failed", mpi_code)
}else{
/* No dup, just copy it. */
info_dup = info;
}
/* Set MPI_ERRORS_RETURN on comm_dup so that MPI failures are not fatal,
and return codes can be checked and handled. May 23, 2017 FTW */
if (MPI_SUCCESS != (mpi_code = MPI_Comm_set_errhandler(comm_dup, MPI_ERRORS_RETURN)))
HMPI_GOTO_ERROR(FAIL, "MPI_Errhandler_set failed", mpi_code)
/* copy them to the return arguments */
*comm_new = comm_dup;
*info_new = info_dup;
done:
if (FAIL == ret_value){
/* need to free anything created here */
if (MPI_COMM_NULL != comm_dup)
MPI_Comm_free(&comm_dup);
if (MPI_INFO_NULL != info_dup)
MPI_Info_free(&info_dup);
}
FUNC_LEAVE_NOAPI(ret_value)
}
/*-------------------------------------------------------------------------
* Function: H5FD_mpi_comm_info_free
*
* Purpose: Free the communicator and Info object.
* If comm or info is in fact MPI_COMM_NULL or MPI_INFO_NULL
* respectively, no action occurs to it.
*
* Return: Success: Non-negative. The values the pointers refer
* to will be set to the corresponding NULL
* handles.
*
* Failure: Negative.
*
* Programmer: Albert Cheng
* Jan 8, 2003
*
* Modifications:
*-------------------------------------------------------------------------
*/
herr_t
H5FD_mpi_comm_info_free(MPI_Comm *comm, MPI_Info *info)
{
herr_t ret_value=SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
if (!comm || !info)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "not a valid argument")
if (MPI_COMM_NULL != *comm)
MPI_Comm_free(comm);
if (MPI_INFO_NULL != *info)
MPI_Info_free(info);
done:
FUNC_LEAVE_NOAPI(ret_value)
}
#ifdef NOT_YET
/*-------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -160,9 +160,6 @@ H5_DLL herr_t H5FD_set_paged_aggr(H5FD_t *file, hbool_t paged);
/* General routines */
H5_DLL haddr_t H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off);
H5_DLL herr_t H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/);
H5_DLL herr_t H5FD_mpi_comm_info_dup(MPI_Comm comm, MPI_Info info,
MPI_Comm *comm_new, MPI_Info *info_new);
H5_DLL herr_t H5FD_mpi_comm_info_free(MPI_Comm *comm, MPI_Info *info);
#ifdef NOT_YET
H5_DLL herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *file);
H5_DLL herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *file);

View File

@ -90,14 +90,14 @@ herr_t
H5F_get_mpi_handle(const H5F_t *f, MPI_File **f_handle)
{
herr_t ret_value = SUCCEED;
hid_t fapl = -1;
hid_t fapl_id = H5I_INVALID_HID;
FUNC_ENTER_NOAPI(FAIL)
HDassert(f && f->shared);
/* Dispatch to driver */
if ((ret_value = H5FD_get_vfd_handle(f->shared->lf, fapl, (void **)f_handle)) < 0)
if ((ret_value = H5FD_get_vfd_handle(f->shared->lf, fapl_id, (void **)f_handle)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get mpi file handle")
done:
@ -106,33 +106,31 @@ done:
/*-------------------------------------------------------------------------
* Function: H5F_mpi_get_rank
* Function: H5F_mpi_get_rank
*
* Purpose: Retrieves the rank of an MPI process.
* Purpose: Retrieves the rank of an MPI process.
*
* Return: Success: The rank (non-negative)
* Return: Success: The rank (non-negative)
*
* Failure: Negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Programmer: Quincey Koziol
* Friday, January 30, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
H5F_mpi_get_rank(const H5F_t *f)
{
int ret_value;
int ret_value = -1;
FUNC_ENTER_NOAPI(FAIL)
FUNC_ENTER_NOAPI((-1))
HDassert(f && f->shared);
/* Dispatch to driver */
if ((ret_value=H5FD_mpi_get_rank(f->shared->lf)) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_rank request failed")
if ((ret_value = H5FD_mpi_get_rank(f->shared->lf)) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, (-1), "driver get_rank request failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@ -140,32 +138,30 @@ done:
/*-------------------------------------------------------------------------
* Function: H5F_mpi_get_comm
* Function: H5F_mpi_get_comm
*
* Purpose: Retrieves the file's communicator
* Purpose: Retrieves the file's communicator
*
* Return: Success: The communicator (non-negative)
* Return: Success: The communicator (non-negative)
*
* Failure: Negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Programmer: Quincey Koziol
* Friday, January 30, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
MPI_Comm
H5F_mpi_get_comm(const H5F_t *f)
{
MPI_Comm ret_value;
MPI_Comm ret_value = MPI_COMM_NULL;
FUNC_ENTER_NOAPI(MPI_COMM_NULL)
HDassert(f && f->shared);
/* Dispatch to driver */
if ((ret_value=H5FD_mpi_get_comm(f->shared->lf))==MPI_COMM_NULL)
if ((ret_value = H5FD_mpi_get_comm(f->shared->lf)) == MPI_COMM_NULL)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, MPI_COMM_NULL, "driver get_comm request failed")
done:
@ -185,22 +181,20 @@ done:
* Programmer: John Mainzer
* Friday, May 6, 2005
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
H5F_mpi_get_size(const H5F_t *f)
{
int ret_value;
int ret_value = -1;
FUNC_ENTER_NOAPI(FAIL)
FUNC_ENTER_NOAPI((-1))
HDassert(f && f->shared);
/* Dispatch to driver */
if ((ret_value=H5FD_mpi_get_size(f->shared->lf)) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_size request failed")
if ((ret_value = H5FD_mpi_get_size(f->shared->lf)) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, (-1), "driver get_size request failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@ -208,16 +202,16 @@ done:
/*-------------------------------------------------------------------------
* Function: H5Fset_mpi_atomicity
* Function: H5Fset_mpi_atomicity
*
* Purpose: Sets the atomicity mode
* Purpose: Sets the atomicity mode
*
* Return: Success: Non-negative
* Return: Success: Non-negative
*
* Failure: Negative
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* Feb 14, 2012
* Programmer: Mohamad Chaarawi
* Feb 14, 2012
*
*-------------------------------------------------------------------------
*/
@ -248,16 +242,16 @@ done:
/*-------------------------------------------------------------------------
* Function: H5Fget_mpi_atomicity
* Function: H5Fget_mpi_atomicity
*
* Purpose: Returns the atomicity mode
* Purpose: Returns the atomicity mode
*
* Return: Success: Non-negative
* Return: Success: Non-negative
*
* Failure: Negative
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* Feb 14, 2012
* Programmer: Mohamad Chaarawi
* Feb 14, 2012
*
*-------------------------------------------------------------------------
*/
@ -288,18 +282,18 @@ done:
/*-------------------------------------------------------------------------
* Function: H5F_mpi_retrieve_comm
* Function: H5F_mpi_retrieve_comm
*
* Purpose: Retrieves an MPI communicator from the file the location ID
* Purpose: Retrieves an MPI communicator from the file the location ID
* is in. If the loc_id is invalid, the fapl_id is used to
* retrieve the communicator.
*
* Return: Success: Non-negative
* Return: Success: Non-negative
*
* Failure: Negative
* Failure: Negative
*
* Programmer: Mohamad Chaarawi
* Feb 14, 2012
* Programmer: Mohamad Chaarawi
* Feb 14, 2012
*
*-------------------------------------------------------------------------
*/

198
src/H5mpi.c Normal file
View File

@ -0,0 +1,198 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: Common MPI routines
*
*/
#include "H5private.h" /* Generic Functions */
#include "H5CXprivate.h" /* API Contexts */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* File access */
#include "H5FDprivate.h" /* File drivers */
#include "H5FDmpi.h" /* Common MPI file driver */
#include "H5Pprivate.h" /* Property lists */
#ifdef H5_HAVE_PARALLEL
/*-------------------------------------------------------------------------
* Function: H5_mpi_comm_dup
*
* Purpose: Duplicate an MPI communicator.
*
* The new communicator is returned via the comm_new pointer.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new)
{
herr_t ret_value = SUCCEED;
MPI_Comm comm_dup = MPI_COMM_NULL;
int mpi_code;
FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
if (!comm_new)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "comm_new cannot be NULL")
if (MPI_COMM_NULL == comm)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't duplicate MPI_COMM_NULL")
/* Duplicate the MPI communicator */
if (MPI_SUCCESS != (mpi_code = MPI_Comm_dup(comm, &comm_dup)))
HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code)
/* Set MPI_ERRORS_RETURN on comm_dup so that MPI failures are not fatal,
* and return codes can be checked and handled.
*/
if (MPI_SUCCESS != (mpi_code = MPI_Comm_set_errhandler(comm_dup, MPI_ERRORS_RETURN)))
HMPI_GOTO_ERROR(FAIL, "MPI_Errhandler_set failed", mpi_code)
/* Copy the new communicator to the return argument */
*comm_new = comm_dup;
done:
if (FAIL == ret_value) {
/* need to free anything created here */
if (MPI_COMM_NULL != comm_dup)
MPI_Comm_free(&comm_dup);
}
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5_mpi_comm_dup() */
/*-------------------------------------------------------------------------
* Function: H5_mpi_info_dup
*
* Purpose: Duplicate an MPI info.
*
* If the info object is MPI_INFO_NULL, no duplicate
* is made but the same value assigned to the new info object
* handle.
*
* The new info is returned via the info_new pointer.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new)
{
herr_t ret_value = SUCCEED;
MPI_Info info_dup = MPI_INFO_NULL;
int mpi_code;
FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
if (!info_new)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "info_new cannot be NULL")
/* Duplicate the MPI info */
if (info == MPI_INFO_NULL) {
/* Don't duplicate MPI_INFO_NULL. Just copy it. */
info_dup = info;
}
else {
/* Duplicate the info */
if (MPI_SUCCESS != (mpi_code = MPI_Info_dup(info, &info_dup)))
HMPI_GOTO_ERROR(FAIL, "MPI_Info_dup failed", mpi_code)
}
/* Copy the new info to the return argument */
*info_new = info_dup;
done:
if (FAIL == ret_value) {
/* need to free anything created here */
if (MPI_INFO_NULL != info_dup)
MPI_Info_free(&info_dup);
}
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5_mpi_info_dup() */
/*-------------------------------------------------------------------------
* Function: H5_mpi_comm_free
*
* Purpose: Free an MPI communicator.
*
* If comm is MPI_COMM_NULL this call does nothing.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5_mpi_comm_free(MPI_Comm *comm)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
if (!comm)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "comm pointer cannot be NULL")
/* Free the communicator */
if (MPI_COMM_NULL != *comm)
MPI_Comm_free(comm);
*comm = MPI_COMM_NULL;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* End H5_mpi_comm_free() */
/*-------------------------------------------------------------------------
* Function: H5_mpi_info_free
*
* Purpose: Free the MPI info.
*
* If info is MPI_INFO_NULL this call does nothing.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5_mpi_info_free(MPI_Info *info)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
if (!info)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "info pointer cannot be NULL")
/* Free the info */
if (MPI_INFO_NULL != *info)
MPI_Info_free(info);
*info = MPI_INFO_NULL;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* End H5_mpi_info_free() */
#endif /* H5_HAVE_PARALLEL */

View File

@ -2668,6 +2668,14 @@ H5_DLL double H5_get_time(void);
H5_DLL herr_t H5_build_extpath(const char *name, char **extpath /*out*/);
H5_DLL herr_t H5_combine_path(const char *path1, const char *path2, char **full_name /*out*/);
#ifdef H5_HAVE_PARALLEL
/* Generic MPI functions */
H5_DLL herr_t H5_mpi_comm_dup(MPI_Comm comm, MPI_Comm *comm_new);
H5_DLL herr_t H5_mpi_info_dup(MPI_Info info, MPI_Info *info_new);
H5_DLL herr_t H5_mpi_comm_free(MPI_Comm *comm);
H5_DLL herr_t H5_mpi_info_free(MPI_Info *info);
#endif /* H5_HAVE_PARALLEL */
/* Functions for debugging */
H5_DLL herr_t H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf,
const uint8_t *marker, size_t buf_offset, size_t buf_size);

View File

@ -126,7 +126,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
# Only compile parallel sources if necessary
if BUILD_PARALLEL_CONDITIONAL
libhdf5_la_SOURCES += H5ACmpio.c H5Cmpio.c H5Dmpio.c H5Fmpi.c H5FDmpi.c H5FDmpio.c H5Smpio.c
libhdf5_la_SOURCES += H5mpi.c H5ACmpio.c H5Cmpio.c H5Dmpio.c H5Fmpi.c H5FDmpi.c H5FDmpio.c H5Smpio.c
endif
# Only compile the direct VFD if necessary