diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-10-29 19:32:36 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-10-29 19:32:36 (GMT) |
commit | 90e269d55269a75fdfab2cc55eb7fafe6d07711a (patch) | |
tree | e66df1882d537ba873f8948bea6f366e06a940f5 /src/H5Smpio.c | |
parent | 03bed9f9ef980530fa7590ef201cb214dab2e6f5 (diff) | |
download | hdf5-90e269d55269a75fdfab2cc55eb7fafe6d07711a.zip hdf5-90e269d55269a75fdfab2cc55eb7fafe6d07711a.tar.gz hdf5-90e269d55269a75fdfab2cc55eb7fafe6d07711a.tar.bz2 |
[svn-r7789] Purpose:
Bug fix & code cleanups
Description:
Change our use of MPI derived datatypes to not create datatypes with
"0-sized" lengths, which causes the LANL Q machine to hang.
Also, get rid of "prefer MPI derived datatypes" environment variable since
it has no advantage.
Platforms tested:
FreeBSD 4.9 (sleipnir) w & w/o parallel
h5committest
Diffstat (limited to 'src/H5Smpio.c')
-rw-r--r-- | src/H5Smpio.c | 208 |
1 files changed, 47 insertions, 161 deletions
diff --git a/src/H5Smpio.c b/src/H5Smpio.c index d147977..92974c3 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -40,44 +40,39 @@ static int interface_initialize_g = 0; static herr_t -H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_types, +H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ); static herr_t -H5S_mpio_none_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_types, +H5S_mpio_none_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ); static herr_t -H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_types, +H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ); static herr_t -H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_types, +H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ); static herr_t -H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_types, +H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ); static herr_t H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout, size_t elmt_size, @@ -96,7 +91,6 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout, size_t elmt_size, * *count how many objects of the new_type in selection * (useful if this is the buffer type for xfer) * *extra_offset Number of bytes of offset within dataset - * *use_view 0 if view not needed, 1 if needed * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: rky 980813 @@ -104,27 +98,20 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout, size_t elmt_size, * Modifications: * * Quincey Koziol, June 18, 2002 - * Added 'extra_offset' and 'use_view' parameters - * - * Quincey Koziol, June 19, 2002 - * Added 'prefer_derived_types' flag to choose whether MPI derived types - * should be created or not. + * Added 'extra_offset' parameter * *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_types, +H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ) { hsize_t total_bytes; unsigned u; - int mpi_code; /* MPI return code */ - herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOINIT(H5S_mpio_all_type); @@ -136,33 +123,13 @@ H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_ for (u=0; u<space->extent.u.simple.rank; ++u) total_bytes *= space->extent.u.simple.size[u]; - /* Check if we should prefer creating a derived type */ - if(prefer_derived_types) { - /* fill in the return values */ - H5_CHECK_OVERFLOW(total_bytes, hsize_t, int); - if (MPI_SUCCESS != (mpi_code=MPI_Type_contiguous( (int)total_bytes, MPI_BYTE, new_type ))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code); - if(MPI_SUCCESS != (mpi_code=MPI_Type_commit(new_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code); - *count = 1; - *extra_offset = 0; - *use_view = 1; - *is_derived_type = 1; - } /* end if */ - else { - /* fill in the return values */ - *new_type = MPI_BYTE; - H5_ASSIGN_OVERFLOW(*count, total_bytes, hsize_t, size_t); - *extra_offset = 0; - *use_view = 0; - *is_derived_type = 0; - } /* end else */ + /* fill in the return values */ + *new_type = MPI_BYTE; + H5_ASSIGN_OVERFLOW(*count, total_bytes, hsize_t, size_t); + *extra_offset = 0; + *is_derived_type = 0; -done: -#ifdef H5Smpi_DEBUG - HDfprintf(stdout, "Leave %s total_bytes=%Hu\n", FUNC, total_bytes ); -#endif - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_mpio_all_type() */ @@ -177,7 +144,6 @@ done: * *count how many objects of the new_type in selection * (useful if this is the buffer type for xfer) * *extra_offset Number of bytes of offset within dataset - * *use_view 0 if view not needed, 1 if needed * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: Quincey Koziol, October 29, 2002 @@ -187,45 +153,22 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_none_type( const H5S_t *space, size_t UNUSED elmt_size, hbool_t prefer_derived_types, +H5S_mpio_none_type( const H5S_t UNUSED *space, size_t UNUSED elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ) { - int mpi_code; /* MPI return code */ - herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOINIT(H5S_mpio_none_type); - /* Check args */ - assert(space); - - /* Check if we should prefer creating a derived type */ - if(prefer_derived_types) { - /* fill in the return values */ - if (MPI_SUCCESS != (mpi_code=MPI_Type_contiguous(0, MPI_BYTE, new_type ))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code); - if(MPI_SUCCESS != (mpi_code=MPI_Type_commit(new_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code); - *count = 1; - *extra_offset = 0; - *use_view = 1; - *is_derived_type = 1; - } /* end if */ - else { - /* fill in the return values */ - *new_type = MPI_BYTE; - *count = 0; - *extra_offset = 0; - *use_view = 0; - *is_derived_type = 0; - } /* end else */ + /* fill in the return values */ + *new_type = MPI_BYTE; + *count = 0; + *extra_offset = 0; + *is_derived_type = 0; -done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(SUCCEED); } /* H5S_mpio_none_type() */ @@ -240,7 +183,6 @@ done: * *count how many objects of the new_type in selection * (useful if this is the buffer type for xfer) * *extra_offset Number of bytes of offset within dataset - * *use_view 0 if view not needed, 1 if needed * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: rky 980813 @@ -253,22 +195,17 @@ done: * H5S_MAX_RANK. * * Quincey Koziol, June 18, 2002 - * Added 'extra_offset' and 'use_view' parameters. Also accomodate + * Added 'extra_offset' parameter. Also accomodate * selection offset in MPI type built. * - * Quincey Koziol, June 19, 2002 - * Added 'prefer_derived_types' flag to choose whether MPI derived types - * should be created or not. (Ignored for this routine) - * *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer_derived_types, +H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ) { struct dim { /* less hassle than malloc/free & ilk */ @@ -549,7 +486,6 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer /* fill in the remaining return values */ *count = 1; /* only have to move one of these suckers! */ *extra_offset = 0; - *use_view = 1; *is_derived_type = 1; HGOTO_DONE(SUCCEED); @@ -558,7 +494,6 @@ empty: *new_type = MPI_BYTE; *count = 0; *extra_offset = 0; - *use_view = 1; /* Note that this 'use_view' could go either way, but go with '1' for now */ *is_derived_type = 0; done: @@ -581,26 +516,20 @@ done: * *count how many objects of the new_type in selection * (useful if this is the buffer type for xfer) * *extra_offset Number of bytes of offset within dataset - * *use_view 0 if view not needed, 1 if needed * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: Quincey Koziol, 2002/06/17 * * Modifications: * - * Quincey Koziol, June 19, 2002 - * Added 'prefer_derived_types' flag to choose whether MPI derived types - * should be created or not. - * *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_types, +H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ) { hsize_t total_bytes; /* Number of bytes in selection */ @@ -611,8 +540,6 @@ H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, hbool_t prefer hssize_t offset[H5O_LAYOUT_NDIMS]; /* Offset in selection */ int ndims; /* Number of dimensions of dataset */ int i; /* Local index */ - int mpi_code; /* MPI return code */ - herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOINIT(H5S_mpio_hyper_contig_type); @@ -625,7 +552,7 @@ H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, hbool_t prefer /* Compute the number of bytes in selection */ total_bytes = (hsize_t)elmt_size*nelem; - /* Set up convenient aliased */ + /* Set up convenient alias */ ndims=space->extent.u.simple.rank; /* Initialize row sizes for each dimension */ @@ -643,33 +570,13 @@ H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, hbool_t prefer for(i=0,byte_offset=0; i<ndims; i++) byte_offset+=offset[i]*slab[i]; - /* Check if we should prefer creating a derived type */ - if(prefer_derived_types) { - /* fill in the return values */ - H5_CHECK_OVERFLOW(total_bytes, hsize_t, int); - if (MPI_SUCCESS != (mpi_code=MPI_Type_contiguous( (int)total_bytes, MPI_BYTE, new_type ))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code); - if(MPI_SUCCESS != (mpi_code=MPI_Type_commit(new_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code); - *count = 1; - *extra_offset = byte_offset; - *use_view = 1; - *is_derived_type = 1; - } /* end if */ - else { - /* fill in the return values */ - *new_type = MPI_BYTE; - H5_ASSIGN_OVERFLOW(*count, total_bytes, hsize_t, size_t); - *extra_offset = byte_offset; - *use_view = 0; - *is_derived_type = 0; - } /* end else */ + /* fill in the return values */ + *new_type = MPI_BYTE; + H5_ASSIGN_OVERFLOW(*count, total_bytes, hsize_t, size_t); + *extra_offset = byte_offset; + *is_derived_type = 0; -done: -#ifdef H5Smpi_DEBUG - HDfprintf(stdout, "Leave %s total_bytes=%Hu\n", FUNC, total_bytes ); -#endif - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(SUCCEED); } /* end H5S_mpio_hyper_contig_type() */ @@ -685,7 +592,6 @@ done: * *count how many objects of the new_type in selection * (useful if this is the buffer type for xfer) * *extra_offset Number of bytes of offset within dataset - * *use_view 0 if view not needed, 1 if needed * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: rky 980813 @@ -693,24 +599,18 @@ done: * Modifications: * * Quincey Koziol, June 18, 2002 - * Added 'extra_offset' and 'use_view' parameters - * - * Quincey Koziol, June 19, 2002 - * Added 'prefer_derived_types' flag to choose whether MPI derived types - * should be created or not. + * Added 'extra_offset' parameter * *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_types, +H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, size_t *count, hsize_t *extra_offset, - hbool_t *use_view, hbool_t *is_derived_type ) { - int err; herr_t ret_value = SUCCEED; FUNC_ENTER_NOINIT(H5S_mpio_space_type); @@ -724,14 +624,14 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derive case H5S_SIMPLE: switch(space->select.type) { case H5S_SEL_NONE: - if ( H5S_mpio_none_type( space, elmt_size, prefer_derived_types, - /* out: */ new_type, count, extra_offset, use_view, is_derived_type ) <0) + if ( H5S_mpio_none_type( space, elmt_size, + /* out: */ new_type, count, extra_offset, is_derived_type ) <0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert \"all\" selection to MPI type"); break; case H5S_SEL_ALL: - if ( H5S_mpio_all_type( space, elmt_size, prefer_derived_types, - /* out: */ new_type, count, extra_offset, use_view, is_derived_type ) <0) + if ( H5S_mpio_all_type( space, elmt_size, + /* out: */ new_type, count, extra_offset, is_derived_type ) <0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert \"all\" selection to MPI type"); break; @@ -742,15 +642,15 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derive case H5S_SEL_HYPERSLABS: if((*space->select.is_contiguous)(space)) { - err = H5S_mpio_hyper_contig_type( space, elmt_size, prefer_derived_types, - /* out: */ new_type, count, extra_offset, use_view, is_derived_type ); + if(H5S_mpio_hyper_contig_type( space, elmt_size, + /* out: */ new_type, count, extra_offset, is_derived_type )<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert \"all\" selection to MPI type"); } /* end if */ else { - err = H5S_mpio_hyper_type( space, elmt_size, prefer_derived_types, - /* out: */ new_type, count, extra_offset, use_view, is_derived_type ); + if(H5S_mpio_hyper_type( space, elmt_size, + /* out: */ new_type, count, extra_offset, is_derived_type )<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert \"all\" selection to MPI type"); } /* end else */ - if (err<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert \"all\" selection to MPI type"); break; default: @@ -761,7 +661,7 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derive case H5S_COMPLEX: /* not yet implemented */ - ret_value = FAIL; + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not supported yet"); break; default: @@ -813,12 +713,7 @@ done: * * QAK - 2002/06/18 * Removed 'dc_plist' parameter, since it was not used. Also, switch to - * getting the 'use_view' and 'extra_offset' settings for each selection. - * - * Quincey Koziol, June 19, 2002 - * Use 'prefer_derived_types' flag (from HDF5_MPI_PREFER_DERIVED_TYPES - * environment variable) to choose whether MPI derived types should be - * preferred or not. + * getting the 'extra_offset' setting for each selection. * *------------------------------------------------------------------------- */ @@ -832,12 +727,9 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout, size_t elmt_size, size_t mpi_buf_count, mpi_file_count; /* Number of "objects" to transfer */ hsize_t mpi_buf_offset, mpi_file_offset; /* Offset within dataset where selection (ie. MPI type) begins */ MPI_Datatype mpi_buf_type, mpi_file_type; /* MPI types for buffer (memory) and file */ - hbool_t mbt_use_view=0, /* Whether we need to use a view for the buffer (memory) type */ - mft_use_view=0; /* Whether we need to use a view for the file type */ hbool_t mbt_is_derived=0, /* Whether the buffer (memory) type is derived and needs to be free'd */ mft_is_derived=0; /* Whether the file type is derived and needs to be free'd */ hbool_t plist_is_setup=0; /* Whether the dxpl has been customized */ - hbool_t prefer_derived_types=0;/* Whether to prefer MPI derived types or not */ uint8_t *buf=(uint8_t *)_buf; /* Alias for pointer arithmetic */ int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; /* Return value */ @@ -854,27 +746,21 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout, size_t elmt_size, /* Make certain we have the correct type of property list */ assert(TRUE==H5P_isa_class(dxpl_id,H5P_DATASET_XFER)); - /* Get the preference for MPI derived types */ - /* (Set via the "HDF5_MPI_PREFER_DERIVED_TYPES" environment variable for now) */ - prefer_derived_types= H5S_mpi_prefer_derived_types_g; - /* create the MPI buffer type */ - if (H5S_mpio_space_type( mem_space, elmt_size, prefer_derived_types, + if (H5S_mpio_space_type( mem_space, elmt_size, /* out: */ &mpi_buf_type, &mpi_buf_count, &mpi_buf_offset, - &mbt_use_view, &mbt_is_derived )<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI buf type"); /* create the MPI file type */ - if ( H5S_mpio_space_type( file_space, elmt_size, prefer_derived_types, + if ( H5S_mpio_space_type( file_space, elmt_size, /* out: */ &mpi_file_type, &mpi_file_count, &mpi_file_offset, - &mft_use_view, &mft_is_derived )<0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI file type"); @@ -891,7 +777,7 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout, size_t elmt_size, * Pass buf type, file type to the file driver. Request an MPI type * transfer (instead of an elementary byteblock transfer). */ - if(H5FD_mpio_setup(dxpl_id, mpi_buf_type, mpi_file_type, (unsigned)(mbt_use_view || mft_use_view))<0) + 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; |