diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-05-10 17:11:06 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-05-10 17:11:06 (GMT) |
commit | 9815305745d7317d7bd6cee494a42bc2a62001c6 (patch) | |
tree | 313372cb935ed20093a2fbc7405a9ebffa1ae9bc /src | |
parent | dabf67548199453f923ea751d7978e7382377ef9 (diff) | |
download | hdf5-9815305745d7317d7bd6cee494a42bc2a62001c6.zip hdf5-9815305745d7317d7bd6cee494a42bc2a62001c6.tar.gz hdf5-9815305745d7317d7bd6cee494a42bc2a62001c6.tar.bz2 |
[svn-r5390] Purpose:
Code cleanup
Description:
The parallel I/O file driver is optimized to only write metadata with one
process (and broadcast the results to the other processes). This is
currently enabled by a separate call to H5FD_mpio_tas_allsame() before
each metadata write to the file. This can easily lead to problems where
the prelude function call is omitted before the actual write code or, in
a threaded environment, lead to race condititions where the value set is
reset before being used.
Solution:
Since we only want to write metadata from one process, key off of the 'type'
parameter (which has information about whether the data being written it
metadata or raw data) to H5FD_mpio_write() as the method for determining
whether to only write from one process or not.
Platforms tested:
IRIX64 6.5 (modi4)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B.c | 6 | ||||
-rw-r--r-- | src/H5F.c | 8 | ||||
-rw-r--r-- | src/H5FDmpio.c | 59 | ||||
-rw-r--r-- | src/H5FDmpio.h | 1 | ||||
-rw-r--r-- | src/H5Gnode.c | 6 | ||||
-rw-r--r-- | src/H5HL.c | 14 | ||||
-rw-r--r-- | src/H5O.c | 16 |
7 files changed, 11 insertions, 99 deletions
@@ -101,8 +101,6 @@ #include "H5MMprivate.h" /*core memory management */ #include "H5Pprivate.h" /*property lists */ -#include "H5FDmpio.h" /*for H5FD_mpio_tas_allsame() */ - #define PABLO_MASK H5B_mask #define BOUND(MIN,X,MAX) ((X)<(MIN)?(MIN):((X)>(MAX)?(MAX):(X))) @@ -527,10 +525,6 @@ H5B_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5B_t *bt) * bother writing data for the child entries that don't exist or * for the final unchanged children. */ -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame(f->shared->lf, TRUE); /* only p0 will write */ -#endif /* H5_HAVE_PARALLEL */ if (H5F_block_write(f, H5FD_MEM_BTREE, addr, size, H5P_DATASET_XFER_DEFAULT, bt->page)<0) { HRETURN_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree node to disk"); @@ -2419,19 +2419,11 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate, } else { /* Write superblock */ -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame(f->shared->lf, TRUE); /*only p0 will write*/ -#endif if (H5FD_write(f->shared->lf, H5FD_MEM_SUPER, H5P_DATASET_XFER_DEFAULT, f->shared->boot_addr, superblock_size, sbuf)<0) HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock"); /* Write driver information block */ if (HADDR_UNDEF!=f->shared->driver_addr) { -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame(f->shared->lf, TRUE); /*only p0 will write*/ -#endif if (H5FD_write(f->shared->lf, H5FD_MEM_SUPER, H5P_DATASET_XFER_DEFAULT, f->shared->base_addr+superblock_size, driver_size, dbuf)<0) HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write driver information block"); diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 0f1be8d..2d28828 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -55,7 +55,6 @@ typedef struct H5FD_mpio_t { int mpi_rank; /* This process's rank */ int mpi_size; /* Total number of processes */ int mpi_round; /* Current round robin process (for metadata I/O) */ - hbool_t allsame; /*same data for all procs? */ haddr_t eof; /*end-of-file marker */ haddr_t eoa; /*end-of-address marker */ MPI_Datatype btype; /*buffer type for xfers */ @@ -421,48 +420,6 @@ H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/) /*------------------------------------------------------------------------- - * Function: H5FD_mpio_tas_allsame - * - * Purpose: Test and set the allsame parameter. - * - * Return: Success: the old value of the allsame flag - * - * Failure: assert fails if access_parms is NULL. - * - * Programmer: rky 980828 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -htri_t -H5FD_mpio_tas_allsame(H5FD_t *_file, hbool_t newval) -{ - H5FD_mpio_t *file = (H5FD_mpio_t*)_file; - hbool_t oldval; - - FUNC_ENTER(H5FD_mpio_tas_allsame, FAIL); - -#ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Entering H5FD_mpio_tas_allsame, newval=%d\n", newval); -#endif - - assert(file); - assert(H5FD_MPIO==file->pub.driver_id); - oldval = file->allsame; - file->allsame = newval; - -#ifdef H5FDmpio_DEBUG - if (H5FD_mpio_Debug[(int)'t']) - fprintf(stdout, "Leaving H5FD_mpio_tas_allsame, oldval=%d\n", oldval); -#endif - - FUNC_LEAVE(oldval); -} - - -/*------------------------------------------------------------------------- * Function: H5FD_mpio_communicator * * Purpose: Returns the MPI communicator for the file. @@ -1336,10 +1293,18 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add * Kim Yates, Pat Weidhaas, 2000-09-26 * Move block of coding where only p0 writes after the * MPI_File_set_view call. + * + * Quincey Koziol, 2002-05-10 + * Instead of always writing metadata from process 0, spread the + * burden among all the processes by using a round-robin rotation + * scheme. + * + * Quincey Koziol, 2002-05-10 + * Removed allsame code, keying off the type parameter instead. *------------------------------------------------------------------------- */ static herr_t -H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t addr, +H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf) { H5FD_mpio_t *file = (H5FD_mpio_t*)_file; @@ -1350,7 +1315,6 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t ad MPI_Datatype buf_type, file_type; int size_i, bytes_written; int use_types_this_time, used_types_last_time; - hbool_t allsame; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; @@ -1436,8 +1400,7 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t ad file->use_types = 0; /* Only p<round> will do the actual write if all procs in comm write same data */ - allsame = H5FD_mpio_tas_allsame(_file, FALSE); - if (allsame && H5_mpi_1_metawrite_g) { + if ((type!=H5FD_MEM_DRAW) && H5_mpi_1_metawrite_g) { if (file->mpi_rank != file->mpi_round) { #ifdef H5FDmpio_DEBUG if (H5FD_mpio_Debug[(int)'w']) { @@ -1504,7 +1467,7 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t ad done: /* if only p<round> writes, need to broadcast the ret_value to other processes */ - if (allsame && H5_mpi_1_metawrite_g) { + if ((type!=H5FD_MEM_DRAW) && H5_mpi_1_metawrite_g) { if (MPI_SUCCESS != MPI_Bcast(&ret_value, sizeof(ret_value), MPI_BYTE, file->mpi_round, file->comm)) HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Bcast failed"); diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h index 86ba0f7..08dd857 100644 --- a/src/H5FDmpio.h +++ b/src/H5FDmpio.h @@ -56,7 +56,6 @@ __DLL__ herr_t H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*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__ htri_t H5FD_mpio_tas_allsame(H5FD_t *_file, hbool_t newval); __DLL__ MPI_Comm H5FD_mpio_communicator(H5FD_t *_file); __DLL__ herr_t H5FD_mpio_setup(H5FD_t *_file, MPI_Datatype btype, MPI_Datatype ftype, haddr_t disp, hbool_t use_types); diff --git a/src/H5Gnode.c b/src/H5Gnode.c index d830a6b..1c34703 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -35,8 +35,6 @@ #include "H5Oprivate.h" /*header messages */ #include "H5Pprivate.h" /*property lists */ -#include "H5FDmpio.h" /*the MPIO file driver */ - #define PABLO_MASK H5G_node_mask /* PRIVATE PROTOTYPES */ @@ -367,10 +365,6 @@ H5G_node_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5G_node_t *sym) H5G_ent_encode_vec(f, &p, sym->entry, sym->nsyms); HDmemset(p, 0, size - (p - buf)); -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame(f->shared->lf, TRUE); /*only p0 will write*/ -#endif /* H5_HAVE_PARALLEL */ status = H5F_block_write(f, H5FD_MEM_BTREE, addr, size, H5P_DATASET_XFER_DEFAULT, buf); if (status < 0) HRETURN_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, @@ -30,8 +30,6 @@ #include "H5MMprivate.h" /*core memory management */ #include "H5Pprivate.h" /*property lists */ -#include "H5FDmpio.h" /*for H5FD_mpio_tas_allsame() */ - #define H5HL_FREE_NULL 1 /*end of free list on disk */ #define PABLO_MASK H5HL_mask @@ -394,10 +392,6 @@ H5HL_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5HL_t *heap) hdr_end_addr = addr + (hsize_t)H5HL_SIZEOF_HDR(f); if (H5F_addr_eq(heap->addr, hdr_end_addr)) { /* The header and data are contiguous */ -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame( f->shared->lf, TRUE ); /* only p0 writes */ -#endif /* H5_HAVE_PARALLEL */ if (H5F_block_write(f, H5FD_MEM_LHEAP, addr, (H5HL_SIZEOF_HDR(f)+heap->disk_alloc), H5P_DATASET_XFER_DEFAULT, heap->chunk) < 0) { @@ -405,19 +399,11 @@ H5HL_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5HL_t *heap) "unable to write heap header and data to file"); } } else { -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame( f->shared->lf, TRUE ); /* only p0 writes */ -#endif /* H5_HAVE_PARALLEL */ if (H5F_block_write(f, H5FD_MEM_LHEAP, addr, H5HL_SIZEOF_HDR(f), H5P_DATASET_XFER_DEFAULT, heap->chunk)<0) { HRETURN_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap header to file"); } -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame( f->shared->lf, TRUE ); /* only p0 writes */ -#endif /* H5_HAVE_PARALLEL */ if (H5F_block_write(f, H5FD_MEM_LHEAP, heap->addr, heap->disk_alloc, H5P_DATASET_XFER_DEFAULT, heap->chunk + H5HL_SIZEOF_HDR(f)) < 0) { @@ -27,10 +27,6 @@ #include "H5Oprivate.h" #include "H5Pprivate.h" -/* The MPIO driver for H5FD_mpio_tas_allsame() */ -#include "H5FDmpio.h" - - #define PABLO_MASK H5O_mask /* PRIVATE PROTOTYPES */ @@ -589,10 +585,6 @@ H5O_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5O_t *oh) combine=1; } /* end if */ else { -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame(f->shared->lf, TRUE); /*only p0 will write*/ -#endif /* H5_HAVE_PARALLEL */ if (H5F_block_write(f, H5FD_MEM_OHDR, addr, H5O_SIZEOF_HDR(f), H5P_DATASET_XFER_DEFAULT, buf) < 0) { HRETURN_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, @@ -675,10 +667,6 @@ H5O_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5O_t *oh) HDmemcpy(p+H5O_SIZEOF_HDR(f),oh->chunk[u].image,oh->chunk[u].size); /* Write the combined prefix/chunk out */ -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame(f->shared->lf, TRUE); /*only p0 write*/ -#endif /* H5_HAVE_PARALLEL */ if (H5F_block_write(f, H5FD_MEM_OHDR, addr, (H5O_SIZEOF_HDR(f)+oh->chunk[u].size), H5P_DATASET_XFER_DEFAULT, p) < 0) { @@ -690,10 +678,6 @@ H5O_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5O_t *oh) p = H5FL_BLK_FREE(chunk_image,p); } /* end if */ else { -#ifdef H5_HAVE_PARALLEL - if (IS_H5FD_MPIO(f)) - H5FD_mpio_tas_allsame(f->shared->lf, TRUE); /*only p0 write*/ -#endif /* H5_HAVE_PARALLEL */ if (H5F_block_write(f, H5FD_MEM_OHDR, oh->chunk[u].addr, (oh->chunk[u].size), H5P_DATASET_XFER_DEFAULT, oh->chunk[u].image) < 0) { |