From 909765f759d9d96e84f4b8b1cc14f7d2b3ac8143 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sat, 3 Apr 2021 11:58:54 -0700 Subject: [PATCH] Adds barrier and rank 0 check to MPI-I/O VFD delete --- src/H5FDmpio.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 45cb5281480..b58d3e75faf 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -1760,26 +1760,39 @@ static herr_t H5FD__mpio_delete(const char *filename, hid_t fapl_id) { H5P_genplist_t *plist; /* Property list pointer */ - MPI_Info info = MPI_INFO_NULL; - herr_t ret_value = SUCCEED; /* Return value */ + MPI_Comm comm = MPI_COMM_NULL; + MPI_Info info = MPI_INFO_NULL; + int mpi_rank = INT_MAX; + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(filename); - /* Get the MPI info from the fapl */ if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if (H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MPIO != H5P_peek_driver(plist)) - info = MPI_INFO_NULL; /* default */ - else { + + /* Get the MPI communicator and info from the fapl */ + if (H5P_FILE_ACCESS_DEFAULT != fapl_id && H5FD_MPIO == H5P_peek_driver(plist)) { if (H5P_get(plist, H5F_ACS_MPI_PARAMS_INFO_NAME, &info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI info object") + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI info object") + if (H5P_get(plist, H5F_ACS_MPI_PARAMS_COMM_NAME, &comm) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get MPI communicator") } + /* Get the MPI rank of this process */ + if (MPI_SUCCESS != (mpi_code = MPI_Comm_rank(comm, &mpi_rank))) + HMPI_GOTO_ERROR(FAIL, "MPI_Comm_rank failed", mpi_code) + + /* Set up a barrier */ + if (MPI_SUCCESS != (mpi_code = MPI_Barrier(comm))) + HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) + /* Delete the file */ - if (MPI_File_delete(filename, info) < 0) - HSYS_GOTO_ERROR(H5E_VFL, H5E_CANTDELETEFILE, FAIL, "unable to delete file") + if (mpi_rank == 0) + if (MPI_SUCCESS != (mpi_code = MPI_File_delete(filename, info))) + HMPI_GOTO_ERROR(FAIL, "MPI_File_delete failed", mpi_code) done: FUNC_LEAVE_NOAPI(ret_value)