summaryrefslogtreecommitdiffstats
path: root/src/H5FDmpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5FDmpio.c')
-rw-r--r--src/H5FDmpio.c835
1 files changed, 247 insertions, 588 deletions
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index 7cf6677..2fb7285 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -19,16 +19,21 @@
* Purpose: This is the MPI-2 I/O driver.
*
*/
-#include "H5private.h" /*library functions */
-#include "H5ACprivate.h" /* Metadata cache */
+
+/* Pablo information */
+/* (Put before include files to avoid problems with inline functions) */
+#define PABLO_MASK H5FD_mpio_mask
+
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dprivate.h" /* Dataset functions */
-#include "H5Eprivate.h" /*error handling */
-#include "H5Fprivate.h" /*files */
-#include "H5FDprivate.h" /*file driver */
-#include "H5FDmpio.h" /* MPI I/O file driver */
-#include "H5Iprivate.h" /*object IDs */
-#include "H5MMprivate.h" /* Memory allocation */
-#include "H5Pprivate.h" /*property lists */
+#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 management */
+#include "H5Pprivate.h" /* Property lists */
#ifdef H5_HAVE_PARALLEL
@@ -57,9 +62,7 @@ typedef struct H5FD_mpio_t {
haddr_t last_eoa; /* Last known end-of-address marker */
} H5FD_mpio_t;
-/* Prototypes */
-static haddr_t H5FD_mpio_MPIOff_to_haddr(MPI_Offset mpi_off);
-static herr_t H5FD_mpio_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/);
+/* Private Prototypes */
/* Callbacks */
static void *H5FD_mpio_fapl_get(H5FD_t *_file);
@@ -78,9 +81,9 @@ static herr_t H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hadd
static herr_t H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
size_t size, const void *buf);
static herr_t H5FD_mpio_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
-static herr_t H5FD_mpio_comm_info_dup(MPI_Comm comm, MPI_Info info,
- MPI_Comm *comm_new, MPI_Info *info_new);
-static herr_t H5FD_mpio_comm_info_free(MPI_Comm *comm, MPI_Info *info);
+static int H5FD_mpio_mpi_rank(const H5FD_t *_file);
+static int H5FD_mpio_mpi_size(const H5FD_t *_file);
+static MPI_Comm H5FD_mpio_communicator(const H5FD_t *_file);
/* MPIO-specific file access properties */
typedef struct H5FD_mpio_fapl_t {
@@ -89,7 +92,8 @@ typedef struct H5FD_mpio_fapl_t {
} H5FD_mpio_fapl_t;
/* The MPIO file driver information */
-static const H5FD_class_t H5FD_mpio_g = {
+static const H5FD_class_mpi_t H5FD_mpio_g = {
+ { /* Start of superclass information */
"mpio", /*name */
HADDR_MAX, /*maxaddr */
H5F_CLOSE_SEMI, /* fc_degree */
@@ -119,6 +123,10 @@ static const H5FD_class_t H5FD_mpio_g = {
NULL, /*lock */
NULL, /*unlock */
H5FD_FLMAP_SINGLE /*fl_map */
+ }, /* End of superclass information */
+ H5FD_mpio_mpi_rank, /*get_rank */
+ H5FD_mpio_mpi_size, /*get_size */
+ H5FD_mpio_communicator /*get_comm */
};
#ifdef H5FDmpio_DEBUG
@@ -142,17 +150,30 @@ static int H5FD_mpio_Debug[256] =
#endif
/* Interface initialization */
-#define PABLO_MASK H5FD_mpio_mask
-#define INTERFACE_INIT H5FD_mpio_init
+#define INTERFACE_INIT H5FD_mpio_init_interface
static int interface_initialize_g = 0;
-/* ======== Temporary, Local data transfer properties ======== */
-/* Definitions for memory MPI type property */
-#define H5FD_MPIO_XFER_MEM_MPI_TYPE_NAME "H5FD_mpio_mem_mpi_type"
-#define H5FD_MPIO_XFER_MEM_MPI_TYPE_SIZE sizeof(MPI_Datatype)
-/* Definitions for file MPI type property */
-#define H5FD_MPIO_XFER_FILE_MPI_TYPE_NAME "H5FD_mpio_file_mpi_type"
-#define H5FD_MPIO_XFER_FILE_MPI_TYPE_SIZE sizeof(MPI_Datatype)
+
+/*--------------------------------------------------------------------------
+NAME
+ H5FD_mpio_init_interface -- Initialize interface-specific information
+USAGE
+ herr_t H5FD_mpio_init_interface()
+
+RETURNS
+ Non-negative on success/Negative on failure
+DESCRIPTION
+ Initializes any interface-specific data or routines. (Just calls
+ H5FD_mpio_init currently).
+
+--------------------------------------------------------------------------*/
+static herr_t
+H5FD_mpio_init_interface(void)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpio_init_interface)
+
+ FUNC_LEAVE_NOAPI(H5FD_mpio_init())
+} /* H5FD_mpio_init_interface() */
/*-------------------------------------------------------------------------
@@ -180,10 +201,10 @@ H5FD_mpio_init(void)
#endif /* H5FDmpio_DEBUG */
hid_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5FD_mpio_init, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_init, FAIL)
if (H5I_VFL!=H5I_get_type(H5FD_MPIO_g))
- H5FD_MPIO_g = H5FDregister(&H5FD_mpio_g);
+ H5FD_MPIO_g = H5FD_register((const H5FD_class_t *)&H5FD_mpio_g,sizeof(H5FD_class_mpi_t));
#ifdef H5FDmpio_DEBUG
if (!H5FD_mpio_Debug_inited)
@@ -205,10 +226,36 @@ H5FD_mpio_init(void)
ret_value=H5FD_MPIO_g;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
+/*---------------------------------------------------------------------------
+ * Function: H5FD_mpio_term
+ *
+ * Purpose: Shut down the VFD
+ *
+ * Return: <none>
+ *
+ * Programmer: Quincey Koziol
+ * Friday, Jan 30, 2004
+ *
+ * Modification:
+ *
+ *---------------------------------------------------------------------------
+ */
+void
+H5FD_mpio_term(void)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpio_term)
+
+ /* Reset VFL ID */
+ H5FD_MPIO_g=0;
+
+ FUNC_LEAVE_NOAPI_VOID
+} /* end H5FD_mpio_term() */
+
+
/*-------------------------------------------------------------------------
* Function: H5Pset_fapl_mpio
*
@@ -275,17 +322,17 @@ H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info)
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value;
- FUNC_ENTER_API(H5Pset_fapl_mpio, FAIL);
+ FUNC_ENTER_API(H5Pset_fapl_mpio, FAIL)
H5TRACE3("e","iMcMi",fapl_id,comm,info);
if(fapl_id==H5P_DEFAULT)
- HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list")
/* 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;
@@ -295,7 +342,7 @@ H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info)
ret_value= H5P_set_driver(plist, H5FD_MPIO, &fa);
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
}
@@ -346,15 +393,15 @@ H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/)
int mpi_code; /* mpi return code */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Pget_fapl_mpio, FAIL);
+ FUNC_ENTER_API(H5Pget_fapl_mpio, FAIL)
H5TRACE3("e","ixx",fapl_id,comm,info);
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_MPIO!=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")
/* Store the duplicated communicator in a temporary variable for error */
/* recovery in case the INFO duplication fails. We cannot attempt to */
@@ -362,13 +409,13 @@ H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/)
/* up freeing whatever *comm holds and that could be invalid. */
if (comm){
if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, &comm_tmp)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code)
}
if (info){
if (MPI_INFO_NULL != fa->info){
if (MPI_SUCCESS != (mpi_code=MPI_Info_dup(fa->info, info)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Info_dup failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_Info_dup failed", mpi_code)
}else{
/* do not dup it */
*info = MPI_INFO_NULL;
@@ -384,7 +431,7 @@ done:
if (comm_tmp != MPI_COMM_NULL)
MPI_Comm_free(&comm_tmp);
}
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
}
@@ -420,27 +467,27 @@ H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode)
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value;
- FUNC_ENTER_API(H5Pset_dxpl_mpio, FAIL);
+ FUNC_ENTER_API(H5Pset_dxpl_mpio, FAIL)
H5TRACE2("e","iDt",dxpl_id,xfer_mode);
if(dxpl_id==H5P_DEFAULT)
- HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list")
/* Check arguments */
if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER)))
- HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl")
if (H5FD_MPIO_INDEPENDENT!=xfer_mode && H5FD_MPIO_COLLECTIVE!=xfer_mode)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incorrect xfer_mode");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incorrect xfer_mode")
/* Set the transfer mode */
if (H5P_set(plist,H5D_XFER_IO_XFER_MODE_NAME,&xfer_mode)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value")
/* Initialize driver-specific properties */
ret_value= H5P_set_driver(plist, H5FD_MPIO, NULL);
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
}
@@ -470,319 +517,21 @@ H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/)
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Pget_dxpl_mpio, FAIL);
+ FUNC_ENTER_API(H5Pget_dxpl_mpio, FAIL)
H5TRACE2("e","ix",dxpl_id,xfer_mode);
if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER)))
- HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl")
if (H5FD_MPIO!=H5P_get_driver(plist))
- HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver")
/* Get the transfer mode */
if (xfer_mode)
if (H5P_get(plist,H5D_XFER_IO_XFER_MODE_NAME,xfer_mode)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to get value");
-
-done:
- FUNC_LEAVE_API(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_communicator
- *
- * Purpose: Returns the MPI communicator for the file.
- *
- * Return: Success: The communicator
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * Monday, August 9, 1999
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-MPI_Comm
-H5FD_mpio_communicator(H5FD_t *_file)
-{
- H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- MPI_Comm ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(H5FD_mpio_communicator, MPI_COMM_NULL);
-
- assert(file);
- assert(H5FD_MPIO==file->pub.driver_id);
-
- /* Set return value */
- ret_value=file->comm;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_mpi_rank
- *
- * Purpose: Returns the MPI rank for a process
- *
- * Return: Success: non-negative
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Thursday, May 16, 2002
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-int
-H5FD_mpio_mpi_rank(H5FD_t *_file)
-{
- H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- int ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(H5FD_mpio_mpi_rank, FAIL);
-
- assert(file);
- assert(H5FD_MPIO==file->pub.driver_id);
-
- /* Set return value */
- ret_value=file->mpi_rank;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5FD_mpio_mpi_rank() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_mpi_size
- *
- * Purpose: Returns the number of MPI processes
- *
- * Return: Success: non-negative
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Thursday, May 16, 2002
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-int
-H5FD_mpio_mpi_size(H5FD_t *_file)
-{
- H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- int ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(H5FD_mpio_mpi_size, FAIL);
-
- assert(file);
- assert(H5FD_MPIO==file->pub.driver_id);
-
- /* Set return value */
- ret_value=file->mpi_size;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5FD_mpio_mpi_size() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_setup
- *
- * Purpose: Set the buffer type BTYPE, file type FTYPE for a data
- * transfer. Also request a MPI type transfer.
- *
- * Return: Success: 0
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Monday, August 9, 1999
- *
- * Modifications:
- *
- * Quincey Koziol - 2002/06/17
- * Removed 'disp' parameter, read & write routines will use
- * the address of the dataset in MPI_File_set_view() calls, as
- * necessary.
- *
- * Quincey Koziol - 2002/06/17
- * Changed to set temporary properties in a dxpl, instead of
- * flags in the file struct, which will make this more threadsafe.
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5FD_mpio_setup(hid_t dxpl_id, MPI_Datatype btype, MPI_Datatype ftype)
-{
- H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5FD_mpio_setup, FAIL);
-
- /* Check arguments */
- if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER)))
- HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list");
-
- /* Set buffer MPI type */
- if(H5P_insert(plist,H5FD_MPIO_XFER_MEM_MPI_TYPE_NAME,H5FD_MPIO_XFER_MEM_MPI_TYPE_SIZE,&btype,NULL,NULL,NULL,NULL,NULL,NULL)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
-
- /* Set file MPI type */
- if(H5P_insert(plist,H5FD_MPIO_XFER_FILE_MPI_TYPE_NAME,H5FD_MPIO_XFER_FILE_MPI_TYPE_SIZE,&ftype,NULL,NULL,NULL,NULL,NULL,NULL)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_teardown
- *
- * Purpose: Remove the temporary MPI-I/O properties from dxpl.
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Monday, June 17, 2002
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5FD_mpio_teardown(hid_t dxpl_id)
-{
- H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5FD_mpio_teardown, FAIL);
-
- /* Check arguments */
- if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER)))
- HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list");
-
- /* Remove buffer MPI type */
- if(H5P_remove(dxpl_id,plist,H5FD_MPIO_XFER_MEM_MPI_TYPE_NAME)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
-
- /* Remove file MPI type */
- if(H5P_remove(dxpl_id,plist,H5FD_MPIO_XFER_FILE_MPI_TYPE_NAME)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_wait_for_left_neighbor
- *
- * Purpose: Blocks until (empty) msg is received from immediately
- * lower-rank neighbor. In conjunction with
- * H5FD_mpio_signal_right_neighbor, useful for enforcing
- * 1-process-at-at-time access to critical regions to avoid race
- * conditions (though it is overkill to require that the
- * processes be allowed to proceed strictly in order of their
- * rank).
- *
- * Note: This routine doesn't read or write any file, just performs
- * interprocess coordination. It really should reside in a
- * separate package of such routines.
- *
- * Return: Success: 0
- * Failure: -1
- *
- * Programmer: rky
- * 19981207
- *
- * Modifications:
- * Robb Matzke, 1999-08-09
- * Modified to work with the virtual file layer.
- *-------------------------------------------------------------------------
- */
-herr_t
-H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file)
-{
- H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- char msgbuf[1];
- MPI_Status rcvstat;
- int mpi_code; /* mpi return code */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5FD_mpio_wait_for_left_neighbor, FAIL);
-
- assert(file);
- assert(H5FD_MPIO==file->pub.driver_id);
-
- /* Portably initialize MPI status variable */
- HDmemset(&rcvstat,0,sizeof(MPI_Status));
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to get value")
- /* p0 has no left neighbor; all other procs wait for msg */
- if (file->mpi_rank != 0) {
- if (MPI_SUCCESS != (mpi_code=MPI_Recv( &msgbuf, 1, MPI_CHAR,
- file->mpi_rank-1, MPI_ANY_TAG, file->comm, &rcvstat )))
- HMPI_GOTO_ERROR(FAIL, "MPI_Recv failed", mpi_code);
- }
-
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_signal_right_neighbor
- *
- * Purpose: Blocks until (empty) msg is received from immediately
- * lower-rank neighbor. In conjunction with
- * H5FD_mpio_wait_for_left_neighbor, useful for enforcing
- * 1-process-at-at-time access to critical regions to avoid race
- * conditions (though it is overkill to require that the
- * processes be allowed to proceed strictly in order of their
- * rank).
- *
- * Note: This routine doesn't read or write any file, just performs
- * interprocess coordination. It really should reside in a
- * separate package of such routines.
- *
- * Return: Success: 0
- * Failure: -1
- *
- * Programmer: rky
- * 19981207
- *
- * Modifications:
- * Robb Matzke, 1999-08-09
- * Modified to work with the virtual file layer.
- *-------------------------------------------------------------------------
- */
-herr_t
-H5FD_mpio_signal_right_neighbor(H5FD_t *_file)
-{
- H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- char msgbuf[1];
- int mpi_code; /* mpi return code */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5FD_mpio_signal_right_neighbor, FAIL);
-
- assert(file);
- assert(H5FD_MPIO==file->pub.driver_id);
-
- if (file->mpi_rank != (file->mpi_size-1)) {
- if (MPI_SUCCESS != (mpi_code=MPI_Send(&msgbuf, 0/*empty msg*/, MPI_CHAR,
- file->mpi_rank+1, 0, file->comm)))
- HMPI_GOTO_ERROR(FAIL, "MPI_Send failed", mpi_code);
- }
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_API(ret_value)
}
@@ -813,25 +562,24 @@ H5FD_mpio_fapl_get(H5FD_t *_file)
H5FD_mpio_fapl_t *fa = NULL;
void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5FD_mpio_fapl_get, NULL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_fapl_get, NULL)
assert(file);
assert(H5FD_MPIO==file->pub.driver_id);
if (NULL==(fa=H5MM_calloc(sizeof(H5FD_mpio_fapl_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Duplicate communicator and Info object. */
- if (FAIL==H5FD_mpio_comm_info_dup(file->comm, file->info,
+ if (FAIL==H5FD_mpi_comm_info_dup(file->comm, file->info,
&fa->comm, &fa->info))
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL,
- "Communicator/Info duplicate failed");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed")
/* Set return value */
ret_value=fa;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -858,23 +606,22 @@ H5FD_mpio_fapl_copy(const void *_old_fa)
const H5FD_mpio_fapl_t *old_fa = (const H5FD_mpio_fapl_t*)_old_fa;
H5FD_mpio_fapl_t *new_fa = NULL;
- FUNC_ENTER_NOAPI(H5FD_mpio_fapl_copy, NULL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_fapl_copy, NULL)
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stderr, "enter H5FD_mpio_fapl_copy\n");
#endif
if (NULL==(new_fa=H5MM_malloc(sizeof(H5FD_mpio_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_mpio_fapl_t));
/* Duplicate communicator and Info object. */
- if (FAIL==H5FD_mpio_comm_info_dup(old_fa->comm, old_fa->info,
+ if (FAIL==H5FD_mpi_comm_info_dup(old_fa->comm, old_fa->info,
&new_fa->comm, &new_fa->info))
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL,
- "Communicator/Info duplicate failed");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed")
ret_value = new_fa;
done:
@@ -888,7 +635,7 @@ done:
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stderr, "leaving H5FD_mpio_fapl_copy\n");
#endif
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_mpio_fapl_copy() */
@@ -914,7 +661,7 @@ H5FD_mpio_fapl_free(void *_fa)
herr_t ret_value = SUCCEED;
H5FD_mpio_fapl_t *fa = (H5FD_mpio_fapl_t*)_fa;
- FUNC_ENTER_NOAPI(H5FD_mpio_fapl_free, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_fapl_free, FAIL)
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stderr, "in H5FD_mpio_fapl_free\n");
@@ -923,7 +670,7 @@ fprintf(stderr, "in H5FD_mpio_fapl_free\n");
/* Free the internal communicator and INFO object */
assert(MPI_COMM_NULL!=fa->comm);
- H5FD_mpio_comm_info_free(&fa->comm, &fa->info);
+ H5FD_mpi_comm_info_free(&fa->comm, &fa->info);
H5MM_xfree(fa);
done:
@@ -931,7 +678,7 @@ done:
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stderr, "leaving H5FD_mpio_fapl_free\n");
#endif
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_mpio_fapl_free() */
@@ -999,7 +746,7 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
MPI_Info info_dup=MPI_INFO_NULL;
H5FD_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5FD_mpio_open, NULL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_open, NULL)
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t']) {
@@ -1010,7 +757,7 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
/* Obtain a pointer to mpio-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_MPIO!=H5P_get_driver(plist)) {
_fa.comm = MPI_COMM_SELF; /*default*/
_fa.info = MPI_INFO_NULL; /*default*/
@@ -1021,9 +768,8 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
}
/* Duplicate communicator and Info object for use by this file. */
- if (FAIL==H5FD_mpio_comm_info_dup(fa->comm, fa->info, &comm_dup, &info_dup))
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL,
- "Communicator/Info duplicate failed");
+ if (FAIL==H5FD_mpi_comm_info_dup(fa->comm, fa->info, &comm_dup, &info_dup))
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed")
/* convert HDF5 flags to MPI-IO flags */
/* some combinations are illegal; let MPI-IO figure it out */
@@ -1037,7 +783,8 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
char debug_str[128];
int flag, i;
if (MPI_INFO_NULL != info_dup) {
- MPI_Info_get(fa->info, H5F_MPIO_DEBUG_KEY, 127, debug_str, &flag);
+ /*OKAY: CAST DISCARDS CONST*/
+ MPI_Info_get(fa->info, (char *)H5F_MPIO_DEBUG_KEY, 127, debug_str, &flag);
if (flag) {
fprintf(stdout, "H5FD_mpio debug flags=%s\n", debug_str );
for (i=0;
@@ -1052,18 +799,18 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
/*OKAY: CAST DISCARDS CONST*/
if (MPI_SUCCESS != (mpi_code=MPI_File_open(comm_dup, (char*)name, mpi_amode, info_dup, &fh)))
- HMPI_GOTO_ERROR(NULL, "MPI_File_open failed", mpi_code);
+ HMPI_GOTO_ERROR(NULL, "MPI_File_open failed", mpi_code)
file_opened=1;
/* 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 return value and initialize it */
if (NULL==(file=H5MM_calloc(sizeof(H5FD_mpio_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
file->f = fh;
file->comm = comm_dup;
file->info = info_dup;
@@ -1077,7 +824,7 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
HMPI_GOTO_ERROR(NULL, "MPI_File_get_size failed", mpi_code)
} /* end if */
- /* Broadcast file-size */
+ /* Broadcast file size */
if (MPI_SUCCESS != (mpi_code=MPI_Bcast(&size, sizeof(MPI_Offset), MPI_BYTE, 0, comm_dup)))
HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code)
@@ -1095,7 +842,7 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
} /* end if */
/* Set the size of the file (from library's perspective) */
- file->eof = H5FD_mpio_MPIOff_to_haddr(size);
+ file->eof = H5FD_mpi_MPIOff_to_haddr(size);
/* Set return value */
ret_value=(H5FD_t*)file;
@@ -1116,7 +863,7 @@ done:
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "Leaving H5FD_mpio_open\n" );
#endif
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1150,7 +897,7 @@ H5FD_mpio_close(H5FD_t *_file)
int mpi_code; /* MPI return code */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5FD_mpio_close, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_close, FAIL)
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
@@ -1161,10 +908,10 @@ H5FD_mpio_close(H5FD_t *_file)
/* MPI_File_close sets argument to MPI_FILE_NULL */
if (MPI_SUCCESS != (mpi_code=MPI_File_close(&(file->f)/*in,out*/)))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_close failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_close failed", mpi_code)
/* Clean up other stuff */
- H5FD_mpio_comm_info_free(&file->comm, &file->info);
+ H5FD_mpi_comm_info_free(&file->comm, &file->info);
H5MM_xfree(file);
done:
@@ -1172,7 +919,7 @@ done:
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "Leaving H5FD_mpio_close\n");
#endif
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1198,7 +945,7 @@ H5FD_mpio_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */)
{
herr_t ret_value=SUCCEED;
- FUNC_ENTER_NOAPI(H5FD_mpio_query, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_query, FAIL)
/* Set the VFL feature flags that this driver supports */
if(flags) {
@@ -1217,7 +964,7 @@ H5FD_mpio_query(const H5FD_t UNUSED *_file, unsigned long *flags /* out */)
} /* end if */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1245,7 +992,7 @@ H5FD_mpio_get_eoa(H5FD_t *_file)
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
haddr_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5FD_mpio_get_eoa, HADDR_UNDEF);
+ FUNC_ENTER_NOAPI(H5FD_mpio_get_eoa, HADDR_UNDEF)
assert(file);
assert(H5FD_MPIO==file->pub.driver_id);
@@ -1254,7 +1001,7 @@ H5FD_mpio_get_eoa(H5FD_t *_file)
ret_value=file->eoa;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1282,7 +1029,7 @@ H5FD_mpio_set_eoa(H5FD_t *_file, haddr_t addr)
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5FD_mpio_set_eoa, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_set_eoa, FAIL)
assert(file);
assert(H5FD_MPIO==file->pub.driver_id);
@@ -1290,7 +1037,7 @@ H5FD_mpio_set_eoa(H5FD_t *_file, haddr_t addr)
file->eoa = addr;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1308,6 +1055,10 @@ done:
* to HADDR_UNDEF which is the error return value of this
* function.
*
+ * Keeping the EOF updated (during write calls) is expensive
+ * because any process may extend the physical end of the
+ * file. -QAK
+ *
* Return: Success: The end-of-address marker.
*
* Failure: HADDR_UNDEF
@@ -1325,7 +1076,7 @@ H5FD_mpio_get_eof(H5FD_t *_file)
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
haddr_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5FD_mpio_get_eof, HADDR_UNDEF);
+ FUNC_ENTER_NOAPI(H5FD_mpio_get_eof, HADDR_UNDEF)
assert(file);
assert(H5FD_MPIO==file->pub.driver_id);
@@ -1334,7 +1085,7 @@ H5FD_mpio_get_eof(H5FD_t *_file)
ret_value=file->eof;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1358,15 +1109,15 @@ H5FD_mpio_get_handle(H5FD_t *_file, hid_t UNUSED fapl, void** file_handle)
H5FD_mpio_t *file = (H5FD_mpio_t *)_file;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5FD_mpio_get_handle, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_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->f);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1455,7 +1206,7 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
unsigned use_view_this_time=0;
herr_t ret_value=SUCCEED;
- FUNC_ENTER_NOAPI(H5FD_mpio_read, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_read, FAIL)
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
@@ -1472,11 +1223,11 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
HDmemset(&mpi_stat,0,sizeof(MPI_Status));
/* some numeric conversions */
- if (H5FD_mpio_haddr_to_MPIOff(addr, &mpi_off/*out*/)<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off");
+ if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off/*out*/)<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off")
size_i = (int)size;
if ((hsize_t)size_i != size)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i")
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'r'])
@@ -1491,7 +1242,7 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
/* 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")
xfer_mode=(H5FD_mpio_xfer_t)H5P_peek_unsigned(plist, H5D_XFER_IO_XFER_MODE_NAME);
/*
@@ -1507,16 +1258,16 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
use_view_this_time=TRUE;
/* prepare for a full-blown xfer using btype, ftype, and disp */
- if(H5P_get(plist,H5FD_MPIO_XFER_MEM_MPI_TYPE_NAME,&buf_type)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property");
- if(H5P_get(plist,H5FD_MPIO_XFER_FILE_MPI_TYPE_NAME,&file_type)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property");
+ if(H5P_get(plist,H5FD_MPI_XFER_MEM_MPI_TYPE_NAME,&buf_type)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property")
+ if(H5P_get(plist,H5FD_MPI_XFER_FILE_MPI_TYPE_NAME,&file_type)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property")
/*
* Set the file view when we are using MPI derived types
*/
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
- if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, (char*)"native", file->info)))
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info)))
HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code)
/* When using types, use the address as the displacement for
@@ -1533,22 +1284,24 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
fprintf(stdout, "H5FD_mpio_read: using MPIO collective mode\n");
#endif
if (MPI_SUCCESS!= (mpi_code=MPI_File_read_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat )))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at_all failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at_all failed", mpi_code)
/*
* Reset the file view when we used MPI derived types
*/
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
- if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, (char*)"native", file->info)))
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info)))
HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code)
} else {
if (MPI_SUCCESS!= (mpi_code=MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat)))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code)
}
/* How many bytes were actually read? */
/* [This works because the "basic elements" we use for all our MPI derived
- * types are MPI_BYTE - QAK]
+ * types are MPI_BYTE. We should be using the 'buf_type' for the MPI
+ * datatype in this call though... (We aren't because using it causes
+ * the LANL "qsc" machine to dump core - 12/19/03) - QAK]
*/
if (MPI_SUCCESS != (mpi_code=MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_read)))
HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code)
@@ -1576,7 +1329,7 @@ done:
fprintf(stdout, "Leaving H5FD_mpio_read\n" );
#endif
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1717,7 +1470,7 @@ H5FD_mpio_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;
- FUNC_ENTER_NOAPI(H5FD_mpio_write, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_write, FAIL)
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
@@ -1734,11 +1487,11 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
HDmemset(&mpi_stat,0,sizeof(MPI_Status));
/* some numeric conversions */
- if (H5FD_mpio_haddr_to_MPIOff(addr, &mpi_off)<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off");
+ if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off)<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off")
size_i = (int)size;
if ((hsize_t)size_i != size)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i")
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'w'])
@@ -1748,7 +1501,7 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
/* 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")
if(type==H5FD_MEM_DRAW) {
H5FD_mpio_xfer_t xfer_mode; /* I/O tranfer mode */
@@ -1769,16 +1522,16 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
use_view_this_time=TRUE;
/* prepare for a full-blown xfer using btype, ftype, and disp */
- if(H5P_get(plist,H5FD_MPIO_XFER_MEM_MPI_TYPE_NAME,&buf_type)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property");
- if(H5P_get(plist,H5FD_MPIO_XFER_FILE_MPI_TYPE_NAME,&file_type)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property");
+ if(H5P_get(plist,H5FD_MPI_XFER_MEM_MPI_TYPE_NAME,&buf_type)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property")
+ if(H5P_get(plist,H5FD_MPI_XFER_FILE_MPI_TYPE_NAME,&file_type)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property")
/*
* Set the file view when we are using MPI derived types
*/
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
- if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, (char*)"native", file->info)))
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info)))
HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code)
/* When using types, use the address as the displacement for
@@ -1802,11 +1555,11 @@ H5FD_mpio_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) {
@@ -1818,7 +1571,7 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
}
#endif
HGOTO_DONE(SUCCEED) /* skip the actual write */
- }
+ } /* end if */
} /* end if */
/* Write the data. */
@@ -1829,23 +1582,25 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
#endif
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
if (MPI_SUCCESS != (mpi_code=MPI_File_write_at_all(file->f, mpi_off, (void*)buf, size_i, buf_type, &mpi_stat)))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mpi_code)
/*
* Reset the file view when we used MPI derived types
*/
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
- if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, (char*)"native", file->info)))
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, H5FD_mpi_native_g, file->info)))
HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code)
} else {
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
if (MPI_SUCCESS != (mpi_code=MPI_File_write_at(file->f, mpi_off, (void*)buf, size_i, buf_type, &mpi_stat)))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code)
}
/* How many bytes were actually written? */
/* [This works because the "basic elements" we use for all our MPI derived
- * types are MPI_BYTE - QAK]
+ * types are MPI_BYTE. We should be using the 'buf_type' for the MPI
+ * datatype in this call though... (We aren't because using it causes
+ * the LANL "qsc" machine to dump core - 12/19/03) - QAK]
*/
if (MPI_SUCCESS != (mpi_code=MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_written)))
HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code)
@@ -1876,7 +1631,7 @@ done:
fprintf(stdout, "proc %d: Leaving H5FD_mpio_write with ret_value=%d\n",
file->mpi_rank, ret_value );
#endif
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1917,7 +1672,7 @@ H5FD_mpio_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned closing)
MPI_Offset mpi_off;
herr_t ret_value=SUCCEED;
- FUNC_ENTER_NOAPI(H5FD_mpio_flush, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_flush, FAIL)
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
@@ -1932,12 +1687,12 @@ H5FD_mpio_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned closing)
* Therefore we'll just read the byte at EOA-1 and then write it back. */
if(file->eoa>file->last_eoa) {
#ifdef H5_MPI_FILE_SET_SIZE_BIG
- if (H5FD_mpio_haddr_to_MPIOff(file->eoa, &mpi_off)<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset");
+ if (H5FD_mpi_haddr_to_MPIOff(file->eoa, &mpi_off)<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset")
/* Extend the file's size */
if (MPI_SUCCESS != (mpi_code=MPI_File_set_size(file->f, mpi_off)))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code)
#else /* H5_MPI_FILE_SET_SIZE_BIG */
if (0==file->mpi_rank) {
uint8_t byte=0;
@@ -1946,12 +1701,12 @@ H5FD_mpio_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned closing)
/* Portably initialize MPI status variable */
HDmemset(&mpi_stat,0,sizeof(MPI_Status));
- if (H5FD_mpio_haddr_to_MPIOff(file->eoa-1, &mpi_off)<0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset");
+ if (H5FD_mpi_haddr_to_MPIOff(file->eoa-1, &mpi_off)<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset")
if (MPI_SUCCESS != (mpi_code=MPI_File_read_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat)))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code)
if (MPI_SUCCESS != (mpi_code=MPI_File_write_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat)))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code)
} /* end if */
#endif /* H5_MPI_FILE_SET_SIZE_BIG */
@@ -1962,7 +1717,7 @@ H5FD_mpio_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned 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 value */
file->last_eoa=file->eoa;
@@ -1971,7 +1726,7 @@ H5FD_mpio_flush(H5FD_t *_file, hid_t UNUSED dxpl_id, unsigned closing)
/* Only sync the file if we are not going to immediately close it */
if(!closing) {
if (MPI_SUCCESS != (mpi_code=MPI_File_sync(file->f)))
- HMPI_GOTO_ERROR(FAIL, "MPI_File_sync failed", mpi_code);
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_sync failed", mpi_code)
} /* end if */
done:
@@ -1980,206 +1735,110 @@ done:
fprintf(stdout, "Leaving H5FD_mpio_flush\n" );
#endif
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_MPIOff_to_haddr
+ * Function: H5FD_mpio_mpi_rank
*
- * Purpose: Convert an MPI_Offset value to haddr_t.
+ * Purpose: Returns the MPI rank for a process
*
- * Return: Success: The haddr_t equivalent of the MPI_OFF
- * argument.
- *
- * Failure: HADDR_UNDEF
+ * Return: Success: non-negative
+ * Failure: negative
*
- * Programmer: Unknown
- * January 30, 1998
+ * Programmer: Quincey Koziol
+ * Thursday, May 16, 2002
*
* Modifications:
- * Robb Matzke, 1999-04-23
- * An error is reported for address overflows. The ADDR output
- * argument is optional.
*
- * Robb Matzke, 1999-08-06
- * Modified to work with the virtual file layer.
- *-------------------------------------------------------------------------
+ *-------------------------------------------------------------------------
*/
-static haddr_t
-H5FD_mpio_MPIOff_to_haddr(MPI_Offset mpi_off)
+static int
+H5FD_mpio_mpi_rank(const H5FD_t *_file)
{
- haddr_t ret_value=HADDR_UNDEF;
+ const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file;
+ int ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpio_MPIOff_to_haddr);
+ FUNC_ENTER_NOAPI(H5FD_mpio_mpi_rank, FAIL)
- if (mpi_off != (MPI_Offset)(haddr_t)mpi_off)
- ret_value=HADDR_UNDEF;
- else
- ret_value=(haddr_t)mpi_off;
+ assert(file);
+ assert(H5FD_MPIO==file->pub.driver_id);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ /* Set return value */
+ ret_value=file->mpi_rank;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_mpio_mpi_rank() */
/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_haddr_to_MPIOff
- *
- * Purpose: Convert an haddr_t value to MPI_Offset.
+ * Function: H5FD_mpio_mpi_size
*
- * Return: Success: Non-negative, the MPI_OFF argument contains
- * the converted value.
+ * Purpose: Returns the number of MPI processes
*
- * Failure: Negative, MPI_OFF is undefined.
+ * Return: Success: non-negative
+ * Failure: negative
*
- * Programmer: Unknown
- * January 30, 1998
+ * Programmer: Quincey Koziol
+ * Thursday, May 16, 2002
*
* Modifications:
- * Robb Matzke, 1999-04-23
- * An error is reported for address overflows. The ADDR output
- * argument is optional.
*
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *
- * Robb Matzke, 1999-08-06
- * Modified to work with the virtual file layer.
*-------------------------------------------------------------------------
*/
-static herr_t
-H5FD_mpio_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/)
+static int
+H5FD_mpio_mpi_size(const H5FD_t *_file)
{
- herr_t ret_value=FAIL;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FD_mpio_haddr_to_MPIOff);
-
- if (mpi_off)
- *mpi_off = (MPI_Offset)addr;
- if (addr != (haddr_t)(MPI_Offset)addr)
- ret_value=FAIL;
- else
- ret_value=SUCCEED;
-
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file;
+ int ret_value; /* Return value */
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_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:
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD_mpio_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(H5FD_mpio_comm_info_dup, FAIL);
+ FUNC_ENTER_NOAPI(H5FD_mpio_mpi_size, FAIL)
-#ifdef H5FDmpio_DEBUG
-if (H5FD_mpio_Debug[(int)'t'])
-fprintf(stderr, "In H5FD_mpio_comm_info_dup: argument comm/info = %d/%ld\n", comm, (long)info);
-#endif
- /* 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;
- }
+ assert(file);
+ assert(H5FD_MPIO==file->pub.driver_id);
- /* copy them to the return arguments */
- *comm_new = comm_dup;
- *info_new = info_dup;
+ /* Set return value */
+ ret_value=file->mpi_size;
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);
- }
-
-#ifdef H5FDmpio_DEBUG
-if (H5FD_mpio_Debug[(int)'t'])
-fprintf(stderr, "Leaving H5FD_mpio_comm_info_dup\n");
-#endif
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_mpio_mpi_size() */
/*-------------------------------------------------------------------------
- * Function: H5FD_mpio_comm_info_free
+ * Function: H5FD_mpio_communicator
*
- * 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.
+ * Purpose: Returns the MPI communicator for the file.
*
- * Return: Success: Non-negative. The values the pointers refer
- * to will be set to the corresponding NULL
- * handles.
+ * Return: Success: The communicator
*
- * Failure: Negative.
+ * Failure: NULL
*
- * Programmer: Albert Cheng
- * Jan 8, 2003
+ * Programmer: Robb Matzke
+ * Monday, August 9, 1999
*
* Modifications:
+ *
*-------------------------------------------------------------------------
*/
-static herr_t
-H5FD_mpio_comm_info_free(MPI_Comm *comm, MPI_Info *info)
+static MPI_Comm
+H5FD_mpio_communicator(const H5FD_t *_file)
{
- herr_t ret_value=SUCCEED;
- FUNC_ENTER_NOAPI(H5FD_mpio_comm_info_free, FAIL);
+ const H5FD_mpio_t *file = (const H5FD_mpio_t*)_file;
+ MPI_Comm ret_value; /* Return value */
-#ifdef H5FDmpio_DEBUG
-if (H5FD_mpio_Debug[(int)'t'])
-fprintf(stderr, "in H5FD_mpio_comm_info_free\n");
-#endif
- /* Check arguments */
- if (!comm || !info)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "not a valid argument");
+ FUNC_ENTER_NOAPI(H5FD_mpio_communicator, MPI_COMM_NULL)
- if (MPI_COMM_NULL != *comm)
- MPI_Comm_free(comm);
- if (MPI_INFO_NULL != *info)
- MPI_Info_free(info);
+ assert(file);
+ assert(H5FD_MPIO==file->pub.driver_id);
+
+ /* Set return value */
+ ret_value=file->comm;
done:
-#ifdef H5FDmpio_DEBUG
-if (H5FD_mpio_Debug[(int)'t'])
-fprintf(stderr, "Leaving H5FD_mpio_comm_info_free\n");
-#endif
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
+
#endif /* H5_HAVE_PARALLEL */