summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-06-17 16:38:43 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-06-17 16:38:43 (GMT)
commit15a916df4ba024d944c2e549fdff8165de3e36a3 (patch)
tree1167886df032fb301047fb4cc59766fb87788abc
parent2ae3f6b8669ce5dc19fe7e3d03eeb4728d8c9d1c (diff)
downloadhdf5-15a916df4ba024d944c2e549fdff8165de3e36a3.zip
hdf5-15a916df4ba024d944c2e549fdff8165de3e36a3.tar.gz
hdf5-15a916df4ba024d944c2e549fdff8165de3e36a3.tar.bz2
[svn-r5652] Purpose:
Code cleanup Description: Use dataset transfer property list to hold information about the MPI types for the current transfer, instead of setting pseudo-global variables in the file's struct. Platforms tested: Linux 2.2.x (eirene) w/parallel & IRIX64 6.5 (modi4) w/parallel & FORTRAN
-rw-r--r--src/H5FDmpio.c117
-rw-r--r--src/H5FDmpio.h4
-rw-r--r--src/H5P.c6
-rw-r--r--src/H5Pprivate.h6
-rw-r--r--src/H5Smpio.c15
5 files changed, 112 insertions, 36 deletions
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index 57efa90..2c4a08b 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -56,12 +56,7 @@ typedef struct H5FD_mpio_t {
haddr_t eof; /*end-of-file marker */
haddr_t eoa; /*end-of-address marker */
haddr_t last_eoa; /* Last known end-of-address marker */
- MPI_Datatype btype; /*buffer type for xfers */
- MPI_Datatype ftype; /*file type for xfers */
- int use_types; /*if !0, use btype, ftype, disp.else do
- * simple byteblk xfer
- */
- int old_use_types; /*remember value of use_types */
+ int old_use_types; /*remember value of use_types */
} H5FD_mpio_t;
/* Prototypes */
@@ -153,6 +148,17 @@ hbool_t H5_mpi_1_metawrite_g = FALSE;
#define INTERFACE_INIT H5FD_mpio_init
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)
+/* Definitions for whether to use MPI types property */
+#define H5FD_MPIO_XFER_USE_MPI_TYPES_NAME "H5FD_mpio_use_mpi_type"
+#define H5FD_MPIO_XFER_USE_MPI_TYPES_SIZE 0
+
/*-------------------------------------------------------------------------
* Function: H5FD_mpio_init
@@ -509,12 +515,9 @@ H5FD_mpio_mpi_size(H5FD_t *_file)
* Function: H5FD_mpio_setup
*
* Purpose: Set the buffer type BTYPE, file type FTYPE for a data
- * transfer. Also request a MPI type transfer or an elementary
- * byteblock transfer depending on whether USE_TYPES is non-zero
- * or zero, respectively.
+ * transfer. Also request a MPI type transfer.
*
* Return: Success: 0
- *
* Failure: -1
*
* Programmer: Robb Matzke
@@ -527,22 +530,76 @@ H5FD_mpio_mpi_size(H5FD_t *_file)
* 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(H5FD_t *_file, MPI_Datatype btype, MPI_Datatype ftype,
- hbool_t use_types)
+H5FD_mpio_setup(hid_t dxpl_id, MPI_Datatype btype, MPI_Datatype ftype)
{
- H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
+ H5P_genplist_t *plist; /* Property list pointer */
FUNC_ENTER_NOAPI(H5FD_mpio_setup, FAIL);
- assert(file);
- assert(H5FD_MPIO==file->pub.driver_id);
+ /* Check arguments */
+ if(TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(dxpl_id)))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list");
- file->btype = btype;
- file->ftype = ftype;
- file->use_types = use_types;
+ /* 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)<0)
+ HRETURN_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)<0)
+ HRETURN_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
+
+ /* Set 'use types' flag property */
+ if(H5P_insert(plist,H5FD_MPIO_XFER_USE_MPI_TYPES_NAME,H5FD_MPIO_XFER_USE_MPI_TYPES_SIZE,NULL,NULL,NULL,NULL,NULL,NULL)<0)
+ HRETURN_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
+
+ FUNC_LEAVE(SUCCEED);
+}
+
+
+/*-------------------------------------------------------------------------
+ * 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 */
+
+ FUNC_ENTER_NOAPI(H5FD_mpio_teardown, FAIL);
+
+ /* Check arguments */
+ if(TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(dxpl_id)))
+ HRETURN_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)
+ HRETURN_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)
+ HRETURN_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
+
+ /* Remove 'use types' flag property */
+ if(H5P_remove(dxpl_id,plist,H5FD_MPIO_XFER_USE_MPI_TYPES_NAME)<0)
+ HRETURN_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
FUNC_LEAVE(SUCCEED);
}
@@ -851,8 +908,6 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
file->mpi_rank = mpi_rank;
file->mpi_size = mpi_size;
file->eof = H5FD_mpio_MPIOff_to_haddr(size);
- file->btype = MPI_DATATYPE_NULL;
- file->ftype = MPI_DATATYPE_NULL;
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t']) {
@@ -1186,11 +1241,15 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
* us to test that btype=ftype=MPI_BYTE (or even MPI_TYPE_NULL, which
* could mean "use MPI_BYTE" by convention).
*/
- use_types_this_time = file->use_types;
+ if((use_types_this_time=H5P_exist_plist(plist,H5FD_MPIO_XFER_USE_MPI_TYPES_NAME))<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property");
+
if (use_types_this_time) {
/* prepare for a full-blown xfer using btype, ftype, and disp */
- buf_type = file->btype;
- file_type = file->ftype;
+ 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");
/* When using types, use the address as the displacement for
* MPI_File_set_view and reset the address for the read to zero
@@ -1225,7 +1284,6 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
* this flag to !=0.
*/
file->old_use_types = use_types_this_time;
- file->use_types = 0;
/* Read the data. */
assert(H5FD_MPIO_INDEPENDENT==dx->xfer_mode || H5FD_MPIO_COLLECTIVE==dx->xfer_mode);
@@ -1479,11 +1537,15 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
* us to test that btype=ftype=MPI_BYTE (or even MPI_TYPE_NULL, which
* could mean "use MPI_BYTE" by convention).
*/
- use_types_this_time = file->use_types;
+ if((use_types_this_time=H5P_exist_plist(plist,H5FD_MPIO_XFER_USE_MPI_TYPES_NAME))<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property");
+
if (use_types_this_time) {
/* prepare for a full-blown xfer using btype, ftype, and disp */
- buf_type = file->btype;
- file_type = file->ftype;
+ 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");
/* When using types, use the address as the displacement for
* MPI_File_set_view and reset the address for the read to zero
@@ -1518,7 +1580,6 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
* this flag to !=0.
*/
file->old_use_types = use_types_this_time;
- file->use_types = 0;
/* Only p<round> will do the actual write if all procs in comm write same data */
if ((type!=H5FD_MEM_DRAW) && H5_mpi_1_metawrite_g) {
diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h
index 2810bfb..1997788 100644
--- a/src/H5FDmpio.h
+++ b/src/H5FDmpio.h
@@ -57,8 +57,8 @@ __DLL__ herr_t H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/,
__DLL__ herr_t H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode);
__DLL__ herr_t H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/);
__DLL__ MPI_Comm H5FD_mpio_communicator(H5FD_t *_file);
-__DLL__ herr_t H5FD_mpio_setup(H5FD_t *_file, MPI_Datatype btype, MPI_Datatype ftype,
- hbool_t use_types);
+__DLL__ herr_t H5FD_mpio_setup(hid_t dxpl_id, MPI_Datatype btype, MPI_Datatype ftype);
+__DLL__ herr_t H5FD_mpio_teardown(hid_t dxpl_id);
__DLL__ herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *file);
__DLL__ herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *file);
__DLL__ int H5FD_mpio_mpi_rank(H5FD_t *_file);
diff --git a/src/H5P.c b/src/H5P.c
index 2e53233..5476089 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -5847,7 +5847,7 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static herr_t
+herr_t
H5P_insert(H5P_genplist_t *plist, const char *name, size_t size,
void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy,
@@ -6185,7 +6185,7 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static htri_t
+htri_t
H5P_exist_plist(H5P_genplist_t *plist, const char *name)
{
htri_t ret_value=FAIL; /* return value */
@@ -7851,7 +7851,7 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static herr_t
+herr_t
H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name)
{
H5P_genprop_t *prop; /* Temporary property pointer */
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index c7b555b..083e383 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -33,6 +33,12 @@ __DLL__ hid_t H5P_create_id(H5P_genclass_t *pclass);
__DLL__ hid_t H5P_copy_plist(H5P_genplist_t *old_plist);
__DLL__ herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value);
__DLL__ herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value);
+__DLL__ herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size,
+ void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
+ H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy,
+ H5P_prp_close_func_t prp_close);
+__DLL__ herr_t H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name);
+__DLL__ htri_t H5P_exist_plist(H5P_genplist_t *plist, const char *name);
__DLL__ char *H5P_get_class_name(H5P_genclass_t *pclass);
__DLL__ herr_t H5P_get_nprops_pclass(H5P_genclass_t *pclass, size_t *nprops);
__DLL__ herr_t H5P_register(H5P_genclass_t *pclass, const char *name, size_t size,
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index 5c4377b..3d5e136 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -567,6 +567,7 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout,
MPI_Datatype mpi_buf_type, mpi_file_type;
hbool_t mbt_is_derived=0,
mft_is_derived=0;
+ hbool_t plist_is_setup=0; /* Whether the dxpl has been customized */
#if 0
H5P_genplist_t *plist; /* Property list pointer */
#endif /* 0 */
@@ -646,7 +647,9 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout,
* Pass buf type, file type to the file driver. Request an MPI type
* transfer (instead of an elementary byteblock transfer).
*/
- H5FD_mpio_setup(f->shared->lf, mpi_buf_type, mpi_file_type, 1);
+ if(H5FD_mpio_setup(dxpl_id, mpi_buf_type, mpi_file_type)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI-I/O properties");
+ plist_is_setup=1;
/* transfer the data */
H5_CHECK_OVERFLOW(mpi_buf_count, hsize_t, size_t);
@@ -654,16 +657,22 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout,
if (do_write) {
err = H5FD_write(f->shared->lf, H5FD_MEM_DRAW, dxpl_id, addr, mpi_count, buf);
if (err) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,"MPI write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,"MPI write failed");
}
} else {
err = H5FD_read (f->shared->lf, H5FD_MEM_DRAW, dxpl_id, addr, mpi_count, buf);
if (err) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,"MPI read failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,"MPI read failed");
}
}
done:
+ /* Reset the dxpl settings */
+ if(plist_is_setup) {
+ if(H5FD_mpio_teardown(dxpl_id)<0)
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to reset dxpl values");
+ } /* end if */
+
/* free the MPI buf and file types */
if (mbt_is_derived) {
err = MPI_Type_free( &mpi_buf_type );