diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5FDmpio.h | 21 | ||||
-rw-r--r-- | src/H5Fsuper.c | 30 |
2 files changed, 49 insertions, 2 deletions
diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h index 6ee0a1a..9bcc182 100644 --- a/src/H5FDmpio.h +++ b/src/H5FDmpio.h @@ -29,6 +29,27 @@ #endif /* H5_HAVE_PARALLEL */ #ifdef H5_HAVE_PARALLEL +#define H5FD_GET_MPI_RANK_AND_SIZE(rank,size, f) { \ + (rank) = 0; (size) = 1; \ + if (H5F_HAS_FEATURE((f), H5FD_FEAT_HAS_MPI)) { \ + (rank) = H5F_mpi_get_rank((f)); \ + (size) = H5F_mpi_get_size((f)); \ + } else { \ + int mpi_initialized = 0, mpi_finalized = 0; \ + MPI_Initialized(&mpi_initialized); \ + MPI_Finalized(&mpi_finalized); \ + if (mpi_initialized && !mpi_finalized) { \ + MPI_Comm_rank(MPI_COMM_WORLD, &(rank)); \ + MPI_Comm_size(MPI_COMM_WORLD, &(size)); \ + } \ + }} + +#define H5FD_GET_MPI_COMM(comm, f) { \ + if (H5F_HAS_FEATURE((f), H5FD_FEAT_HAS_MPI)) \ + (comm) = H5F_mpi_get_comm((f)); \ + else (comm) = MPI_COMM_WORLD; \ + } + /*Turn on H5FDmpio_debug if H5F_DEBUG is on */ #ifdef H5F_DEBUG #ifndef H5FDmpio_DEBUG diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 7c70a64..32051f3 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -333,6 +333,7 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial unsigned rw_flags; /* Read/write permissions for file */ hbool_t skip_eof_check = FALSE; /* Whether to skip checking the EOF value */ herr_t ret_value = SUCCEED; /* Return value */ + int mpi_rank = 0, mpi_size = 1; FUNC_ENTER_PACKAGE_TAG(meta_dxpl_id, H5AC__SUPERBLOCK_TAG, FAIL) @@ -354,8 +355,33 @@ H5F__super_read(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t initial HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Find the superblock */ - if(H5FD_locate_signature(&fdio_info, &super_addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") +#ifdef H5_HAVE_PARALLEL + H5FD_GET_MPI_RANK_AND_SIZE(mpi_rank, mpi_size, f); + /* If we are an MPI application with at least two processes, the + * following superblock signature location optimization is applicable. + */ + if ( mpi_size > 1 ) { + MPI_Comm this_comm = MPI_COMM_NULL; + + if ( mpi_rank == 0 ) { + if(H5FD_locate_signature(&fdio_info, &super_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") + } + H5FD_GET_MPI_COMM(this_comm, f); + if (( this_comm == MPI_COMM_NULL ) || + ( MPI_Bcast(&super_addr,sizeof(super_addr), MPI_BYTE, 0, this_comm) != MPI_SUCCESS)) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") + } + else { + /* Locate the signature as per per the serial library */ +#endif /* H5_HAVE_PARALLEL */ + + if(H5FD_locate_signature(&fdio_info, &super_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") + +#ifdef H5_HAVE_PARALLEL + } +#endif if(HADDR_UNDEF == super_addr) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "file signature not found") |