summaryrefslogtreecommitdiffstats
path: root/src/H5FDmpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5FDmpi.c')
-rw-r--r--src/H5FDmpi.c224
1 files changed, 101 insertions, 123 deletions
diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c
index b2959a5..7eb1463 100644
--- a/src/H5FDmpi.c
+++ b/src/H5FDmpi.c
@@ -6,31 +6,29 @@
* 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. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Programmer: Quincey Koziol
* Friday, January 30, 2004
*
* Purpose: Common routines for all MPI-based VFL drivers.
*
*/
-
-#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 */
+#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: H5FD_mpi_get_rank
*
@@ -43,33 +41,46 @@
* Programmer: Quincey Koziol
* Friday, January 30, 2004
*
- * Modifications:
+ * Changes: Reworked function to use the ctl callback so we can get
+ * rid of H5FD_class_mpi_t. Since there are no real limits
+ * on what the ctl callback can do, its file parameter can't
+ * be constant. Thus, I had to remove the const qualifier
+ * on this functions file parameter as well. Note also the
+ * circumlocution required to use the ctl callbacks output
+ * parameter to pass back the rank without introducing
+ * compiler warnings.
+ * JRM -- 8/13/21
*
*-------------------------------------------------------------------------
*/
int
-H5FD_mpi_get_rank(const H5FD_t *file)
+H5FD_mpi_get_rank(H5FD_t *file)
{
- const H5FD_class_mpi_t *cls;
-
- int ret_value;
+ const H5FD_class_t *cls;
+ uint64_t flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG | H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG;
+ int rank = -1;
+ void * rank_ptr = (void *)(&rank);
+ int ret_value;
FUNC_ENTER_NOAPI(FAIL)
HDassert(file);
- cls = (const H5FD_class_mpi_t *)(file->cls);
+ cls = (const H5FD_class_t *)(file->cls);
HDassert(cls);
- HDassert(cls->get_rank); /* All MPI drivers must implement this */
+ HDassert(cls->ctl); /* All MPI drivers must implement this */
/* Dispatch to driver */
- if ((ret_value=(cls->get_rank)(file))<0)
+ if ((cls->ctl)(file, H5FD_CTL__GET_MPI_RANK_OPCODE, flags, NULL, &rank_ptr) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_rank request failed")
+ HDassert(rank >= 0);
+
+ ret_value = rank;
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_mpi_get_rank() */
-
/*-------------------------------------------------------------------------
* Function: H5FD_mpi_get_size
*
@@ -82,32 +93,47 @@ done:
* Programmer: Quincey Koziol
* Friday, January 30, 2004
*
- * Modifications:
+ * Changes: Reworked function to use the ctl callback so we can get
+ * rid of H5FD_class_mpi_t. Since there are no real limits
+ * on what the ctl callback can do, its file parameter can't
+ * be constant. Thus, I had to remove the const qualifier
+ * on this functions file parameter as well. Note also the
+ * circumlocution required to use the ctl callbacks output
+ * parameter to pass back the rank without introducing
+ * compiler warnings.
+ * JRM -- 8/13/21
*
*-------------------------------------------------------------------------
*/
int
-H5FD_mpi_get_size(const H5FD_t *file)
+H5FD_mpi_get_size(H5FD_t *file)
{
- const H5FD_class_mpi_t *cls;
- int ret_value;
+ const H5FD_class_t *cls;
+ uint64_t flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG | H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG;
+ int size = 0;
+ void * size_ptr = (void *)(&size);
+ int ret_value;
FUNC_ENTER_NOAPI(FAIL)
HDassert(file);
- cls = (const H5FD_class_mpi_t *)(file->cls);
+ cls = (const H5FD_class_t *)(file->cls);
HDassert(cls);
- HDassert(cls->get_size); /* All MPI drivers must implement this */
+ HDassert(cls->ctl); /* All MPI drivers must implement this */
/* Dispatch to driver */
- if ((ret_value=(cls->get_size)(file))<0)
+ if ((cls->ctl)(file, H5FD_CTL__GET_MPI_SIZE_OPCODE, flags, NULL, &size_ptr) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_size request failed")
+ if (0 >= size)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_size request returned bad value")
+
+ ret_value = size;
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_mpi_get_size() */
-
/*-------------------------------------------------------------------------
* Function: H5FD_mpi_get_comm
*
@@ -120,70 +146,47 @@ done:
* Programmer: Quincey Koziol
* Friday, January 30, 2004
*
- * Modifications:
+ * Changes: Reworked function to use the ctl callback so we can get
+ * rid of H5FD_class_mpi_t. Since there are no real limits
+ * on what the ctl callback can do, its file parameter can't
+ * be constant. Thus, I had to remove the const qualifier
+ * on this functions file parameter as well. Note also the
+ * circumlocution required to use the ctl callbacks output
+ * parameter to pass back the rank without introducing
+ * compiler warnings.
+ * JRM -- 8/13/21
*
*-------------------------------------------------------------------------
*/
MPI_Comm
-H5FD_mpi_get_comm(const H5FD_t *file)
+H5FD_mpi_get_comm(H5FD_t *file)
{
- const H5FD_class_mpi_t *cls;
- MPI_Comm ret_value;
+ const H5FD_class_t *cls;
+ uint64_t flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG | H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG;
+ MPI_Comm comm = MPI_COMM_NULL;
+ void * comm_ptr = (void *)(&comm);
+ MPI_Comm ret_value;
FUNC_ENTER_NOAPI(MPI_COMM_NULL)
HDassert(file);
- cls = (const H5FD_class_mpi_t *)(file->cls);
+ cls = (const H5FD_class_t *)(file->cls);
HDassert(cls);
- HDassert(cls->get_comm); /* All MPI drivers must implement this */
+ HDassert(cls->ctl); /* All MPI drivers must implement this */
/* Dispatch to driver */
- if ((ret_value=(cls->get_comm)(file))==MPI_COMM_NULL)
+ if ((cls->ctl)(file, H5FD_CTL__GET_MPI_COMMUNICATOR_OPCODE, flags, NULL, &comm_ptr) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTGET, MPI_COMM_NULL, "driver get_comm request failed")
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD_mpi_get_comm() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_get_mpi_info
- *
- * Purpose: Retrieves the file's mpi info
- *
- * Return: Success: SUCCEED
- *
- * Failure: FAIL
- *
- * Programmer: John Mainzer
- * 4/4/17
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5FD_get_mpi_info(H5FD_t *file, void** mpi_info)
-{
- const H5FD_class_mpi_t *cls;
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI_NOINIT
-
- HDassert(file);
- cls = (const H5FD_class_mpi_t *)(file->cls);
- HDassert(cls);
- HDassert(cls->get_mpi_info); /* All MPI drivers must implement this */
+ if (comm == MPI_COMM_NULL)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTGET, MPI_COMM_NULL, "driver get_comm request failed -- bad comm")
- /* Dispatch to driver */
- if((ret_value = (cls->get_mpi_info)(file, mpi_info)) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_mpi_info request failed")
+ ret_value = comm;
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD_get_mpi_info() */
+} /* end H5FD_mpi_get_comm() */
-
/*-------------------------------------------------------------------------
* Function: H5FD_mpi_MPIOff_to_haddr
*
@@ -197,31 +200,23 @@ done:
* Programmer: Unknown
* January 30, 1998
*
- * 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.
*-------------------------------------------------------------------------
*/
haddr_t
H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off)
{
- haddr_t ret_value=HADDR_UNDEF;
+ haddr_t ret_value = HADDR_UNDEF;
FUNC_ENTER_NOAPI_NOINIT_NOERR
if (mpi_off != (MPI_Offset)(haddr_t)mpi_off)
- ret_value=HADDR_UNDEF;
+ ret_value = HADDR_UNDEF;
else
- ret_value=(haddr_t)mpi_off;
+ ret_value = (haddr_t)mpi_off;
FUNC_LEAVE_NOAPI(ret_value)
}
-
/*-------------------------------------------------------------------------
* Function: H5FD_mpi_haddr_to_MPIOff
*
@@ -235,22 +230,12 @@ H5FD_mpi_MPIOff_to_haddr(MPI_Offset mpi_off)
* Programmer: Unknown
* January 30, 1998
*
- * 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.
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/)
+H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off /*out*/)
{
- herr_t ret_value=FAIL;
+ herr_t ret_value = FAIL;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -260,15 +245,15 @@ H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/)
*mpi_off = (MPI_Offset)addr;
if (addr != (haddr_t)((MPI_Offset)addr))
- ret_value=FAIL;
+ ret_value = FAIL;
else
- ret_value=SUCCEED;
+ ret_value = SUCCEED;
FUNC_LEAVE_NOAPI(ret_value)
}
#ifdef NOT_YET
-
+
/*-------------------------------------------------------------------------
* Function: H5FD_mpio_wait_for_left_neighbor
*
@@ -290,32 +275,29 @@ H5FD_mpi_haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/)
* 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 */
+ 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(FAIL)
HDassert(file);
- HDassert(H5FD_MPIO==file->pub.driver_id);
+ HDassert(H5FD_MPIO == file->pub.driver_id);
/* Portably initialize MPI status variable */
- HDmemset(&rcvstat,0,sizeof(MPI_Status));
+ HDmemset(&rcvstat, 0, sizeof(MPI_Status));
/* 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 )))
+ 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)
}
@@ -323,7 +305,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
-
/*-------------------------------------------------------------------------
* Function: H5FD_mpio_signal_right_neighbor
*
@@ -345,26 +326,24 @@ done:
* 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 */
+ 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(FAIL)
HDassert(file);
- HDassert(H5FD_MPIO==file->pub.driver_id);
+ HDassert(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)))
+ 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:
@@ -372,4 +351,3 @@ done:
}
#endif /* NOT_YET */
#endif /* H5_HAVE_PARALLEL */
-